]>
Commit | Line | Data |
---|---|---|
1 | /* Cycript - Inlining/Optimizing JavaScript Compiler | |
2 | * Copyright (C) 2009 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* Modified BSD License {{{ */ | |
6 | /* | |
7 | * Redistribution and use in source and binary | |
8 | * forms, with or without modification, are permitted | |
9 | * provided that the following conditions are met: | |
10 | * | |
11 | * 1. Redistributions of source code must retain the | |
12 | * above copyright notice, this list of conditions | |
13 | * and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the | |
15 | * above copyright notice, this list of conditions | |
16 | * and the following disclaimer in the documentation | |
17 | * and/or other materials provided with the | |
18 | * distribution. | |
19 | * 3. The name of the author may not be used to endorse | |
20 | * or promote products derived from this software | |
21 | * without specific prior written permission. | |
22 | * | |
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' | |
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
25 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | |
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
30 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
34 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
36 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | |
38 | /* }}} */ | |
39 | ||
40 | %code top { | |
41 | #include "Cycript.tab.hh" | |
42 | #define scanner driver.scanner_ | |
43 | #define YYSTACKEXPANDABLE 1 | |
44 | } | |
45 | ||
46 | %code requires { | |
47 | #include "Parser.hpp" | |
48 | ||
49 | @begin ObjectiveC | |
50 | #include "ObjectiveC/Syntax.hpp" | |
51 | @end | |
52 | ||
53 | @begin E4X | |
54 | #include "E4X/Syntax.hpp" | |
55 | @end | |
56 | ||
57 | typedef struct { | |
58 | bool newline_; | |
59 | ||
60 | union { | |
61 | bool bool_; | |
62 | ||
63 | CYDriver::Condition condition_; | |
64 | ||
65 | CYArgument *argument_; | |
66 | CYAssignment *assignment_; | |
67 | CYBoolean *boolean_; | |
68 | CYClause *clause_; | |
69 | cy::Syntax::Catch *catch_; | |
70 | CYComprehension *comprehension_; | |
71 | CYCompound *compound_; | |
72 | CYDeclaration *declaration_; | |
73 | CYDeclarations *declarations_; | |
74 | CYElement *element_; | |
75 | CYExpression *expression_; | |
76 | CYFalse *false_; | |
77 | CYFinally *finally_; | |
78 | CYForInitialiser *for_; | |
79 | CYForInInitialiser *forin_; | |
80 | CYFunctionParameter *functionParameter_; | |
81 | CYIdentifier *identifier_; | |
82 | CYInfix *infix_; | |
83 | CYLiteral *literal_; | |
84 | CYMember *member_; | |
85 | CYNull *null_; | |
86 | CYNumber *number_; | |
87 | CYProgram *program_; | |
88 | CYProperty *property_; | |
89 | CYPropertyName *propertyName_; | |
90 | CYStatement *statement_; | |
91 | CYString *string_; | |
92 | CYThis *this_; | |
93 | CYTrue *true_; | |
94 | CYWord *word_; | |
95 | ||
96 | @begin ObjectiveC | |
97 | CYClassName *className_; | |
98 | CYField *field_; | |
99 | CYMessage *message_; | |
100 | CYMessageParameter *messageParameter_; | |
101 | CYSelectorPart *selector_; | |
102 | @end | |
103 | ||
104 | @begin E4X | |
105 | CYAttribute *attribute_; | |
106 | CYPropertyIdentifier *propertyIdentifier_; | |
107 | CYSelector *selector_; | |
108 | @end | |
109 | }; | |
110 | } YYSTYPE; | |
111 | ||
112 | } | |
113 | ||
114 | %code provides { | |
115 | int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); | |
116 | } | |
117 | ||
118 | %name-prefix "cy" | |
119 | ||
120 | %language "C++" | |
121 | %locations | |
122 | ||
123 | %initial-action { | |
124 | @$.begin.filename = @$.end.filename = &driver.filename_; | |
125 | }; | |
126 | ||
127 | %defines | |
128 | ||
129 | //%glr-parser | |
130 | //%expect 1 | |
131 | ||
132 | %error-verbose | |
133 | ||
134 | %parse-param { CYDriver &driver } | |
135 | %lex-param { void *scanner } | |
136 | ||
137 | @begin E4X | |
138 | %token XMLCDATA | |
139 | %token XMLComment | |
140 | %token XMLPI | |
141 | ||
142 | %token XMLAttributeValue | |
143 | %token XMLName | |
144 | %token XMLTagCharacters | |
145 | %token XMLText | |
146 | %token XMLWhitespace | |
147 | @end | |
148 | ||
149 | @begin E4X | |
150 | %token LeftRight "<>" | |
151 | %token LeftSlashRight "</>" | |
152 | ||
153 | %token SlashRight "/>" | |
154 | %token LeftSlash "</" | |
155 | ||
156 | %token ColonColon "::" | |
157 | %token PeriodPeriod ".." | |
158 | @end | |
159 | ||
160 | @begin E4X ObjectiveC | |
161 | %token At "@" | |
162 | @end | |
163 | ||
164 | %token Ampersand "&" | |
165 | %token AmpersandAmpersand "&&" | |
166 | %token AmpersandEqual "&=" | |
167 | %token Carrot "^" | |
168 | %token CarrotEqual "^=" | |
169 | %token Equal "=" | |
170 | %token EqualEqual "==" | |
171 | %token EqualEqualEqual "===" | |
172 | %token Exclamation "!" | |
173 | %token ExclamationEqual "!=" | |
174 | %token ExclamationEqualEqual "!==" | |
175 | %token Hyphen "-" | |
176 | %token HyphenEqual "-=" | |
177 | %token HyphenHyphen "--" | |
178 | %token HyphenHyphen_ "\n--" | |
179 | %token HyphenRight "->" | |
180 | %token Left "<" | |
181 | %token LeftEqual "<=" | |
182 | %token LeftLeft "<<" | |
183 | %token LeftLeftEqual "<<=" | |
184 | %token Percent "%" | |
185 | %token PercentEqual "%=" | |
186 | %token Period "." | |
187 | %token Pipe "|" | |
188 | %token PipeEqual "|=" | |
189 | %token PipePipe "||" | |
190 | %token Plus "+" | |
191 | %token PlusEqual "+=" | |
192 | %token PlusPlus "++" | |
193 | %token PlusPlus_ "\n++" | |
194 | %token Right ">" | |
195 | %token RightEqual ">=" | |
196 | %token RightRight ">>" | |
197 | %token RightRightEqual ">>=" | |
198 | %token RightRightRight ">>>" | |
199 | %token RightRightRightEqual ">>>=" | |
200 | %token Slash "/" | |
201 | %token SlashEqual "/=" | |
202 | %token Star "*" | |
203 | %token StarEqual "*=" | |
204 | %token Tilde "~" | |
205 | ||
206 | %token Colon ":" | |
207 | %token Comma "," | |
208 | %token Question "?" | |
209 | %token SemiColon ";" | |
210 | %token NewLine "\n" | |
211 | ||
212 | %token OpenParen "(" | |
213 | %token CloseParen ")" | |
214 | ||
215 | %token OpenBrace "{" | |
216 | %token CloseBrace "}" | |
217 | ||
218 | %token OpenBracket "[" | |
219 | %token CloseBracket "]" | |
220 | ||
221 | %token AtClass "@class" | |
222 | %token AtSelector "@selector" | |
223 | %token AtEnd "@end" | |
224 | ||
225 | %token <false_> False "false" | |
226 | %token <null_> Null "null" | |
227 | %token <true_> True "true" | |
228 | ||
229 | // ES3/ES5/WIE/JSC Reserved | |
230 | %token <word_> Break "break" | |
231 | %token <word_> Case "case" | |
232 | %token <word_> Catch "catch" | |
233 | %token <word_> Continue "continue" | |
234 | %token <word_> Default "default" | |
235 | %token <word_> Delete "delete" | |
236 | %token <word_> Do "do" | |
237 | %token <word_> Else "else" | |
238 | %token <word_> Finally "finally" | |
239 | %token <word_> For "for" | |
240 | %token <word_> Function "function" | |
241 | %token <word_> If "if" | |
242 | %token <word_> In "in" | |
243 | %token <word_> InstanceOf "instanceof" | |
244 | %token <word_> New "new" | |
245 | %token <word_> Return "return" | |
246 | %token <word_> Switch "switch" | |
247 | %token <this_> This "this" | |
248 | %token <word_> Throw "throw" | |
249 | %token <word_> Try "try" | |
250 | %token <word_> TypeOf "typeof" | |
251 | %token <word_> Var "var" | |
252 | %token <word_> Void "void" | |
253 | %token <word_> While "while" | |
254 | %token <word_> With "with" | |
255 | ||
256 | // ES3/IE6 Future, ES5/JSC Reserved | |
257 | %token <word_> Debugger "debugger" | |
258 | ||
259 | // ES3/ES5/IE6 Future, JSC Reserved | |
260 | %token <word_> Const "const" | |
261 | ||
262 | // ES3/ES5/IE6/JSC Future | |
263 | %token <word_> Class "class" | |
264 | %token <word_> Enum "enum" | |
265 | %token <word_> Export "export" | |
266 | %token <word_> Extends "extends" | |
267 | %token <word_> Import "import" | |
268 | %token <word_> Super "super" | |
269 | ||
270 | // ES3 Future, ES5 Strict Future | |
271 | %token <identifier_> Implements "implements" | |
272 | %token <identifier_> Interface "interface" | |
273 | %token <identifier_> Package "package" | |
274 | %token <identifier_> Private "private" | |
275 | %token <identifier_> Protected "protected" | |
276 | %token <identifier_> Public "public" | |
277 | %token <identifier_> Static "static" | |
278 | ||
279 | // ES3 Future | |
280 | %token <identifier_> Abstract "abstract" | |
281 | %token <identifier_> Boolean "boolean" | |
282 | %token <identifier_> Byte "byte" | |
283 | %token <identifier_> Char "char" | |
284 | %token <identifier_> Double "double" | |
285 | %token <identifier_> Final "final" | |
286 | %token <identifier_> Float "float" | |
287 | %token <identifier_> Goto "goto" | |
288 | %token <identifier_> Int "int" | |
289 | %token <identifier_> Long "long" | |
290 | %token <identifier_> Native "native" | |
291 | %token <identifier_> Short "short" | |
292 | %token <identifier_> Synchronized "synchronized" | |
293 | %token <identifier_> Throws "throws" | |
294 | %token <identifier_> Transient "transient" | |
295 | %token <identifier_> Volatile "volatile" | |
296 | ||
297 | // ES5 Strict | |
298 | %token <identifier_> Let "let" | |
299 | %token <identifier_> Yield "yield" | |
300 | ||
301 | // Woah?! | |
302 | %token <identifier_> Each "each" | |
303 | ||
304 | @begin E4X | |
305 | // E4X Conditional | |
306 | %token <identifier_> Namespace "namespace" | |
307 | %token <identifier_> XML "xml" | |
308 | @end | |
309 | ||
310 | @begin ObjectiveC | |
311 | %type <expression_> AdditiveExpressionNoWC | |
312 | %type <expression_> AssigneeExpressionNoWC | |
313 | %type <expression_> AssignmentExpressionNoWC | |
314 | %type <expression_> BitwiseANDExpressionNoWC | |
315 | %type <expression_> BitwiseXORExpressionNoWC | |
316 | %type <expression_> BitwiseORExpressionNoWC | |
317 | %type <expression_> ConditionalExpressionNoWC | |
318 | %type <expression_> EqualityExpressionNoWC | |
319 | %type <expression_> LeftHandSideExpressionNoWC | |
320 | %type <expression_> LogicalANDExpressionNoWC | |
321 | %type <expression_> LogicalORExpressionNoWC | |
322 | %type <expression_> MemberExpressionNoWC | |
323 | %type <expression_> MultiplicativeExpressionNoWC | |
324 | %type <expression_> NewExpressionNoWC | |
325 | %type <expression_> PostfixExpressionNoWC | |
326 | %type <expression_> RelationalExpressionNoWC | |
327 | %type <expression_> ShiftExpressionNoWC | |
328 | %type <expression_> UnaryExpressionNoWC | |
329 | @end | |
330 | ||
331 | %token <identifier_> Identifier_ | |
332 | %token <number_> NumericLiteral | |
333 | %token <string_> StringLiteral | |
334 | %token <literal_> RegularExpressionLiteral | |
335 | ||
336 | %type <expression_> AdditiveExpression | |
337 | %type <expression_> AdditiveExpressionNoBF | |
338 | %type <argument_> ArgumentList | |
339 | %type <argument_> ArgumentList_ | |
340 | %type <argument_> ArgumentListOpt | |
341 | %type <argument_> Arguments | |
342 | %type <literal_> ArrayLiteral | |
343 | %type <expression_> AssigneeExpression | |
344 | %type <expression_> AssigneeExpressionNoBF | |
345 | %type <expression_> AssigneeExpressionNoRE | |
346 | %type <expression_> AssignmentExpression | |
347 | %type <assignment_> AssignmentExpression_ | |
348 | %type <expression_> AssignmentExpressionNoBF | |
349 | %type <expression_> AssignmentExpressionNoIn | |
350 | %type <expression_> BitwiseANDExpression | |
351 | %type <expression_> BitwiseANDExpressionNoBF | |
352 | %type <expression_> BitwiseANDExpressionNoIn | |
353 | %type <statement_> Block | |
354 | %type <statement_> Block_ | |
355 | %type <boolean_> BooleanLiteral | |
356 | %type <expression_> BitwiseORExpression | |
357 | %type <expression_> BitwiseORExpressionNoBF | |
358 | %type <expression_> BitwiseORExpressionNoIn | |
359 | %type <expression_> BitwiseXORExpression | |
360 | %type <expression_> BitwiseXORExpressionNoBF | |
361 | %type <expression_> BitwiseXORExpressionNoIn | |
362 | %type <statement_> BreakStatement | |
363 | %type <expression_> CallExpression | |
364 | %type <expression_> CallExpressionNoBF | |
365 | %type <expression_> CallExpressionNoRE | |
366 | %type <clause_> CaseBlock | |
367 | %type <clause_> CaseClause | |
368 | %type <clause_> CaseClausesOpt | |
369 | %type <catch_> CatchOpt | |
370 | %type <comprehension_> ComprehensionList | |
371 | %type <comprehension_> ComprehensionListOpt | |
372 | %type <expression_> ConditionalExpression | |
373 | %type <expression_> ConditionalExpressionNoBF | |
374 | %type <expression_> ConditionalExpressionNoIn | |
375 | %type <statement_> ContinueStatement | |
376 | %type <clause_> DefaultClause | |
377 | %type <statement_> DoWhileStatement | |
378 | %type <expression_> Element | |
379 | %type <expression_> ElementOpt | |
380 | %type <element_> ElementList | |
381 | %type <element_> ElementListOpt | |
382 | %type <statement_> ElseStatementOpt | |
383 | %type <statement_> EmptyStatement | |
384 | %type <expression_> EqualityExpression | |
385 | %type <expression_> EqualityExpressionNoBF | |
386 | %type <expression_> EqualityExpressionNoIn | |
387 | %type <expression_> Expression | |
388 | %type <expression_> ExpressionOpt | |
389 | %type <compound_> Expression_ | |
390 | %type <expression_> ExpressionNoBF | |
391 | %type <expression_> ExpressionNoIn | |
392 | %type <compound_> ExpressionNoIn_ | |
393 | %type <expression_> ExpressionNoInOpt | |
394 | %type <statement_> ExpressionStatement | |
395 | %type <finally_> FinallyOpt | |
396 | %type <comprehension_> ForComprehension | |
397 | %type <statement_> ForStatement | |
398 | %type <for_> ForStatementInitialiser | |
399 | %type <statement_> ForInStatement | |
400 | %type <forin_> ForInStatementInitialiser | |
401 | %type <functionParameter_> FormalParameterList | |
402 | %type <functionParameter_> FormalParameterList_ | |
403 | %type <statement_> FunctionBody | |
404 | %type <statement_> FunctionDeclaration | |
405 | %type <expression_> FunctionExpression | |
406 | %type <identifier_> Identifier | |
407 | %type <identifier_> IdentifierOpt | |
408 | %type <comprehension_> IfComprehension | |
409 | %type <statement_> IfStatement | |
410 | %type <expression_> Initialiser | |
411 | %type <expression_> InitialiserOpt | |
412 | %type <expression_> InitialiserNoIn | |
413 | %type <expression_> InitialiserNoInOpt | |
414 | %type <statement_> IterationStatement | |
415 | %type <statement_> LabelledStatement | |
416 | %type <expression_> LeftHandSideExpression | |
417 | %type <expression_> LeftHandSideExpressionNoBF | |
418 | %type <expression_> LeftHandSideExpressionNoRE | |
419 | //%type <statement_> LetStatement | |
420 | %type <literal_> Literal | |
421 | %type <literal_> LiteralNoRE | |
422 | %type <literal_> LiteralRE | |
423 | %type <expression_> LogicalANDExpression | |
424 | %type <expression_> LogicalANDExpressionNoBF | |
425 | %type <expression_> LogicalANDExpressionNoIn | |
426 | %type <expression_> LogicalORExpression | |
427 | %type <expression_> LogicalORExpressionNoBF | |
428 | %type <expression_> LogicalORExpressionNoIn | |
429 | %type <member_> MemberAccess | |
430 | %type <expression_> MemberExpression | |
431 | %type <expression_> MemberExpression_ | |
432 | %type <expression_> MemberExpressionNoBF | |
433 | %type <expression_> MemberExpressionNoRE | |
434 | %type <expression_> MultiplicativeExpression | |
435 | %type <expression_> MultiplicativeExpressionNoBF | |
436 | %type <expression_> NewExpression | |
437 | %type <expression_> NewExpression_ | |
438 | %type <expression_> NewExpressionNoBF | |
439 | %type <expression_> NewExpressionNoRE | |
440 | %type <null_> NullLiteral | |
441 | %type <literal_> ObjectLiteral | |
442 | %type <expression_> PostfixExpression | |
443 | %type <expression_> PostfixExpressionNoBF | |
444 | %type <expression_> PostfixExpressionNoRE | |
445 | %type <expression_> PrimaryExpression | |
446 | %type <expression_> PrimaryExpressionNo | |
447 | %type <expression_> PrimaryExpressionNoBF | |
448 | %type <expression_> PrimaryExpressionNoRE | |
449 | %type <expression_> PrimaryExpressionNoWC | |
450 | %type <expression_> PrimaryExpressionNoWC_ | |
451 | @begin E4X | |
452 | %type <expression_> PrimaryExpressionWC | |
453 | @end | |
454 | %type <expression_> PrimaryExpressionBF | |
455 | %type <statement_> Program | |
456 | %type <propertyName_> PropertyName | |
457 | %type <propertyName_> PropertyName_ | |
458 | %type <property_> PropertyNameAndValueList | |
459 | %type <property_> PropertyNameAndValueList_ | |
460 | %type <property_> PropertyNameAndValueListOpt | |
461 | %type <expression_> RelationalExpression | |
462 | %type <infix_> RelationalExpression_ | |
463 | %type <expression_> RelationalExpressionNoBF | |
464 | %type <expression_> RelationalExpressionNoIn | |
465 | %type <infix_> RelationalExpressionNoIn_ | |
466 | %type <statement_> ReturnStatement | |
467 | %type <expression_> ShiftExpression | |
468 | %type <expression_> ShiftExpressionNoBF | |
469 | %type <statement_> SourceElement | |
470 | %type <statement_> SourceElement_ | |
471 | %type <statement_> SourceElements | |
472 | %type <statement_> Statement | |
473 | %type <statement_> Statement_ | |
474 | %type <statement_> StatementList | |
475 | %type <statement_> StatementListOpt | |
476 | %type <statement_> SwitchStatement | |
477 | %type <statement_> ThrowStatement | |
478 | %type <statement_> TryStatement | |
479 | %type <expression_> UnaryAssigneeExpression | |
480 | %type <expression_> UnaryExpression | |
481 | %type <expression_> UnaryExpression_ | |
482 | %type <expression_> UnaryExpressionNoBF | |
483 | %type <expression_> UnaryExpressionNoRE | |
484 | %type <declaration_> VariableDeclaration | |
485 | %type <declaration_> VariableDeclarationNoIn | |
486 | %type <declarations_> VariableDeclarationList | |
487 | %type <declarations_> VariableDeclarationList_ | |
488 | %type <declarations_> VariableDeclarationListNoIn | |
489 | %type <declarations_> VariableDeclarationListNoIn_ | |
490 | %type <statement_> VariableStatement | |
491 | %type <statement_> WhileStatement | |
492 | %type <statement_> WithStatement | |
493 | ||
494 | @begin ObjectiveC | |
495 | %type <statement_> CategoryStatement | |
496 | %type <expression_> ClassExpression | |
497 | %type <statement_> ClassStatement | |
498 | %type <expression_> ClassSuperOpt | |
499 | %type <field_> ClassFieldList | |
500 | %type <message_> ClassMessageDeclaration | |
501 | %type <message_> ClassMessageDeclarationListOpt | |
502 | %type <className_> ClassName | |
503 | %type <className_> ClassNameOpt | |
504 | %type <expression_> MessageExpression | |
505 | %type <messageParameter_> MessageParameter | |
506 | %type <messageParameter_> MessageParameters | |
507 | %type <messageParameter_> MessageParameterList | |
508 | %type <messageParameter_> MessageParameterListOpt | |
509 | %type <bool_> MessageScope | |
510 | %type <argument_> SelectorCall | |
511 | %type <argument_> SelectorCall_ | |
512 | %type <selector_> SelectorExpression | |
513 | %type <selector_> SelectorExpression_ | |
514 | %type <selector_> SelectorExpressionOpt | |
515 | %type <argument_> SelectorList | |
516 | %type <expression_> TypeOpt | |
517 | %type <argument_> VariadicCall | |
518 | %type <word_> Word | |
519 | %type <word_> WordOpt | |
520 | @end | |
521 | ||
522 | @begin E4X | |
523 | %type <propertyIdentifier_> PropertyIdentifier_ | |
524 | %type <selector_> PropertySelector | |
525 | %type <selector_> PropertySelector_ | |
526 | %type <identifier_> QualifiedIdentifier | |
527 | %type <identifier_> QualifiedIdentifier_ | |
528 | %type <identifier_> WildcardIdentifier | |
529 | %type <identifier_> XMLComment | |
530 | %type <identifier_> XMLCDATA | |
531 | %type <identifier_> XMLElement | |
532 | %type <identifier_> XMLElementContent | |
533 | %type <identifier_> XMLMarkup | |
534 | %type <identifier_> XMLPI | |
535 | ||
536 | %type <attribute_> AttributeIdentifier | |
537 | /* XXX: %type <statement_> DefaultXMLNamespaceStatement */ | |
538 | %type <expression_> PropertyIdentifier | |
539 | %type <expression_> XMLListInitialiser | |
540 | %type <expression_> XMLInitialiser | |
541 | @end | |
542 | ||
543 | %token WC | |
544 | ||
545 | %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield" | |
546 | ||
547 | %nonassoc "if" | |
548 | %nonassoc "else" | |
549 | ||
550 | %nonassoc "++" "--" | |
551 | %nonassoc "(" "[" | |
552 | ||
553 | %left "*" "/" "%" | |
554 | %left "+" "-" | |
555 | %left "<<" ">>" ">>>" | |
556 | %left "<" ">" "<=" ">=" "instanceof" "in" | |
557 | %left "==" "!=" "===" "!==" | |
558 | %left "&" | |
559 | %left "^" | |
560 | %left "|" | |
561 | %left "&&" | |
562 | %left "||" | |
563 | ||
564 | %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|=" | |
565 | ||
566 | %start Program | |
567 | ||
568 | %% | |
569 | ||
570 | /* Lexer State {{{ */ | |
571 | LexSetRegExp | |
572 | : { driver.SetCondition(CYDriver::RegExpCondition); } | |
573 | ; | |
574 | /* }}} */ | |
575 | ||
576 | StrictSemi | |
577 | : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } | |
578 | ; | |
579 | ||
580 | Terminator_ | |
581 | : ";" | |
582 | | "\n" StrictSemi | |
583 | ; | |
584 | ||
585 | TerminatorOpt | |
586 | : Terminator_ | |
587 | | error { yyerrok; driver.errors_.pop_back(); } StrictSemi | |
588 | ; | |
589 | ||
590 | Terminator | |
591 | : Terminator_ | |
592 | | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi | |
593 | ; | |
594 | ||
595 | /*CommaOpt | |
596 | : "," | |
597 | | | |
598 | ;*/ | |
599 | ||
600 | @begin ObjectiveC | |
601 | NewLineOpt | |
602 | : "\n" | |
603 | | | |
604 | ; | |
605 | ||
606 | WordOpt | |
607 | : Word { $$ = $1; } | |
608 | | { $$ = NULL; } | |
609 | ; | |
610 | ||
611 | Word | |
612 | : Identifier { $$ = $1; } | |
613 | | "break" NewLineOpt { $$ = $1; } | |
614 | | "case" { $$ = $1; } | |
615 | | "catch" { $$ = $1; } | |
616 | | "class" { $$ = $1; } | |
617 | | "const" { $$ = $1; } | |
618 | | "continue" NewLineOpt { $$ = $1; } | |
619 | | "debugger" { $$ = $1; } | |
620 | | "default" { $$ = $1; } | |
621 | | "delete" { $$ = $1; } | |
622 | | "do" { $$ = $1; } | |
623 | | "else" { $$ = $1; } | |
624 | | "enum" { $$ = $1; } | |
625 | | "export" { $$ = $1; } | |
626 | | "extends" { $$ = $1; } | |
627 | | "false" { $$ = $1; } | |
628 | | "finally" { $$ = $1; } | |
629 | /* XXX: | "for" { $$ = $1; } */ | |
630 | | "function" { $$ = $1; } | |
631 | | "if" { $$ = $1; } | |
632 | | "import" { $$ = $1; } | |
633 | /* XXX: | "in" { $$ = $1; } */ | |
634 | /* XXX: | "instanceof" { $$ = $1; } */ | |
635 | | "new" { $$ = $1; } | |
636 | | "null" { $$ = $1; } | |
637 | | "return" NewLineOpt { $$ = $1; } | |
638 | | "super" { $$ = $1; } | |
639 | | "switch" { $$ = $1; } | |
640 | | "this" { $$ = $1; } | |
641 | | "throw" NewLineOpt { $$ = $1; } | |
642 | | "true" { $$ = $1; } | |
643 | | "try" { $$ = $1; } | |
644 | | "typeof" { $$ = $1; } | |
645 | | "var" { $$ = $1; } | |
646 | | "void" { $$ = $1; } | |
647 | | "while" { $$ = $1; } | |
648 | | "with" { $$ = $1; } | |
649 | ; | |
650 | @end | |
651 | ||
652 | Identifier | |
653 | : Identifier_ { $$ = $1; } | |
654 | ||
655 | | "implements" { $$ = $1; } | |
656 | | "interface" { $$ = $1; } | |
657 | | "package" { $$ = $1; } | |
658 | | "private" { $$ = $1; } | |
659 | | "protected" { $$ = $1; } | |
660 | | "public" { $$ = $1; } | |
661 | | "static" { $$ = $1; } | |
662 | ||
663 | | "abstract" { $$ = $1; } | |
664 | | "boolean" { $$ = $1; } | |
665 | | "byte" { $$ = $1; } | |
666 | | "char" { $$ = $1; } | |
667 | | "double" { $$ = $1; } | |
668 | | "final" { $$ = $1; } | |
669 | | "float" { $$ = $1; } | |
670 | | "goto" { $$ = $1; } | |
671 | | "int" { $$ = $1; } | |
672 | | "long" { $$ = $1; } | |
673 | | "native" { $$ = $1; } | |
674 | | "short" { $$ = $1; } | |
675 | | "synchronized" { $$ = $1; } | |
676 | | "throws" { $$ = $1; } | |
677 | | "transient" { $$ = $1; } | |
678 | | "volatile" { $$ = $1; } | |
679 | ||
680 | | "let" { $$ = $1; } | |
681 | | "yield" { $$ = $1; } | |
682 | ||
683 | | "each" { $$ = $1; } | |
684 | ; | |
685 | ||
686 | IdentifierOpt | |
687 | : Identifier { $$ = $1; } | |
688 | | { $$ = NULL; } | |
689 | ; | |
690 | ||
691 | LiteralNoRE | |
692 | : NullLiteral { $$ = $1; } | |
693 | | BooleanLiteral { $$ = $1; } | |
694 | | NumericLiteral { $$ = $1; } | |
695 | | StringLiteral { $$ = $1; } | |
696 | | "@" StringLiteral { $$ = $2; } | |
697 | ; | |
698 | ||
699 | LiteralRE | |
700 | : RegularExpressionLiteral { $$ = $1; } | |
701 | ; | |
702 | ||
703 | Literal | |
704 | : LiteralNoRE { $$ = $1; } | |
705 | | LiteralRE { $$ = $1; } | |
706 | ; | |
707 | ||
708 | NullLiteral | |
709 | : "null" { $$ = $1; } | |
710 | ; | |
711 | ||
712 | BooleanLiteral | |
713 | : "true" { $$ = $1; } | |
714 | | "false" { $$ = $1; } | |
715 | ; | |
716 | ||
717 | /* 11.1 Primary Expressions {{{ */ | |
718 | PrimaryExpression | |
719 | : PrimaryExpressionNoWC { $$ = $1; } | |
720 | @begin E4X | |
721 | | LexSetRegExp PrimaryExpressionWC { $$ = $2; } | |
722 | @end | |
723 | ; | |
724 | ||
725 | PrimaryExpressionNoBF | |
726 | : PrimaryExpressionNo { $$ = $1; } | |
727 | @begin E4X | |
728 | | PrimaryExpressionWC { $$ = $1; } | |
729 | @end | |
730 | ; | |
731 | ||
732 | PrimaryExpressionNoRE | |
733 | : PrimaryExpressionNoWC_ { $$ = $1; } | |
734 | @begin E4X | |
735 | | PrimaryExpressionWC { $$ = $1; } | |
736 | @end | |
737 | ; | |
738 | ||
739 | PrimaryExpressionNoWC_ | |
740 | : PrimaryExpressionBF { $$ = $1; } | |
741 | | PrimaryExpressionNo { $$ = $1; } | |
742 | ; | |
743 | ||
744 | PrimaryExpressionNoWC | |
745 | : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; } | |
746 | ; | |
747 | ||
748 | PrimaryExpressionNo | |
749 | : "this" { $$ = $1; } | |
750 | | Identifier { $$ = new(driver.pool_) CYVariable($1); } | |
751 | | Literal { $$ = $1; } | |
752 | | ArrayLiteral { $$ = $1; } | |
753 | | "(" Expression ")" { $$ = $2; } | |
754 | ; | |
755 | ||
756 | PrimaryExpressionBF | |
757 | : ObjectLiteral { $$ = $1; } | |
758 | ; | |
759 | /* }}} */ | |
760 | /* 11.1.4 Array Initialiser {{{ */ | |
761 | ArrayLiteral | |
762 | : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); } | |
763 | ; | |
764 | ||
765 | Element | |
766 | : AssignmentExpression { $$ = $1; } | |
767 | ; | |
768 | ||
769 | ElementOpt | |
770 | : Element { $$ = $1; } | |
771 | | LexSetRegExp { $$ = NULL; } | |
772 | ; | |
773 | ||
774 | ElementListOpt | |
775 | : ElementList { $$ = $1; } | |
776 | | LexSetRegExp { $$ = NULL; } | |
777 | ; | |
778 | ||
779 | ElementList | |
780 | : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); } | |
781 | | Element { $$ = new(driver.pool_) CYElement($1, NULL); } | |
782 | ; | |
783 | /* }}} */ | |
784 | /* 11.1.5 Object Initialiser {{{ */ | |
785 | ObjectLiteral | |
786 | : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); } | |
787 | ; | |
788 | ||
789 | PropertyNameAndValueList_ | |
790 | : "," PropertyNameAndValueList { $$ = $2; } | |
791 | | { $$ = NULL; } | |
792 | ; | |
793 | ||
794 | PropertyNameAndValueListOpt | |
795 | : PropertyNameAndValueList { $$ = $1; } | |
796 | | { $$ = NULL; } | |
797 | ; | |
798 | ||
799 | PropertyNameAndValueList | |
800 | : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); } | |
801 | ; | |
802 | ||
803 | PropertyName_ | |
804 | : Identifier { $$ = $1; } | |
805 | | StringLiteral { $$ = $1; } | |
806 | | NumericLiteral { $$ = $1; } | |
807 | ; | |
808 | ||
809 | PropertyName | |
810 | : LexSetRegExp PropertyName_ { $$ = $2; } | |
811 | ; | |
812 | /* }}} */ | |
813 | ||
814 | /* 11.2 Left-Hand-Side Expressions {{{ */ | |
815 | MemberExpression_ | |
816 | : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); } | |
817 | ; | |
818 | ||
819 | MemberAccess | |
820 | : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); } | |
821 | | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); } | |
822 | ; | |
823 | ||
824 | MemberExpression | |
825 | : PrimaryExpression { $$ = $1; } | |
826 | | LexSetRegExp FunctionExpression { $$ = $2; } | |
827 | | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | |
828 | | LexSetRegExp MemberExpression_ { $$ = $2; } | |
829 | ; | |
830 | ||
831 | MemberExpressionNoBF | |
832 | : PrimaryExpressionNoBF { $$ = $1; } | |
833 | | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } | |
834 | | MemberExpression_ { $$ = $1; } | |
835 | ; | |
836 | ||
837 | MemberExpressionNoRE | |
838 | : PrimaryExpressionNoRE { $$ = $1; } | |
839 | | FunctionExpression { $$ = $1; } | |
840 | | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
841 | | MemberExpression_ { $$ = $1; } | |
842 | ; | |
843 | ||
844 | @begin ObjectiveC | |
845 | MemberExpressionNoWC | |
846 | : PrimaryExpression { $$ = $1; } | |
847 | | LexSetRegExp FunctionExpression { $$ = $2; } | |
848 | | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | |
849 | | LexSetRegExp MemberExpression_ { $$ = $2; } | |
850 | ; | |
851 | @end | |
852 | ||
853 | NewExpression_ | |
854 | : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } | |
855 | ; | |
856 | ||
857 | NewExpression | |
858 | : MemberExpression { $$ = $1; } | |
859 | | LexSetRegExp NewExpression_ { $$ = $2; } | |
860 | ; | |
861 | ||
862 | NewExpressionNoBF | |
863 | : MemberExpressionNoBF { $$ = $1; } | |
864 | | NewExpression_ { $$ = $1; } | |
865 | ; | |
866 | ||
867 | NewExpressionNoRE | |
868 | : MemberExpressionNoRE { $$ = $1; } | |
869 | | NewExpression_ { $$ = $1; } | |
870 | ; | |
871 | ||
872 | @begin ObjectiveC | |
873 | NewExpressionNoWC | |
874 | : MemberExpressionNoWC { $$ = $1; } | |
875 | | LexSetRegExp NewExpression_ { $$ = $2; } | |
876 | ; | |
877 | @end | |
878 | ||
879 | CallExpression | |
880 | : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
881 | | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
882 | | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | |
883 | ; | |
884 | ||
885 | CallExpressionNoBF | |
886 | : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
887 | | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
888 | | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } | |
889 | ; | |
890 | ||
891 | CallExpressionNoRE | |
892 | : PrimaryExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
893 | | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
894 | | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
895 | ; | |
896 | ||
897 | ArgumentList_ | |
898 | : "," ArgumentList { $$ = $2; } | |
899 | | { $$ = NULL; } | |
900 | ; | |
901 | ||
902 | ArgumentListOpt | |
903 | : ArgumentList { $$ = $1; } | |
904 | | LexSetRegExp { $$ = NULL; } | |
905 | ; | |
906 | ||
907 | ArgumentList | |
908 | : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); } | |
909 | ; | |
910 | ||
911 | Arguments | |
912 | : "(" ArgumentListOpt ")" { $$ = $2; } | |
913 | ; | |
914 | ||
915 | LeftHandSideExpression | |
916 | : NewExpression { $$ = $1; } | |
917 | | CallExpression { $$ = $1; } | |
918 | ; | |
919 | ||
920 | LeftHandSideExpressionNoBF | |
921 | : NewExpressionNoBF { $$ = $1; } | |
922 | | CallExpressionNoBF { $$ = $1; } | |
923 | ; | |
924 | ||
925 | LeftHandSideExpressionNoRE | |
926 | : NewExpressionNoRE { $$ = $1; } | |
927 | | CallExpressionNoRE { $$ = $1; } | |
928 | ; | |
929 | ||
930 | @begin ObjectiveC | |
931 | LeftHandSideExpressionNoWC | |
932 | : NewExpressionNoWC { $$ = $1; } | |
933 | | CallExpression { $$ = $1; } | |
934 | ; | |
935 | @end | |
936 | /* }}} */ | |
937 | /* 11.3 Postfix Expressions {{{ */ | |
938 | PostfixExpression | |
939 | : AssigneeExpression { $$ = $1; } | |
940 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
941 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
942 | ; | |
943 | ||
944 | PostfixExpressionNoBF | |
945 | : AssigneeExpressionNoBF { $$ = $1; } | |
946 | | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
947 | | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
948 | ; | |
949 | ||
950 | PostfixExpressionNoRE | |
951 | : AssigneeExpressionNoRE { $$ = $1; } | |
952 | | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
953 | | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
954 | ; | |
955 | ||
956 | @begin ObjectiveC | |
957 | PostfixExpressionNoWC | |
958 | : AssigneeExpressionNoWC { $$ = $1; } | |
959 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
960 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
961 | ; | |
962 | @end | |
963 | /* }}} */ | |
964 | /* 11.4 Unary Operators {{{ */ | |
965 | UnaryExpression_ | |
966 | : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); } | |
967 | | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); } | |
968 | | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); } | |
969 | | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
970 | | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
971 | | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
972 | | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
973 | | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); } | |
974 | | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); } | |
975 | | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); } | |
976 | | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); } | |
977 | ; | |
978 | ||
979 | UnaryExpression | |
980 | : PostfixExpression { $$ = $1; } | |
981 | | LexSetRegExp UnaryExpression_ { $$ = $2; } | |
982 | ; | |
983 | ||
984 | UnaryExpressionNoBF | |
985 | : PostfixExpressionNoBF { $$ = $1; } | |
986 | | UnaryExpression_ { $$ = $1; } | |
987 | ; | |
988 | ||
989 | UnaryExpressionNoRE | |
990 | : PostfixExpressionNoRE { $$ = $1; } | |
991 | | UnaryExpression_ { $$ = $1; } | |
992 | ; | |
993 | ||
994 | @begin ObjectiveC | |
995 | UnaryExpressionNoWC | |
996 | : PostfixExpressionNoWC { $$ = $1; } | |
997 | | LexSetRegExp UnaryExpression_ { $$ = $2; } | |
998 | ; | |
999 | @end | |
1000 | /* }}} */ | |
1001 | /* 11.5 Multiplicative Operators {{{ */ | |
1002 | MultiplicativeExpression | |
1003 | : UnaryExpression { $$ = $1; } | |
1004 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
1005 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1006 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1007 | ; | |
1008 | ||
1009 | MultiplicativeExpressionNoBF | |
1010 | : UnaryExpressionNoBF { $$ = $1; } | |
1011 | | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
1012 | | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1013 | | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1014 | ; | |
1015 | ||
1016 | @begin ObjectiveC | |
1017 | MultiplicativeExpressionNoWC | |
1018 | : UnaryExpressionNoWC { $$ = $1; } | |
1019 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
1020 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1021 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1022 | ; | |
1023 | @end | |
1024 | /* }}} */ | |
1025 | /* 11.6 Additive Operators {{{ */ | |
1026 | AdditiveExpression | |
1027 | : MultiplicativeExpression { $$ = $1; } | |
1028 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
1029 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1030 | ; | |
1031 | ||
1032 | AdditiveExpressionNoBF | |
1033 | : MultiplicativeExpressionNoBF { $$ = $1; } | |
1034 | | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
1035 | | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1036 | ; | |
1037 | ||
1038 | @begin ObjectiveC | |
1039 | AdditiveExpressionNoWC | |
1040 | : MultiplicativeExpressionNoWC { $$ = $1; } | |
1041 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
1042 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1043 | ; | |
1044 | @end | |
1045 | /* }}} */ | |
1046 | /* 11.7 Bitwise Shift Operators {{{ */ | |
1047 | ShiftExpression | |
1048 | : AdditiveExpression { $$ = $1; } | |
1049 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
1050 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1051 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1052 | ; | |
1053 | ||
1054 | ShiftExpressionNoBF | |
1055 | : AdditiveExpressionNoBF { $$ = $1; } | |
1056 | | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
1057 | | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1058 | | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1059 | ; | |
1060 | ||
1061 | @begin ObjectiveC | |
1062 | ShiftExpressionNoWC | |
1063 | : AdditiveExpressionNoWC { $$ = $1; } | |
1064 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
1065 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1066 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1067 | ; | |
1068 | @end | |
1069 | /* }}} */ | |
1070 | /* 11.8 Relational Operators {{{ */ | |
1071 | RelationalExpressionNoIn_ | |
1072 | : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); } | |
1073 | | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); } | |
1074 | | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); } | |
1075 | | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); } | |
1076 | | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); } | |
1077 | ; | |
1078 | ||
1079 | RelationalExpression_ | |
1080 | : RelationalExpressionNoIn_ { $$ = $1; } | |
1081 | | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); } | |
1082 | ; | |
1083 | ||
1084 | RelationalExpression | |
1085 | : ShiftExpression { $$ = $1; } | |
1086 | | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
1087 | ; | |
1088 | ||
1089 | RelationalExpressionNoIn | |
1090 | : ShiftExpression { $$ = $1; } | |
1091 | | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; } | |
1092 | ; | |
1093 | ||
1094 | RelationalExpressionNoBF | |
1095 | : ShiftExpressionNoBF { $$ = $1; } | |
1096 | | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
1097 | ; | |
1098 | ||
1099 | @begin ObjectiveC | |
1100 | RelationalExpressionNoWC | |
1101 | : ShiftExpressionNoWC { $$ = $1; } | |
1102 | | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
1103 | ; | |
1104 | @end | |
1105 | /* }}} */ | |
1106 | /* 11.9 Equality Operators {{{ */ | |
1107 | EqualityExpression | |
1108 | : RelationalExpression { $$ = $1; } | |
1109 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1110 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1111 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1112 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1113 | ; | |
1114 | ||
1115 | EqualityExpressionNoIn | |
1116 | : RelationalExpressionNoIn { $$ = $1; } | |
1117 | | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1118 | | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1119 | | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1120 | | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1121 | ; | |
1122 | ||
1123 | EqualityExpressionNoBF | |
1124 | : RelationalExpressionNoBF { $$ = $1; } | |
1125 | | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1126 | | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1127 | | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1128 | | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1129 | ; | |
1130 | ||
1131 | @begin ObjectiveC | |
1132 | EqualityExpressionNoWC | |
1133 | : RelationalExpressionNoWC { $$ = $1; } | |
1134 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1135 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1136 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1137 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1138 | ; | |
1139 | @end | |
1140 | /* }}} */ | |
1141 | /* 11.10 Binary Bitwise Operators {{{ */ | |
1142 | BitwiseANDExpression | |
1143 | : EqualityExpression { $$ = $1; } | |
1144 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1145 | ; | |
1146 | ||
1147 | BitwiseANDExpressionNoIn | |
1148 | : EqualityExpressionNoIn { $$ = $1; } | |
1149 | | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1150 | ; | |
1151 | ||
1152 | BitwiseANDExpressionNoBF | |
1153 | : EqualityExpressionNoBF { $$ = $1; } | |
1154 | | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1155 | ; | |
1156 | ||
1157 | @begin ObjectiveC | |
1158 | BitwiseANDExpressionNoWC | |
1159 | : EqualityExpressionNoWC { $$ = $1; } | |
1160 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1161 | ; | |
1162 | @end | |
1163 | ||
1164 | BitwiseXORExpression | |
1165 | : BitwiseANDExpression { $$ = $1; } | |
1166 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1167 | ; | |
1168 | ||
1169 | BitwiseXORExpressionNoIn | |
1170 | : BitwiseANDExpressionNoIn { $$ = $1; } | |
1171 | | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1172 | ; | |
1173 | ||
1174 | BitwiseXORExpressionNoBF | |
1175 | : BitwiseANDExpressionNoBF { $$ = $1; } | |
1176 | | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1177 | ; | |
1178 | ||
1179 | @begin ObjectiveC | |
1180 | BitwiseXORExpressionNoWC | |
1181 | : BitwiseANDExpressionNoWC { $$ = $1; } | |
1182 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1183 | ; | |
1184 | @end | |
1185 | ||
1186 | BitwiseORExpression | |
1187 | : BitwiseXORExpression { $$ = $1; } | |
1188 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1189 | ; | |
1190 | ||
1191 | BitwiseORExpressionNoIn | |
1192 | : BitwiseXORExpressionNoIn { $$ = $1; } | |
1193 | | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1194 | ; | |
1195 | ||
1196 | BitwiseORExpressionNoBF | |
1197 | : BitwiseXORExpressionNoBF { $$ = $1; } | |
1198 | | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1199 | ; | |
1200 | ||
1201 | @begin ObjectiveC | |
1202 | BitwiseORExpressionNoWC | |
1203 | : BitwiseXORExpressionNoWC { $$ = $1; } | |
1204 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1205 | ; | |
1206 | @end | |
1207 | /* }}} */ | |
1208 | /* 11.11 Binary Logical Operators {{{ */ | |
1209 | LogicalANDExpression | |
1210 | : BitwiseORExpression { $$ = $1; } | |
1211 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1212 | ; | |
1213 | ||
1214 | LogicalANDExpressionNoIn | |
1215 | : BitwiseORExpressionNoIn { $$ = $1; } | |
1216 | | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1217 | ; | |
1218 | ||
1219 | LogicalANDExpressionNoBF | |
1220 | : BitwiseORExpressionNoBF { $$ = $1; } | |
1221 | | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1222 | ; | |
1223 | ||
1224 | @begin ObjectiveC | |
1225 | LogicalANDExpressionNoWC | |
1226 | : BitwiseORExpressionNoWC { $$ = $1; } | |
1227 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1228 | ; | |
1229 | @end | |
1230 | ||
1231 | LogicalORExpression | |
1232 | : LogicalANDExpression { $$ = $1; } | |
1233 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1234 | ; | |
1235 | ||
1236 | LogicalORExpressionNoIn | |
1237 | : LogicalANDExpressionNoIn { $$ = $1; } | |
1238 | | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1239 | ; | |
1240 | ||
1241 | LogicalORExpressionNoBF | |
1242 | : LogicalANDExpressionNoBF { $$ = $1; } | |
1243 | | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1244 | ; | |
1245 | ||
1246 | @begin ObjectiveC | |
1247 | LogicalORExpressionNoWC | |
1248 | : LogicalANDExpressionNoWC { $$ = $1; } | |
1249 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1250 | ; | |
1251 | @end | |
1252 | /* }}} */ | |
1253 | /* 11.12 Conditional Operator ( ? : ) {{{ */ | |
1254 | ConditionalExpression | |
1255 | : LogicalORExpression { $$ = $1; } | |
1256 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1257 | ; | |
1258 | ||
1259 | ConditionalExpressionNoIn | |
1260 | : LogicalORExpressionNoIn { $$ = $1; } | |
1261 | | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1262 | ; | |
1263 | ||
1264 | ConditionalExpressionNoBF | |
1265 | : LogicalORExpressionNoBF { $$ = $1; } | |
1266 | | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1267 | ; | |
1268 | ||
1269 | @begin ObjectiveC | |
1270 | ConditionalExpressionNoWC | |
1271 | : LogicalORExpressionNoWC { $$ = $1; } | |
1272 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1273 | ; | |
1274 | @end | |
1275 | /* }}} */ | |
1276 | /* 11.13 Assignment Operators {{{ */ | |
1277 | AssignmentExpression_ | |
1278 | : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); } | |
1279 | | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); } | |
1280 | | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); } | |
1281 | | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); } | |
1282 | | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); } | |
1283 | | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); } | |
1284 | | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); } | |
1285 | | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); } | |
1286 | | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); } | |
1287 | | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); } | |
1288 | | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); } | |
1289 | | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); } | |
1290 | ; | |
1291 | ||
1292 | AssigneeExpression | |
1293 | : LeftHandSideExpression { $$ = $1; } | |
1294 | | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } | |
1295 | ; | |
1296 | ||
1297 | AssigneeExpressionNoBF | |
1298 | : LeftHandSideExpressionNoBF { $$ = $1; } | |
1299 | | UnaryAssigneeExpression { $$ = $1; } | |
1300 | ; | |
1301 | ||
1302 | AssigneeExpressionNoRE | |
1303 | : LeftHandSideExpressionNoRE { $$ = $1; } | |
1304 | | UnaryAssigneeExpression { $$ = $1; } | |
1305 | ; | |
1306 | ||
1307 | @begin ObjectiveC | |
1308 | AssigneeExpressionNoWC | |
1309 | : LeftHandSideExpressionNoWC { $$ = $1; } | |
1310 | | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } | |
1311 | ; | |
1312 | @end | |
1313 | ||
1314 | AssignmentExpression | |
1315 | : ConditionalExpression { $$ = $1; } | |
1316 | | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1317 | ; | |
1318 | ||
1319 | AssignmentExpressionNoIn | |
1320 | : ConditionalExpressionNoIn { $$ = $1; } | |
1321 | | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); } | |
1322 | | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
1323 | | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
1324 | | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
1325 | | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
1326 | | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
1327 | | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
1328 | | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
1329 | | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
1330 | | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
1331 | | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
1332 | | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
1333 | ; | |
1334 | ||
1335 | AssignmentExpressionNoBF | |
1336 | : ConditionalExpressionNoBF { $$ = $1; } | |
1337 | | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1338 | ; | |
1339 | ||
1340 | @begin ObjectiveC | |
1341 | AssignmentExpressionNoWC | |
1342 | : ConditionalExpressionNoWC { $$ = $1; } | |
1343 | | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1344 | ; | |
1345 | @end | |
1346 | /* }}} */ | |
1347 | /* 11.14 Comma Operator {{{ */ | |
1348 | Expression_ | |
1349 | : "," Expression { $$ = new(driver.pool_) CYCompound($2); } | |
1350 | | { $$ = NULL; } | |
1351 | ; | |
1352 | ||
1353 | ExpressionNoIn_ | |
1354 | : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); } | |
1355 | | { $$ = NULL; } | |
1356 | ; | |
1357 | ||
1358 | ExpressionOpt | |
1359 | : Expression { $$ = $1; } | |
1360 | | LexSetRegExp { $$ = NULL; } | |
1361 | ; | |
1362 | ||
1363 | ExpressionNoInOpt | |
1364 | : ExpressionNoIn { $$ = $1; } | |
1365 | | LexSetRegExp { $$ = NULL; } | |
1366 | ; | |
1367 | ||
1368 | Expression | |
1369 | : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1370 | ; | |
1371 | ||
1372 | ExpressionNoIn | |
1373 | : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1374 | ; | |
1375 | ||
1376 | ExpressionNoBF | |
1377 | : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1378 | ; | |
1379 | /* }}} */ | |
1380 | ||
1381 | /* 12 Statements {{{ */ | |
1382 | Statement_ | |
1383 | : Block { $$ = $1; } | |
1384 | | VariableStatement { $$ = $1; } | |
1385 | | EmptyStatement { $$ = $1; } | |
1386 | | ExpressionStatement { $$ = $1; } | |
1387 | | IfStatement { $$ = $1; } | |
1388 | | IterationStatement { $$ = $1; } | |
1389 | | ContinueStatement { $$ = $1; } | |
1390 | | BreakStatement { $$ = $1; } | |
1391 | | ReturnStatement { $$ = $1; } | |
1392 | | WithStatement { $$ = $1; } | |
1393 | | LabelledStatement { $$ = $1; } | |
1394 | | SwitchStatement { $$ = $1; } | |
1395 | | ThrowStatement { $$ = $1; } | |
1396 | | TryStatement { $$ = $1; } | |
1397 | ; | |
1398 | ||
1399 | Statement | |
1400 | : LexSetRegExp Statement_ { $$ = $2; } | |
1401 | ; | |
1402 | /* }}} */ | |
1403 | /* 12.1 Block {{{ */ | |
1404 | Block_ | |
1405 | : "{" StatementListOpt "}" { $$ = $2; } | |
1406 | ; | |
1407 | ||
1408 | Block | |
1409 | : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); } | |
1410 | ; | |
1411 | ||
1412 | StatementList | |
1413 | : Statement StatementListOpt { $1->SetNext($2); $$ = $1; } | |
1414 | ; | |
1415 | ||
1416 | StatementListOpt | |
1417 | : StatementList { $$ = $1; } | |
1418 | | LexSetRegExp { $$ = NULL; } | |
1419 | ; | |
1420 | /* }}} */ | |
1421 | /* 12.2 Variable Statement {{{ */ | |
1422 | VariableStatement | |
1423 | : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); } | |
1424 | ; | |
1425 | ||
1426 | VariableDeclarationList_ | |
1427 | : "," VariableDeclarationList { $$ = $2; } | |
1428 | | { $$ = NULL; } | |
1429 | ; | |
1430 | ||
1431 | VariableDeclarationListNoIn_ | |
1432 | : "," VariableDeclarationListNoIn { $$ = $2; } | |
1433 | | { $$ = NULL; } | |
1434 | ; | |
1435 | ||
1436 | VariableDeclarationList | |
1437 | : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
1438 | ; | |
1439 | ||
1440 | VariableDeclarationListNoIn | |
1441 | : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
1442 | ; | |
1443 | ||
1444 | VariableDeclaration | |
1445 | : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1446 | ; | |
1447 | ||
1448 | VariableDeclarationNoIn | |
1449 | : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1450 | ; | |
1451 | ||
1452 | InitialiserOpt | |
1453 | : Initialiser { $$ = $1; } | |
1454 | | { $$ = NULL; } | |
1455 | ; | |
1456 | ||
1457 | InitialiserNoInOpt | |
1458 | : InitialiserNoIn { $$ = $1; } | |
1459 | | { $$ = NULL; } | |
1460 | ; | |
1461 | ||
1462 | Initialiser | |
1463 | : "=" AssignmentExpression { $$ = $2; } | |
1464 | ; | |
1465 | ||
1466 | InitialiserNoIn | |
1467 | : "=" AssignmentExpressionNoIn { $$ = $2; } | |
1468 | ; | |
1469 | /* }}} */ | |
1470 | /* 12.3 Empty Statement {{{ */ | |
1471 | EmptyStatement | |
1472 | : ";" { $$ = new(driver.pool_) CYEmpty(); } | |
1473 | ; | |
1474 | /* }}} */ | |
1475 | /* 12.4 Expression Statement {{{ */ | |
1476 | ExpressionStatement | |
1477 | : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); } | |
1478 | ; | |
1479 | /* }}} */ | |
1480 | /* 12.5 The if Statement {{{ */ | |
1481 | ElseStatementOpt | |
1482 | : "else" Statement { $$ = $2; } | |
1483 | | %prec "if" { $$ = NULL; } | |
1484 | ; | |
1485 | ||
1486 | IfStatement | |
1487 | : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); } | |
1488 | ; | |
1489 | /* }}} */ | |
1490 | ||
1491 | /* 12.6 Iteration Statements {{{ */ | |
1492 | IterationStatement | |
1493 | : DoWhileStatement { $$ = $1; } | |
1494 | | WhileStatement { $$ = $1; } | |
1495 | | ForStatement { $$ = $1; } | |
1496 | | ForInStatement { $$ = $1; } | |
1497 | ; | |
1498 | /* }}} */ | |
1499 | /* 12.6.1 The do-while Statement {{{ */ | |
1500 | DoWhileStatement | |
1501 | : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); } | |
1502 | ; | |
1503 | /* }}} */ | |
1504 | /* 12.6.2 The while Statement {{{ */ | |
1505 | WhileStatement | |
1506 | : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); } | |
1507 | ; | |
1508 | /* }}} */ | |
1509 | /* 12.6.3 The for Statement {{{ */ | |
1510 | ForStatement | |
1511 | : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); } | |
1512 | ; | |
1513 | ||
1514 | ForStatementInitialiser | |
1515 | : ExpressionNoInOpt { $$ = $1; } | |
1516 | | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; } | |
1517 | ; | |
1518 | /* }}} */ | |
1519 | /* 12.6.4 The for-in Statement {{{ */ | |
1520 | ForInStatement | |
1521 | : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); } | |
1522 | ; | |
1523 | ||
1524 | ForInStatementInitialiser | |
1525 | : LeftHandSideExpression { $$ = $1; } | |
1526 | | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; } | |
1527 | ; | |
1528 | /* }}} */ | |
1529 | ||
1530 | /* 12.7 The continue Statement {{{ */ | |
1531 | ContinueStatement | |
1532 | : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); } | |
1533 | ; | |
1534 | /* }}} */ | |
1535 | /* 12.8 The break Statement {{{ */ | |
1536 | BreakStatement | |
1537 | : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); } | |
1538 | ; | |
1539 | /* }}} */ | |
1540 | /* 12.9 The return Statement {{{ */ | |
1541 | ReturnStatement | |
1542 | : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); } | |
1543 | ; | |
1544 | /* }}} */ | |
1545 | /* 12.10 The with Statement {{{ */ | |
1546 | WithStatement | |
1547 | : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); } | |
1548 | ; | |
1549 | /* }}} */ | |
1550 | ||
1551 | /* 12.11 The switch Statement {{{ */ | |
1552 | SwitchStatement | |
1553 | : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); } | |
1554 | ; | |
1555 | ||
1556 | CaseBlock | |
1557 | : "{" CaseClausesOpt "}" { $$ = $2; } | |
1558 | ; | |
1559 | ||
1560 | CaseClausesOpt | |
1561 | : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1562 | | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1563 | | { $$ = NULL; } | |
1564 | ; | |
1565 | ||
1566 | CaseClause | |
1567 | : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); } | |
1568 | ; | |
1569 | ||
1570 | DefaultClause | |
1571 | : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); } | |
1572 | ; | |
1573 | /* }}} */ | |
1574 | /* 12.12 Labelled Statements {{{ */ | |
1575 | LabelledStatement | |
1576 | : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); } | |
1577 | ; | |
1578 | /* }}} */ | |
1579 | /* 12.13 The throw Statement {{{ */ | |
1580 | ThrowStatement | |
1581 | : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); } | |
1582 | ; | |
1583 | /* }}} */ | |
1584 | /* 12.14 The try Statement {{{ */ | |
1585 | TryStatement | |
1586 | : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); } | |
1587 | ; | |
1588 | ||
1589 | CatchOpt | |
1590 | : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); } | |
1591 | | { $$ = NULL; } | |
1592 | ; | |
1593 | ||
1594 | FinallyOpt | |
1595 | : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); } | |
1596 | | { $$ = NULL; } | |
1597 | ; | |
1598 | /* }}} */ | |
1599 | ||
1600 | /* 13 Function Definition {{{ */ | |
1601 | FunctionDeclaration | |
1602 | : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); } | |
1603 | ; | |
1604 | ||
1605 | FunctionExpression | |
1606 | : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } | |
1607 | ; | |
1608 | ||
1609 | FormalParameterList_ | |
1610 | : "," FormalParameterList { $$ = $2; } | |
1611 | | { $$ = NULL; } | |
1612 | ; | |
1613 | ||
1614 | FormalParameterList | |
1615 | : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); } | |
1616 | | { $$ = NULL; } | |
1617 | ; | |
1618 | ||
1619 | FunctionBody | |
1620 | : SourceElements { $$ = $1; } | |
1621 | ; | |
1622 | /* }}} */ | |
1623 | /* 14 Program {{{ */ | |
1624 | Program | |
1625 | : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); } | |
1626 | ; | |
1627 | ||
1628 | SourceElements | |
1629 | : SourceElement SourceElements { $1->SetNext($2); $$ = $1; } | |
1630 | | LexSetRegExp { $$ = NULL; } | |
1631 | ; | |
1632 | ||
1633 | SourceElement_ | |
1634 | : Statement_ { $$ = $1; } | |
1635 | | FunctionDeclaration { $$ = $1; } | |
1636 | ; | |
1637 | ||
1638 | SourceElement | |
1639 | : LexSetRegExp SourceElement_ { $$ = $2; } | |
1640 | ; | |
1641 | /* }}} */ | |
1642 | ||
1643 | @begin ObjectiveC | |
1644 | /* Cycript (Objective-C): @class Declaration {{{ */ | |
1645 | ClassSuperOpt | |
1646 | /* XXX: why the hell did I choose MemberExpressionNoBF? */ | |
1647 | : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; } | |
1648 | | { $$ = NULL; } | |
1649 | ; | |
1650 | ||
1651 | ClassFieldList | |
1652 | : "{" "}" { $$ = NULL; } | |
1653 | ; | |
1654 | ||
1655 | MessageScope | |
1656 | : "+" { $$ = false; } | |
1657 | | "-" { $$ = true; } | |
1658 | ; | |
1659 | ||
1660 | TypeOpt | |
1661 | : "(" Expression ")" { $$ = $2; } | |
1662 | | { $$ = NULL; } | |
1663 | ; | |
1664 | ||
1665 | MessageParameter | |
1666 | : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); } | |
1667 | ; | |
1668 | ||
1669 | MessageParameterListOpt | |
1670 | : MessageParameterList { $$ = $1; } | |
1671 | | { $$ = NULL; } | |
1672 | ; | |
1673 | ||
1674 | MessageParameterList | |
1675 | : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; } | |
1676 | ; | |
1677 | ||
1678 | MessageParameters | |
1679 | : MessageParameterList { $$ = $1; } | |
1680 | | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); } | |
1681 | ; | |
1682 | ||
1683 | ClassMessageDeclaration | |
1684 | : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); } | |
1685 | ; | |
1686 | ||
1687 | ClassMessageDeclarationListOpt | |
1688 | : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; } | |
1689 | | { $$ = NULL; } | |
1690 | ; | |
1691 | ||
1692 | ClassName | |
1693 | : Identifier { $$ = $1; } | |
1694 | | "(" AssignmentExpression ")" { $$ = $2; } | |
1695 | ; | |
1696 | ||
1697 | ClassNameOpt | |
1698 | : ClassName { $$ = $1; } | |
1699 | | { $$ = NULL; } | |
1700 | ; | |
1701 | ||
1702 | ClassExpression | |
1703 | : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); } | |
1704 | ; | |
1705 | ||
1706 | ClassStatement | |
1707 | : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); } | |
1708 | ; | |
1709 | ||
1710 | CategoryStatement | |
1711 | : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); } | |
1712 | ; | |
1713 | ||
1714 | PrimaryExpressionBF | |
1715 | : ClassExpression { $$ = $1; } | |
1716 | ; | |
1717 | ||
1718 | Statement_ | |
1719 | : ClassStatement { $$ = $1; } | |
1720 | | CategoryStatement { $$ = $1; } | |
1721 | ; | |
1722 | /* }}} */ | |
1723 | /* Cycript (Objective-C): Send Message {{{ */ | |
1724 | VariadicCall | |
1725 | : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); } | |
1726 | | { $$ = NULL; } | |
1727 | ; | |
1728 | ||
1729 | SelectorCall_ | |
1730 | : SelectorCall { $$ = $1; } | |
1731 | | VariadicCall { $$ = $1; } | |
1732 | ; | |
1733 | ||
1734 | SelectorCall | |
1735 | : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); } | |
1736 | ; | |
1737 | ||
1738 | SelectorList | |
1739 | : SelectorCall { $$ = $1; } | |
1740 | | Word { $$ = new(driver.pool_) CYArgument($1, NULL); } | |
1741 | ; | |
1742 | ||
1743 | MessageExpression | |
1744 | : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); } | |
1745 | | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); } | |
1746 | ; | |
1747 | ||
1748 | SelectorExpressionOpt | |
1749 | : SelectorExpression_ { $$ = $1; } | |
1750 | | { $$ = NULL; } | |
1751 | ; | |
1752 | ||
1753 | SelectorExpression_ | |
1754 | : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); } | |
1755 | ; | |
1756 | ||
1757 | SelectorExpression | |
1758 | : SelectorExpression_ { $$ = $1; } | |
1759 | | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); } | |
1760 | ; | |
1761 | ||
1762 | PrimaryExpressionNo | |
1763 | : MessageExpression { $$ = $1; } | |
1764 | | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); } | |
1765 | ; | |
1766 | /* }}} */ | |
1767 | @end | |
1768 | ||
1769 | @begin C | |
1770 | /* Cycript (C): Pointer Indirection/Addressing {{{ */ | |
1771 | UnaryAssigneeExpression | |
1772 | : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); } | |
1773 | ; | |
1774 | ||
1775 | UnaryExpression_ | |
1776 | : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); } | |
1777 | ; | |
1778 | ||
1779 | MemberAccess | |
1780 | : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); } | |
1781 | | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); } | |
1782 | ; | |
1783 | /* }}} */ | |
1784 | @end | |
1785 | ||
1786 | @begin E4X | |
1787 | /* Lexer State {{{ */ | |
1788 | LexPushRegExp | |
1789 | : { driver.PushCondition(CYDriver::RegExpCondition); } | |
1790 | ; | |
1791 | ||
1792 | LexPushXMLContent | |
1793 | : { driver.PushCondition(CYDriver::XMLContentCondition); } | |
1794 | ; | |
1795 | ||
1796 | LexPushXMLTag | |
1797 | : { driver.PushCondition(CYDriver::XMLTagCondition); } | |
1798 | ; | |
1799 | ||
1800 | LexPop | |
1801 | : { driver.PopCondition(); } | |
1802 | ; | |
1803 | ||
1804 | LexSetXMLContent | |
1805 | : { driver.SetCondition(CYDriver::XMLContentCondition); } | |
1806 | ; | |
1807 | ||
1808 | LexSetXMLTag | |
1809 | : { driver.SetCondition(CYDriver::XMLTagCondition); } | |
1810 | ; | |
1811 | /* }}} */ | |
1812 | ||
1813 | XMLWhitespaceOpt | |
1814 | : XMLWhitespace | |
1815 | | | |
1816 | ; | |
1817 | ||
1818 | /* 8.1 Context Keywords {{{ */ | |
1819 | Identifier | |
1820 | : "namespace" { $$ = $1; } | |
1821 | | "xml" { $$ = $1; } | |
1822 | ; | |
1823 | /* }}} */ | |
1824 | /* 8.3 XML Initialiser Input Elements {{{ */ | |
1825 | XMLMarkup | |
1826 | : XMLComment { $$ = $1; } | |
1827 | | XMLCDATA { $$ = $1; } | |
1828 | | XMLPI { $$ = $1; } | |
1829 | ; | |
1830 | /* }}} */ | |
1831 | /* 11.1 Primary Expressions {{{ */ | |
1832 | PrimaryExpressionWC | |
1833 | : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } | |
1834 | | XMLInitialiser { $$ = $1; } | |
1835 | | XMLListInitialiser { $$ = $1; } | |
1836 | ; | |
1837 | ||
1838 | PropertyIdentifier | |
1839 | : AttributeIdentifier { $$ = $1; } | |
1840 | | QualifiedIdentifier { $$ = $1; } | |
1841 | | WildcardIdentifier { $$ = $1; } | |
1842 | ; | |
1843 | /* }}} */ | |
1844 | /* 11.1.1 Attribute Identifiers {{{ */ | |
1845 | AttributeIdentifier | |
1846 | : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); } | |
1847 | ; | |
1848 | ||
1849 | PropertySelector_ | |
1850 | : PropertySelector { $$ = $1; } | |
1851 | | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); } | |
1852 | ; | |
1853 | ||
1854 | PropertySelector | |
1855 | : Identifier { $$ = new(driver.pool_) CYSelector($1); } | |
1856 | | WildcardIdentifier { $$ = $1; } | |
1857 | ; | |
1858 | /* }}} */ | |
1859 | /* 11.1.2 Qualified Identifiers {{{ */ | |
1860 | QualifiedIdentifier_ | |
1861 | : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); } | |
1862 | | QualifiedIdentifier { $$ = $1; } | |
1863 | ; | |
1864 | ||
1865 | QualifiedIdentifier | |
1866 | : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); } | |
1867 | ; | |
1868 | /* }}} */ | |
1869 | /* 11.1.3 Wildcard Identifiers {{{ */ | |
1870 | WildcardIdentifier | |
1871 | : "*" { $$ = new(driver.pool_) CYWildcard(); } | |
1872 | ; | |
1873 | /* }}} */ | |
1874 | /* 11.1.4 XML Initialiser {{{ */ | |
1875 | XMLInitialiser | |
1876 | : XMLMarkup { $$ = $1; } | |
1877 | | XMLElement { $$ = $1; } | |
1878 | ; | |
1879 | ||
1880 | XMLElement | |
1881 | : "<" XMLTagContent "/>" LexPop | |
1882 | | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop | |
1883 | ; | |
1884 | ||
1885 | XMLTagContent | |
1886 | : LexPushXMLTag XMLTagName XMLAttributes | |
1887 | ; | |
1888 | ||
1889 | XMLExpression | |
1890 | : "{" LexPushRegExp Expression "}" LexPop | |
1891 | ; | |
1892 | ||
1893 | XMLTagName | |
1894 | : XMLExpression | |
1895 | | XMLName | |
1896 | ; | |
1897 | ||
1898 | XMLAttributes_ | |
1899 | : XMLAttributes_ XMLAttribute | |
1900 | | | |
1901 | ; | |
1902 | ||
1903 | XMLAttributes | |
1904 | : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt | |
1905 | | XMLAttributes_ XMLWhitespaceOpt | |
1906 | ; | |
1907 | ||
1908 | XMLAttributeValue_ | |
1909 | : XMLExpression | |
1910 | | XMLAttributeValue | |
1911 | ; | |
1912 | ||
1913 | XMLAttribute | |
1914 | : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_ | |
1915 | ; | |
1916 | ||
1917 | XMLElementContent | |
1918 | : XMLExpression XMLElementContentOpt | |
1919 | | XMLMarkup XMLElementContentOpt | |
1920 | | XMLText XMLElementContentOpt | |
1921 | | XMLElement XMLElementContentOpt | |
1922 | ; | |
1923 | ||
1924 | XMLElementContentOpt | |
1925 | : XMLElementContent | |
1926 | | | |
1927 | ; | |
1928 | /* }}} */ | |
1929 | /* 11.1.5 XMLList Initialiser {{{ */ | |
1930 | XMLListInitialiser | |
1931 | : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); } | |
1932 | ; | |
1933 | /* }}} */ | |
1934 | /* 11.2 Left-Hand-Side Expressions {{{ */ | |
1935 | PropertyIdentifier_ | |
1936 | : Identifier { $$ = $1; } | |
1937 | | PropertyIdentifier { $$ = $1; } | |
1938 | ; | |
1939 | ||
1940 | MemberAccess | |
1941 | : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); } | |
1942 | | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); } | |
1943 | | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); } | |
1944 | ; | |
1945 | /* }}} */ | |
1946 | /* 12.1 The default xml namespace Statement {{{ */ | |
1947 | /* XXX: DefaultXMLNamespaceStatement | |
1948 | : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); } | |
1949 | ; | |
1950 | ||
1951 | Statement_ | |
1952 | : DefaultXMLNamespaceStatement { $$ = $1; } | |
1953 | ; */ | |
1954 | /* }}} */ | |
1955 | @end | |
1956 | ||
1957 | /* ECMAScript5: Object Literal Trailing Comma {{{ */ | |
1958 | PropertyNameAndValueList_ | |
1959 | : "," { $$ = NULL; } | |
1960 | ; | |
1961 | /* }}} */ | |
1962 | /* JavaScript 1.7: Array Comprehensions {{{ */ | |
1963 | IfComprehension | |
1964 | : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); } | |
1965 | ; | |
1966 | ||
1967 | ForComprehension | |
1968 | : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); } | |
1969 | | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); } | |
1970 | ; | |
1971 | ||
1972 | ComprehensionListOpt | |
1973 | : ComprehensionList { $$ = $1; } | |
1974 | | IfComprehension { $$ = $1; } | |
1975 | | { $$ = NULL; } | |
1976 | ; | |
1977 | ||
1978 | ComprehensionList | |
1979 | : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; } | |
1980 | ; | |
1981 | ||
1982 | PrimaryExpressionNo | |
1983 | : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); } | |
1984 | ; | |
1985 | /* }}} */ | |
1986 | /* JavaScript 1.7: for each {{{ */ | |
1987 | ForInStatement | |
1988 | : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); } | |
1989 | ; | |
1990 | /* }}} */ | |
1991 | /* JavaScript 1.7: let Statements {{{ *//* | |
1992 | LetStatement | |
1993 | : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); } | |
1994 | ; | |
1995 | ||
1996 | Statement_ | |
1997 | : LetStatement | |
1998 | ; | |
1999 | *//* }}} */ | |
2000 | /* JavaScript FTW: Function Statements {{{ */ | |
2001 | Statement | |
2002 | : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; } | |
2003 | ; | |
2004 | /* }}} */ | |
2005 | ||
2006 | %% |