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_;
32 CYSelectorPart *selector_;
34 CYStatement *statement_;
45 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
54 @$.begin.filename = @$.end.filename = &driver.filename_;
62 %parse-param { CYDriver &driver }
63 %lex-param { void *scanner }
66 %token AmpersandAmpersand "&&"
67 %token AmpersandEqual "&="
69 %token CarrotEqual "^="
71 %token EqualEqual "=="
72 %token EqualEqualEqual "==="
73 %token Exclamation "!"
74 %token ExclamationEqual "!="
75 %token ExclamationEqualEqual "!=="
77 %token HyphenEqual "-="
78 %token HyphenHyphen "--"
79 %token HyphenHyphen_ "\n--"
80 %token HyphenRight "->"
84 %token LeftLeftEqual "<<="
86 %token PercentEqual "%="
94 %token PlusPlus_ "\n++"
96 %token RightEqual ">="
97 %token RightRight ">>"
98 %token RightRightEqual ">>="
99 %token RightRightRight ">>>"
100 %token RightRightRightEqual ">>>="
102 %token SlashEqual "/="
104 %token StarEqual "*="
114 %token CloseParen ")"
117 %token CloseBrace "}"
119 %token OpenBracket "["
120 %token CloseBracket "]"
122 %token AtSelector "@selector"
124 %token <word_> Break "break"
125 %token <word_> Case "case"
126 %token <word_> Catch "catch"
127 %token <word_> Continue "continue"
128 %token <word_> Default "default"
129 %token <word_> Delete "delete"
130 %token <word_> Do "do"
131 %token <word_> Else "else"
132 %token <false_> False "false"
133 %token <word_> Finally "finally"
134 %token <word_> For "for"
135 %token <word_> Function "function"
136 %token <word_> If "if"
137 %token <word_> In "in"
138 %token <word_> InstanceOf "instanceof"
139 %token <word_> New "new"
140 %token <null_> Null "null"
141 %token <word_> Return "return"
142 %token <word_> Switch "switch"
143 %token <this_> This "this"
144 %token <word_> Throw "throw"
145 %token <true_> True "true"
146 %token <word_> Try "try"
147 %token <word_> TypeOf "typeof"
148 %token <word_> Var "var"
149 %token <word_> Void "void"
150 %token <word_> While "while"
151 %token <word_> With "with"
153 %token <identifier_> Identifier
154 %token <number_> NumericLiteral
155 %token <string_> StringLiteral
157 %type <expression_> AdditiveExpression
158 %type <expression_> AdditiveExpressionNoBF
159 %type <argument_> ArgumentList
160 %type <argument_> ArgumentList_
161 %type <argument_> ArgumentListOpt
162 %type <argument_> Arguments
163 %type <literal_> ArrayLiteral
164 %type <expression_> AssignmentExpression
165 %type <expression_> AssignmentExpressionNoBF
166 %type <expression_> AssignmentExpressionNoIn
167 %type <expression_> BitwiseANDExpression
168 %type <expression_> BitwiseANDExpressionNoBF
169 %type <expression_> BitwiseANDExpressionNoIn
170 %type <statement_> Block
171 %type <boolean_> BooleanLiteral
172 %type <expression_> BitwiseORExpression
173 %type <expression_> BitwiseORExpressionNoBF
174 %type <expression_> BitwiseORExpressionNoIn
175 %type <expression_> BitwiseXORExpression
176 %type <expression_> BitwiseXORExpressionNoBF
177 %type <expression_> BitwiseXORExpressionNoIn
178 %type <statement_> BreakStatement
179 %type <expression_> CallExpression
180 %type <expression_> CallExpressionNoBF
181 %type <clause_> CaseBlock
182 %type <clause_> CaseClause
183 %type <clause_> CaseClausesOpt
184 %type <catch_> CatchOpt
185 %type <expression_> ConditionalExpression
186 %type <expression_> ConditionalExpressionNoBF
187 %type <expression_> ConditionalExpressionNoIn
188 %type <statement_> ContinueStatement
189 %type <clause_> DefaultClause
190 %type <statement_> DoWhileStatement
191 %type <expression_> Element
192 %type <expression_> ElementOpt
193 %type <element_> ElementList
194 %type <element_> ElementListOpt
195 %type <statement_> ElseStatementOpt
196 %type <statement_> EmptyStatement
197 %type <expression_> EqualityExpression
198 %type <expression_> EqualityExpressionNoBF
199 %type <expression_> EqualityExpressionNoIn
200 %type <expression_> Expression
201 %type <expression_> ExpressionOpt
202 %type <expression_> Expression_
203 %type <expression_> ExpressionNoBF
204 %type <expression_> ExpressionNoIn
205 %type <expression_> ExpressionNoIn_
206 %type <expression_> ExpressionNoInOpt
207 %type <statement_> ExpressionStatement
208 %type <statement_> FinallyOpt
209 %type <statement_> ForStatement
210 %type <for_> ForStatementInitialiser
211 %type <statement_> ForInStatement
212 %type <forin_> ForInStatementInitialiser
213 %type <parameter_> FormalParameterList
214 %type <parameter_> FormalParameterList_
215 %type <source_> FunctionBody
216 %type <source_> FunctionDeclaration
217 %type <expression_> FunctionExpression
218 %type <identifier_> IdentifierOpt
219 %type <statement_> IfStatement
220 %type <expression_> Initialiser
221 %type <expression_> InitialiserOpt
222 %type <expression_> InitialiserNoIn
223 %type <expression_> InitialiserNoInOpt
224 %type <statement_> IterationStatement
225 %type <statement_> LabelledStatement
226 %type <expression_> LeftHandSideExpression
227 %type <expression_> LeftHandSideExpression_
228 %type <expression_> LeftHandSideExpressionNoBF
229 %type <literal_> Literal
230 %type <expression_> LogicalANDExpression
231 %type <expression_> LogicalANDExpressionNoBF
232 %type <expression_> LogicalANDExpressionNoIn
233 %type <expression_> LogicalORExpression
234 %type <expression_> LogicalORExpressionNoBF
235 %type <expression_> LogicalORExpressionNoIn
236 %type <expression_> MemberExpression
237 %type <expression_> MemberExpression_
238 %type <expression_> MemberExpressionNoBF
239 %type <expression_> MultiplicativeExpression
240 %type <expression_> MultiplicativeExpressionNoBF
241 %type <expression_> NewExpression
242 %type <expression_> NewExpression_
243 %type <expression_> NewExpressionNoBF
244 %type <null_> NullLiteral
245 %type <literal_> ObjectLiteral
246 %type <expression_> PostfixExpression
247 %type <expression_> PostfixExpressionNoBF
248 %type <expression_> PrimaryExpression
249 %type <expression_> PrimaryExpression_
250 %type <expression_> PrimaryExpressionNoBF
251 %type <source_> Program
252 %type <name_> PropertyName
253 %type <property_> PropertyNameAndValueList
254 %type <property_> PropertyNameAndValueList_
255 %type <property_> PropertyNameAndValueListOpt
256 %type <expression_> RelationalExpression
257 %type <expression_> RelationalExpressionNoBF
258 %type <expression_> RelationalExpressionNoIn
259 %type <statement_> ReturnStatement
260 %type <selector_> SelectorExpression
261 %type <selector_> SelectorExpression_
262 %type <selector_> SelectorExpressionOpt
263 %type <expression_> ShiftExpression
264 %type <expression_> ShiftExpressionNoBF
265 %type <source_> SourceElement
266 %type <source_> SourceElements
267 %type <statement_> Statement
268 %type <statement_> StatementList
269 %type <statement_> StatementListOpt
270 %type <statement_> SwitchStatement
271 %type <statement_> ThrowStatement
272 %type <statement_> TryStatement
273 %type <expression_> UnaryExpression
274 %type <expression_> UnaryExpression_
275 %type <expression_> UnaryExpressionNoBF
276 %type <declaration_> VariableDeclaration
277 %type <declaration_> VariableDeclarationNoIn
278 %type <declarations_> VariableDeclarationList
279 %type <declarations_> VariableDeclarationList_
280 %type <declarations_> VariableDeclarationListNoIn
281 %type <declarations_> VariableDeclarationListNoIn_
282 %type <statement_> VariableStatement
283 %type <statement_> WhileStatement
284 %type <statement_> WithStatement
286 %type <word_> WordOpt
288 %type <expression_> MessageExpression
289 %type <argument_> SelectorCall
290 %type <argument_> SelectorCall_
291 %type <argument_> SelectorList
292 %type <argument_> VariadicCall
304 | error { yyerrok; driver.errors_.pop_back(); }
310 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
329 : Identifier { $$ = $1; }
330 | "break" NewLineOpt { $$ = $1; }
331 | "case" { $$ = $1; }
332 | "catch" { $$ = $1; }
333 | "continue" NewLineOpt { $$ = $1; }
334 | "default" { $$ = $1; }
335 | "delete" { $$ = $1; }
337 | "else" { $$ = $1; }
338 | "false" { $$ = $1; }
339 | "finally" { $$ = $1; }
341 | "function" { $$ = $1; }
343 /* XXX: | "in" { $$ = $1; } */
344 /* XXX: | "instanceof" { $$ = $1; } */
346 | "null" { $$ = $1; }
347 | "return" NewLineOpt { $$ = $1; }
348 | "switch" { $$ = $1; }
349 | "this" { $$ = $1; }
350 | "throw" NewLineOpt { $$ = $1; }
351 | "true" { $$ = $1; }
353 | "typeof" { $$ = $1; }
355 | "void" { $$ = $1; }
356 | "while" { $$ = $1; }
357 | "with" { $$ = $1; }
361 : Identifier { $$ = $1; }
366 : NullLiteral { $$ = $1; }
367 | BooleanLiteral { $$ = $1; }
368 | NumericLiteral { $$ = $1; }
369 | StringLiteral { $$ = $1; }
373 : "null" { $$ = $1; }
377 : "true" { $$ = $1; }
378 | "false" { $$ = $1; }
381 /* 11.1 Primary Expressions {{{ */
383 : "this" { $$ = $1; }
384 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
385 | Literal { $$ = $1; }
386 | ArrayLiteral { $$ = $1; }
387 | "(" Expression ")" { $$ = $2; }
391 : ObjectLiteral { $$ = $1; }
392 | PrimaryExpression_ { $$ = $1; }
395 PrimaryExpressionNoBF
396 : PrimaryExpression_ { $$ = $1; }
399 /* 11.1.4 Array Initialiser {{{ */
401 : "[" ElementList "]" { $$ = new(driver.pool_) CYArray($2); }
405 : AssignmentExpression { $$ = $1; }
409 : Element { $$ = $1; }
414 : ElementList { $$ = $1; }
419 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
420 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
423 /* 11.1.5 Object Initialiser {{{ */
425 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
428 PropertyNameAndValueList_
429 : "," PropertyNameAndValueList { $$ = $2; }
430 | CommaOpt { $$ = NULL; }
433 PropertyNameAndValueListOpt
434 : PropertyNameAndValueList { $$ = $1; }
438 PropertyNameAndValueList
439 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
443 : Identifier { $$ = $1; }
444 | StringLiteral { $$ = $1; }
445 | NumericLiteral { $$ = $1; }
450 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
454 : PrimaryExpression { $$ = $1; }
455 | FunctionExpression { $$ = $1; }
456 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
457 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
458 | MemberExpression_ { $$ = $1; }
462 : PrimaryExpressionNoBF { $$ = $1; }
463 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
464 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
465 | MemberExpression_ { $$ = $1; }
469 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
473 : MemberExpression { $$ = $1; }
474 | NewExpression_ { $$ = $1; }
478 : MemberExpressionNoBF { $$ = $1; }
479 | NewExpression_ { $$ = $1; }
483 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
484 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
485 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
486 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
490 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
491 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
492 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
493 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
497 : "," ArgumentList { $$ = $2; }
502 : ArgumentList { $$ = $1; }
507 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
511 : "(" ArgumentListOpt ")" { $$ = $2; }
514 LeftHandSideExpression
515 : NewExpression { $$ = $1; }
516 | CallExpression { $$ = $1; }
517 | LeftHandSideExpression_ { $$ = $1; }
520 LeftHandSideExpressionNoBF
521 : NewExpressionNoBF { $$ = $1; }
522 | CallExpressionNoBF { $$ = $1; }
523 | LeftHandSideExpression_ { $$ = $1; }
527 : LeftHandSideExpression { $$ = $1; }
528 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
529 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
532 PostfixExpressionNoBF
533 : LeftHandSideExpressionNoBF { $$ = $1; }
534 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
535 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
539 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
540 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
541 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
542 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
543 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
544 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
545 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
546 | "+" UnaryExpression { $$ = $2; }
547 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
548 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
549 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
553 : PostfixExpression { $$ = $1; }
554 | UnaryExpression_ { $$ = $1; }
558 : PostfixExpressionNoBF { $$ = $1; }
559 | UnaryExpression_ { $$ = $1; }
562 MultiplicativeExpression
563 : UnaryExpression { $$ = $1; }
564 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
565 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
566 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
569 MultiplicativeExpressionNoBF
570 : UnaryExpressionNoBF { $$ = $1; }
571 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
572 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
573 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
577 : MultiplicativeExpression { $$ = $1; }
578 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
579 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
582 AdditiveExpressionNoBF
583 : MultiplicativeExpressionNoBF { $$ = $1; }
584 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
585 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
589 : AdditiveExpression { $$ = $1; }
590 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
591 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
592 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
596 : AdditiveExpressionNoBF { $$ = $1; }
597 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
598 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
599 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
603 : ShiftExpression { $$ = $1; }
604 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
605 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
606 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
607 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
608 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
609 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
612 RelationalExpressionNoIn
613 : ShiftExpression { $$ = $1; }
614 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
615 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
616 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
617 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
618 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
621 RelationalExpressionNoBF
622 : ShiftExpressionNoBF { $$ = $1; }
623 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
624 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
625 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
626 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
627 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
628 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
632 : RelationalExpression { $$ = $1; }
633 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
634 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
635 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
636 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
639 EqualityExpressionNoIn
640 : RelationalExpressionNoIn { $$ = $1; }
641 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
642 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
643 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
644 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
647 EqualityExpressionNoBF
648 : RelationalExpressionNoBF { $$ = $1; }
649 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
650 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
651 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
652 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
656 : EqualityExpression { $$ = $1; }
657 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
660 BitwiseANDExpressionNoIn
661 : EqualityExpressionNoIn { $$ = $1; }
662 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
665 BitwiseANDExpressionNoBF
666 : EqualityExpressionNoBF { $$ = $1; }
667 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
671 : BitwiseANDExpression { $$ = $1; }
672 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
675 BitwiseXORExpressionNoIn
676 : BitwiseANDExpressionNoIn { $$ = $1; }
677 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
680 BitwiseXORExpressionNoBF
681 : BitwiseANDExpressionNoBF { $$ = $1; }
682 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
686 : BitwiseXORExpression { $$ = $1; }
687 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
690 BitwiseORExpressionNoIn
691 : BitwiseXORExpressionNoIn { $$ = $1; }
692 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
695 BitwiseORExpressionNoBF
696 : BitwiseXORExpressionNoBF { $$ = $1; }
697 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
701 : BitwiseORExpression { $$ = $1; }
702 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
705 LogicalANDExpressionNoIn
706 : BitwiseORExpressionNoIn { $$ = $1; }
707 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
710 LogicalANDExpressionNoBF
711 : BitwiseORExpressionNoBF { $$ = $1; }
712 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
716 : LogicalANDExpression { $$ = $1; }
717 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
720 LogicalORExpressionNoIn
721 : LogicalANDExpressionNoIn { $$ = $1; }
722 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
725 LogicalORExpressionNoBF
726 : LogicalANDExpressionNoBF { $$ = $1; }
727 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
730 ConditionalExpression
731 : LogicalORExpression { $$ = $1; }
732 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
735 ConditionalExpressionNoIn
736 : LogicalORExpressionNoIn { $$ = $1; }
737 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
740 ConditionalExpressionNoBF
741 : LogicalORExpressionNoBF { $$ = $1; }
742 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
746 : ConditionalExpression { $$ = $1; }
747 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
748 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
749 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
750 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
751 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
752 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
753 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
754 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
755 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
756 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
757 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
758 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
761 AssignmentExpressionNoIn
762 : ConditionalExpressionNoIn { $$ = $1; }
763 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
764 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
765 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
766 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
767 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
768 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
769 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
770 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
771 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
772 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
773 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
774 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
777 AssignmentExpressionNoBF
778 : ConditionalExpressionNoBF { $$ = $1; }
779 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
780 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
781 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
782 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
783 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
784 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
785 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
786 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
787 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
788 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
789 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
790 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
794 : "," Expression { $$ = $2; }
799 : "," ExpressionNoIn { $$ = $2; }
804 : Expression { $$ = $1; }
809 : ExpressionNoIn { $$ = $1; }
814 : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
818 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
822 : AssignmentExpressionNoBF Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
827 | VariableStatement { $$ = $1; }
828 | EmptyStatement { $$ = $1; }
829 | ExpressionStatement { $$ = $1; }
830 | IfStatement { $$ = $1; }
831 | IterationStatement { $$ = $1; }
832 | ContinueStatement { $$ = $1; }
833 | BreakStatement { $$ = $1; }
834 | ReturnStatement { $$ = $1; }
835 | WithStatement { $$ = $1; }
836 | LabelledStatement { $$ = $1; }
837 | SwitchStatement { $$ = $1; }
838 | ThrowStatement { $$ = $1; }
839 | TryStatement { $$ = $1; }
843 : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
847 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
851 : StatementList { $$ = $1; }
856 : "var" VariableDeclarationList Terminator { $$ = $2; }
859 VariableDeclarationList_
860 : "," VariableDeclarationList { $$ = $2; }
864 VariableDeclarationListNoIn_
865 : "," VariableDeclarationListNoIn { $$ = $2; }
869 VariableDeclarationList
870 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
873 VariableDeclarationListNoIn
874 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
878 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
881 VariableDeclarationNoIn
882 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
886 : Initialiser { $$ = $1; }
891 : InitialiserNoIn { $$ = $1; }
896 : "=" AssignmentExpression { $$ = $2; }
900 : "=" AssignmentExpressionNoIn { $$ = $2; }
904 : ";" { $$ = new(driver.pool_) CYEmpty(); }
908 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
912 : "else" Statement { $$ = $2; }
913 | %prec "if" { $$ = NULL; }
917 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
921 : DoWhileStatement { $$ = $1; }
922 | WhileStatement { $$ = $1; }
923 | ForStatement { $$ = $1; }
924 | ForInStatement { $$ = $1; }
928 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
932 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
936 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
939 ForStatementInitialiser
940 : ExpressionNoInOpt { $$ = $1; }
941 | "var" VariableDeclarationListNoIn { $$ = $2; }
945 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
948 ForInStatementInitialiser
949 : LeftHandSideExpression { $$ = $1; }
950 | "var" VariableDeclarationNoIn { $$ = $2; }
954 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
958 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
962 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
966 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
970 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
974 : "{" CaseClausesOpt "}" { $$ = $2; }
978 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
979 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
984 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
988 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
992 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
996 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1000 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1004 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1009 : "finally" Block { $$ = $2; }
1014 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1018 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1021 FormalParameterList_
1022 : "," FormalParameterList { $$ = $2; }
1027 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($1, $2); }
1032 : SourceElements { $$ = $1; }
1036 : SourceElements { driver.source_ = $1; }
1040 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1045 : Statement { $$ = $1; }
1046 | FunctionDeclaration { $$ = $1; }
1049 /* Objective-C Extensions {{{ */
1051 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1056 : SelectorCall { $$ = $1; }
1057 | VariadicCall { $$ = $1; }
1061 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1065 : SelectorCall { $$ = $1; }
1066 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1070 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); }
1073 SelectorExpressionOpt
1074 : SelectorExpression_ { $$ = $1; }
1079 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1083 : SelectorExpression_ { $$ = $1; }
1084 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1088 : MessageExpression { $$ = $1; }
1089 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1093 LeftHandSideExpression_
1094 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1098 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }