2 #include "Cycript.tab.hh"
3 #define scanner driver.scanner_
4 #define YYSTACKEXPANDABLE 1
14 CYArgument *argument_;
18 CYDeclaration *declaration_;
19 CYDeclarations *declarations_;
21 CYExpression *expression_;
23 CYForInitialiser *for_;
24 CYForInInitialiser *forin_;
25 CYIdentifier *identifier_;
30 CYParameter *parameter_;
31 CYProperty *property_;
33 CYStatement *statement_;
44 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
53 @$.begin.filename = @$.end.filename = &driver.filename_;
61 %parse-param { CYDriver &driver }
62 %lex-param { void *scanner }
65 %token AmpersandAmpersand "&&"
66 %token AmpersandEqual "&="
68 %token CarrotEqual "^="
70 %token EqualEqual "=="
71 %token EqualEqualEqual "==="
72 %token Exclamation "!"
73 %token ExclamationEqual "!="
74 %token ExclamationEqualEqual "!=="
76 %token HyphenEqual "-="
77 %token HyphenHyphen "--"
78 %token HyphenHyphen_ "\n--"
79 %token HyphenRight "->"
83 %token LeftLeftEqual "<<="
85 %token PercentEqual "%="
93 %token PlusPlus_ "\n++"
95 %token RightEqual ">="
96 %token RightRight ">>"
97 %token RightRightEqual ">>="
98 %token RightRightRight ">>>"
99 %token RightRightRightEqual ">>>="
101 %token SlashEqual "/="
103 %token StarEqual "*="
113 %token CloseParen ")"
116 %token CloseBrace "}"
118 %token OpenBracket "["
119 %token CloseBracket "]"
121 %token <word_> Break "break"
122 %token <word_> Case "case"
123 %token <word_> Catch "catch"
124 %token <word_> Continue "continue"
125 %token <word_> Default "default"
126 %token <word_> Delete "delete"
127 %token <word_> Do "do"
128 %token <word_> Else "else"
129 %token <false_> False "false"
130 %token <word_> Finally "finally"
131 %token <word_> For "for"
132 %token <word_> Function "function"
133 %token <word_> If "if"
134 %token <word_> In "in"
135 %token <word_> InstanceOf "instanceof"
136 %token <word_> New "new"
137 %token <null_> Null "null"
138 %token <word_> Return "return"
139 %token <word_> Switch "switch"
140 %token <this_> This "this"
141 %token <word_> Throw "throw"
142 %token <true_> True "true"
143 %token <word_> Try "try"
144 %token <word_> TypeOf "typeof"
145 %token <word_> Var "var"
146 %token <word_> Void "void"
147 %token <word_> While "while"
148 %token <word_> With "with"
150 %token <identifier_> Identifier
151 %token <number_> NumericLiteral
152 %token <string_> StringLiteral
154 %type <expression_> AdditiveExpression
155 %type <expression_> AdditiveExpressionNoBF
156 %type <argument_> ArgumentList
157 %type <argument_> ArgumentList_
158 %type <argument_> ArgumentListOpt
159 %type <argument_> Arguments
160 %type <literal_> ArrayLiteral
161 %type <expression_> AssignmentExpression
162 %type <expression_> AssignmentExpressionNoBF
163 %type <expression_> AssignmentExpressionNoIn
164 %type <expression_> BitwiseANDExpression
165 %type <expression_> BitwiseANDExpressionNoBF
166 %type <expression_> BitwiseANDExpressionNoIn
167 %type <statement_> Block
168 %type <boolean_> BooleanLiteral
169 %type <expression_> BitwiseORExpression
170 %type <expression_> BitwiseORExpressionNoBF
171 %type <expression_> BitwiseORExpressionNoIn
172 %type <expression_> BitwiseXORExpression
173 %type <expression_> BitwiseXORExpressionNoBF
174 %type <expression_> BitwiseXORExpressionNoIn
175 %type <statement_> BreakStatement
176 %type <expression_> CallExpression
177 %type <expression_> CallExpressionNoBF
178 %type <clause_> CaseBlock
179 %type <clause_> CaseClause
180 %type <clause_> CaseClausesOpt
181 %type <catch_> CatchOpt
182 %type <expression_> ConditionalExpression
183 %type <expression_> ConditionalExpressionNoBF
184 %type <expression_> ConditionalExpressionNoIn
185 %type <statement_> ContinueStatement
186 %type <clause_> DefaultClause
187 %type <statement_> DoWhileStatement
188 %type <expression_> Element
189 %type <element_> ElementList
190 %type <element_> ElementList_
191 %type <statement_> ElseStatementOpt
192 %type <statement_> EmptyStatement
193 %type <expression_> EqualityExpression
194 %type <expression_> EqualityExpressionNoBF
195 %type <expression_> EqualityExpressionNoIn
196 %type <expression_> Expression
197 %type <expression_> ExpressionOpt
198 %type <expression_> Expression_
199 %type <expression_> ExpressionNoBF
200 %type <expression_> ExpressionNoIn
201 %type <expression_> ExpressionNoIn_
202 %type <expression_> ExpressionNoInOpt
203 %type <statement_> ExpressionStatement
204 %type <statement_> FinallyOpt
205 %type <statement_> ForStatement
206 %type <for_> ForStatementInitialiser
207 %type <statement_> ForInStatement
208 %type <forin_> ForInStatementInitialiser
209 %type <parameter_> FormalParameterList
210 %type <parameter_> FormalParameterList_
211 %type <source_> FunctionBody
212 %type <source_> FunctionDeclaration
213 %type <expression_> FunctionExpression
214 %type <identifier_> IdentifierOpt
215 %type <statement_> IfStatement
216 %type <expression_> Initialiser
217 %type <expression_> InitialiserOpt
218 %type <expression_> InitialiserNoIn
219 %type <expression_> InitialiserNoInOpt
220 %type <statement_> IterationStatement
221 %type <statement_> LabelledStatement
222 %type <expression_> LeftHandSideExpression
223 %type <expression_> LeftHandSideExpression_
224 %type <expression_> LeftHandSideExpressionNoBF
225 %type <literal_> Literal
226 %type <expression_> LogicalANDExpression
227 %type <expression_> LogicalANDExpressionNoBF
228 %type <expression_> LogicalANDExpressionNoIn
229 %type <expression_> LogicalORExpression
230 %type <expression_> LogicalORExpressionNoBF
231 %type <expression_> LogicalORExpressionNoIn
232 %type <expression_> MemberExpression
233 %type <expression_> MemberExpression_
234 %type <expression_> MemberExpressionNoBF
235 %type <expression_> MultiplicativeExpression
236 %type <expression_> MultiplicativeExpressionNoBF
237 %type <expression_> NewExpression
238 %type <expression_> NewExpression_
239 %type <expression_> NewExpressionNoBF
240 %type <null_> NullLiteral
241 %type <literal_> ObjectLiteral
242 %type <expression_> PostfixExpression
243 %type <expression_> PostfixExpressionNoBF
244 %type <expression_> PrimaryExpression
245 %type <expression_> PrimaryExpression_
246 %type <expression_> PrimaryExpressionNoBF
247 %type <source_> Program
248 %type <name_> PropertyName
249 %type <property_> PropertyNameAndValueList
250 %type <property_> PropertyNameAndValueList_
251 %type <property_> PropertyNameAndValueListOpt
252 %type <expression_> RelationalExpression
253 %type <expression_> RelationalExpressionNoBF
254 %type <expression_> RelationalExpressionNoIn
255 %type <statement_> ReturnStatement
256 %type <expression_> ShiftExpression
257 %type <expression_> ShiftExpressionNoBF
258 %type <source_> SourceElement
259 %type <source_> SourceElements
260 %type <statement_> Statement
261 %type <statement_> StatementList
262 %type <statement_> StatementListOpt
263 %type <statement_> SwitchStatement
264 %type <statement_> ThrowStatement
265 %type <statement_> TryStatement
266 %type <expression_> UnaryExpression
267 %type <expression_> UnaryExpression_
268 %type <expression_> UnaryExpressionNoBF
269 %type <declaration_> VariableDeclaration
270 %type <declaration_> VariableDeclarationNoIn
271 %type <declarations_> VariableDeclarationList
272 %type <declarations_> VariableDeclarationList_
273 %type <declarations_> VariableDeclarationListNoIn
274 %type <declarations_> VariableDeclarationListNoIn_
275 %type <statement_> VariableStatement
276 %type <statement_> WhileStatement
277 %type <statement_> WithStatement
279 %type <word_> WordOpt
281 %type <expression_> MessageExpression
282 %type <argument_> SelectorCall
283 %type <argument_> SelectorCall_
284 %type <argument_> SelectorList
285 %type <argument_> VariadicCall
303 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else yyerrok; }
322 : Identifier { $$ = $1; }
323 | "break" NewLineOpt { $$ = $1; }
324 | "case" { $$ = $1; }
325 | "catch" { $$ = $1; }
326 | "continue" NewLineOpt { $$ = $1; }
327 | "default" { $$ = $1; }
328 | "delete" { $$ = $1; }
330 | "else" { $$ = $1; }
331 | "false" { $$ = $1; }
332 | "finally" { $$ = $1; }
334 | "function" { $$ = $1; }
336 /* XXX: | "in" { $$ = $1; } */
337 /* XXX: | "instanceof" { $$ = $1; } */
339 | "null" { $$ = $1; }
340 | "return" NewLineOpt { $$ = $1; }
341 | "switch" { $$ = $1; }
342 | "this" { $$ = $1; }
343 | "throw" NewLineOpt { $$ = $1; }
344 | "true" { $$ = $1; }
346 | "typeof" { $$ = $1; }
348 | "void" { $$ = $1; }
349 | "while" { $$ = $1; }
350 | "with" { $$ = $1; }
354 : Identifier { $$ = $1; }
359 : NullLiteral { $$ = $1; }
360 | BooleanLiteral { $$ = $1; }
361 | NumericLiteral { $$ = $1; }
362 | StringLiteral { $$ = $1; }
366 : "null" { $$ = $1; }
370 : "true" { $$ = $1; }
371 | "false" { $$ = $1; }
374 /* 11.1 Primary Expressions {{{ */
376 : "this" { $$ = $1; }
377 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
378 | Literal { $$ = $1; }
379 | ArrayLiteral { $$ = $1; }
380 | "(" Expression ")" { $$ = $2; }
384 : ObjectLiteral { $$ = $1; }
385 | PrimaryExpression_ { $$ = $1; }
388 PrimaryExpressionNoBF
389 : PrimaryExpression_ { $$ = $1; }
392 /* 11.1.4 Array Initialiser {{{ */
394 : "[" ElementList "]" { $$ = $2; }
398 : AssignmentExpression { $$ = $1; }
403 : "," ElementList { $$ = $2; }
408 : Element ElementList_ { $$ = new(driver.pool_) CYElement($1, $2); }
411 /* 11.1.5 Object Initialiser {{{ */
413 : "{" PropertyNameAndValueListOpt "}" { $$ = new CYObject($2); }
416 PropertyNameAndValueList_
417 : "," PropertyNameAndValueList { $$ = $2; }
418 | CommaOpt { $$ = NULL; }
421 PropertyNameAndValueListOpt
422 : PropertyNameAndValueList { $$ = $1; }
426 PropertyNameAndValueList
427 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
431 : Identifier { $$ = $1; }
432 | StringLiteral { $$ = $1; }
433 | NumericLiteral { $$ = $1; }
438 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
442 : PrimaryExpression { $$ = $1; }
443 | FunctionExpression { $$ = $1; }
444 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
445 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
446 | MemberExpression_ { $$ = $1; }
450 : PrimaryExpressionNoBF { $$ = $1; }
451 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
452 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
453 | MemberExpression_ { $$ = $1; }
457 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
461 : MemberExpression { $$ = $1; }
462 | NewExpression_ { $$ = $1; }
466 : MemberExpressionNoBF { $$ = $1; }
467 | NewExpression_ { $$ = $1; }
471 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
472 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
473 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
474 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
478 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
479 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
480 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
481 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
485 : "," ArgumentList { $$ = $2; }
490 : ArgumentList { $$ = $1; }
495 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
499 : "(" ArgumentListOpt ")" { $$ = $2; }
502 LeftHandSideExpression
503 : NewExpression { $$ = $1; }
504 | CallExpression { $$ = $1; }
505 | LeftHandSideExpression_ { $$ = $1; }
508 LeftHandSideExpressionNoBF
509 : NewExpressionNoBF { $$ = $1; }
510 | CallExpressionNoBF { $$ = $1; }
511 | LeftHandSideExpression_ { $$ = $1; }
515 : LeftHandSideExpression { $$ = $1; }
516 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
517 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
520 PostfixExpressionNoBF
521 : LeftHandSideExpressionNoBF { $$ = $1; }
522 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
523 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
527 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
528 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
529 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
530 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
531 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
532 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
533 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
534 | "+" UnaryExpression { $$ = $2; }
535 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
536 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
537 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
541 : PostfixExpression { $$ = $1; }
542 | UnaryExpression_ { $$ = $1; }
546 : PostfixExpressionNoBF { $$ = $1; }
547 | UnaryExpression_ { $$ = $1; }
550 MultiplicativeExpression
551 : UnaryExpression { $$ = $1; }
552 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
553 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
554 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
557 MultiplicativeExpressionNoBF
558 : UnaryExpressionNoBF { $$ = $1; }
559 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
560 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
561 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
565 : MultiplicativeExpression { $$ = $1; }
566 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
567 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
570 AdditiveExpressionNoBF
571 : MultiplicativeExpressionNoBF { $$ = $1; }
572 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
573 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
577 : AdditiveExpression { $$ = $1; }
578 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
579 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
580 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
584 : AdditiveExpressionNoBF { $$ = $1; }
585 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
586 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
587 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
591 : ShiftExpression { $$ = $1; }
592 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
593 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
594 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
595 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
596 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
597 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
600 RelationalExpressionNoIn
601 : ShiftExpression { $$ = $1; }
602 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
603 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
604 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
605 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
606 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
609 RelationalExpressionNoBF
610 : ShiftExpressionNoBF { $$ = $1; }
611 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
612 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
613 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
614 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
615 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
616 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
620 : RelationalExpression { $$ = $1; }
621 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
622 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
623 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
624 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
627 EqualityExpressionNoIn
628 : RelationalExpressionNoIn { $$ = $1; }
629 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
630 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
631 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
632 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
635 EqualityExpressionNoBF
636 : RelationalExpressionNoBF { $$ = $1; }
637 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
638 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
639 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
640 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
644 : EqualityExpression { $$ = $1; }
645 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
648 BitwiseANDExpressionNoIn
649 : EqualityExpressionNoIn { $$ = $1; }
650 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
653 BitwiseANDExpressionNoBF
654 : EqualityExpressionNoBF { $$ = $1; }
655 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
659 : BitwiseANDExpression { $$ = $1; }
660 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
663 BitwiseXORExpressionNoIn
664 : BitwiseANDExpressionNoIn { $$ = $1; }
665 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
668 BitwiseXORExpressionNoBF
669 : BitwiseANDExpressionNoBF { $$ = $1; }
670 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
674 : BitwiseXORExpression { $$ = $1; }
675 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
678 BitwiseORExpressionNoIn
679 : BitwiseXORExpressionNoIn { $$ = $1; }
680 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
683 BitwiseORExpressionNoBF
684 : BitwiseXORExpressionNoBF { $$ = $1; }
685 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
689 : BitwiseORExpression { $$ = $1; }
690 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
693 LogicalANDExpressionNoIn
694 : BitwiseORExpressionNoIn { $$ = $1; }
695 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
698 LogicalANDExpressionNoBF
699 : BitwiseORExpressionNoBF { $$ = $1; }
700 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
704 : LogicalANDExpression { $$ = $1; }
705 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
708 LogicalORExpressionNoIn
709 : LogicalANDExpressionNoIn { $$ = $1; }
710 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
713 LogicalORExpressionNoBF
714 : LogicalANDExpressionNoBF { $$ = $1; }
715 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
718 ConditionalExpression
719 : LogicalORExpression { $$ = $1; }
720 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
723 ConditionalExpressionNoIn
724 : LogicalORExpressionNoIn { $$ = $1; }
725 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
728 ConditionalExpressionNoBF
729 : LogicalORExpressionNoBF { $$ = $1; }
730 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
734 : ConditionalExpression { $$ = $1; }
735 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
736 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
737 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
738 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
739 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
740 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
741 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
742 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
743 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
744 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
745 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
746 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
749 AssignmentExpressionNoIn
750 : ConditionalExpressionNoIn { $$ = $1; }
751 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
752 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
753 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
754 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
755 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
756 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
757 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
758 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
759 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
760 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
761 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
762 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
765 AssignmentExpressionNoBF
766 : ConditionalExpressionNoBF { $$ = $1; }
767 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
768 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
769 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
770 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
771 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
772 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
773 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
774 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
775 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
776 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
777 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
778 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
782 : "," Expression { $$ = $2; }
787 : "," ExpressionNoIn { $$ = $2; }
792 : Expression { $$ = $1; }
797 : ExpressionNoIn { $$ = $1; }
802 : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
806 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
810 : AssignmentExpressionNoBF Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
815 | VariableStatement { $$ = $1; }
816 | EmptyStatement { $$ = $1; }
817 | ExpressionStatement { $$ = $1; }
818 | IfStatement { $$ = $1; }
819 | IterationStatement { $$ = $1; }
820 | ContinueStatement { $$ = $1; }
821 | BreakStatement { $$ = $1; }
822 | ReturnStatement { $$ = $1; }
823 | WithStatement { $$ = $1; }
824 | LabelledStatement { $$ = $1; }
825 | SwitchStatement { $$ = $1; }
826 | ThrowStatement { $$ = $1; }
827 | TryStatement { $$ = $1; }
831 : "{" "}" { $$ = new(driver.pool_) CYEmpty(); }
832 | "{" StatementList "}" { $$ = $2; }
836 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
840 : StatementList { $$ = $1; }
845 : "var" VariableDeclarationList Terminator { $$ = $2; }
848 VariableDeclarationList_
849 : "," VariableDeclarationList { $$ = $2; }
853 VariableDeclarationListNoIn_
854 : "," VariableDeclarationListNoIn { $$ = $2; }
858 VariableDeclarationList
859 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
862 VariableDeclarationListNoIn
863 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
867 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
870 VariableDeclarationNoIn
871 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
875 : Initialiser { $$ = $1; }
880 : InitialiserNoIn { $$ = $1; }
885 : "=" AssignmentExpression { $$ = $2; }
889 : "=" AssignmentExpressionNoIn { $$ = $2; }
893 : ";" { $$ = new(driver.pool_) CYEmpty(); }
897 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
901 : "else" Statement { $$ = $2; }
902 | %prec "if" { $$ = NULL; }
906 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
910 : DoWhileStatement { $$ = $1; }
911 | WhileStatement { $$ = $1; }
912 | ForStatement { $$ = $1; }
913 | ForInStatement { $$ = $1; }
917 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
921 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
925 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
928 ForStatementInitialiser
929 : ExpressionNoInOpt { $$ = $1; }
930 | "var" VariableDeclarationListNoIn { $$ = $2; }
934 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
937 ForInStatementInitialiser
938 : LeftHandSideExpression { $$ = $1; }
939 | "var" VariableDeclarationNoIn { $$ = $2; }
943 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
947 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
951 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
955 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
959 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
963 : "{" CaseClausesOpt "}" { $$ = $2; }
967 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
968 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
973 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
977 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
981 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
985 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
989 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
993 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
998 : "finally" Block { $$ = $2; }
1003 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1007 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1010 FormalParameterList_
1011 : "," FormalParameterList { $$ = $2; }
1016 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($1, $2); }
1021 : SourceElements { $$ = $1; }
1025 : SourceElements { driver.source_.push_back($1); $$ = $1; }
1029 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1034 : SourceElement { driver.source_.push_back($2); if (driver.filename_.empty() && false) YYACCEPT; $2->Show(std::cout); }
1038 : Statement { $$ = $1; }
1039 | FunctionDeclaration { $$ = $1; }
1042 /* Objective-C Extensions {{{ */
1044 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1049 : SelectorCall { $$ = $1; }
1050 | VariadicCall { $$ = $1; }
1054 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1058 : SelectorCall { $$ = $1; }
1059 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1063 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); }
1067 : MessageExpression { $$ = $1; }
1071 LeftHandSideExpression_
1072 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1076 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }