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