]>
Commit | Line | Data |
---|---|---|
7341eedb JF |
1 | /* Cycript - The Truly Universal Scripting Language |
2 | * Copyright (C) 2009-2016 Jay Freeman (saurik) | |
b4aa79af JF |
3 | */ |
4 | ||
f95d2598 | 5 | /* GNU Affero General Public License, Version 3 {{{ */ |
b4aa79af | 6 | /* |
f95d2598 JF |
7 | * This program is free software: you can redistribute it and/or modify |
8 | * it under the terms of the GNU Affero General Public License as published by | |
9 | * the Free Software Foundation, either version 3 of the License, or | |
10 | * (at your option) any later version. | |
11 | ||
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
c15969fd | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f95d2598 JF |
15 | * GNU Affero General Public License for more details. |
16 | ||
17 | * You should have received a copy of the GNU Affero General Public License | |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
b3378a02 | 19 | **/ |
b4aa79af JF |
20 | /* }}} */ |
21 | ||
6ce9ac92 | 22 | %code top { |
693d501b | 23 | #define YYSTACKEXPANDABLE 1 |
6ce9ac92 | 24 | } |
1dbba6cc | 25 | |
6ce9ac92 | 26 | %code requires { |
b12a9965 | 27 | #include "Driver.hpp" |
63b4c5a8 | 28 | #include "Parser.hpp" |
ddeb1876 | 29 | #include "Stack.hpp" |
e2ce853b | 30 | #include "Syntax.hpp" |
2c1d569a | 31 | #define CYNew new(driver.pool_) |
63b4c5a8 | 32 | |
cbaa5f0f | 33 | @begin ObjectiveC |
3c1c3635 | 34 | #include "ObjectiveC/Syntax.hpp" |
4de0686f JF |
35 | @end |
36 | ||
691e4717 | 37 | @begin E4X |
b92ceddb | 38 | #include "E4X/Syntax.hpp" |
691e4717 JF |
39 | @end |
40 | ||
82a02ede | 41 | #include "Highlight.hpp" |
a5662a53 | 42 | } |
82a02ede | 43 | |
a5662a53 JF |
44 | %union { bool bool_; } |
45 | ||
c5b15840 | 46 | %union { CYMember *access_; } |
a5662a53 JF |
47 | %union { CYArgument *argument_; } |
48 | %union { CYAssignment *assignment_; } | |
09fc3efb JF |
49 | %union { CYBinding *binding_; } |
50 | %union { CYBindings *bindings_; } | |
a5662a53 | 51 | %union { CYBoolean *boolean_; } |
4f3e597c | 52 | %union { CYBraced *braced_; } |
a5662a53 JF |
53 | %union { CYClause *clause_; } |
54 | %union { cy::Syntax::Catch *catch_; } | |
c5b15840 | 55 | %union { CYClassTail *classTail_; } |
a5662a53 | 56 | %union { CYComprehension *comprehension_; } |
a5662a53 | 57 | %union { CYElement *element_; } |
aaa29c28 | 58 | %union { CYEnumConstant *constant_; } |
a5662a53 JF |
59 | %union { CYExpression *expression_; } |
60 | %union { CYFalse *false_; } | |
9d2b125d | 61 | %union { CYVariable *variable_; } |
a5662a53 | 62 | %union { CYFinally *finally_; } |
a7d8b413 JF |
63 | %union { CYForInitializer *for_; } |
64 | %union { CYForInInitializer *forin_; } | |
a5662a53 JF |
65 | %union { CYFunctionParameter *functionParameter_; } |
66 | %union { CYIdentifier *identifier_; } | |
90dd6ff1 | 67 | %union { CYImportSpecifier *import_; } |
a5662a53 JF |
68 | %union { CYInfix *infix_; } |
69 | %union { CYLiteral *literal_; } | |
c5b15840 | 70 | %union { CYMethod *method_; } |
a5662a53 JF |
71 | %union { CYModule *module_; } |
72 | %union { CYNull *null_; } | |
73 | %union { CYNumber *number_; } | |
74 | %union { CYParenthetical *parenthetical_; } | |
a5662a53 JF |
75 | %union { CYProperty *property_; } |
76 | %union { CYPropertyName *propertyName_; } | |
24ffc58c | 77 | %union { CYTypeSigning signing_; } |
b900e1a4 | 78 | %union { CYSpan *span_; } |
a5662a53 JF |
79 | %union { CYStatement *statement_; } |
80 | %union { CYString *string_; } | |
7085e1ab | 81 | %union { CYTarget *target_; } |
a5662a53 JF |
82 | %union { CYThis *this_; } |
83 | %union { CYTrue *true_; } | |
84 | %union { CYWord *word_; } | |
4de0686f | 85 | |
7b750785 | 86 | @begin C |
0559abf8 | 87 | %union { CYTypeIntegral *integral_; } |
b3c38c5f | 88 | %union { CYTypeStructField *structField_; } |
a5662a53 JF |
89 | %union { CYTypeModifier *modifier_; } |
90 | %union { CYTypeSpecifier *specifier_; } | |
574d4720 | 91 | %union { CYTypedFormal *typedFormal_; } |
5b4dabb2 JF |
92 | %union { CYTypedLocation *typedLocation_; } |
93 | %union { CYTypedName *typedName_; } | |
a5662a53 | 94 | %union { CYTypedParameter *typedParameter_; } |
5b4dabb2 | 95 | %union { CYType *typedThing_; } |
7b750785 JF |
96 | @end |
97 | ||
cbaa5f0f | 98 | @begin ObjectiveC |
5a6c975a | 99 | %union { CYObjCKeyValue *keyValue_; } |
7cf0481b | 100 | %union { CYImplementationField *implementationField_; } |
a5662a53 JF |
101 | %union { CYMessage *message_; } |
102 | %union { CYMessageParameter *messageParameter_; } | |
103 | %union { CYProtocol *protocol_; } | |
104 | %union { CYSelectorPart *selector_; } | |
4de0686f | 105 | @end |
691e4717 JF |
106 | |
107 | @begin E4X | |
a5662a53 JF |
108 | %union { CYAttribute *attribute_; } |
109 | %union { CYPropertyIdentifier *propertyIdentifier_; } | |
110 | %union { CYSelector *selector_; } | |
691e4717 | 111 | @end |
63b4c5a8 | 112 | |
6ce9ac92 | 113 | %code provides { |
a5662a53 JF |
114 | |
115 | struct YYSTYPE { | |
116 | cy::parser::semantic_type semantic_; | |
117 | hi::Value highlight_; | |
118 | }; | |
119 | ||
58afc6aa | 120 | int cylex(YYSTYPE *, CYLocation *, void *); |
a5662a53 JF |
121 | |
122 | } | |
123 | ||
124 | %code { | |
125 | ||
126 | #undef yylex | |
9d2b125d | 127 | |
675ff733 | 128 | typedef cy::parser::token tk; |
b23692f3 | 129 | |
675ff733 JF |
130 | _finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) { |
131 | driver.newline_ = false; | |
132 | lex: | |
a5662a53 | 133 | YYSTYPE data; |
9d2b125d | 134 | int token(cylex(&data, location, driver.scanner_)); |
a5662a53 | 135 | *semantic = data.semantic_; |
b23692f3 JF |
136 | |
137 | switch (token) { | |
20ac4226 JF |
138 | case tk::OpenBrace: |
139 | case tk::OpenBracket: | |
140 | case tk::OpenParen: | |
141 | driver.in_.push(false); | |
142 | break; | |
143 | ||
b23692f3 JF |
144 | case tk::_in_: |
145 | if (driver.in_.top()) | |
146 | token = tk::_in__; | |
147 | break; | |
148 | ||
20ac4226 JF |
149 | case tk::CloseBrace: |
150 | case tk::CloseBracket: | |
151 | case tk::CloseParen: | |
152 | driver.in_.pop(); | |
153 | break; | |
154 | ||
155 | ||
b23692f3 JF |
156 | case tk::_yield_: |
157 | if (driver.yield_.top()) | |
158 | token = tk::_yield__; | |
159 | break; | |
160 | ||
b23692f3 | 161 | case tk::NewLine: |
675ff733 JF |
162 | driver.newline_ = true; |
163 | goto lex; | |
b23692f3 | 164 | break; |
b23692f3 JF |
165 | } |
166 | ||
a5662a53 JF |
167 | return token; |
168 | } | |
169 | ||
675ff733 JF |
170 | #define yylex_(semantic, location, driver) ({ \ |
171 | int type; \ | |
172 | if (driver.hold_ == cy::parser::empty_symbol) \ | |
173 | type = yytranslate_(cylex_(semantic, location, driver)); \ | |
174 | else { \ | |
175 | type = driver.hold_; \ | |
176 | driver.hold_ = cy::parser::empty_symbol; \ | |
177 | } \ | |
178 | type; }) | |
179 | ||
98711170 JF |
180 | #define CYLEX() do if (yyla.empty()) { \ |
181 | YYCDEBUG << "Mapping a token: "; \ | |
675ff733 | 182 | yyla.type = yylex_(&yyla.value, &yyla.location, driver); \ |
98711170 JF |
183 | YY_SYMBOL_PRINT("Next token is", yyla); \ |
184 | } while (false) | |
185 | ||
442609f7 | 186 | #define CYMAP(to, from) do { \ |
98711170 | 187 | CYLEX(); \ |
442609f7 JF |
188 | if (yyla.type == yytranslate_(token::from)) \ |
189 | yyla.type = yytranslate_(token::to); \ | |
190 | } while (false) | |
191 | ||
197e361c JF |
192 | #define CYHLD(location, token) do { \ |
193 | if (driver.hold_ != empty_symbol) \ | |
194 | CYERR(location, "unexpected hold"); \ | |
195 | driver.hold_ = yyla.type; \ | |
196 | yyla.type = yytranslate_(token); \ | |
197 | } while (false) | |
198 | ||
0b40da30 JF |
199 | #define CYERR(location, message) do { \ |
200 | error(location, message); \ | |
201 | YYABORT; \ | |
202 | } while (false) | |
203 | ||
6244bca0 JF |
204 | #define CYEOK() do { \ |
205 | yyerrok; \ | |
206 | driver.errors_.pop_back(); \ | |
207 | } while (false) | |
208 | ||
9d2b125d JF |
209 | #define CYNOT(location) \ |
210 | CYERR(location, "unimplemented feature") | |
211 | ||
6244bca0 JF |
212 | #define CYMPT(location) do { \ |
213 | if (!yyla.empty() && yyla.type_get() != yyeof_) \ | |
214 | CYERR(location, "unexpected lookahead"); \ | |
215 | } while (false) | |
216 | ||
6ce9ac92 | 217 | } |
c5aeb567 | 218 | |
6ce9ac92 | 219 | %name-prefix "cy" |
e5332278 | 220 | |
6ce9ac92 | 221 | %language "C++" |
1dbba6cc | 222 | |
5999c315 JF |
223 | %initial-action { |
224 | @$.begin.filename = @$.end.filename = &driver.filename_; | |
675ff733 JF |
225 | |
226 | switch (driver.mark_) { | |
227 | case CYMarkScript: | |
228 | driver.hold_ = yytranslate_(token::MarkScript); | |
229 | break; | |
230 | case CYMarkModule: | |
231 | driver.hold_ = yytranslate_(token::MarkModule); | |
232 | break; | |
a4d849b7 JF |
233 | case CYMarkExpression: |
234 | driver.hold_ = yytranslate_(token::MarkExpression); | |
235 | break; | |
675ff733 | 236 | } |
5999c315 JF |
237 | }; |
238 | ||
be36c292 | 239 | %locations |
e5332278 | 240 | %defines |
1dbba6cc | 241 | |
58afc6aa JF |
242 | %define api.location.type { CYLocation } |
243 | ||
534fb6da JF |
244 | //%glr-parser |
245 | //%expect 1 | |
cac61857 | 246 | |
e5332278 JF |
247 | %error-verbose |
248 | ||
9d2b125d | 249 | %param { CYDriver &driver } |
e5332278 | 250 | |
c3b144b8 | 251 | /* Token Declarations {{{ */ |
cb02f8ae | 252 | @begin E4X |
cb02f8ae JF |
253 | %token XMLCDATA |
254 | %token XMLComment | |
255 | %token XMLPI | |
691e4717 JF |
256 | |
257 | %token XMLAttributeValue | |
258 | %token XMLName | |
259 | %token XMLTagCharacters | |
260 | %token XMLText | |
261 | %token XMLWhitespace | |
262 | @end | |
263 | ||
264 | @begin E4X | |
265 | %token LeftRight "<>" | |
266 | %token LeftSlashRight "</>" | |
267 | ||
268 | %token SlashRight "/>" | |
269 | %token LeftSlash "</" | |
270 | ||
691e4717 | 271 | %token PeriodPeriod ".." |
cb02f8ae | 272 | @end |
ac9a5ce1 | 273 | |
b1589845 JF |
274 | @begin E4X ObjectiveC |
275 | %token At "@" | |
276 | @end | |
277 | ||
63b4c5a8 JF |
278 | %token Ampersand "&" |
279 | %token AmpersandAmpersand "&&" | |
280 | %token AmpersandEqual "&=" | |
281 | %token Carrot "^" | |
282 | %token CarrotEqual "^=" | |
283 | %token Equal "=" | |
284 | %token EqualEqual "==" | |
285 | %token EqualEqualEqual "===" | |
4b2fd91c | 286 | %token EqualRight "=>" |
63b4c5a8 JF |
287 | %token Exclamation "!" |
288 | %token ExclamationEqual "!=" | |
289 | %token ExclamationEqualEqual "!==" | |
290 | %token Hyphen "-" | |
291 | %token HyphenEqual "-=" | |
292 | %token HyphenHyphen "--" | |
293 | %token HyphenRight "->" | |
294 | %token Left "<" | |
295 | %token LeftEqual "<=" | |
296 | %token LeftLeft "<<" | |
297 | %token LeftLeftEqual "<<=" | |
298 | %token Percent "%" | |
299 | %token PercentEqual "%=" | |
300 | %token Period "." | |
c8a0500b | 301 | %token PeriodPeriodPeriod "..." |
63b4c5a8 JF |
302 | %token Pipe "|" |
303 | %token PipeEqual "|=" | |
304 | %token PipePipe "||" | |
305 | %token Plus "+" | |
306 | %token PlusEqual "+=" | |
307 | %token PlusPlus "++" | |
308 | %token Right ">" | |
309 | %token RightEqual ">=" | |
310 | %token RightRight ">>" | |
311 | %token RightRightEqual ">>=" | |
312 | %token RightRightRight ">>>" | |
313 | %token RightRightRightEqual ">>>=" | |
314 | %token Slash "/" | |
315 | %token SlashEqual "/=" | |
316 | %token Star "*" | |
317 | %token StarEqual "*=" | |
318 | %token Tilde "~" | |
319 | ||
320 | %token Colon ":" | |
2fad14e5 | 321 | %token ColonColon "::" |
63b4c5a8 JF |
322 | %token Comma "," |
323 | %token Question "?" | |
324 | %token SemiColon ";" | |
61a5b9da | 325 | %token Pound "#" |
c3c20102 | 326 | %token NewLine "\n" |
fdcef8e7 | 327 | %token __ "" |
63b4c5a8 | 328 | |
b900e1a4 | 329 | %token Comment |
320ce753 | 330 | |
63b4c5a8 JF |
331 | %token OpenParen "(" |
332 | %token CloseParen ")" | |
924f67b2 | 333 | |
63b4c5a8 | 334 | %token OpenBrace "{" |
675ff733 | 335 | %token OpenBrace_ ";{" |
b41e4739 | 336 | %token OpenBrace_let "let {" |
63b4c5a8 | 337 | %token CloseBrace "}" |
924f67b2 | 338 | |
63b4c5a8 | 339 | %token OpenBracket "[" |
b41e4739 | 340 | %token OpenBracket_let "let [" |
63b4c5a8 JF |
341 | %token CloseBracket "]" |
342 | ||
09e4db67 | 343 | %token At_error_ "@error" |
dc5d7cf4 | 344 | |
1ba6903e | 345 | @begin Java |
09e4db67 | 346 | %token At_class_ "@class" |
1ba6903e JF |
347 | @end |
348 | ||
60097023 | 349 | @begin C |
09e4db67 JF |
350 | %token _typedef_ "typedef" |
351 | %token _unsigned_ "unsigned" | |
352 | %token _signed_ "signed" | |
b3c38c5f | 353 | %token _struct_ "struct" |
09e4db67 | 354 | %token _extern_ "extern" |
60097023 JF |
355 | @end |
356 | ||
8a2eb1be | 357 | @begin C |
09e4db67 | 358 | %token At_encode_ "@encode" |
8a2eb1be JF |
359 | @end |
360 | ||
1ba6903e | 361 | @begin ObjectiveC |
09e4db67 | 362 | %token At_implementation_ "@implementation" |
09e4db67 JF |
363 | %token At_import_ "@import" |
364 | %token At_end_ "@end" | |
365 | %token At_selector_ "@selector" | |
366 | %token At_null_ "@null" | |
367 | %token At_YES_ "@YES" | |
368 | %token At_NO_ "@NO" | |
369 | %token At_true_ "@true" | |
370 | %token At_false_ "@false" | |
371 | %token _YES_ "YES" | |
372 | %token _NO_ "NO" | |
1ba6903e | 373 | @end |
e7ed5354 | 374 | |
09e4db67 JF |
375 | %token _false_ "false" |
376 | %token _null_ "null" | |
377 | %token _true_ "true" | |
378 | ||
90dd6ff1 | 379 | %token _as_ "as" |
09e4db67 JF |
380 | %token _break_ "break" |
381 | %token _case_ "case" | |
382 | %token _catch_ "catch" | |
383 | %token _class_ "class" | |
8a392978 | 384 | %token _class__ ";class" |
09e4db67 JF |
385 | %token _const_ "const" |
386 | %token _continue_ "continue" | |
387 | %token _debugger_ "debugger" | |
388 | %token _default_ "default" | |
389 | %token _delete_ "delete" | |
390 | %token _do_ "do" | |
391 | %token _else_ "else" | |
392 | %token _enum_ "enum" | |
393 | %token _export_ "export" | |
394 | %token _extends_ "extends" | |
395 | %token _finally_ "finally" | |
396 | %token _for_ "for" | |
397 | %token _function_ "function" | |
398 | %token _function__ ";function" | |
399 | %token _if_ "if" | |
400 | %token _import_ "import" | |
401 | %token _in_ "in" | |
402 | %token _in__ "!in" | |
5f6902c2 | 403 | %token _Infinity_ "Infinity" |
09e4db67 JF |
404 | %token _instanceof_ "instanceof" |
405 | %token _new_ "new" | |
406 | %token _return_ "return" | |
407 | %token _super_ "super" | |
408 | %token _switch_ "switch" | |
322286dd | 409 | %token _target_ "target" |
09e4db67 JF |
410 | %token _this_ "this" |
411 | %token _throw_ "throw" | |
412 | %token _try_ "try" | |
413 | %token _typeof_ "typeof" | |
414 | %token _var_ "var" | |
415 | %token _void_ "void" | |
416 | %token _while_ "while" | |
417 | %token _with_ "with" | |
418 | ||
419 | %token _abstract_ "abstract" | |
420 | %token _await_ "await" | |
421 | %token _boolean_ "boolean" | |
422 | %token _byte_ "byte" | |
423 | %token _char_ "char" | |
c5b15840 | 424 | %token _constructor_ "constructor" |
09e4db67 | 425 | %token _double_ "double" |
7085e1ab | 426 | %token _eval_ "eval" |
09e4db67 JF |
427 | %token _final_ "final" |
428 | %token _float_ "float" | |
9d2b125d JF |
429 | %token _from_ "from" |
430 | %token _get_ "get" | |
09e4db67 JF |
431 | %token _goto_ "goto" |
432 | %token _implements_ "implements" | |
433 | %token _int_ "int" | |
24ffc58c | 434 | %token ___int128_ "__int128" |
09e4db67 JF |
435 | %token _interface_ "interface" |
436 | %token _let_ "let" | |
b41e4739 | 437 | %token _let__ "!let" |
09e4db67 JF |
438 | %token _long_ "long" |
439 | %token _native_ "native" | |
440 | %token _package_ "package" | |
441 | %token _private_ "private" | |
442 | %token _protected_ "protected" | |
a02c6df3 | 443 | %token ___proto___ "__proto__" |
c5b15840 | 444 | %token _prototype_ "prototype" |
09e4db67 | 445 | %token _public_ "public" |
9d2b125d | 446 | %token _set_ "set" |
09e4db67 JF |
447 | %token _short_ "short" |
448 | %token _static_ "static" | |
449 | %token _synchronized_ "synchronized" | |
450 | %token _throws_ "throws" | |
451 | %token _transient_ "transient" | |
574d4720 | 452 | %token _typeid_ "typeid" |
09e4db67 JF |
453 | %token _volatile_ "volatile" |
454 | %token _yield_ "yield" | |
9d2b125d | 455 | %token _yield__ "!yield" |
09e4db67 JF |
456 | |
457 | %token _undefined_ "undefined" | |
458 | ||
459 | @begin ObjectiveC | |
460 | %token _bool_ "bool" | |
461 | %token _BOOL_ "BOOL" | |
462 | %token _id_ "id" | |
463 | %token _nil_ "nil" | |
464 | %token _NULL_ "NULL" | |
465 | %token _SEL_ "SEL" | |
466 | @end | |
467 | ||
09e4db67 JF |
468 | %token _each_ "each" |
469 | %token _of_ "of" | |
b41e4739 | 470 | %token _of__ "!of" |
75b0a457 | 471 | |
691e4717 | 472 | @begin E4X |
09e4db67 JF |
473 | %token _namespace_ "namespace" |
474 | %token _xml_ "xml" | |
691e4717 JF |
475 | @end |
476 | ||
7e5391fd | 477 | %token AutoComplete |
fdcef8e7 | 478 | %token YieldStar "yield *" |
7e5391fd | 479 | |
75b0a457 | 480 | %token <identifier_> Identifier_ |
63b4c5a8 JF |
481 | %token <number_> NumericLiteral |
482 | %token <string_> StringLiteral | |
f356a43d | 483 | %token <literal_> RegularExpressionLiteral_ |
1dbba6cc | 484 | |
b900e1a4 JF |
485 | %token <string_> NoSubstitutionTemplate |
486 | %token <string_> TemplateHead | |
487 | %token <string_> TemplateMiddle | |
488 | %token <string_> TemplateTail | |
489 | ||
620c82a1 | 490 | %type <target_> AccessExpression |
cf7d4c69 | 491 | %type <expression_> AdditiveExpression |
cf7d4c69 | 492 | %type <argument_> ArgumentList_ |
55fc1817 | 493 | %type <argument_> ArgumentList |
cf7d4c69 JF |
494 | %type <argument_> ArgumentListOpt |
495 | %type <argument_> Arguments | |
7085e1ab | 496 | %type <target_> ArrayComprehension |
5a6c975a | 497 | %type <element_> ArrayElement |
cf7d4c69 | 498 | %type <literal_> ArrayLiteral |
4b2fd91c JF |
499 | %type <expression_> ArrowFunction |
500 | %type <functionParameter_> ArrowParameters | |
55fc1817 | 501 | %type <expression_> AssignmentExpression |
c8a0500b | 502 | %type <identifier_> BindingIdentifier |
9d2b125d | 503 | %type <identifier_> BindingIdentifierOpt |
09fc3efb JF |
504 | %type <bindings_> BindingList_ |
505 | %type <bindings_> BindingList | |
cf7d4c69 | 506 | %type <expression_> BitwiseANDExpression |
55fc1817 | 507 | %type <statement_> Block |
a7d8b413 | 508 | %type <statement_> BlockStatement |
cf7d4c69 | 509 | %type <boolean_> BooleanLiteral |
09fc3efb | 510 | %type <binding_> BindingElement |
cf7d4c69 JF |
511 | %type <expression_> BitwiseORExpression |
512 | %type <expression_> BitwiseXORExpression | |
4f3e597c JF |
513 | %type <target_> BracedExpression_ |
514 | %type <target_> BracedExpression | |
cf7d4c69 | 515 | %type <statement_> BreakStatement |
c8a0500b | 516 | %type <statement_> BreakableStatement |
3ea7eed0 | 517 | %type <expression_> CallExpression_ |
7085e1ab | 518 | %type <target_> CallExpression |
cf7d4c69 JF |
519 | %type <clause_> CaseBlock |
520 | %type <clause_> CaseClause | |
521 | %type <clause_> CaseClausesOpt | |
a7d8b413 JF |
522 | %type <catch_> Catch |
523 | %type <identifier_> CatchParameter | |
9d2b125d | 524 | %type <statement_> ClassDeclaration |
7085e1ab | 525 | %type <target_> ClassExpression |
c5b15840 JF |
526 | %type <classTail_> ClassHeritage |
527 | %type <classTail_> ClassHeritageOpt | |
528 | %type <classTail_> ClassTail | |
7085e1ab | 529 | %type <target_> Comprehension |
b3aa25d8 JF |
530 | %type <comprehension_> ComprehensionFor |
531 | %type <comprehension_> ComprehensionIf | |
532 | %type <comprehension_> ComprehensionTail | |
c5b15840 | 533 | %type <propertyName_> ComputedPropertyName |
cf7d4c69 JF |
534 | %type <expression_> ConditionalExpression |
535 | %type <statement_> ContinueStatement | |
4b2fd91c | 536 | %type <statement_> ConciseBody |
a7d8b413 | 537 | %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList |
c8a0500b | 538 | %type <statement_> DebuggerStatement |
3ea7eed0 | 539 | %type <statement_> Declaration_ |
c8a0500b | 540 | %type <statement_> Declaration |
cf7d4c69 | 541 | %type <clause_> DefaultClause |
5a6c975a | 542 | %type <element_> ElementList_ |
cf7d4c69 | 543 | %type <element_> ElementList |
5befe15e | 544 | %type <element_> ElementListOpt |
cf7d4c69 | 545 | %type <statement_> ElseStatementOpt |
bfd79fae | 546 | %type <for_> EmptyStatement |
cf7d4c69 | 547 | %type <expression_> EqualityExpression |
b0385401 | 548 | %type <expression_> Expression |
cf7d4c69 | 549 | %type <expression_> ExpressionOpt |
bfd79fae | 550 | %type <for_> ExpressionStatement_ |
cf7d4c69 | 551 | %type <statement_> ExpressionStatement |
ffc2d225 JF |
552 | %type <statement_> ExternC |
553 | %type <statement_> ExternCStatement | |
554 | %type <statement_> ExternCStatementListOpt | |
a7d8b413 | 555 | %type <finally_> Finally |
09fc3efb | 556 | %type <binding_> ForBinding |
7085e1ab | 557 | %type <forin_> ForDeclaration |
a7d8b413 | 558 | %type <forin_> ForInStatementInitializer |
4e3c9056 | 559 | %type <for_> ForStatementInitializer |
09fc3efb | 560 | %type <binding_> FormalParameter |
b09da87b | 561 | %type <functionParameter_> FormalParameterList_ |
55fc1817 | 562 | %type <functionParameter_> FormalParameterList |
9d2b125d | 563 | %type <functionParameter_> FormalParameters |
90dd6ff1 | 564 | %type <string_> FromClause |
b10bd496 JF |
565 | %type <statement_> FunctionBody |
566 | %type <statement_> FunctionDeclaration | |
7085e1ab | 567 | %type <target_> FunctionExpression |
9d2b125d JF |
568 | %type <statement_> FunctionStatementList |
569 | %type <statement_> GeneratorBody | |
570 | %type <statement_> GeneratorDeclaration | |
7085e1ab | 571 | %type <target_> GeneratorExpression |
c5b15840 | 572 | %type <method_> GeneratorMethod |
a7d8b413 | 573 | %type <statement_> HoistableDeclaration |
75b0a457 | 574 | %type <identifier_> Identifier |
b0fa2761 | 575 | %type <identifier_> IdentifierNoOf |
3fe283c5 | 576 | %type <identifier_> IdentifierType |
b0fa2761 | 577 | %type <identifier_> IdentifierTypeNoOf |
b3c38c5f | 578 | %type <identifier_> IdentifierTypeOpt |
4492c19c | 579 | %type <word_> IdentifierName |
9d2b125d | 580 | %type <variable_> IdentifierReference |
cf7d4c69 | 581 | %type <statement_> IfStatement |
90dd6ff1 JF |
582 | %type <import_> ImportClause |
583 | %type <statement_> ImportDeclaration | |
584 | %type <import_> ImportSpecifier | |
585 | %type <identifier_> ImportedBinding | |
586 | %type <import_> ImportedDefaultBinding | |
587 | %type <import_> ImportsList_ | |
588 | %type <import_> ImportsList | |
589 | %type <import_> ImportsListOpt | |
620c82a1 | 590 | %type <target_> IndirectExpression |
a7d8b413 JF |
591 | %type <expression_> Initializer |
592 | %type <expression_> InitializerOpt | |
cf7d4c69 | 593 | %type <statement_> IterationStatement |
a7d8b413 JF |
594 | %type <identifier_> LabelIdentifier |
595 | %type <statement_> LabelledItem | |
cf7d4c69 | 596 | %type <statement_> LabelledStatement |
8b77acf1 | 597 | %type <assignment_> LeftHandSideAssignment |
7085e1ab JF |
598 | %type <target_> LeftHandSideExpression |
599 | %type <bool_> LetOrConst | |
09fc3efb | 600 | %type <binding_> LexicalBinding |
bfd79fae | 601 | %type <for_> LexicalDeclaration_ |
c8a0500b | 602 | %type <statement_> LexicalDeclaration |
cf7d4c69 | 603 | %type <literal_> Literal |
9d2b125d | 604 | %type <propertyName_> LiteralPropertyName |
cf7d4c69 JF |
605 | %type <expression_> LogicalANDExpression |
606 | %type <expression_> LogicalORExpression | |
c5b15840 | 607 | %type <access_> MemberAccess |
7085e1ab | 608 | %type <target_> MemberExpression |
c5b15840 | 609 | %type <method_> MethodDefinition |
90dd6ff1 JF |
610 | %type <statement_> ModuleBody |
611 | %type <statement_> ModuleBodyOpt | |
612 | %type <statement_> ModuleItem | |
613 | %type <statement_> ModuleItemList | |
614 | %type <statement_> ModuleItemListOpt | |
9d2b125d | 615 | %type <module_> ModulePath |
90dd6ff1 | 616 | %type <string_> ModuleSpecifier |
cf7d4c69 | 617 | %type <expression_> MultiplicativeExpression |
90dd6ff1 JF |
618 | %type <import_> NameSpaceImport |
619 | %type <import_> NamedImports | |
7085e1ab | 620 | %type <target_> NewExpression |
cf7d4c69 JF |
621 | %type <null_> NullLiteral |
622 | %type <literal_> ObjectLiteral | |
cf7d4c69 | 623 | %type <expression_> PostfixExpression |
7085e1ab | 624 | %type <target_> PrimaryExpression |
55fc1817 | 625 | %type <propertyName_> PropertyName |
aea76473 JF |
626 | %type <property_> PropertyDefinition |
627 | %type <property_> PropertyDefinitionList_ | |
628 | %type <property_> PropertyDefinitionList | |
629 | %type <property_> PropertyDefinitionListOpt | |
09fc3efb | 630 | %type <functionParameter_> PropertySetParameterList |
f356a43d JF |
631 | %type <literal_> RegularExpressionLiteral |
632 | %type <bool_> RegularExpressionSlash | |
55fc1817 | 633 | %type <expression_> RelationalExpression |
cf7d4c69 | 634 | %type <statement_> ReturnStatement |
4f3e597c | 635 | %type <braced_> BracedParameter |
6c093cce | 636 | %type <functionParameter_> RubyProcParameterList_ |
55fc1817 | 637 | %type <functionParameter_> RubyProcParameterList |
d7205a63 | 638 | %type <functionParameter_> RubyProcParameters |
6c093cce | 639 | %type <functionParameter_> RubyProcParametersOpt |
a7d8b413 JF |
640 | %type <statement_> Script |
641 | %type <statement_> ScriptBody | |
642 | %type <statement_> ScriptBodyOpt | |
cf7d4c69 | 643 | %type <expression_> ShiftExpression |
09fc3efb | 644 | %type <binding_> SingleNameBinding |
3ea7eed0 | 645 | %type <statement_> Statement__ |
b10bd496 | 646 | %type <statement_> Statement_ |
55fc1817 | 647 | %type <statement_> Statement |
693d501b | 648 | %type <statement_> StatementList |
cf7d4c69 | 649 | %type <statement_> StatementListOpt |
c8a0500b | 650 | %type <statement_> StatementListItem |
9d2b125d | 651 | %type <functionParameter_> StrictFormalParameters |
7085e1ab JF |
652 | %type <target_> SuperCall |
653 | %type <target_> SuperProperty | |
cf7d4c69 | 654 | %type <statement_> SwitchStatement |
7085e1ab | 655 | %type <target_> TemplateLiteral |
b900e1a4 | 656 | %type <span_> TemplateSpans |
cf7d4c69 JF |
657 | %type <statement_> ThrowStatement |
658 | %type <statement_> TryStatement | |
ffc2d225 | 659 | %type <statement_> TypeDefinition |
693d501b | 660 | %type <expression_> UnaryExpression_ |
55fc1817 | 661 | %type <expression_> UnaryExpression |
09fc3efb JF |
662 | %type <binding_> VariableDeclaration |
663 | %type <bindings_> VariableDeclarationList_ | |
664 | %type <bindings_> VariableDeclarationList | |
bfd79fae | 665 | %type <for_> VariableStatement_ |
cf7d4c69 | 666 | %type <statement_> VariableStatement |
cf7d4c69 | 667 | %type <statement_> WithStatement |
4492c19c | 668 | %type <word_> Word |
2fad14e5 | 669 | %type <word_> WordNoUnary |
73f04979 | 670 | @begin ObjectiveC |
4492c19c | 671 | %type <word_> WordOpt |
73f04979 | 672 | @end |
9d2b125d | 673 | %type <expression_> YieldExpression |
cf7d4c69 | 674 | |
7b750785 | 675 | @begin C |
aaa29c28 JF |
676 | %type <constant_> EnumConstantListOpt_ |
677 | %type <constant_> EnumConstantListOpt | |
678 | %type <number_> IntegerNumber | |
0559abf8 JF |
679 | %type <integral_> IntegerType |
680 | %type <integral_> IntegerTypeOpt | |
5b4dabb2 | 681 | %type <typedName_> PrefixedType |
aaa29c28 | 682 | %type <specifier_> PrimitiveReference |
7b750785 | 683 | %type <specifier_> PrimitiveType |
b3c38c5f | 684 | %type <structField_> StructFieldListOpt |
5b4dabb2 JF |
685 | %type <typedName_> SuffixedType |
686 | %type <typedName_> SuffixedTypeOpt | |
687 | %type <typedName_> TypeSignifier | |
688 | %type <typedName_> TypeSignifierNone | |
689 | %type <typedName_> TypeSignifierOpt | |
24ffc58c | 690 | %type <signing_> TypeSigning |
88085bb4 | 691 | %type <modifier_> ParameterTail |
7b750785 | 692 | %type <modifier_> TypeQualifierLeft |
15e52267 | 693 | %type <modifier_> TypeQualifierLeftOpt |
5b4dabb2 JF |
694 | %type <typedName_> TypeQualifierRight |
695 | %type <typedName_> TypeQualifierRightOpt | |
696 | %type <typedName_> TypedIdentifierDefinition | |
697 | %type <typedThing_> TypedIdentifierEncoding | |
698 | %type <typedName_> TypedIdentifierField | |
699 | %type <typedName_> TypedIdentifierMaybe | |
700 | %type <typedLocation_> TypedIdentifierNo | |
701 | %type <typedName_> TypedIdentifierTagged | |
702 | %type <typedName_> TypedIdentifierYes | |
574d4720 JF |
703 | %type <typedFormal_> TypedParameterList_ |
704 | %type <typedFormal_> TypedParameterList | |
705 | %type <typedFormal_> TypedParameterListOpt | |
706 | %type <typedParameter_> TypedParameters | |
7b750785 JF |
707 | @end |
708 | ||
709 | @begin ObjectiveC | |
8b77acf1 | 710 | %type <expression_> AssignmentExpressionClassic |
c3b144b8 | 711 | %type <expression_> BoxableExpression |
328ad766 | 712 | %type <statement_> CategoryStatement |
328ad766 | 713 | %type <expression_> ClassSuperOpt |
8b77acf1 | 714 | %type <expression_> ConditionalExpressionClassic |
328ad766 JF |
715 | %type <message_> ClassMessageDeclaration |
716 | %type <message_> ClassMessageDeclarationListOpt | |
64b8d29f JF |
717 | %type <protocol_> ClassProtocolListOpt |
718 | %type <protocol_> ClassProtocols | |
719 | %type <protocol_> ClassProtocolsOpt | |
7cf0481b | 720 | %type <implementationField_> ImplementationFieldListOpt |
c5b15840 | 721 | %type <statement_> ImplementationStatement |
5a6c975a JF |
722 | %type <keyValue_> KeyValuePairList_ |
723 | %type <keyValue_> KeyValuePairList | |
724 | %type <keyValue_> KeyValuePairListOpt | |
7085e1ab | 725 | %type <target_> MessageExpression |
328ad766 JF |
726 | %type <messageParameter_> MessageParameter |
727 | %type <messageParameter_> MessageParameters | |
728 | %type <messageParameter_> MessageParameterList | |
729 | %type <messageParameter_> MessageParameterListOpt | |
730 | %type <bool_> MessageScope | |
693d501b | 731 | %type <argument_> SelectorCall_ |
55fc1817 | 732 | %type <argument_> SelectorCall |
328ad766 | 733 | %type <selector_> SelectorExpression_ |
55fc1817 | 734 | %type <selector_> SelectorExpression |
328ad766 | 735 | %type <selector_> SelectorExpressionOpt |
693d501b | 736 | %type <argument_> SelectorList |
7e5391fd | 737 | %type <word_> SelectorWordOpt |
5b4dabb2 | 738 | %type <typedThing_> TypeOpt |
693d501b | 739 | %type <argument_> VariadicCall |
328ad766 | 740 | @end |
693d501b | 741 | |
691e4717 | 742 | @begin E4X |
b92ceddb | 743 | %type <propertyIdentifier_> PropertyIdentifier_ |
b92ceddb | 744 | %type <selector_> PropertySelector_ |
55fc1817 | 745 | %type <selector_> PropertySelector |
691e4717 | 746 | %type <identifier_> QualifiedIdentifier_ |
55fc1817 | 747 | %type <identifier_> QualifiedIdentifier |
691e4717 JF |
748 | %type <identifier_> WildcardIdentifier |
749 | %type <identifier_> XMLComment | |
750 | %type <identifier_> XMLCDATA | |
751 | %type <identifier_> XMLElement | |
752 | %type <identifier_> XMLElementContent | |
753 | %type <identifier_> XMLMarkup | |
754 | %type <identifier_> XMLPI | |
755 | ||
756 | %type <attribute_> AttributeIdentifier | |
b92ceddb | 757 | /* XXX: %type <statement_> DefaultXMLNamespaceStatement */ |
691e4717 | 758 | %type <expression_> PropertyIdentifier |
09fc3efb JF |
759 | %type <expression_> XMLListInitilizer |
760 | %type <expression_> XMLInitilizer | |
691e4717 | 761 | @end |
c3b144b8 JF |
762 | /* }}} */ |
763 | /* Token Priorities {{{ */ | |
b92ceddb JF |
764 | %nonassoc "if" |
765 | %nonassoc "else" | |
2fad14e5 JF |
766 | |
767 | %nonassoc ":" | |
768 | %nonassoc "!yield" | |
c3b144b8 | 769 | /* }}} */ |
b92ceddb | 770 | |
9d2b125d JF |
771 | %start Program |
772 | %token MarkModule | |
773 | %token MarkScript | |
a4d849b7 | 774 | %token MarkExpression |
e5332278 | 775 | |
693d501b | 776 | %% |
c3c20102 | 777 | |
9d2b125d JF |
778 | Program |
779 | : MarkScript Script | |
780 | | MarkModule Module | |
a4d849b7 | 781 | | MarkExpression Expression[expression] { driver.context_ = $expression; } |
3ea7eed0 JF |
782 | ; |
783 | ||
9d2b125d JF |
784 | /* Lexer State {{{ */ |
785 | LexPushInOn: { driver.in_.push(true); }; | |
786 | LexPushInOff: { driver.in_.push(false); }; | |
787 | LexPopIn: { driver.in_.pop(); }; | |
3ea7eed0 | 788 | |
9d2b125d JF |
789 | LexPushReturnOn: { driver.return_.push(true); }; |
790 | LexPopReturn: { driver.return_.pop(); }; | |
57efef5f | 791 | Return: "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }; |
9d2b125d | 792 | |
c5b15840 JF |
793 | LexPushSuperOn: { driver.super_.push(true); }; |
794 | LexPushSuperOff: { driver.super_.push(false); }; | |
795 | LexPopSuper: { driver.super_.pop(); }; | |
57efef5f | 796 | Super: "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); }; |
c5b15840 | 797 | |
9d2b125d JF |
798 | LexPushYieldOn: { driver.yield_.push(true); }; |
799 | LexPushYieldOff: { driver.yield_.push(false); }; | |
800 | LexPopYield: { driver.yield_.pop(); }; | |
3ea7eed0 | 801 | |
fdcef8e7 | 802 | LexNewLineOrOpt |
197e361c | 803 | : { CYLEX(); if (driver.newline_) { CYHLD(@$, tk::NewLine); } } |
a5662a53 JF |
804 | ; |
805 | ||
fdcef8e7 | 806 | LexNewLineOrNot |
197e361c | 807 | : { CYLEX(); CYHLD(@$, driver.newline_ ? tk::NewLine : tk::__); } |
fdcef8e7 JF |
808 | ; |
809 | ||
9d2b125d JF |
810 | LexNoStar |
811 | : { CYMAP(YieldStar, Star); } | |
812 | ; | |
813 | ||
4b2fd91c | 814 | LexNoBrace |
675ff733 | 815 | : { CYMAP(OpenBrace_, OpenBrace); } |
4b2fd91c | 816 | ; |
066da9f6 | 817 | |
a7d8b413 | 818 | LexNoClass |
442609f7 | 819 | : { CYMAP(_class__, _class_); } |
a7d8b413 JF |
820 | ; |
821 | ||
4b2fd91c | 822 | LexNoFunction |
442609f7 | 823 | : { CYMAP(_function__, _function_); } |
4b2fd91c JF |
824 | ; |
825 | ||
826 | LexSetStatement | |
ec18682d | 827 | : LexNoBrace LexNoClass LexNoFunction |
3ea7eed0 | 828 | ; |
691e4717 | 829 | /* }}} */ |
c3b144b8 | 830 | /* Virtual Tokens {{{ */ |
a87d7060 JF |
831 | Var_ |
832 | : "var" | |
833 | ; | |
c3b144b8 | 834 | /* }}} */ |
6c093cce | 835 | |
a7d8b413 | 836 | /* 11.6 Names and Keywords {{{ */ |
c3b144b8 | 837 | IdentifierName |
09fc3efb | 838 | : Word[pass] { $$ = $pass; } |
49392246 JF |
839 | | "for" { $$ = CYNew CYWord("for"); } |
840 | | "in" { $$ = CYNew CYWord("in"); } | |
841 | | "instanceof" { $$ = CYNew CYWord("instanceof"); } | |
c3c20102 JF |
842 | ; |
843 | ||
2fad14e5 | 844 | WordNoUnary |
09fc3efb | 845 | : IdentifierNoOf[pass] { $$ = $pass; } |
a5662a53 | 846 | | "break" { $$ = CYNew CYWord("break"); } |
8f56307d JF |
847 | | "case" { $$ = CYNew CYWord("case"); } |
848 | | "catch" { $$ = CYNew CYWord("catch"); } | |
b0fa2761 | 849 | | "class" LexOf { $$ = CYNew CYWord("class"); } |
8a392978 | 850 | | ";class" { $$ = CYNew CYWord("class"); } |
8f56307d | 851 | | "const" { $$ = CYNew CYWord("const"); } |
a5662a53 | 852 | | "continue" { $$ = CYNew CYWord("continue"); } |
8f56307d JF |
853 | | "debugger" { $$ = CYNew CYWord("debugger"); } |
854 | | "default" { $$ = CYNew CYWord("default"); } | |
8f56307d JF |
855 | | "do" { $$ = CYNew CYWord("do"); } |
856 | | "else" { $$ = CYNew CYWord("else"); } | |
857 | | "enum" { $$ = CYNew CYWord("enum"); } | |
858 | | "export" { $$ = CYNew CYWord("export"); } | |
859 | | "extends" { $$ = CYNew CYWord("extends"); } | |
860 | | "false" { $$ = CYNew CYWord("false"); } | |
861 | | "finally" { $$ = CYNew CYWord("finally"); } | |
b0fa2761 | 862 | | "function" LexOf { $$ = CYNew CYWord("function"); } |
8f56307d JF |
863 | | "if" { $$ = CYNew CYWord("if"); } |
864 | | "import" { $$ = CYNew CYWord("import"); } | |
8f56307d | 865 | | "!in" { $$ = CYNew CYWord("in"); } |
b0fa2761 | 866 | | "!of" { $$ = CYNew CYWord("of"); } |
8f56307d | 867 | | "null" { $$ = CYNew CYWord("null"); } |
a5662a53 | 868 | | "return" { $$ = CYNew CYWord("return"); } |
8f56307d JF |
869 | | "super" { $$ = CYNew CYWord("super"); } |
870 | | "switch" { $$ = CYNew CYWord("switch"); } | |
871 | | "this" { $$ = CYNew CYWord("this"); } | |
a5662a53 | 872 | | "throw" { $$ = CYNew CYWord("throw"); } |
8f56307d JF |
873 | | "true" { $$ = CYNew CYWord("true"); } |
874 | | "try" { $$ = CYNew CYWord("try"); } | |
8f56307d | 875 | | "var" { $$ = CYNew CYWord("var"); } |
8f56307d JF |
876 | | "while" { $$ = CYNew CYWord("while"); } |
877 | | "with" { $$ = CYNew CYWord("with"); } | |
2fad14e5 JF |
878 | ; |
879 | ||
880 | Word | |
881 | : WordNoUnary[pass] { $$ = $pass; } | |
882 | | "delete" { $$ = CYNew CYWord("delete"); } | |
883 | | "typeof" { $$ = CYNew CYWord("typeof"); } | |
884 | | "void" { $$ = CYNew CYWord("void"); } | |
9d2b125d | 885 | | "yield" { $$ = CYNew CYIdentifier("yield"); } |
2bf24581 | 886 | ; |
f2f0d1d1 | 887 | |
73f04979 | 888 | @begin ObjectiveC |
55fc1817 | 889 | WordOpt |
09fc3efb | 890 | : Word[pass] { $$ = $pass; } |
55fc1817 JF |
891 | | { $$ = NULL; } |
892 | ; | |
73f04979 | 893 | @end |
a7d8b413 JF |
894 | /* }}} */ |
895 | /* 11.8.1 Null Literals {{{ */ | |
896 | NullLiteral | |
897 | : "null" { $$ = CYNew CYNull(); } | |
898 | ; | |
899 | /* }}} */ | |
900 | /* 11.8.2 Boolean Literals {{{ */ | |
901 | BooleanLiteral | |
902 | : "true" { $$ = CYNew CYTrue(); } | |
903 | | "false" { $$ = CYNew CYFalse(); } | |
904 | ; | |
905 | /* }}} */ | |
f356a43d JF |
906 | /* 11.8.5 Regular Expression Literals {{{ */ |
907 | RegularExpressionSlash | |
908 | : "/" { $$ = false; } | |
909 | | "/=" { $$ = true; } | |
910 | ; | |
911 | ||
912 | RegularExpressionLiteral | |
09fc3efb | 913 | : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; } |
f356a43d JF |
914 | ; |
915 | /* }}} */ | |
a7d8b413 JF |
916 | |
917 | /* 11.9 Automatic Semicolon Insertion {{{ */ | |
918 | StrictSemi | |
919 | : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); } | |
920 | ; | |
921 | ||
fdcef8e7 JF |
922 | NewLineNot |
923 | : LexNewLineOrNot "" | |
924 | ; | |
925 | ||
926 | NewLineOpt | |
927 | : LexNewLineOrNot "\n" | |
928 | | NewLineNot | |
929 | ; | |
930 | ||
a7d8b413 | 931 | TerminatorSoft |
fdcef8e7 JF |
932 | : LexNewLineOrNot "\n" StrictSemi |
933 | | NewLineNot LexOf Terminator | |
a7d8b413 JF |
934 | ; |
935 | ||
ffc2d225 JF |
936 | TerminatorHard |
937 | : ";" | |
938 | | error { if (yyla.type_get() != yyeof_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi | |
939 | ; | |
940 | ||
a7d8b413 JF |
941 | Terminator |
942 | : ";" | |
675ff733 | 943 | | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi |
a7d8b413 JF |
944 | ; |
945 | ||
946 | TerminatorOpt | |
947 | : ";" | |
948 | | error { yyerrok; driver.errors_.pop_back(); } StrictSemi | |
949 | ; | |
950 | /* }}} */ | |
951 | ||
952 | /* 12.1 Identifiers {{{ */ | |
953 | IdentifierReference | |
09fc3efb | 954 | : Identifier[pass] { $$ = CYNew CYVariable($pass); } |
9d2b125d | 955 | | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); } |
a7d8b413 JF |
956 | ; |
957 | ||
958 | BindingIdentifier | |
484bab66 JF |
959 | : LexOf IdentifierNoOf[pass] { $$ = $pass; } |
960 | | LexOf "!of" { $$ = CYNew CYIdentifier("of"); } | |
961 | | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); } | |
9d2b125d JF |
962 | ; |
963 | ||
964 | BindingIdentifierOpt | |
09fc3efb | 965 | : BindingIdentifier[pass] { $$ = $pass; } |
484bab66 | 966 | | LexOf { $$ = NULL; } |
a7d8b413 JF |
967 | ; |
968 | ||
969 | LabelIdentifier | |
09fc3efb | 970 | : Identifier[pass] { $$ = $pass; } |
9d2b125d | 971 | | "yield" { $$ = CYNew CYIdentifier("yield"); } |
a7d8b413 | 972 | ; |
55fc1817 | 973 | |
b0fa2761 | 974 | IdentifierTypeNoOf |
09fc3efb | 975 | : Identifier_[pass] { $$ = $pass; } |
d6e7cafb | 976 | | "abstract" { $$ = CYNew CYIdentifier("abstract"); } |
90dd6ff1 | 977 | | "as" { $$ = CYNew CYIdentifier("as"); } |
d6e7cafb JF |
978 | | "await" { $$ = CYNew CYIdentifier("await"); } |
979 | | "boolean" { $$ = CYNew CYIdentifier("boolean"); } | |
980 | | "byte" { $$ = CYNew CYIdentifier("byte"); } | |
c5b15840 | 981 | | "constructor" { $$ = CYNew CYIdentifier("constructor"); } |
49392246 | 982 | | "each" { $$ = CYNew CYIdentifier("each"); } |
7085e1ab | 983 | | "eval" { $$ = CYNew CYIdentifier("eval"); } |
d6e7cafb | 984 | | "final" { $$ = CYNew CYIdentifier("final"); } |
c5b15840 JF |
985 | | "from" { $$ = CYNew CYIdentifier("from"); } |
986 | | "get" { $$ = CYNew CYIdentifier("get"); } | |
d6e7cafb JF |
987 | | "goto" { $$ = CYNew CYIdentifier("goto"); } |
988 | | "implements" { $$ = CYNew CYIdentifier("implements"); } | |
a2909cb7 | 989 | | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); } |
d6e7cafb | 990 | | "interface" { $$ = CYNew CYIdentifier("interface"); } |
b41e4739 | 991 | | "let" { $$ = CYNew CYIdentifier("let"); } |
484bab66 | 992 | | "!let" LexBind LexOf { $$ = CYNew CYIdentifier("let"); } |
d6e7cafb JF |
993 | | "native" { $$ = CYNew CYIdentifier("native"); } |
994 | | "package" { $$ = CYNew CYIdentifier("package"); } | |
995 | | "private" { $$ = CYNew CYIdentifier("private"); } | |
996 | | "protected" { $$ = CYNew CYIdentifier("protected"); } | |
a02c6df3 | 997 | | "__proto__" { $$ = CYNew CYIdentifier("__proto__"); } |
c5b15840 | 998 | | "prototype" { $$ = CYNew CYIdentifier("prototype"); } |
d6e7cafb | 999 | | "public" { $$ = CYNew CYIdentifier("public"); } |
c5b15840 | 1000 | | "set" { $$ = CYNew CYIdentifier("set"); } |
d6e7cafb | 1001 | | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); } |
322286dd | 1002 | | "target" { $$ = CYNew CYIdentifier("target"); } |
d6e7cafb JF |
1003 | | "throws" { $$ = CYNew CYIdentifier("throws"); } |
1004 | | "transient" { $$ = CYNew CYIdentifier("transient"); } | |
574d4720 | 1005 | | "typeid" { $$ = CYNew CYIdentifier("typeid"); } |
c5b15840 | 1006 | | "undefined" { $$ = CYNew CYIdentifier("undefined"); } |
09e4db67 JF |
1007 | @begin ObjectiveC |
1008 | | "bool" { $$ = CYNew CYIdentifier("bool"); } | |
1009 | | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); } | |
1010 | | "id" { $$ = CYNew CYIdentifier("id"); } | |
1011 | | "SEL" { $$ = CYNew CYIdentifier("SEL"); } | |
1012 | @end | |
75b0a457 JF |
1013 | ; |
1014 | ||
b0fa2761 | 1015 | IdentifierType |
09fc3efb | 1016 | : IdentifierTypeNoOf[pass] { $$ = $pass; } |
b0fa2761 JF |
1017 | | "of" { $$ = CYNew CYIdentifier("of"); } |
1018 | ; | |
1019 | ||
b3c38c5f JF |
1020 | IdentifierTypeOpt |
1021 | : IdentifierType[pass] { $$ = $pass; } | |
1022 | | { $$ = NULL; } | |
1023 | ; | |
1024 | ||
b0fa2761 JF |
1025 | IdentifierNoOf |
1026 | : IdentifierTypeNoOf | |
d6e7cafb | 1027 | | "char" { $$ = CYNew CYIdentifier("char"); } |
1e8d8047 JF |
1028 | | "double" { $$ = CYNew CYIdentifier("double"); } |
1029 | | "float" { $$ = CYNew CYIdentifier("float"); } | |
d6e7cafb | 1030 | | "int" { $$ = CYNew CYIdentifier("int"); } |
24ffc58c | 1031 | | "__int128" { $$ = CYNew CYIdentifier("__int128"); } |
d6e7cafb JF |
1032 | | "long" { $$ = CYNew CYIdentifier("long"); } |
1033 | | "short" { $$ = CYNew CYIdentifier("short"); } | |
c5b15840 | 1034 | | "static" { $$ = CYNew CYIdentifier("static"); } |
d6e7cafb | 1035 | | "volatile" { $$ = CYNew CYIdentifier("volatile"); } |
3fe283c5 | 1036 | @begin C |
d6e7cafb | 1037 | | "signed" { $$ = CYNew CYIdentifier("signed"); } |
d6e7cafb | 1038 | | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); } |
7b750785 JF |
1039 | @end |
1040 | @begin ObjectiveC | |
09e4db67 | 1041 | | "nil" { $$ = CYNew CYIdentifier("nil"); } |
d6e7cafb | 1042 | | "NO" { $$ = CYNew CYIdentifier("NO"); } |
09e4db67 | 1043 | | "NULL" { $$ = CYNew CYIdentifier("NULL"); } |
d6e7cafb | 1044 | | "YES" { $$ = CYNew CYIdentifier("YES"); } |
3fe283c5 JF |
1045 | @end |
1046 | ; | |
b0fa2761 JF |
1047 | |
1048 | Identifier | |
09fc3efb | 1049 | : IdentifierNoOf[pass] { $$ = $pass; } |
b0fa2761 | 1050 | | "of" { $$ = CYNew CYIdentifier("of"); } |
484bab66 | 1051 | | "!of" { $$ = CYNew CYIdentifier("of"); } |
b0fa2761 | 1052 | ; |
c3b144b8 | 1053 | /* }}} */ |
a7d8b413 | 1054 | /* 12.2 Primary Expression {{{ */ |
3ea7eed0 | 1055 | PrimaryExpression |
8f56307d | 1056 | : "this" { $$ = CYNew CYThis(); } |
09fc3efb JF |
1057 | | IdentifierReference[pass] { $$ = $pass; } |
1058 | | Literal[pass] { $$ = $pass; } | |
1059 | | ArrayLiteral[pass] { $$ = $pass; } | |
1060 | | ObjectLiteral[pass] { $$ = $pass; } | |
1061 | | FunctionExpression[pass] { $$ = $pass; } | |
1062 | | ClassExpression[pass] { $$ = $pass; } | |
1063 | | GeneratorExpression[pass] { $$ = $pass; } | |
1064 | | RegularExpressionLiteral[pass] { $$ = $pass; } | |
1065 | | TemplateLiteral[pass] { $$ = $pass; } | |
1066 | | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; } | |
3ea7eed0 | 1067 | | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; } |
1dbba6cc | 1068 | ; |
a7d8b413 JF |
1069 | |
1070 | CoverParenthesizedExpressionAndArrowParameterList | |
09fc3efb | 1071 | : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); } |
484bab66 JF |
1072 | | "(" LexOf ")" { $$ = NULL; } |
1073 | | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); } | |
1074 | | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); } | |
a7d8b413 | 1075 | ; |
1dbba6cc | 1076 | /* }}} */ |
a7d8b413 JF |
1077 | /* 12.2.4 Literals {{{ */ |
1078 | Literal | |
09fc3efb JF |
1079 | : NullLiteral[pass] { $$ = $pass; } |
1080 | | BooleanLiteral[pass] { $$ = $pass; } | |
1081 | | NumericLiteral[pass] { $$ = $pass; } | |
1082 | | StringLiteral[pass] { $$ = $pass; } | |
b3aa25d8 JF |
1083 | ; |
1084 | /* }}} */ | |
a7d8b413 | 1085 | /* 12.2.5 Array Initializer {{{ */ |
36cd3cb9 | 1086 | ArrayLiteral |
09fc3efb | 1087 | : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); } |
1dbba6cc JF |
1088 | ; |
1089 | ||
5a6c975a JF |
1090 | ArrayElement |
1091 | : AssignmentExpression[value] { $$ = CYNew CYElementValue($value); } | |
484bab66 | 1092 | | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); } |
5a6c975a JF |
1093 | ; |
1094 | ||
1095 | ElementList_ | |
1096 | : "," ElementListOpt[elements] { $$ = $elements; } | |
1097 | | { $$ = NULL; } | |
1098 | ; | |
1099 | ||
1100 | ElementList | |
1101 | : ArrayElement[element] ElementList_[next] { $$ = $element; $$->SetNext($next); } | |
1102 | | LexOf "," ElementListOpt[next] { $$ = CYNew CYElementValue(NULL, $next); } | |
1dbba6cc | 1103 | ; |
55fc1817 JF |
1104 | |
1105 | ElementListOpt | |
09fc3efb | 1106 | : ElementList[pass] { $$ = $pass; } |
484bab66 | 1107 | | LexOf { $$ = NULL; } |
55fc1817 | 1108 | ; |
1dbba6cc | 1109 | /* }}} */ |
a7d8b413 | 1110 | /* 12.2.6 Object Initializer {{{ */ |
36cd3cb9 | 1111 | ObjectLiteral |
675ff733 | 1112 | : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); } |
1dbba6cc JF |
1113 | ; |
1114 | ||
aea76473 | 1115 | PropertyDefinitionList_ |
09fc3efb | 1116 | : "," PropertyDefinitionListOpt[properties] { $$ = $properties; } |
cac61857 | 1117 | | { $$ = NULL; } |
1dbba6cc JF |
1118 | ; |
1119 | ||
aea76473 | 1120 | PropertyDefinitionList |
09fc3efb | 1121 | : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; } |
55fc1817 JF |
1122 | ; |
1123 | ||
aea76473 | 1124 | PropertyDefinitionListOpt |
5fe10198 JF |
1125 | : PropertyDefinitionList[properties] { $$ = $properties; } |
1126 | | { $$ = NULL; } | |
1dbba6cc JF |
1127 | ; |
1128 | ||
aea76473 | 1129 | PropertyDefinition |
09fc3efb JF |
1130 | : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); } |
1131 | | CoverInitializedName[name] { CYNOT(@$); } | |
1132 | | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); } | |
1133 | | MethodDefinition[pass] { $$ = $pass; } | |
9d2b125d JF |
1134 | ; |
1135 | ||
1136 | PropertyName | |
09fc3efb JF |
1137 | : LiteralPropertyName[pass] { $$ = $pass; } |
1138 | | ComputedPropertyName[pass] { $$ = $pass; } | |
aea76473 JF |
1139 | ; |
1140 | ||
9d2b125d | 1141 | LiteralPropertyName |
09fc3efb JF |
1142 | : IdentifierName[pass] { $$ = $pass; } |
1143 | | StringLiteral[pass] { $$ = $pass; } | |
1144 | | NumericLiteral[pass] { $$ = $pass; } | |
1dbba6cc | 1145 | ; |
b92ceddb | 1146 | |
9d2b125d | 1147 | ComputedPropertyName |
09fc3efb | 1148 | : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); } |
b92ceddb | 1149 | ; |
a7d8b413 | 1150 | |
9d2b125d JF |
1151 | CoverInitializedName |
1152 | : IdentifierReference Initializer | |
1153 | ; | |
a7d8b413 JF |
1154 | |
1155 | Initializer | |
09fc3efb | 1156 | : "=" AssignmentExpression[initializer] { $$ = $initializer; } |
a7d8b413 JF |
1157 | ; |
1158 | ||
1159 | InitializerOpt | |
09fc3efb | 1160 | : Initializer[pass] { $$ = $pass; } |
a7d8b413 JF |
1161 | | { $$ = NULL; } |
1162 | ; | |
1163 | /* }}} */ | |
1164 | /* 12.2.9 Template Literals {{{ */ | |
b900e1a4 | 1165 | TemplateLiteral |
09fc3efb | 1166 | : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); } |
fbbf5d6a | 1167 | | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); } |
b900e1a4 | 1168 | ; |
1dbba6cc | 1169 | |
b900e1a4 | 1170 | TemplateSpans |
09fc3efb | 1171 | : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); } |
fbbf5d6a | 1172 | | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); } |
b900e1a4 JF |
1173 | ; |
1174 | /* }}} */ | |
a7d8b413 | 1175 | |
8a392978 | 1176 | /* 12.3 Left-Hand-Side Expressions {{{ */ |
9b5527f0 | 1177 | MemberAccess |
09fc3efb JF |
1178 | : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); } |
1179 | | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); } | |
7e5391fd | 1180 | | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; } |
9d2b125d | 1181 | | TemplateLiteral { CYNOT(@$); } |
55fc1817 JF |
1182 | ; |
1183 | ||
36cd3cb9 | 1184 | MemberExpression |
5fe10198 | 1185 | : PrimaryExpression[pass] { $$ = $pass; } |
09fc3efb JF |
1186 | | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; } |
1187 | | SuperProperty[pass] { $$ = $pass; } | |
9d2b125d | 1188 | | MetaProperty { CYNOT(@$); } |
5fe10198 | 1189 | | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); } |
1dbba6cc JF |
1190 | ; |
1191 | ||
9d2b125d | 1192 | SuperProperty |
57efef5f JF |
1193 | : Super "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); } |
1194 | | Super "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); } | |
9d2b125d JF |
1195 | ; |
1196 | ||
1197 | MetaProperty | |
1198 | : NewTarget | |
1199 | ; | |
1200 | ||
1201 | NewTarget | |
5fe10198 | 1202 | : "new" "." "target" |
9d2b125d JF |
1203 | ; |
1204 | ||
36cd3cb9 | 1205 | NewExpression |
09fc3efb | 1206 | : MemberExpression[pass] { $$ = $pass; } |
5fe10198 | 1207 | | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); } |
1dbba6cc JF |
1208 | ; |
1209 | ||
3ea7eed0 | 1210 | CallExpression_ |
09fc3efb JF |
1211 | : MemberExpression[pass] { $$ = $pass; } |
1212 | | CallExpression[pass] { $$ = $pass; } | |
b1589845 JF |
1213 | ; |
1214 | ||
36cd3cb9 | 1215 | CallExpression |
09fc3efb JF |
1216 | : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); } |
1217 | | SuperCall[pass] { $$ = $pass; } | |
1218 | | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; } | |
1dbba6cc JF |
1219 | ; |
1220 | ||
9d2b125d | 1221 | SuperCall |
57efef5f | 1222 | : Super Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); } |
9d2b125d JF |
1223 | ; |
1224 | ||
3ea7eed0 | 1225 | Arguments |
09fc3efb | 1226 | : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; } |
b1589845 JF |
1227 | ; |
1228 | ||
36cd3cb9 | 1229 | ArgumentList_ |
09fc3efb | 1230 | : "," ArgumentList[arguments] { $$ = $arguments; } |
cf7d4c69 | 1231 | | { $$ = NULL; } |
1dbba6cc JF |
1232 | ; |
1233 | ||
55fc1817 | 1234 | ArgumentList |
09fc3efb | 1235 | : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); } |
484bab66 | 1236 | | LexOf "..." AssignmentExpression { CYNOT(@$); } |
55fc1817 JF |
1237 | ; |
1238 | ||
36cd3cb9 | 1239 | ArgumentListOpt |
09fc3efb | 1240 | : ArgumentList[pass] { $$ = $pass; } |
484bab66 | 1241 | | LexOf { $$ = NULL; } |
1dbba6cc JF |
1242 | ; |
1243 | ||
620c82a1 | 1244 | AccessExpression |
09fc3efb JF |
1245 | : NewExpression[pass] { $$ = $pass; } |
1246 | | CallExpression[pass] { $$ = $pass; } | |
693d501b | 1247 | ; |
620c82a1 JF |
1248 | |
1249 | LeftHandSideExpression | |
4f3e597c | 1250 | : BracedExpression[pass] { $$ = $pass; } |
5fe10198 | 1251 | | IndirectExpression[pass] { $$ = $pass; } |
620c82a1 | 1252 | ; |
63cd45c9 | 1253 | /* }}} */ |
a7d8b413 | 1254 | /* 12.4 Postfix Expressions {{{ */ |
36cd3cb9 | 1255 | PostfixExpression |
4f3e597c | 1256 | : BracedExpression[pass] { $$ = $pass; } |
fdcef8e7 JF |
1257 | | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); } |
1258 | | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); } | |
1dbba6cc | 1259 | ; |
63cd45c9 | 1260 | /* }}} */ |
a7d8b413 | 1261 | /* 12.5 Unary Operators {{{ */ |
693d501b | 1262 | UnaryExpression_ |
09fc3efb JF |
1263 | : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); } |
1264 | | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); } | |
1265 | | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); } | |
1266 | | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); } | |
09fc3efb | 1267 | | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); } |
09fc3efb JF |
1268 | | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); } |
1269 | | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); } | |
1270 | | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); } | |
1271 | | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); } | |
693d501b JF |
1272 | ; |
1273 | ||
1274 | UnaryExpression | |
675ff733 | 1275 | : PostfixExpression[expression] { $$ = $expression; } |
5fe10198 | 1276 | | UnaryExpression_[pass] { $$ = $pass; } |
693d501b | 1277 | ; |
63cd45c9 | 1278 | /* }}} */ |
a7d8b413 | 1279 | /* 12.6 Multiplicative Operators {{{ */ |
36cd3cb9 | 1280 | MultiplicativeExpression |
09fc3efb JF |
1281 | : UnaryExpression[pass] { $$ = $pass; } |
1282 | | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); } | |
1283 | | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); } | |
1284 | | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); } | |
1dbba6cc | 1285 | ; |
63cd45c9 | 1286 | /* }}} */ |
a7d8b413 | 1287 | /* 12.7 Additive Operators {{{ */ |
36cd3cb9 | 1288 | AdditiveExpression |
09fc3efb JF |
1289 | : MultiplicativeExpression[pass] { $$ = $pass; } |
1290 | | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); } | |
1291 | | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); } | |
1dbba6cc | 1292 | ; |
63cd45c9 | 1293 | /* }}} */ |
a7d8b413 | 1294 | /* 12.8 Bitwise Shift Operators {{{ */ |
36cd3cb9 | 1295 | ShiftExpression |
09fc3efb JF |
1296 | : AdditiveExpression[pass] { $$ = $pass; } |
1297 | | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); } | |
1298 | | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); } | |
1299 | | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); } | |
1dbba6cc | 1300 | ; |
63cd45c9 | 1301 | /* }}} */ |
a7d8b413 | 1302 | /* 12.9 Relational Operators {{{ */ |
3ea7eed0 | 1303 | RelationalExpression |
09fc3efb JF |
1304 | : ShiftExpression[pass] { $$ = $pass; } |
1305 | | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); } | |
1306 | | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); } | |
1307 | | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); } | |
1308 | | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); } | |
1309 | | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); } | |
1310 | | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); } | |
693d501b | 1311 | ; |
63cd45c9 | 1312 | /* }}} */ |
a7d8b413 | 1313 | /* 12.10 Equality Operators {{{ */ |
36cd3cb9 | 1314 | EqualityExpression |
09fc3efb JF |
1315 | : RelationalExpression[pass] { $$ = $pass; } |
1316 | | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); } | |
1317 | | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); } | |
1318 | | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); } | |
1319 | | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); } | |
1dbba6cc | 1320 | ; |
63cd45c9 | 1321 | /* }}} */ |
a7d8b413 | 1322 | /* 12.11 Binary Bitwise Operators {{{ */ |
36cd3cb9 | 1323 | BitwiseANDExpression |
09fc3efb JF |
1324 | : EqualityExpression[pass] { $$ = $pass; } |
1325 | | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); } | |
1dbba6cc JF |
1326 | ; |
1327 | ||
36cd3cb9 | 1328 | BitwiseXORExpression |
09fc3efb JF |
1329 | : BitwiseANDExpression[pass] { $$ = $pass; } |
1330 | | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); } | |
1dbba6cc JF |
1331 | ; |
1332 | ||
36cd3cb9 | 1333 | BitwiseORExpression |
09fc3efb JF |
1334 | : BitwiseXORExpression[pass] { $$ = $pass; } |
1335 | | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); } | |
1dbba6cc | 1336 | ; |
63cd45c9 | 1337 | /* }}} */ |
a7d8b413 | 1338 | /* 12.12 Binary Logical Operators {{{ */ |
36cd3cb9 | 1339 | LogicalANDExpression |
09fc3efb JF |
1340 | : BitwiseORExpression[pass] { $$ = $pass; } |
1341 | | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); } | |
1dbba6cc JF |
1342 | ; |
1343 | ||
36cd3cb9 | 1344 | LogicalORExpression |
09fc3efb JF |
1345 | : LogicalANDExpression[pass] { $$ = $pass; } |
1346 | | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); } | |
1dbba6cc | 1347 | ; |
63cd45c9 | 1348 | /* }}} */ |
a7d8b413 | 1349 | /* 12.13 Conditional Operator ( ? : ) {{{ */ |
8b77acf1 JF |
1350 | @begin ObjectiveC |
1351 | ConditionalExpressionClassic | |
09fc3efb JF |
1352 | : LogicalORExpression[pass] { $$ = $pass; } |
1353 | | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); } | |
8b77acf1 JF |
1354 | ; |
1355 | @end | |
1356 | ||
36cd3cb9 | 1357 | ConditionalExpression |
09fc3efb JF |
1358 | : LogicalORExpression[pass] { $$ = $pass; } |
1359 | | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); } | |
693d501b | 1360 | ; |
63cd45c9 | 1361 | /* }}} */ |
a7d8b413 | 1362 | /* 12.14 Assignment Operators {{{ */ |
8b77acf1 | 1363 | LeftHandSideAssignment |
09fc3efb JF |
1364 | : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); } |
1365 | | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); } | |
1366 | | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); } | |
1367 | | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); } | |
1368 | | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); } | |
1369 | | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); } | |
1370 | | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); } | |
1371 | | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); } | |
1372 | | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); } | |
1373 | | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); } | |
1374 | | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); } | |
1375 | | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); } | |
8b77acf1 JF |
1376 | ; |
1377 | ||
1378 | @begin ObjectiveC | |
1379 | AssignmentExpressionClassic | |
484bab66 JF |
1380 | : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; } |
1381 | | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; } | |
8b77acf1 JF |
1382 | ; |
1383 | @end | |
1384 | ||
36cd3cb9 | 1385 | AssignmentExpression |
484bab66 JF |
1386 | : LexOf ConditionalExpression[pass] { $$ = $pass; } |
1387 | | LexOf YieldExpression[pass] { $$ = $pass; } | |
09fc3efb | 1388 | | ArrowFunction[pass] { $$ = $pass; } |
484bab66 | 1389 | | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; } |
693d501b | 1390 | ; |
63cd45c9 | 1391 | /* }}} */ |
a7d8b413 | 1392 | /* 12.15 Comma Operator ( , ) {{{ */ |
55fc1817 | 1393 | Expression |
09fc3efb JF |
1394 | : AssignmentExpression[pass] { $$ = $pass; } |
1395 | | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); } | |
693d501b JF |
1396 | ; |
1397 | ||
36cd3cb9 | 1398 | ExpressionOpt |
09fc3efb | 1399 | : Expression[pass] { $$ = $pass; } |
484bab66 | 1400 | | LexOf { $$ = NULL; } |
1dbba6cc | 1401 | ; |
63cd45c9 | 1402 | /* }}} */ |
693d501b | 1403 | |
a7d8b413 | 1404 | /* 13 Statements and Declarations {{{ */ |
3ea7eed0 | 1405 | Statement__ |
09fc3efb JF |
1406 | : BlockStatement[pass] { $$ = $pass; } |
1407 | | VariableStatement[pass] { $$ = $pass; } | |
1408 | | EmptyStatement[pass] { $$ = $pass; } | |
1409 | | IfStatement[pass] { $$ = $pass; } | |
1410 | | BreakableStatement[pass] { $$ = $pass; } | |
1411 | | ContinueStatement[pass] { $$ = $pass; } | |
1412 | | BreakStatement[pass] { $$ = $pass; } | |
1413 | | ReturnStatement[pass] { $$ = $pass; } | |
1414 | | WithStatement[pass] { $$ = $pass; } | |
1415 | | LabelledStatement[pass] { $$ = $pass; } | |
1416 | | ThrowStatement[pass] { $$ = $pass; } | |
1417 | | TryStatement[pass] { $$ = $pass; } | |
1418 | | DebuggerStatement[pass] { $$ = $pass; } | |
1dbba6cc | 1419 | ; |
b10bd496 | 1420 | |
3ea7eed0 | 1421 | Statement_ |
484bab66 | 1422 | : LexOf Statement__[pass] { $$ = $pass; } |
09fc3efb | 1423 | | ExpressionStatement[pass] { $$ = $pass; } |
3ea7eed0 JF |
1424 | ; |
1425 | ||
b10bd496 | 1426 | Statement |
09fc3efb | 1427 | : LexSetStatement LexLet Statement_[pass] { $$ = $pass; } |
b10bd496 | 1428 | ; |
c8a0500b | 1429 | |
484bab66 | 1430 | Declaration_ |
09fc3efb JF |
1431 | : HoistableDeclaration[pass] { $$ = $pass; } |
1432 | | ClassDeclaration[pass] { $$ = $pass; } | |
c8a0500b JF |
1433 | ; |
1434 | ||
3ea7eed0 | 1435 | Declaration |
484bab66 JF |
1436 | : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; } |
1437 | | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; } | |
3ea7eed0 JF |
1438 | ; |
1439 | ||
a7d8b413 | 1440 | HoistableDeclaration |
09fc3efb JF |
1441 | : FunctionDeclaration[pass] { $$ = $pass; } |
1442 | | GeneratorDeclaration[pass] { $$ = $pass; } | |
a7d8b413 JF |
1443 | ; |
1444 | ||
c8a0500b | 1445 | BreakableStatement |
09fc3efb JF |
1446 | : IterationStatement[pass] { $$ = $pass; } |
1447 | | SwitchStatement[pass] { $$ = $pass; } | |
c8a0500b | 1448 | ; |
63cd45c9 | 1449 | /* }}} */ |
a7d8b413 JF |
1450 | /* 13.2 Block {{{ */ |
1451 | BlockStatement | |
09fc3efb | 1452 | : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); } |
cac61857 JF |
1453 | ; |
1454 | ||
36cd3cb9 | 1455 | Block |
675ff733 | 1456 | : "{" StatementListOpt[code] "}" { $$ = $code; } |
1dbba6cc JF |
1457 | ; |
1458 | ||
693d501b | 1459 | StatementList |
ffc2d225 | 1460 | : StatementListItem[statement] StatementListOpt[next] { $$ = $statement; CYSetLast($$) = $next; } |
693d501b JF |
1461 | ; |
1462 | ||
1463 | StatementListOpt | |
09fc3efb | 1464 | : StatementList[pass] { $$ = $pass; } |
484bab66 | 1465 | | LexSetStatement LexLet LexOf { $$ = NULL; } |
1dbba6cc | 1466 | ; |
c8a0500b JF |
1467 | |
1468 | StatementListItem | |
09fc3efb JF |
1469 | : Statement[pass] { $$ = $pass; } |
1470 | | Declaration[pass] { $$ = $pass; } | |
c8a0500b JF |
1471 | ; |
1472 | /* }}} */ | |
4e3c9056 | 1473 | /* 13.3 Let and Const Declarations {{{ */ |
bfd79fae | 1474 | LexicalDeclaration_ |
09fc3efb | 1475 | : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); } |
bfd79fae JF |
1476 | ; |
1477 | ||
c8a0500b | 1478 | LexicalDeclaration |
09fc3efb | 1479 | : LexicalDeclaration_[statement] Terminator { $$ = $statement; } |
c8a0500b JF |
1480 | ; |
1481 | ||
b41e4739 JF |
1482 | LexLet |
1483 | : { CYMAP(_let__, _let_); } | |
1484 | ; | |
1485 | ||
b0fa2761 JF |
1486 | LexOf |
1487 | : { CYMAP(_of__, _of_); } | |
1488 | ; | |
1489 | ||
b41e4739 | 1490 | LexBind |
484bab66 | 1491 | : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); } |
b41e4739 JF |
1492 | ; |
1493 | ||
c8a0500b | 1494 | LetOrConst |
484bab66 JF |
1495 | : LexLet LexOf "!let" LexBind LexOf { $$ = false; } |
1496 | | LexLet LexOf "const" { $$ = true; } | |
c8a0500b | 1497 | ; |
a7d8b413 | 1498 | |
4e3c9056 | 1499 | BindingList_ |
09fc3efb | 1500 | : "," LexBind BindingList[bindings] { $$ = $bindings; } |
4e3c9056 JF |
1501 | | { $$ = NULL; } |
1502 | ; | |
1503 | ||
1504 | BindingList | |
09fc3efb | 1505 | : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); } |
a7d8b413 JF |
1506 | ; |
1507 | ||
4e3c9056 | 1508 | LexicalBinding |
09fc3efb | 1509 | : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } |
484bab66 | 1510 | | LexOf BindingPattern Initializer { CYNOT(@$); } |
4e3c9056 | 1511 | ; |
63cd45c9 | 1512 | /* }}} */ |
4e3c9056 | 1513 | /* 13.3.2 Variable Statement {{{ */ |
bfd79fae | 1514 | VariableStatement_ |
09fc3efb | 1515 | : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); } |
bfd79fae JF |
1516 | ; |
1517 | ||
36cd3cb9 | 1518 | VariableStatement |
09fc3efb | 1519 | : VariableStatement_[statement] Terminator { $$ = $statement; } |
1dbba6cc JF |
1520 | ; |
1521 | ||
36cd3cb9 | 1522 | VariableDeclarationList_ |
09fc3efb | 1523 | : "," VariableDeclarationList[bindings] { $$ = $bindings; } |
cf7d4c69 | 1524 | | { $$ = NULL; } |
1dbba6cc JF |
1525 | ; |
1526 | ||
55fc1817 | 1527 | VariableDeclarationList |
09fc3efb | 1528 | : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); } |
55fc1817 JF |
1529 | ; |
1530 | ||
36cd3cb9 | 1531 | VariableDeclaration |
09fc3efb | 1532 | : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } |
484bab66 | 1533 | | LexOf BindingPattern Initializer { CYNOT(@$); } |
1dbba6cc | 1534 | ; |
63cd45c9 | 1535 | /* }}} */ |
9d2b125d JF |
1536 | /* 13.3.3 Destructuring Binding Patterns {{{ */ |
1537 | BindingPattern | |
1538 | : ObjectBindingPattern | |
1539 | | ArrayBindingPattern | |
1540 | ; | |
1541 | ||
1542 | ObjectBindingPattern | |
b41e4739 | 1543 | : "let {" BindingPropertyListOpt "}" |
9d2b125d JF |
1544 | ; |
1545 | ||
1546 | ArrayBindingPattern | |
93d4b2d7 | 1547 | : "let [" BindingElementListOpt "]" |
9d2b125d JF |
1548 | ; |
1549 | ||
1550 | BindingPropertyList_ | |
1551 | : "," BindingPropertyListOpt | |
1552 | | | |
1553 | ; | |
1554 | ||
1555 | BindingPropertyList | |
1556 | : BindingProperty BindingPropertyList_ | |
1557 | ; | |
1558 | ||
1559 | BindingPropertyListOpt | |
1560 | : BindingPropertyList | |
484bab66 | 1561 | | LexOf |
9d2b125d JF |
1562 | ; |
1563 | ||
93d4b2d7 JF |
1564 | BindingElementList |
1565 | : BindingElementOpt[element] "," BindingElementListOpt[next] | |
1566 | | BindingRestElement[element] | |
1567 | | BindingElement[element] | |
1568 | ; | |
1569 | ||
1570 | BindingElementListOpt | |
1571 | : BindingElementList[pass] | |
1572 | | LexBind LexOf | |
1573 | ; | |
1574 | ||
9d2b125d JF |
1575 | BindingProperty |
1576 | : SingleNameBinding | |
484bab66 | 1577 | | LexOf PropertyName ":" BindingElement |
9d2b125d | 1578 | ; |
c8a0500b JF |
1579 | |
1580 | BindingElement | |
09fc3efb | 1581 | : LexBind SingleNameBinding[pass] { $$ = $pass; } |
484bab66 | 1582 | | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); } |
c8a0500b JF |
1583 | ; |
1584 | ||
93d4b2d7 JF |
1585 | BindingElementOpt |
1586 | : BindingElement[pass] | |
1587 | | LexBind LexOf | |
1588 | ; | |
1589 | ||
c8a0500b | 1590 | SingleNameBinding |
09fc3efb | 1591 | : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); } |
c8a0500b | 1592 | ; |
9d2b125d JF |
1593 | |
1594 | BindingRestElement | |
93d4b2d7 | 1595 | : LexBind LexOf "..." BindingIdentifier |
9d2b125d | 1596 | ; |
c8a0500b | 1597 | /* }}} */ |
a7d8b413 | 1598 | /* 13.4 Empty Statement {{{ */ |
36cd3cb9 | 1599 | EmptyStatement |
2eb8215d | 1600 | : ";" { $$ = CYNew CYEmpty(); } |
1dbba6cc | 1601 | ; |
63cd45c9 | 1602 | /* }}} */ |
a7d8b413 | 1603 | /* 13.5 Expression Statement {{{ */ |
bfd79fae | 1604 | ExpressionStatement_ |
09fc3efb | 1605 | : Expression[expression] { $$ = CYNew CYExpress($[expression]); } |
bfd79fae | 1606 | |
36cd3cb9 | 1607 | ExpressionStatement |
09fc3efb | 1608 | : ExpressionStatement_[statement] Terminator { $$ = $statement; } |
1dbba6cc | 1609 | ; |
63cd45c9 | 1610 | /* }}} */ |
a7d8b413 | 1611 | /* 13.6 The if Statement {{{ */ |
36cd3cb9 | 1612 | ElseStatementOpt |
09fc3efb | 1613 | : "else" Statement[false] { $$ = $false; } |
c3c20102 | 1614 | | %prec "if" { $$ = NULL; } |
1dbba6cc JF |
1615 | ; |
1616 | ||
36cd3cb9 | 1617 | IfStatement |
09fc3efb | 1618 | : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); } |
1dbba6cc | 1619 | ; |
63cd45c9 | 1620 | /* }}} */ |
4e3c9056 | 1621 | /* 13.7 Iteration Statements {{{ */ |
d5618df7 | 1622 | IterationStatement |
09fc3efb JF |
1623 | : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); } |
1624 | | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); } | |
1625 | | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); } | |
484bab66 | 1626 | | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); } |
09fc3efb JF |
1627 | | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); } |
1628 | | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); } | |
1dbba6cc JF |
1629 | ; |
1630 | ||
a7d8b413 | 1631 | ForStatementInitializer |
484bab66 | 1632 | : LexLet LexOf EmptyStatement[pass] { $$ = $pass; } |
09fc3efb | 1633 | | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; } |
484bab66 | 1634 | | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; } |
09fc3efb | 1635 | | LexicalDeclaration_[initializer] ";" { $$ = $initializer; } |
1dbba6cc | 1636 | ; |
1dbba6cc | 1637 | |
a7d8b413 | 1638 | ForInStatementInitializer |
4f3e597c | 1639 | : LexLet LexOf BracedExpression[pass] { $$ = $pass; } |
484bab66 JF |
1640 | | LexLet LexOf IndirectExpression[pass] { $$ = $pass; } |
1641 | | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); } | |
09fc3efb | 1642 | | ForDeclaration[pass] { $$ = $pass; } |
4e3c9056 JF |
1643 | ; |
1644 | ||
1645 | ForDeclaration | |
09fc3efb | 1646 | : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); } |
4e3c9056 JF |
1647 | ; |
1648 | ||
1649 | ForBinding | |
09fc3efb | 1650 | : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); } |
484bab66 | 1651 | | LexOf BindingPattern { CYNOT(@$); } |
1dbba6cc | 1652 | ; |
63cd45c9 | 1653 | /* }}} */ |
a7d8b413 | 1654 | /* 13.8 The continue Statement {{{ */ |
36cd3cb9 | 1655 | ContinueStatement |
fdcef8e7 JF |
1656 | : "continue" TerminatorSoft { $$ = CYNew CYContinue(NULL); } |
1657 | | "continue" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYContinue($label); } | |
1dbba6cc | 1658 | ; |
63cd45c9 | 1659 | /* }}} */ |
a7d8b413 | 1660 | /* 13.9 The break Statement {{{ */ |
36cd3cb9 | 1661 | BreakStatement |
fdcef8e7 JF |
1662 | : "break" TerminatorSoft { $$ = CYNew CYBreak(NULL); } |
1663 | | "break" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYBreak($label); } | |
1dbba6cc | 1664 | ; |
63cd45c9 | 1665 | /* }}} */ |
a7d8b413 | 1666 | /* 13.10 The return Statement {{{ */ |
36cd3cb9 | 1667 | ReturnStatement |
fdcef8e7 JF |
1668 | : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); } |
1669 | | Return NewLineNot Expression[value] Terminator { $$ = CYNew CYReturn($value); } | |
1dbba6cc | 1670 | ; |
63cd45c9 | 1671 | /* }}} */ |
a7d8b413 | 1672 | /* 13.11 The with Statement {{{ */ |
36cd3cb9 | 1673 | WithStatement |
09fc3efb | 1674 | : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); } |
1dbba6cc | 1675 | ; |
63cd45c9 | 1676 | /* }}} */ |
a7d8b413 | 1677 | /* 13.12 The switch Statement {{{ */ |
36cd3cb9 | 1678 | SwitchStatement |
09fc3efb | 1679 | : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); } |
1dbba6cc JF |
1680 | ; |
1681 | ||
1682 | CaseBlock | |
675ff733 | 1683 | : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; } |
1dbba6cc JF |
1684 | ; |
1685 | ||
55fc1817 | 1686 | CaseClause |
09fc3efb | 1687 | : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); } |
55fc1817 JF |
1688 | ; |
1689 | ||
36cd3cb9 | 1690 | CaseClausesOpt |
09fc3efb JF |
1691 | : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; } |
1692 | | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; } | |
cf7d4c69 | 1693 | | { $$ = NULL; } |
1dbba6cc JF |
1694 | ; |
1695 | ||
a7d8b413 | 1696 | // XXX: the standard makes certain you can only have one of these |
36cd3cb9 | 1697 | DefaultClause |
09fc3efb | 1698 | : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); } |
1dbba6cc | 1699 | ; |
63cd45c9 | 1700 | /* }}} */ |
a7d8b413 | 1701 | /* 13.13 Labelled Statements {{{ */ |
36cd3cb9 | 1702 | LabelledStatement |
09fc3efb | 1703 | : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); } |
a7d8b413 JF |
1704 | ; |
1705 | ||
1706 | LabelledItem | |
09fc3efb | 1707 | : Statement[pass] { $$ = $pass; } |
484bab66 | 1708 | | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; } |
1dbba6cc | 1709 | ; |
63cd45c9 | 1710 | /* }}} */ |
a7d8b413 | 1711 | /* 13.14 The throw Statement {{{ */ |
36cd3cb9 | 1712 | ThrowStatement |
fdcef8e7 JF |
1713 | : "throw"[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); } |
1714 | | "throw" NewLineNot Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); } | |
1dbba6cc | 1715 | ; |
63cd45c9 | 1716 | /* }}} */ |
a7d8b413 | 1717 | /* 13.15 The try Statement {{{ */ |
36cd3cb9 | 1718 | TryStatement |
09fc3efb JF |
1719 | : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); } |
1720 | | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); } | |
1721 | | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); } | |
1dbba6cc JF |
1722 | ; |
1723 | ||
a7d8b413 | 1724 | Catch |
09fc3efb | 1725 | : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); } |
1dbba6cc JF |
1726 | ; |
1727 | ||
a7d8b413 | 1728 | Finally |
09fc3efb | 1729 | : "finally" Block[code] { $$ = CYNew CYFinally($code); } |
a7d8b413 JF |
1730 | ; |
1731 | ||
1732 | CatchParameter | |
09fc3efb | 1733 | : BindingIdentifier[pass] { $$ = $pass; } |
484bab66 | 1734 | | LexOf BindingPattern { CYNOT(@$); } |
1dbba6cc | 1735 | ; |
63cd45c9 | 1736 | /* }}} */ |
a7d8b413 | 1737 | /* 13.16 The debugger Statement {{{ */ |
c8a0500b JF |
1738 | DebuggerStatement |
1739 | : "debugger" Terminator { $$ = CYNew CYDebugger(); } | |
1740 | ; | |
1741 | /* }}} */ | |
1dbba6cc | 1742 | |
9d2b125d | 1743 | /* 14.1 Function Definitions {{{ */ |
36cd3cb9 | 1744 | FunctionDeclaration |
675ff733 | 1745 | : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); } |
1dbba6cc JF |
1746 | ; |
1747 | ||
36cd3cb9 | 1748 | FunctionExpression |
675ff733 | 1749 | : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); } |
9d2b125d JF |
1750 | ; |
1751 | ||
1752 | StrictFormalParameters | |
09fc3efb | 1753 | : FormalParameters[pass] { $$ = $pass; } |
9d2b125d JF |
1754 | ; |
1755 | ||
1756 | FormalParameters | |
484bab66 | 1757 | : LexBind LexOf { $$ = NULL; } |
9d2b125d | 1758 | | FormalParameterList |
1dbba6cc JF |
1759 | ; |
1760 | ||
1761 | FormalParameterList_ | |
09fc3efb | 1762 | : "," FormalParameterList[parameters] { $$ = $parameters; } |
cf7d4c69 | 1763 | | { $$ = NULL; } |
1dbba6cc JF |
1764 | ; |
1765 | ||
c8a0500b | 1766 | FormalParameterList |
93d4b2d7 | 1767 | : FunctionRestParameter { CYNOT(@$); } |
09fc3efb | 1768 | | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); } |
c8a0500b JF |
1769 | ; |
1770 | ||
9d2b125d JF |
1771 | FunctionRestParameter |
1772 | : BindingRestElement | |
55fc1817 JF |
1773 | ; |
1774 | ||
c8a0500b | 1775 | FormalParameter |
09fc3efb | 1776 | : BindingElement[pass] { $$ = $pass; } |
c8a0500b JF |
1777 | ; |
1778 | ||
36cd3cb9 | 1779 | FunctionBody |
09fc3efb | 1780 | : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; } |
9d2b125d JF |
1781 | ; |
1782 | ||
1783 | FunctionStatementList | |
09fc3efb | 1784 | : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; } |
1dbba6cc | 1785 | ; |
63cd45c9 | 1786 | /* }}} */ |
a7d8b413 | 1787 | /* 14.2 Arrow Function Definitions {{{ */ |
4b2fd91c | 1788 | ArrowFunction |
fdcef8e7 | 1789 | : ArrowParameters[parameters] LexNewLineOrOpt "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); } |
4b2fd91c JF |
1790 | ; |
1791 | ||
1792 | ArrowParameters | |
09fc3efb | 1793 | : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); } |
484bab66 | 1794 | | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } } |
4b2fd91c JF |
1795 | ; |
1796 | ||
1797 | ConciseBody | |
09fc3efb | 1798 | : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); } |
484bab66 | 1799 | | LexOf ";{" FunctionBody[code] "}" { $$ = $code; } |
4b2fd91c JF |
1800 | ; |
1801 | /* }}} */ | |
9d2b125d JF |
1802 | /* 14.3 Method Definitions {{{ */ |
1803 | MethodDefinition | |
675ff733 | 1804 | : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); } |
09fc3efb | 1805 | | GeneratorMethod[pass] { $$ = $pass; } |
675ff733 JF |
1806 | | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); } |
1807 | | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); } | |
9d2b125d JF |
1808 | ; |
1809 | ||
1810 | PropertySetParameterList | |
09fc3efb | 1811 | : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); } |
9d2b125d | 1812 | ; |
a7d8b413 | 1813 | /* }}} */ |
9d2b125d JF |
1814 | /* 14.4 Generator Function Definitions {{{ */ |
1815 | GeneratorMethod | |
675ff733 | 1816 | : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ } |
9d2b125d JF |
1817 | ; |
1818 | ||
1819 | GeneratorDeclaration | |
675ff733 | 1820 | : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ } |
9d2b125d JF |
1821 | ; |
1822 | ||
1823 | GeneratorExpression | |
675ff733 | 1824 | : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ } |
9d2b125d JF |
1825 | ; |
1826 | ||
1827 | GeneratorBody | |
09fc3efb | 1828 | : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; } |
9d2b125d JF |
1829 | ; |
1830 | ||
9d2b125d | 1831 | YieldExpression |
fdcef8e7 | 1832 | : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } |
2fad14e5 | 1833 | | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } %prec "!yield" |
fdcef8e7 JF |
1834 | | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ } |
1835 | | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ } | |
9d2b125d | 1836 | ; |
a7d8b413 | 1837 | /* }}} */ |
9d2b125d JF |
1838 | /* 14.5 Class Definitions {{{ */ |
1839 | ClassDeclaration | |
484bab66 | 1840 | : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); } |
9d2b125d JF |
1841 | ; |
1842 | ||
1843 | ClassExpression | |
484bab66 | 1844 | : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); } |
9d2b125d JF |
1845 | ; |
1846 | ||
1847 | ClassTail | |
675ff733 | 1848 | : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; } |
9d2b125d JF |
1849 | ; |
1850 | ||
1851 | ClassHeritage | |
09fc3efb | 1852 | : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); } |
9d2b125d JF |
1853 | ; |
1854 | ||
1855 | ClassHeritageOpt | |
09fc3efb | 1856 | : ClassHeritage[pass] { $$ = $pass; } |
c5b15840 | 1857 | | { $$ = CYNew CYClassTail(NULL); } |
9d2b125d JF |
1858 | ; |
1859 | ||
1860 | ClassBody | |
1861 | : ClassElementList | |
1862 | ; | |
1863 | ||
1864 | ClassBodyOpt | |
1865 | : ClassBody | |
1866 | | | |
1867 | ; | |
1868 | ||
1869 | ClassElementList | |
1870 | : ClassElementListOpt ClassElement | |
1871 | ; | |
1872 | ||
1873 | ClassElementListOpt | |
1874 | : ClassElementList | |
1875 | | | |
1876 | ; | |
1877 | ||
1878 | ClassElement | |
09fc3efb JF |
1879 | : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; } |
1880 | | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; } | |
9d2b125d JF |
1881 | | ";" |
1882 | ; | |
a7d8b413 JF |
1883 | /* }}} */ |
1884 | ||
1885 | /* 15.1 Scripts {{{ */ | |
1886 | Script | |
09fc3efb | 1887 | : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); } |
1dbba6cc JF |
1888 | ; |
1889 | ||
a7d8b413 | 1890 | ScriptBody |
09fc3efb | 1891 | : StatementList[pass] { $$ = $pass; } |
55fc1817 JF |
1892 | ; |
1893 | ||
a7d8b413 | 1894 | ScriptBodyOpt |
09fc3efb | 1895 | : ScriptBody[pass] { $$ = $pass; } |
484bab66 | 1896 | | LexSetStatement LexLet LexOf { $$ = NULL; } |
1dbba6cc | 1897 | ; |
63cd45c9 | 1898 | /* }}} */ |
9d2b125d JF |
1899 | /* 15.2 Modules {{{ */ |
1900 | Module | |
90dd6ff1 | 1901 | : ModuleBodyOpt[code] { driver.script_ = CYNew CYScript($code); } |
9d2b125d JF |
1902 | ; |
1903 | ||
1904 | ModuleBody | |
90dd6ff1 | 1905 | : ModuleItemList[pass] { $$ = $pass; } |
9d2b125d JF |
1906 | ; |
1907 | ||
1908 | ModuleBodyOpt | |
90dd6ff1 JF |
1909 | : ModuleBody[pass] { $$ = $pass; } |
1910 | | LexSetStatement LexLet LexOf { $$ = NULL; } | |
9d2b125d JF |
1911 | ; |
1912 | ||
1913 | ModuleItemList | |
90dd6ff1 | 1914 | : ModuleItem[statement] ModuleItemListOpt[next] { $$ = $statement; CYSetLast($$) = $next; } |
9d2b125d JF |
1915 | ; |
1916 | ||
1917 | ModuleItemListOpt | |
90dd6ff1 JF |
1918 | : ModuleItemList[pass] { $$ = $pass; } |
1919 | | LexSetStatement LexLet LexOf { $$ = NULL; } | |
9d2b125d JF |
1920 | ; |
1921 | ||
1922 | ModuleItem | |
90dd6ff1 JF |
1923 | : LexSetStatement LexLet LexOf ImportDeclaration[pass] { $$ = $pass; } |
1924 | | LexSetStatement LexLet LexOf ExportDeclaration { CYNOT(@$); } | |
1925 | | StatementListItem[pass] { $$ = $pass; } | |
9d2b125d | 1926 | ; |
a7d8b413 | 1927 | /* }}} */ |
9d2b125d JF |
1928 | /* 15.2.2 Imports {{{ */ |
1929 | ImportDeclaration | |
90dd6ff1 JF |
1930 | : "import" ImportClause[specifiers] FromClause[module] Terminator { $$ = CYNew CYImportDeclaration($specifiers, $module); } |
1931 | | "import" LexOf ModuleSpecifier[module] Terminator { $$ = CYNew CYImportDeclaration(NULL, $module); } | |
9d2b125d JF |
1932 | ; |
1933 | ||
1934 | ImportClause | |
90dd6ff1 JF |
1935 | : ImportedDefaultBinding[default] { $$ = $default; } |
1936 | | LexOf NameSpaceImport[pass] { $$ = $pass; } | |
1937 | | LexOf NamedImports[pass] { $$ = $pass; } | |
1938 | | ImportedDefaultBinding[default] "," NameSpaceImport[next] { $$ = $default; CYSetLast($$) = $next; } | |
1939 | | ImportedDefaultBinding[default] "," NamedImports[next] { $$ = $default; CYSetLast($$) = $next; } | |
9d2b125d JF |
1940 | ; |
1941 | ||
1942 | ImportedDefaultBinding | |
90dd6ff1 | 1943 | : ImportedBinding[binding] { $$ = CYNew CYImportSpecifier(CYNew CYIdentifier("default"), $binding); } |
9d2b125d JF |
1944 | ; |
1945 | ||
1946 | NameSpaceImport | |
90dd6ff1 | 1947 | : "*" "as" ImportedBinding[binding] { $$ = CYNew CYImportSpecifier(NULL, $binding); } |
9d2b125d JF |
1948 | ; |
1949 | ||
1950 | NamedImports | |
90dd6ff1 | 1951 | : "{" ImportsListOpt[pass] "}" { $$ = $pass; } |
9d2b125d JF |
1952 | ; |
1953 | ||
1954 | FromClause | |
90dd6ff1 | 1955 | : "from" ModuleSpecifier[pass] { $$ = $pass; } |
9d2b125d JF |
1956 | ; |
1957 | ||
1958 | ImportsList_ | |
90dd6ff1 JF |
1959 | : "," ImportsListOpt[pass] { $$ = $pass; } |
1960 | | { $$ = NULL; } | |
9d2b125d JF |
1961 | ; |
1962 | ||
1963 | ImportsList | |
90dd6ff1 | 1964 | : ImportSpecifier[import] ImportsList_[next] { $$ = $import; CYSetLast($$) = $next; } |
9d2b125d JF |
1965 | ; |
1966 | ||
1967 | ImportsListOpt | |
90dd6ff1 JF |
1968 | : ImportsList[pass] { $$ = $pass; } |
1969 | | LexOf { $$ = NULL; } | |
9d2b125d JF |
1970 | ; |
1971 | ||
1972 | ImportSpecifier | |
90dd6ff1 JF |
1973 | : ImportedBinding[binding] { $$ = CYNew CYImportSpecifier($binding, $binding); } |
1974 | | LexOf IdentifierName[name] "as" ImportedBinding[binding] { $$ = CYNew CYImportSpecifier($name, $binding); } | |
9d2b125d JF |
1975 | ; |
1976 | ||
1977 | ModuleSpecifier | |
90dd6ff1 | 1978 | : StringLiteral[pass] { $$ = $pass; } |
9d2b125d JF |
1979 | ; |
1980 | ||
1981 | ImportedBinding | |
90dd6ff1 | 1982 | : BindingIdentifier[pass] { $$ = $pass; } |
9d2b125d | 1983 | ; |
a7d8b413 | 1984 | /* }}} */ |
9d2b125d JF |
1985 | /* 15.2.3 Exports {{{ */ |
1986 | ExportDeclaration_ | |
1987 | : "*" FromClause Terminator | |
1988 | | ExportClause FromClause Terminator | |
1989 | | ExportClause Terminator | |
1990 | | VariableStatement | |
484bab66 JF |
1991 | | "default" LexSetStatement LexOf HoistableDeclaration |
1992 | | "default" LexSetStatement LexOf ClassDeclaration | |
9d2b125d JF |
1993 | | "default" LexSetStatement AssignmentExpression Terminator |
1994 | ; | |
1995 | ||
1996 | ExportDeclaration | |
484bab66 | 1997 | : "export" LexSetStatement LexLet LexOf ExportDeclaration_ |
9d2b125d JF |
1998 | | "export" Declaration |
1999 | ; | |
2000 | ||
2001 | ExportClause | |
2002 | : ";{" ExportsListOpt "}" | |
2003 | ; | |
2004 | ||
2005 | ExportsList_ | |
2006 | : "," ExportsListOpt | |
2007 | | | |
2008 | ; | |
2009 | ||
2010 | ExportsList | |
2011 | : ExportSpecifier ExportsList_ | |
2012 | ; | |
2013 | ||
2014 | ExportsListOpt | |
2015 | : ExportsList | |
2016 | | | |
2017 | ; | |
2018 | ||
2019 | ExportSpecifier | |
2020 | : IdentifierName | |
2021 | | IdentifierName "as" IdentifierName | |
2022 | ; | |
a7d8b413 | 2023 | /* }}} */ |
e5332278 | 2024 | |
7b750785 JF |
2025 | @begin C |
2026 | /* Cycript (C): Type Encoding {{{ */ | |
663c538f | 2027 | TypeSignifier |
5b4dabb2 JF |
2028 | : IdentifierType[name] { $$ = CYNew CYTypedName(@name, $name); } |
2029 | | StringLiteral[name] { $$ = CYNew CYTypedName(@name, $name); } | |
17764b01 | 2030 | | NumericLiteral[name] { $$ = CYNew CYTypedName(@name, $name); } |
8e216acc | 2031 | | "(" "*" TypeQualifierRightOpt[typed] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); } |
15e52267 JF |
2032 | ; |
2033 | ||
d8380373 | 2034 | TypeSignifierNone |
5b4dabb2 | 2035 | : { $$ = CYNew CYTypedName(@$); } |
d8380373 JF |
2036 | ; |
2037 | ||
15e52267 JF |
2038 | TypeSignifierOpt |
2039 | : TypeSignifier[pass] { $$ = $pass; } | |
d8380373 | 2040 | | TypeSignifierNone[pass] { $$ = $pass; } |
663c538f JF |
2041 | ; |
2042 | ||
88085bb4 | 2043 | ParameterTail |
3cc3e14d | 2044 | : TypedParameterListOpt[formal] ")" { $$ = CYNew CYTypeFunctionWith($formal->variadic_, $formal->parameters_); } |
88085bb4 JF |
2045 | ; |
2046 | ||
46f4f308 | 2047 | SuffixedType |
1d00044a | 2048 | : SuffixedTypeOpt[typed] "[" AssignmentExpression[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); } |
574d4720 | 2049 | | "(" "^" TypeQualifierRightOpt[typed] ")" "(" TypedParameters[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); } |
88085bb4 | 2050 | | TypeSignifier[typed] "(" ParameterTail[modifier] { $$ = $typed; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } |
5b4dabb2 | 2051 | | "("[parenthesis] ParameterTail[modifier] { $$ = CYNew CYTypedName(@parenthesis); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } |
15e52267 JF |
2052 | ; |
2053 | ||
2054 | SuffixedTypeOpt | |
2055 | : SuffixedType[pass] { $$ = $pass; } | |
2056 | | TypeSignifierOpt[pass] { $$ = $pass; } | |
46f4f308 JF |
2057 | ; |
2058 | ||
2059 | PrefixedType | |
15e52267 | 2060 | : "*" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); } |
46f4f308 JF |
2061 | ; |
2062 | ||
663c538f | 2063 | TypeQualifierLeft |
15e52267 JF |
2064 | : "const" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); } |
2065 | | "volatile" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); } | |
2066 | ; | |
2067 | ||
2068 | TypeQualifierLeftOpt | |
2069 | : TypeQualifierLeft[pass] { $$ = $pass; } | |
2070 | | { $$ = NULL; } | |
663c538f JF |
2071 | ; |
2072 | ||
2073 | TypeQualifierRight | |
15e52267 JF |
2074 | : SuffixedType[pass] { $$ = $pass; } |
2075 | | PrefixedType[pass] { $$ = $pass; } | |
2076 | | "const" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); } | |
2077 | | "volatile" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); } | |
2078 | ; | |
2079 | ||
2080 | TypeQualifierRightOpt | |
2081 | : TypeQualifierRight[pass] { $$ = $pass; } | |
2082 | | TypeSignifierOpt[pass] { $$ = $pass; } | |
3fe283c5 JF |
2083 | ; |
2084 | ||
2085 | IntegerType | |
0559abf8 JF |
2086 | : "int" { $$ = CYNew CYTypeIntegral(CYTypeNeutral); } |
2087 | | "unsigned" IntegerTypeOpt[integral] { $$ = $integral->Unsigned(); if ($$ == NULL) CYERR(@1, "incompatible unsigned"); } | |
2088 | | "signed" IntegerTypeOpt[integral] { $$ = $integral->Signed(); if ($$ == NULL) CYERR(@1, "incompatible signed"); } | |
2089 | | "long" IntegerTypeOpt[integral] { $$ = $integral->Long(); if ($$ == NULL) CYERR(@1, "incompatible long"); } | |
2090 | | "short" IntegerTypeOpt[integral] { $$ = $integral->Short(); if ($$ == NULL) CYERR(@1, "incompatible short"); } | |
3fe283c5 JF |
2091 | ; |
2092 | ||
2093 | IntegerTypeOpt | |
09fc3efb | 2094 | : IntegerType[pass] { $$ = $pass; } |
0559abf8 | 2095 | | { $$ = CYNew CYTypeIntegral(CYTypeNeutral); } |
56e02e5b JF |
2096 | ; |
2097 | ||
b3c38c5f | 2098 | StructFieldListOpt |
5b4dabb2 | 2099 | : TypedIdentifierField[typed] ";" StructFieldListOpt[next] { $$ = CYNew CYTypeStructField($typed, $typed->name_, $next); } |
b3c38c5f JF |
2100 | | { $$ = NULL; } |
2101 | ; | |
2102 | ||
aaa29c28 JF |
2103 | IntegerNumber |
2104 | : NumericLiteral[pass] { $$ = $pass; } | |
2105 | | "-" NumericLiteral[positive] { $$ = $positive; $$->value_ = -$$->value_; } | |
2106 | ; | |
2107 | ||
2108 | EnumConstantListOpt_ | |
2109 | : "," EnumConstantListOpt[pass] { $$ = $pass; } | |
2110 | | { $$ = NULL; } | |
2111 | ; | |
2112 | ||
2113 | EnumConstantListOpt | |
2114 | : IdentifierType[name] "=" IntegerNumber[value] EnumConstantListOpt_[next] { $$ = CYNew CYEnumConstant($name, $value, $next); } | |
2115 | | { $$ = NULL; } | |
2116 | ; | |
2117 | ||
24ffc58c JF |
2118 | TypeSigning |
2119 | : { $$ = CYTypeNeutral; } | |
2120 | | "signed" { $$ = CYTypeSigned; } | |
2121 | | "unsigned" { $$ = CYTypeUnsigned; } | |
2122 | ; | |
2123 | ||
663c538f | 2124 | PrimitiveType |
09fc3efb JF |
2125 | : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); } |
2126 | | IntegerType[pass] { $$ = $pass; } | |
24ffc58c JF |
2127 | | TypeSigning[signing] "char" { $$ = CYNew CYTypeCharacter($signing); } |
2128 | | TypeSigning[signing] "__int128" { $$ = CYNew CYTypeInt128($signing); } | |
1e8d8047 JF |
2129 | | "float" { $$ = CYNew CYTypeFloating(0); } |
2130 | | "double" { $$ = CYNew CYTypeFloating(1); } | |
2131 | | "long" "double" { $$ = CYNew CYTypeFloating(2); } | |
aaa29c28 JF |
2132 | ; |
2133 | ||
2134 | PrimitiveReference | |
2135 | : PrimitiveType[pass] { $$ = $pass; } | |
2136 | | "struct" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); } | |
2137 | | "enum" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceEnum, $name); } | |
84096608 JF |
2138 | | "struct" AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; } |
2139 | | "enum" AutoComplete { driver.mode_ = CYDriver::AutoEnum; YYACCEPT; } | |
46f4f308 JF |
2140 | ; |
2141 | ||
0e63c25f | 2142 | TypedIdentifierMaybe |
d8380373 | 2143 | : TypeQualifierLeft[modifier] "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } |
15e52267 | 2144 | | "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } |
aaa29c28 | 2145 | | TypeQualifierLeftOpt[modifier] PrimitiveReference[specifier] TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } |
561e7f1c JF |
2146 | ; |
2147 | ||
0e63c25f | 2148 | TypedIdentifierYes |
5b4dabb2 | 2149 | : TypedIdentifierMaybe[typed] { if ($typed->name_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; } |
0e63c25f JF |
2150 | ; |
2151 | ||
2152 | TypedIdentifierNo | |
5b4dabb2 | 2153 | : TypedIdentifierMaybe[typed] { if ($typed->name_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; } |
0e63c25f JF |
2154 | ; |
2155 | ||
aaa29c28 JF |
2156 | TypedIdentifierTagged |
2157 | : TypeQualifierLeftOpt[modifier] "struct" "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeStruct(NULL, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } | |
2158 | | TypeQualifierLeftOpt[modifier] "enum" ":" PrimitiveType[specifier] "{" EnumConstantListOpt[constants] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeEnum(NULL, $specifier, $constants); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } | |
2159 | ; | |
2160 | ||
d8380373 JF |
2161 | TypedIdentifierField |
2162 | : TypedIdentifierYes[pass] { $$ = $pass; } | |
5b4dabb2 | 2163 | | TypedIdentifierTagged[typed] { if ($typed->name_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; } |
d8380373 JF |
2164 | ; |
2165 | ||
2166 | TypedIdentifierEncoding | |
2167 | : TypedIdentifierNo[pass] { $$ = $pass; } | |
5b4dabb2 | 2168 | | TypedIdentifierTagged[typed] { if ($typed->name_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; } |
0846ea04 | 2169 | | "void" TypeSignifierNone[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } |
d8380373 JF |
2170 | ; |
2171 | ||
2172 | TypedIdentifierDefinition | |
2173 | : TypedIdentifierYes[pass] { $$ = $pass; } | |
5b4dabb2 | 2174 | | TypeQualifierLeftOpt[modifier] "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { if ($typed->name_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; $$->specifier_ = CYNew CYTypeStruct($name, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; } |
0846ea04 | 2175 | | "void" TypeSignifier[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); } |
d8380373 JF |
2176 | ; |
2177 | ||
46f4f308 | 2178 | PrimaryExpression |
d8380373 | 2179 | : "@encode" "(" TypedIdentifierEncoding[typed] ")" { $$ = CYNew CYEncodedType($typed); } |
46f4f308 JF |
2180 | ; |
2181 | /* }}} */ | |
7b750785 JF |
2182 | @end |
2183 | ||
2184 | @begin ObjectiveC | |
4de0686f | 2185 | /* Cycript (Objective-C): @class Declaration {{{ */ |
b09da87b | 2186 | ClassSuperOpt |
3ea7eed0 | 2187 | /* XXX: why the hell did I choose MemberExpression? */ |
5fe10198 | 2188 | : ":" MemberExpression[extends] { $$ = $extends; } |
b09da87b JF |
2189 | | { $$ = NULL; } |
2190 | ; | |
2191 | ||
c5b15840 | 2192 | ImplementationFieldListOpt |
5b4dabb2 | 2193 | : TypedIdentifierField[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $typed->name_, $next); } |
5fe10198 | 2194 | | { $$ = NULL; } |
55fc1817 JF |
2195 | ; |
2196 | ||
b09da87b JF |
2197 | MessageScope |
2198 | : "+" { $$ = false; } | |
2199 | | "-" { $$ = true; } | |
2200 | ; | |
2201 | ||
2202 | TypeOpt | |
0e63c25f | 2203 | : "(" TypedIdentifierNo[type] ")" { $$ = $type; } |
5b4dabb2 | 2204 | | { $$ = CYNew CYType(CYNew CYTypeVariable("id")); } |
b09da87b JF |
2205 | ; |
2206 | ||
2207 | MessageParameter | |
5b4dabb2 | 2208 | : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $$ = CYNew CYMessageParameter($tag, $type, $identifier); } |
b09da87b JF |
2209 | ; |
2210 | ||
55fc1817 | 2211 | MessageParameterList |
09fc3efb | 2212 | : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; } |
55fc1817 JF |
2213 | ; |
2214 | ||
b09da87b | 2215 | MessageParameterListOpt |
09fc3efb | 2216 | : MessageParameterList[pass] { $$ = $pass; } |
574d4720 | 2217 | | TypedParameterList_[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); /*XXX*/ if ($formal->parameters_ != NULL) CYERR(@$, "temporarily unsupported"); $$ = NULL; } |
b09da87b JF |
2218 | ; |
2219 | ||
b09da87b | 2220 | MessageParameters |
09fc3efb | 2221 | : MessageParameterList[pass] { $$ = $pass; } |
5b4dabb2 | 2222 | | Word[tag] { $$ = CYNew CYMessageParameter($tag); } |
b09da87b JF |
2223 | ; |
2224 | ||
2225 | ClassMessageDeclaration | |
675ff733 | 2226 | : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); } |
b09da87b JF |
2227 | ; |
2228 | ||
2229 | ClassMessageDeclarationListOpt | |
09fc3efb | 2230 | : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; } |
b09da87b JF |
2231 | | { $$ = NULL; } |
2232 | ; | |
2233 | ||
64b8d29f JF |
2234 | // XXX: this should be AssignmentExpressionNoRight |
2235 | ClassProtocols | |
09fc3efb | 2236 | : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); } |
64b8d29f JF |
2237 | ; |
2238 | ||
2239 | ClassProtocolsOpt | |
09fc3efb | 2240 | : "," ClassProtocols[protocols] { $$ = $protocols; } |
64b8d29f JF |
2241 | | { $$ = NULL; } |
2242 | ; | |
2243 | ||
2244 | ClassProtocolListOpt | |
09fc3efb | 2245 | : "<" ClassProtocols[protocols] ">" { $$ = $protocols; } |
64b8d29f JF |
2246 | | { $$ = NULL; } |
2247 | ; | |
2248 | ||
c5b15840 | 2249 | ImplementationStatement |
7cf0481b | 2250 | : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] "{" ImplementationFieldListOpt[fields] "}" ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); } |
1ba6903e JF |
2251 | ; |
2252 | ||
2253 | CategoryName | |
a630a9eb | 2254 | : "(" WordOpt ")" |
367eebb1 JF |
2255 | ; |
2256 | ||
2257 | CategoryStatement | |
09fc3efb | 2258 | : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); } |
367eebb1 JF |
2259 | ; |
2260 | ||
3ea7eed0 | 2261 | Statement__ |
09fc3efb JF |
2262 | : ImplementationStatement[pass] { $$ = $pass; } |
2263 | | CategoryStatement[pass] { $$ = $pass; } | |
b09da87b | 2264 | ; |
cac61857 | 2265 | /* }}} */ |
4de0686f | 2266 | /* Cycript (Objective-C): Send Message {{{ */ |
693d501b | 2267 | VariadicCall |
09fc3efb | 2268 | : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); } |
693d501b JF |
2269 | | { $$ = NULL; } |
2270 | ; | |
2271 | ||
7e5391fd | 2272 | SelectorWordOpt |
09fc3efb | 2273 | : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; } |
7e5391fd JF |
2274 | | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; } |
2275 | ; | |
2276 | ||
55fc1817 | 2277 | SelectorCall_ |
09fc3efb JF |
2278 | : SelectorCall[pass] { $$ = $pass; } |
2279 | | VariadicCall[pass] { $$ = $pass; } | |
55fc1817 JF |
2280 | ; |
2281 | ||
693d501b | 2282 | SelectorCall |
09fc3efb | 2283 | : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); } |
693d501b JF |
2284 | ; |
2285 | ||
2286 | SelectorList | |
09fc3efb JF |
2287 | : SelectorCall[pass] { $$ = $pass; } |
2288 | | Word[name] { $$ = CYNew CYArgument($name, NULL); } | |
693d501b JF |
2289 | ; |
2290 | ||
2291 | MessageExpression | |
09fc3efb | 2292 | : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); } |
484bab66 | 2293 | | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); } |
693d501b JF |
2294 | ; |
2295 | ||
e7ed5354 | 2296 | SelectorExpression_ |
09fc3efb | 2297 | : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); } |
e7ed5354 JF |
2298 | ; |
2299 | ||
2300 | SelectorExpression | |
09fc3efb JF |
2301 | : SelectorExpression_[pass] { $$ = $pass; } |
2302 | | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); } | |
e7ed5354 JF |
2303 | ; |
2304 | ||
55fc1817 | 2305 | SelectorExpressionOpt |
09fc3efb | 2306 | : SelectorExpression_[pass] { $$ = $pass; } |
55fc1817 JF |
2307 | | { $$ = NULL; } |
2308 | ; | |
2309 | ||
3ea7eed0 | 2310 | PrimaryExpression |
09fc3efb JF |
2311 | : MessageExpression[pass] { $$ = $pass; } |
2312 | | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); } | |
693d501b JF |
2313 | ; |
2314 | /* }}} */ | |
7b750785 JF |
2315 | @end |
2316 | ||
2317 | /* Cycript: @import Directive {{{ */ | |
9d2b125d | 2318 | ModulePath |
09fc3efb JF |
2319 | : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); } |
2320 | | Word[part] { $$ = CYNew CYModule($part); } | |
1ba6903e JF |
2321 | ; |
2322 | ||
484bab66 | 2323 | Declaration_ |
09fc3efb | 2324 | : "@import" ModulePath[path] { $$ = CYNew CYImport($path); } |
1ba6903e JF |
2325 | ; |
2326 | /* }}} */ | |
7b750785 JF |
2327 | |
2328 | @begin ObjectiveC | |
c3b144b8 JF |
2329 | /* Cycript (Objective-C): Boxed Expressions {{{ */ |
2330 | BoxableExpression | |
09fc3efb JF |
2331 | : NullLiteral[pass] { $$ = $pass; } |
2332 | | BooleanLiteral[pass] { $$ = $pass; } | |
2333 | | NumericLiteral[pass] { $$ = $pass; } | |
2334 | | StringLiteral[pass] { $$ = $pass; } | |
09fc3efb | 2335 | | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; } |
60496dd5 JF |
2336 | | "YES" { $$ = CYNew CYTrue(); } |
2337 | | "NO" { $$ = CYNew CYFalse(); } | |
c3b144b8 JF |
2338 | ; |
2339 | ||
5a6c975a JF |
2340 | KeyValuePairList_ |
2341 | : "," KeyValuePairListOpt[next] { $$ = $next; } | |
2342 | | { $$ = NULL; } | |
2343 | ||
2344 | KeyValuePairList | |
2345 | : AssignmentExpression[key] ":" AssignmentExpression[value] KeyValuePairList_[next] { $$ = CYNew CYObjCKeyValue($key, $value, $next); } | |
2346 | ; | |
2347 | ||
2348 | KeyValuePairListOpt | |
2349 | : KeyValuePairList[pass] { $$ = $pass; } | |
2350 | | LexOf { $$ = NULL; } | |
2351 | ; | |
2352 | ||
c3b144b8 | 2353 | PrimaryExpression |
09fc3efb | 2354 | : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); } |
5a6c975a JF |
2355 | | "@" "[" ElementListOpt[elements] "]" { $$ = CYNew CYObjCArray($elements); } |
2356 | | "@" "{" KeyValuePairListOpt[pairs] "}" { $$ = CYNew CYObjCDictionary($pairs); } | |
2357 | ||
4ea461c0 JF |
2358 | | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); } |
2359 | | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); } | |
2360 | | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); } | |
2361 | | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); } | |
2362 | | "@null" { $$ = CYNew CYBox(CYNew CYNull()); } | |
c3b144b8 JF |
2363 | ; |
2364 | /* }}} */ | |
56e02e5b | 2365 | /* Cycript (Objective-C): Block Expressions {{{ */ |
56e02e5b | 2366 | PrimaryExpression |
0e63c25f | 2367 | : "^" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); } |
56e02e5b JF |
2368 | ; |
2369 | /* }}} */ | |
61769f4f JF |
2370 | /* Cycript (Objective-C): Instance Literals {{{ */ |
2371 | PrimaryExpression | |
09fc3efb | 2372 | : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); } |
61769f4f JF |
2373 | ; |
2374 | /* }}} */ | |
4de0686f JF |
2375 | @end |
2376 | ||
2377 | @begin C | |
2378 | /* Cycript (C): Pointer Indirection/Addressing {{{ */ | |
620c82a1 | 2379 | UnaryExpression_ |
09fc3efb | 2380 | : IndirectExpression[pass] { $$ = $pass; } |
620c82a1 JF |
2381 | ; |
2382 | ||
2383 | IndirectExpression | |
09fc3efb | 2384 | : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); } |
693d501b JF |
2385 | ; |
2386 | ||
2387 | UnaryExpression_ | |
09fc3efb | 2388 | : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); } |
693d501b JF |
2389 | ; |
2390 | ||
9b5527f0 | 2391 | MemberAccess |
09fc3efb JF |
2392 | : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); } |
2393 | | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); } | |
7e5391fd | 2394 | | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; } |
9b5527f0 | 2395 | ; |
cac61857 | 2396 | /* }}} */ |
690cf1a8 JF |
2397 | /* Cycript (C): Lambda Expressions {{{ */ |
2398 | TypedParameterList_ | |
09fc3efb | 2399 | : "," TypedParameterList[parameters] { $$ = $parameters; } |
574d4720 | 2400 | | { $$ = CYNew CYTypedFormal(false); } |
690cf1a8 JF |
2401 | ; |
2402 | ||
2403 | TypedParameterList | |
5b4dabb2 | 2404 | : TypedIdentifierMaybe[typed] TypedParameterList_[formal] { CYIdentifier *identifier; if ($typed->name_ == NULL) identifier = NULL; else { identifier = $typed->name_->Identifier(); if (identifier == NULL) CYERR($typed->location_, "invalid identifier"); } $$ = $formal; $$->parameters_ = CYNew CYTypedParameter($typed, identifier, $$->parameters_); } |
574d4720 | 2405 | | "..." { $$ = CYNew CYTypedFormal(true); } |
690cf1a8 JF |
2406 | ; |
2407 | ||
2408 | TypedParameterListOpt | |
09fc3efb | 2409 | : TypedParameterList[pass] { $$ = $pass; } |
574d4720 JF |
2410 | | "void" { $$ = CYNew CYTypedFormal(false); } |
2411 | | { $$ = CYNew CYTypedFormal(false); } | |
2412 | ; | |
2413 | ||
2414 | TypedParameters | |
2415 | : TypedParameterListOpt[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); $$ = $formal->parameters_; } | |
690cf1a8 JF |
2416 | ; |
2417 | ||
2418 | PrimaryExpression | |
574d4720 | 2419 | : "[" LexOf "&" "]" "(" TypedParameters[parameters] ")" "->" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); } |
d8380373 JF |
2420 | ; |
2421 | /* }}} */ | |
2422 | /* Cycript (C): Structure Definitions {{{ */ | |
2423 | IdentifierNoOf | |
2424 | : "struct" NewLineOpt { $$ = CYNew CYIdentifier("struct"); } | |
2425 | ; | |
2426 | ||
2427 | Statement__ | |
2428 | : "struct" NewLineNot IdentifierType[name] "{" StructFieldListOpt[fields] "}" { $$ = CYNew CYStructDefinition($name, CYNew CYStructTail($fields)); } | |
2429 | ; | |
2430 | ||
2431 | PrimaryExpression | |
aaa29c28 | 2432 | : "(" LexOf "struct" NewLineOpt IdentifierType[name] TypeQualifierRightOpt[typed] ")" { $typed->specifier_ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); $$ = CYNew CYTypeExpression($typed); } |
84096608 | 2433 | | "(" LexOf "struct" NewLineOpt AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; } |
690cf1a8 JF |
2434 | ; |
2435 | /* }}} */ | |
60097023 | 2436 | /* Cycript (C): Type Definitions {{{ */ |
fdcef8e7 JF |
2437 | IdentifierNoOf |
2438 | : "typedef" NewLineOpt { $$ = CYNew CYIdentifier("typedef"); } | |
2439 | ; | |
2440 | ||
ffc2d225 | 2441 | TypeDefinition |
5b4dabb2 | 2442 | : "typedef" NewLineNot TypedIdentifierDefinition[typed] TerminatorHard { CYIdentifier *identifier; if ($typed->name_ == NULL) identifier = NULL; else { identifier = $typed->name_->Identifier(); if (identifier == NULL) CYERR($typed->location_, "invalid identifier"); } $$ = CYNew CYTypeDefinition($typed, identifier); } |
ffc2d225 JF |
2443 | ; |
2444 | ||
60097023 | 2445 | Statement__ |
ffc2d225 | 2446 | : TypeDefinition[pass] { $$ = $pass; } |
60097023 | 2447 | ; |
64a505ff JF |
2448 | |
2449 | PrimaryExpression | |
d8380373 | 2450 | : "(" LexOf "typedef" NewLineOpt TypedIdentifierEncoding[typed] ")" { $$ = CYNew CYTypeExpression($typed); } |
64a505ff | 2451 | ; |
60097023 | 2452 | /* }}} */ |
c5587ed7 | 2453 | /* Cycript (C): extern "C" {{{ */ |
fdcef8e7 JF |
2454 | IdentifierNoOf |
2455 | : "extern" NewLineOpt { $$ = CYNew CYIdentifier("extern"); } | |
2456 | ; | |
2457 | ||
ffc2d225 | 2458 | ExternCStatement |
5b4dabb2 | 2459 | : TypedIdentifierField[typed] TerminatorHard { CYIdentifier *identifier; if ($typed->name_ == NULL) identifier = NULL; else { identifier = $typed->name_->Identifier(); if (identifier == NULL) CYERR($typed->location_, "invalid identifier"); } $$ = CYNew CYExternalDefinition(CYNew CYString("C"), $typed, identifier); } |
ffc2d225 JF |
2460 | | TypeDefinition[pass] { $$ = $pass; } |
2461 | ; | |
2462 | ||
2463 | ExternCStatementListOpt | |
2464 | : ExternCStatement[statement] ExternCStatementListOpt[next] { $$ = $statement; CYSetLast($$) = $next; } | |
2465 | | { $$ = NULL; } | |
2466 | ; | |
2467 | ||
2468 | ExternC | |
2469 | : "{" ExternCStatementListOpt[pass] "}" { $$ = $pass; } | |
2470 | | ExternCStatement[pass] { $$ = $pass; } | |
2471 | ; | |
2472 | ||
436a877b JF |
2473 | ABI |
2474 | : StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } | |
2475 | ; | |
2476 | ||
c5587ed7 | 2477 | Statement__ |
436a877b JF |
2478 | : "extern" NewLineNot ABI[abi] ExternC[pass] { $$ = $pass; } |
2479 | ; | |
2480 | ||
2481 | PrimaryExpression | |
5b4dabb2 | 2482 | : "(" LexOf "extern" NewLineOpt ABI[abi] TypedIdentifierField[typed] ")" { $$ = CYNew CYExternalExpression(CYNew CYString("C"), $typed, $typed->name_); } |
c5587ed7 JF |
2483 | ; |
2484 | /* }}} */ | |
4de0686f JF |
2485 | @end |
2486 | ||
cb02f8ae | 2487 | @begin E4X |
691e4717 JF |
2488 | /* Lexer State {{{ */ |
2489 | LexPushRegExp | |
2490 | : { driver.PushCondition(CYDriver::RegExpCondition); } | |
2491 | ; | |
2492 | ||
2493 | LexPushXMLContent | |
2494 | : { driver.PushCondition(CYDriver::XMLContentCondition); } | |
2495 | ; | |
2496 | ||
2497 | LexPushXMLTag | |
2498 | : { driver.PushCondition(CYDriver::XMLTagCondition); } | |
2499 | ; | |
2500 | ||
2501 | LexPop | |
2502 | : { driver.PopCondition(); } | |
2503 | ; | |
2504 | ||
2505 | LexSetXMLContent | |
2506 | : { driver.SetCondition(CYDriver::XMLContentCondition); } | |
2507 | ; | |
2508 | ||
2509 | LexSetXMLTag | |
2510 | : { driver.SetCondition(CYDriver::XMLTagCondition); } | |
2511 | ; | |
2512 | /* }}} */ | |
c3b144b8 | 2513 | /* Virtual Tokens {{{ */ |
691e4717 JF |
2514 | XMLWhitespaceOpt |
2515 | : XMLWhitespace | |
2516 | | | |
2517 | ; | |
c3b144b8 | 2518 | /* }}} */ |
691e4717 JF |
2519 | |
2520 | /* 8.1 Context Keywords {{{ */ | |
2521 | Identifier | |
d6e7cafb JF |
2522 | : "namespace" { $$ = CYNew CYIdentifier("namespace"); } |
2523 | | "xml" { $$ = CYNew CYIdentifier("xml"); } | |
691e4717 JF |
2524 | ; |
2525 | /* }}} */ | |
a7d8b413 | 2526 | /* 8.3 XML Initializer Input Elements {{{ */ |
cb02f8ae | 2527 | XMLMarkup |
691e4717 JF |
2528 | : XMLComment { $$ = $1; } |
2529 | | XMLCDATA { $$ = $1; } | |
2530 | | XMLPI { $$ = $1; } | |
cb02f8ae JF |
2531 | ; |
2532 | /* }}} */ | |
c3b144b8 | 2533 | |
cb02f8ae | 2534 | /* 11.1 Primary Expressions {{{ */ |
3ea7eed0 | 2535 | PrimaryExpression |
2eb8215d | 2536 | : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); } |
09fc3efb JF |
2537 | | XMLInitilizer { $$ = $1; } |
2538 | | XMLListInitilizer { $$ = $1; } | |
cb02f8ae JF |
2539 | ; |
2540 | ||
2541 | PropertyIdentifier | |
691e4717 JF |
2542 | : AttributeIdentifier { $$ = $1; } |
2543 | | QualifiedIdentifier { $$ = $1; } | |
2544 | | WildcardIdentifier { $$ = $1; } | |
cb02f8ae JF |
2545 | ; |
2546 | /* }}} */ | |
2547 | /* 11.1.1 Attribute Identifiers {{{ */ | |
2548 | AttributeIdentifier | |
2eb8215d | 2549 | : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); } |
691e4717 JF |
2550 | ; |
2551 | ||
2552 | PropertySelector_ | |
b92ceddb | 2553 | : PropertySelector { $$ = $1; } |
20ac4226 | 2554 | | "[" Expression "]" { $$ = CYNew CYSelector($2); } |
cb02f8ae JF |
2555 | ; |
2556 | ||
2557 | PropertySelector | |
2eb8215d | 2558 | : Identifier { $$ = CYNew CYSelector($1); } |
691e4717 | 2559 | | WildcardIdentifier { $$ = $1; } |
cb02f8ae JF |
2560 | ; |
2561 | /* }}} */ | |
2562 | /* 11.1.2 Qualified Identifiers {{{ */ | |
691e4717 | 2563 | QualifiedIdentifier_ |
2eb8215d | 2564 | : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); } |
691e4717 JF |
2565 | | QualifiedIdentifier { $$ = $1; } |
2566 | ; | |
2567 | ||
cb02f8ae | 2568 | QualifiedIdentifier |
2eb8215d | 2569 | : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); } |
cb02f8ae JF |
2570 | ; |
2571 | /* }}} */ | |
2572 | /* 11.1.3 Wildcard Identifiers {{{ */ | |
2573 | WildcardIdentifier | |
2eb8215d | 2574 | : "*" { $$ = CYNew CYWildcard(); } |
cb02f8ae JF |
2575 | ; |
2576 | /* }}} */ | |
a7d8b413 | 2577 | /* 11.1.4 XML Initializer {{{ */ |
09fc3efb | 2578 | XMLInitilizer |
691e4717 JF |
2579 | : XMLMarkup { $$ = $1; } |
2580 | | XMLElement { $$ = $1; } | |
cb02f8ae JF |
2581 | ; |
2582 | ||
2583 | XMLElement | |
440424e2 JF |
2584 | : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn |
2585 | | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn | |
cb02f8ae JF |
2586 | ; |
2587 | ||
2588 | XMLTagContent | |
0347fadf | 2589 | : LexPushXMLTag XMLTagName XMLAttributes |
cb02f8ae JF |
2590 | ; |
2591 | ||
691e4717 | 2592 | XMLExpression |
675ff733 | 2593 | : "{" LexPushRegExp Expression LexPop "}" |
691e4717 JF |
2594 | ; |
2595 | ||
cb02f8ae | 2596 | XMLTagName |
691e4717 | 2597 | : XMLExpression |
cb02f8ae JF |
2598 | | XMLName |
2599 | ; | |
2600 | ||
0347fadf JF |
2601 | XMLAttributes_ |
2602 | : XMLAttributes_ XMLAttribute | |
2603 | | | |
cb02f8ae JF |
2604 | ; |
2605 | ||
0347fadf JF |
2606 | XMLAttributes |
2607 | : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt | |
2608 | | XMLAttributes_ XMLWhitespaceOpt | |
cb02f8ae JF |
2609 | ; |
2610 | ||
691e4717 JF |
2611 | XMLAttributeValue_ |
2612 | : XMLExpression | |
2613 | | XMLAttributeValue | |
2614 | ; | |
2615 | ||
cb02f8ae | 2616 | XMLAttribute |
691e4717 | 2617 | : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_ |
cb02f8ae JF |
2618 | ; |
2619 | ||
cb02f8ae | 2620 | XMLElementContent |
691e4717 | 2621 | : XMLExpression XMLElementContentOpt |
cb02f8ae JF |
2622 | | XMLMarkup XMLElementContentOpt |
2623 | | XMLText XMLElementContentOpt | |
2624 | | XMLElement XMLElementContentOpt | |
2625 | ; | |
2626 | ||
2627 | XMLElementContentOpt | |
2628 | : XMLElementContent | |
2629 | | | |
2630 | ; | |
2631 | /* }}} */ | |
a7d8b413 | 2632 | /* 11.1.5 XMLList Initializer {{{ */ |
09fc3efb | 2633 | XMLListInitilizer |
440424e2 | 2634 | : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); } |
691e4717 JF |
2635 | ; |
2636 | /* }}} */ | |
c3b144b8 | 2637 | |
691e4717 JF |
2638 | /* 11.2 Left-Hand-Side Expressions {{{ */ |
2639 | PropertyIdentifier_ | |
0347fadf | 2640 | : Identifier { $$ = $1; } |
691e4717 JF |
2641 | | PropertyIdentifier { $$ = $1; } |
2642 | ; | |
2643 | ||
2644 | MemberAccess | |
2eb8215d JF |
2645 | : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); } |
2646 | | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); } | |
2647 | | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); } | |
691e4717 JF |
2648 | ; |
2649 | /* }}} */ | |
2650 | /* 12.1 The default xml namespace Statement {{{ */ | |
b92ceddb | 2651 | /* XXX: DefaultXMLNamespaceStatement |
2eb8215d | 2652 | : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); } |
691e4717 JF |
2653 | ; |
2654 | ||
3ea7eed0 | 2655 | Statement__ |
691e4717 | 2656 | : DefaultXMLNamespaceStatement { $$ = $1; } |
b92ceddb | 2657 | ; */ |
cb02f8ae JF |
2658 | /* }}} */ |
2659 | @end | |
2660 | ||
a7d8b413 | 2661 | /* JavaScript FTL: Array Comprehensions {{{ */ |
b3aa25d8 | 2662 | Comprehension |
09fc3efb | 2663 | : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); } |
367eebb1 JF |
2664 | ; |
2665 | ||
b3aa25d8 | 2666 | ComprehensionFor |
09fc3efb | 2667 | : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); } |
367eebb1 | 2668 | ; |
cac61857 | 2669 | /* }}} */ |
a7d8b413 | 2670 | /* JavaScript FTL: for each {{{ */ |
d5618df7 | 2671 | IterationStatement |
09fc3efb | 2672 | : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); } |
cac61857 JF |
2673 | ; |
2674 | /* }}} */ | |
4e11a430 | 2675 | |
a7d8b413 JF |
2676 | /* JavaScript FTW: Array Comprehensions {{{ */ |
2677 | PrimaryExpression | |
2678 | : ArrayComprehension | |
2679 | ; | |
2680 | ||
2681 | ArrayComprehension | |
09fc3efb | 2682 | : "[" Comprehension[comprehension] "]" { $$ = $comprehension; } |
a7d8b413 JF |
2683 | ; |
2684 | ||
2685 | Comprehension | |
484bab66 | 2686 | : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); } |
a7d8b413 JF |
2687 | ; |
2688 | ||
2689 | ComprehensionTail | |
2690 | : { $$ = NULL; } | |
09fc3efb JF |
2691 | | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; } |
2692 | | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; } | |
a7d8b413 JF |
2693 | ; |
2694 | ||
2695 | ComprehensionFor | |
09fc3efb JF |
2696 | : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); } |
2697 | | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); } | |
a7d8b413 JF |
2698 | ; |
2699 | ||
2700 | ComprehensionIf | |
09fc3efb | 2701 | : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); } |
a7d8b413 JF |
2702 | ; |
2703 | /* }}} */ | |
9d2b125d JF |
2704 | /* JavaScript FTW: Named Arguments {{{ */ |
2705 | ArgumentList | |
2fad14e5 | 2706 | : LexOf WordNoUnary[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); } |
9d2b125d JF |
2707 | ; |
2708 | /* }}} */ | |
e56c2499 JF |
2709 | /* JavaScript FTW: Subscript Access {{{ */ |
2710 | MemberAccess | |
2711 | : "." "[" AssignmentExpression[property] "]" { $$ = CYNew CYSubscriptMember(NULL, $property); } | |
2712 | ; | |
2713 | /* }}} */ | |
2fad14e5 | 2714 | |
4f3e597c JF |
2715 | /* JavaScript FTW: Java "Anonymous Inner Classes" {{{ */ |
2716 | BracedParameter | |
2717 | : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYExtend(NULL, $properties); } | |
2718 | ; | |
2719 | /* }}} */ | |
2720 | ||
6c093cce JF |
2721 | /* JavaScript FTW: Ruby Blocks {{{ */ |
2722 | RubyProcParameterList_ | |
09fc3efb | 2723 | : "," RubyProcParameterList[parameters] { $$ = $parameters; } |
6c093cce JF |
2724 | | { $$ = NULL; } |
2725 | ; | |
2726 | ||
2727 | RubyProcParameterList | |
09fc3efb | 2728 | : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); } |
484bab66 | 2729 | | LexOf { $$ = NULL; } |
6c093cce JF |
2730 | ; |
2731 | ||
d7205a63 | 2732 | RubyProcParameters |
5fe10198 JF |
2733 | : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; } |
2734 | | "||" { $$ = NULL; } | |
d7205a63 JF |
2735 | ; |
2736 | ||
2737 | RubyProcParametersOpt | |
09fc3efb | 2738 | : RubyProcParameters[pass] { $$ = $pass; } |
5fe10198 | 2739 | | { $$ = NULL; } |
6c093cce JF |
2740 | ; |
2741 | ||
4f3e597c JF |
2742 | BracedParameter |
2743 | : ";{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyBlock(NULL, CYNew CYRubyProc($parameters, $code)); } | |
6c093cce JF |
2744 | ; |
2745 | ||
3ea7eed0 | 2746 | PrimaryExpression |
675ff733 | 2747 | : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); } |
6c093cce JF |
2748 | ; |
2749 | ||
4f3e597c | 2750 | BracedExpression_ |
a61a2713 | 2751 | : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; } |
4f3e597c | 2752 | | BracedExpression_[lhs] { if (!$lhs->IsNew()) CYMAP(OpenBrace_, OpenBrace); } BracedParameter[rhs] LexNewLineOrOpt { $rhs->SetLeft($lhs); $$ = $rhs; } |
a61a2713 JF |
2753 | ; |
2754 | ||
4f3e597c JF |
2755 | BracedExpression |
2756 | : BracedExpression_[pass] "\n" { $$ = $pass; } | |
2757 | | BracedExpression_[pass] { $$ = $pass; } | |
6c093cce | 2758 | ; |
6c093cce | 2759 | /* }}} */ |
2fad14e5 JF |
2760 | /* JavaScript FTW: Ruby Scopes {{{ */ |
2761 | MemberAccess | |
2762 | : "::" "[" Expression[property] "]" { $$ = CYNew CYResolveMember(NULL, $property); } | |
2763 | | "::" IdentifierName[property] { $$ = CYNew CYResolveMember(NULL, CYNew CYString($property)); } | |
2764 | | "::" AutoComplete { driver.mode_ = CYDriver::AutoResolve; YYACCEPT; } | |
2765 | ; | |
2766 | /* }}} */ | |
2767 | /* JavaScript FTW: Ruby Symbols {{{ */ | |
2768 | PrimaryExpression | |
2769 | : ":" Word[name] { $$ = CYNew CYSymbol($name->Word()); } | |
2770 | ; | |
2771 | /* }}} */ | |
367eebb1 | 2772 | |
e5332278 | 2773 | %% |
8a392978 JF |
2774 | |
2775 | bool CYDriver::Parse(CYMark mark) { | |
2776 | mark_ = mark; | |
2777 | CYLocal<CYPool> local(&pool_); | |
2778 | cy::parser parser(*this); | |
2779 | #ifdef YYDEBUG | |
2780 | parser.set_debug_level(debug_); | |
2781 | #endif | |
2782 | return parser.parse() != 0; | |
2783 | } | |
2784 | ||
2785 | void CYDriver::Warning(const cy::parser::location_type &location, const char *message) { | |
2786 | if (!strict_) | |
2787 | return; | |
2788 | ||
2789 | CYDriver::Error error; | |
2790 | error.warning_ = true; | |
2791 | error.location_ = location; | |
2792 | error.message_ = message; | |
2793 | errors_.push_back(error); | |
2794 | } | |
2795 | ||
2796 | void cy::parser::error(const cy::parser::location_type &location, const std::string &message) { | |
2797 | CYDriver::Error error; | |
2798 | error.warning_ = false; | |
2799 | error.location_ = location; | |
2800 | error.message_ = message; | |
2801 | driver.errors_.push_back(error); | |
2802 | } |