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 CYSelector *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 <element_> ElementList
193 %type <element_> ElementList_
194 %type <statement_> ElseStatementOpt
195 %type <statement_> EmptyStatement
196 %type <expression_> EqualityExpression
197 %type <expression_> EqualityExpressionNoBF
198 %type <expression_> EqualityExpressionNoIn
199 %type <expression_> Expression
200 %type <expression_> ExpressionOpt
201 %type <expression_> Expression_
202 %type <expression_> ExpressionNoBF
203 %type <expression_> ExpressionNoIn
204 %type <expression_> ExpressionNoIn_
205 %type <expression_> ExpressionNoInOpt
206 %type <statement_> ExpressionStatement
207 %type <statement_> FinallyOpt
208 %type <statement_> ForStatement
209 %type <for_> ForStatementInitialiser
210 %type <statement_> ForInStatement
211 %type <forin_> ForInStatementInitialiser
212 %type <parameter_> FormalParameterList
213 %type <parameter_> FormalParameterList_
214 %type <source_> FunctionBody
215 %type <source_> FunctionDeclaration
216 %type <expression_> FunctionExpression
217 %type <identifier_> IdentifierOpt
218 %type <statement_> IfStatement
219 %type <expression_> Initialiser
220 %type <expression_> InitialiserOpt
221 %type <expression_> InitialiserNoIn
222 %type <expression_> InitialiserNoInOpt
223 %type <statement_> IterationStatement
224 %type <statement_> LabelledStatement
225 %type <expression_> LeftHandSideExpression
226 %type <expression_> LeftHandSideExpression_
227 %type <expression_> LeftHandSideExpressionNoBF
228 %type <literal_> Literal
229 %type <expression_> LogicalANDExpression
230 %type <expression_> LogicalANDExpressionNoBF
231 %type <expression_> LogicalANDExpressionNoIn
232 %type <expression_> LogicalORExpression
233 %type <expression_> LogicalORExpressionNoBF
234 %type <expression_> LogicalORExpressionNoIn
235 %type <expression_> MemberExpression
236 %type <expression_> MemberExpression_
237 %type <expression_> MemberExpressionNoBF
238 %type <expression_> MultiplicativeExpression
239 %type <expression_> MultiplicativeExpressionNoBF
240 %type <expression_> NewExpression
241 %type <expression_> NewExpression_
242 %type <expression_> NewExpressionNoBF
243 %type <null_> NullLiteral
244 %type <literal_> ObjectLiteral
245 %type <expression_> PostfixExpression
246 %type <expression_> PostfixExpressionNoBF
247 %type <expression_> PrimaryExpression
248 %type <expression_> PrimaryExpression_
249 %type <expression_> PrimaryExpressionNoBF
250 %type <source_> Program
251 %type <name_> PropertyName
252 %type <property_> PropertyNameAndValueList
253 %type <property_> PropertyNameAndValueList_
254 %type <property_> PropertyNameAndValueListOpt
255 %type <expression_> RelationalExpression
256 %type <expression_> RelationalExpressionNoBF
257 %type <expression_> RelationalExpressionNoIn
258 %type <statement_> ReturnStatement
259 %type <selector_> SelectorExpression
260 %type <selector_> SelectorExpression_
261 %type <selector_> SelectorExpressionOpt
262 %type <expression_> ShiftExpression
263 %type <expression_> ShiftExpressionNoBF
264 %type <source_> SourceElement
265 %type <source_> SourceElements
266 %type <statement_> Statement
267 %type <statement_> StatementList
268 %type <statement_> StatementListOpt
269 %type <statement_> SwitchStatement
270 %type <statement_> ThrowStatement
271 %type <statement_> TryStatement
272 %type <expression_> UnaryExpression
273 %type <expression_> UnaryExpression_
274 %type <expression_> UnaryExpressionNoBF
275 %type <declaration_> VariableDeclaration
276 %type <declaration_> VariableDeclarationNoIn
277 %type <declarations_> VariableDeclarationList
278 %type <declarations_> VariableDeclarationList_
279 %type <declarations_> VariableDeclarationListNoIn
280 %type <declarations_> VariableDeclarationListNoIn_
281 %type <statement_> VariableStatement
282 %type <statement_> WhileStatement
283 %type <statement_> WithStatement
285 %type <word_> WordOpt
287 %type <expression_> MessageExpression
288 %type <argument_> SelectorCall
289 %type <argument_> SelectorCall_
290 %type <argument_> SelectorList
291 %type <argument_> VariadicCall
309 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else yyerrok; }
328 : Identifier { $$ = $1; }
329 | "break" NewLineOpt { $$ = $1; }
330 | "case" { $$ = $1; }
331 | "catch" { $$ = $1; }
332 | "continue" NewLineOpt { $$ = $1; }
333 | "default" { $$ = $1; }
334 | "delete" { $$ = $1; }
336 | "else" { $$ = $1; }
337 | "false" { $$ = $1; }
338 | "finally" { $$ = $1; }
340 | "function" { $$ = $1; }
342 /* XXX: | "in" { $$ = $1; } */
343 /* XXX: | "instanceof" { $$ = $1; } */
345 | "null" { $$ = $1; }
346 | "return" NewLineOpt { $$ = $1; }
347 | "switch" { $$ = $1; }
348 | "this" { $$ = $1; }
349 | "throw" NewLineOpt { $$ = $1; }
350 | "true" { $$ = $1; }
352 | "typeof" { $$ = $1; }
354 | "void" { $$ = $1; }
355 | "while" { $$ = $1; }
356 | "with" { $$ = $1; }
360 : Identifier { $$ = $1; }
365 : NullLiteral { $$ = $1; }
366 | BooleanLiteral { $$ = $1; }
367 | NumericLiteral { $$ = $1; }
368 | StringLiteral { $$ = $1; }
372 : "null" { $$ = $1; }
376 : "true" { $$ = $1; }
377 | "false" { $$ = $1; }
380 /* 11.1 Primary Expressions {{{ */
382 : "this" { $$ = $1; }
383 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
384 | Literal { $$ = $1; }
385 | ArrayLiteral { $$ = $1; }
386 | "(" Expression ")" { $$ = $2; }
390 : ObjectLiteral { $$ = $1; }
391 | PrimaryExpression_ { $$ = $1; }
394 PrimaryExpressionNoBF
395 : PrimaryExpression_ { $$ = $1; }
398 /* 11.1.4 Array Initialiser {{{ */
400 : "[" ElementList "]" { $$ = $2; }
404 : AssignmentExpression { $$ = $1; }
409 : "," ElementList { $$ = $2; }
414 : Element ElementList_ { $$ = new(driver.pool_) CYElement($1, $2); }
417 /* 11.1.5 Object Initialiser {{{ */
419 : "{" PropertyNameAndValueListOpt "}" { $$ = new CYObject($2); }
422 PropertyNameAndValueList_
423 : "," PropertyNameAndValueList { $$ = $2; }
424 | CommaOpt { $$ = NULL; }
427 PropertyNameAndValueListOpt
428 : PropertyNameAndValueList { $$ = $1; }
432 PropertyNameAndValueList
433 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
437 : Identifier { $$ = $1; }
438 | StringLiteral { $$ = $1; }
439 | NumericLiteral { $$ = $1; }
444 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
448 : PrimaryExpression { $$ = $1; }
449 | FunctionExpression { $$ = $1; }
450 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
451 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
452 | MemberExpression_ { $$ = $1; }
456 : PrimaryExpressionNoBF { $$ = $1; }
457 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
458 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
459 | MemberExpression_ { $$ = $1; }
463 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
467 : MemberExpression { $$ = $1; }
468 | NewExpression_ { $$ = $1; }
472 : MemberExpressionNoBF { $$ = $1; }
473 | NewExpression_ { $$ = $1; }
477 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
478 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
479 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
480 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
484 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
485 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
486 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
487 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
491 : "," ArgumentList { $$ = $2; }
496 : ArgumentList { $$ = $1; }
501 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
505 : "(" ArgumentListOpt ")" { $$ = $2; }
508 LeftHandSideExpression
509 : NewExpression { $$ = $1; }
510 | CallExpression { $$ = $1; }
511 | LeftHandSideExpression_ { $$ = $1; }
514 LeftHandSideExpressionNoBF
515 : NewExpressionNoBF { $$ = $1; }
516 | CallExpressionNoBF { $$ = $1; }
517 | LeftHandSideExpression_ { $$ = $1; }
521 : LeftHandSideExpression { $$ = $1; }
522 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
523 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
526 PostfixExpressionNoBF
527 : LeftHandSideExpressionNoBF { $$ = $1; }
528 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
529 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
533 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
534 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
535 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
536 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
537 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
538 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
539 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
540 | "+" UnaryExpression { $$ = $2; }
541 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
542 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
543 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
547 : PostfixExpression { $$ = $1; }
548 | UnaryExpression_ { $$ = $1; }
552 : PostfixExpressionNoBF { $$ = $1; }
553 | UnaryExpression_ { $$ = $1; }
556 MultiplicativeExpression
557 : UnaryExpression { $$ = $1; }
558 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
559 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
560 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
563 MultiplicativeExpressionNoBF
564 : UnaryExpressionNoBF { $$ = $1; }
565 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
566 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
567 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
571 : MultiplicativeExpression { $$ = $1; }
572 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
573 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
576 AdditiveExpressionNoBF
577 : MultiplicativeExpressionNoBF { $$ = $1; }
578 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
579 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
583 : AdditiveExpression { $$ = $1; }
584 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
585 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
586 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
590 : AdditiveExpressionNoBF { $$ = $1; }
591 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
592 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
593 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
597 : ShiftExpression { $$ = $1; }
598 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
599 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
600 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
601 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
602 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
603 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
606 RelationalExpressionNoIn
607 : ShiftExpression { $$ = $1; }
608 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
609 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
610 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
611 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
612 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
615 RelationalExpressionNoBF
616 : ShiftExpressionNoBF { $$ = $1; }
617 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
618 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
619 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
620 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
621 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
622 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
626 : RelationalExpression { $$ = $1; }
627 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
628 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
629 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
630 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
633 EqualityExpressionNoIn
634 : RelationalExpressionNoIn { $$ = $1; }
635 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
636 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
637 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
638 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
641 EqualityExpressionNoBF
642 : RelationalExpressionNoBF { $$ = $1; }
643 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
644 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
645 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
646 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
650 : EqualityExpression { $$ = $1; }
651 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
654 BitwiseANDExpressionNoIn
655 : EqualityExpressionNoIn { $$ = $1; }
656 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
659 BitwiseANDExpressionNoBF
660 : EqualityExpressionNoBF { $$ = $1; }
661 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
665 : BitwiseANDExpression { $$ = $1; }
666 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
669 BitwiseXORExpressionNoIn
670 : BitwiseANDExpressionNoIn { $$ = $1; }
671 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
674 BitwiseXORExpressionNoBF
675 : BitwiseANDExpressionNoBF { $$ = $1; }
676 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
680 : BitwiseXORExpression { $$ = $1; }
681 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
684 BitwiseORExpressionNoIn
685 : BitwiseXORExpressionNoIn { $$ = $1; }
686 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
689 BitwiseORExpressionNoBF
690 : BitwiseXORExpressionNoBF { $$ = $1; }
691 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
695 : BitwiseORExpression { $$ = $1; }
696 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
699 LogicalANDExpressionNoIn
700 : BitwiseORExpressionNoIn { $$ = $1; }
701 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
704 LogicalANDExpressionNoBF
705 : BitwiseORExpressionNoBF { $$ = $1; }
706 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
710 : LogicalANDExpression { $$ = $1; }
711 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
714 LogicalORExpressionNoIn
715 : LogicalANDExpressionNoIn { $$ = $1; }
716 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
719 LogicalORExpressionNoBF
720 : LogicalANDExpressionNoBF { $$ = $1; }
721 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
724 ConditionalExpression
725 : LogicalORExpression { $$ = $1; }
726 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
729 ConditionalExpressionNoIn
730 : LogicalORExpressionNoIn { $$ = $1; }
731 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
734 ConditionalExpressionNoBF
735 : LogicalORExpressionNoBF { $$ = $1; }
736 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
740 : ConditionalExpression { $$ = $1; }
741 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
742 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
743 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
744 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
745 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
746 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
747 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
748 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
749 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
750 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
751 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
752 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
755 AssignmentExpressionNoIn
756 : ConditionalExpressionNoIn { $$ = $1; }
757 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
758 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
759 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
760 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
761 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
762 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
763 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
764 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
765 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
766 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
767 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
768 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
771 AssignmentExpressionNoBF
772 : ConditionalExpressionNoBF { $$ = $1; }
773 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
774 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
775 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
776 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
777 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
778 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
779 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
780 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
781 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
782 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
783 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
784 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
788 : "," Expression { $$ = $2; }
793 : "," ExpressionNoIn { $$ = $2; }
798 : Expression { $$ = $1; }
803 : ExpressionNoIn { $$ = $1; }
808 : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
812 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
816 : AssignmentExpressionNoBF Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
821 | VariableStatement { $$ = $1; }
822 | EmptyStatement { $$ = $1; }
823 | ExpressionStatement { $$ = $1; }
824 | IfStatement { $$ = $1; }
825 | IterationStatement { $$ = $1; }
826 | ContinueStatement { $$ = $1; }
827 | BreakStatement { $$ = $1; }
828 | ReturnStatement { $$ = $1; }
829 | WithStatement { $$ = $1; }
830 | LabelledStatement { $$ = $1; }
831 | SwitchStatement { $$ = $1; }
832 | ThrowStatement { $$ = $1; }
833 | TryStatement { $$ = $1; }
837 : "{" "}" { $$ = new(driver.pool_) CYEmpty(); }
838 | "{" StatementList "}" { $$ = $2; }
842 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
846 : StatementList { $$ = $1; }
851 : "var" VariableDeclarationList Terminator { $$ = $2; }
854 VariableDeclarationList_
855 : "," VariableDeclarationList { $$ = $2; }
859 VariableDeclarationListNoIn_
860 : "," VariableDeclarationListNoIn { $$ = $2; }
864 VariableDeclarationList
865 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
868 VariableDeclarationListNoIn
869 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
873 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
876 VariableDeclarationNoIn
877 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
881 : Initialiser { $$ = $1; }
886 : InitialiserNoIn { $$ = $1; }
891 : "=" AssignmentExpression { $$ = $2; }
895 : "=" AssignmentExpressionNoIn { $$ = $2; }
899 : ";" { $$ = new(driver.pool_) CYEmpty(); }
903 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
907 : "else" Statement { $$ = $2; }
908 | %prec "if" { $$ = NULL; }
912 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
916 : DoWhileStatement { $$ = $1; }
917 | WhileStatement { $$ = $1; }
918 | ForStatement { $$ = $1; }
919 | ForInStatement { $$ = $1; }
923 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
927 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
931 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
934 ForStatementInitialiser
935 : ExpressionNoInOpt { $$ = $1; }
936 | "var" VariableDeclarationListNoIn { $$ = $2; }
940 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
943 ForInStatementInitialiser
944 : LeftHandSideExpression { $$ = $1; }
945 | "var" VariableDeclarationNoIn { $$ = $2; }
949 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
953 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
957 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
961 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
965 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
969 : "{" CaseClausesOpt "}" { $$ = $2; }
973 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
974 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
979 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
983 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
987 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
991 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
995 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
999 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1004 : "finally" Block { $$ = $2; }
1009 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1013 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1016 FormalParameterList_
1017 : "," FormalParameterList { $$ = $2; }
1022 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($1, $2); }
1027 : SourceElements { $$ = $1; }
1031 : SourceElements { driver.source_.push_back($1); $$ = $1; }
1035 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1040 : SourceElement { driver.source_.push_back($2); if (driver.filename_.empty() && false) YYACCEPT; $2->Show(std::cout); }
1044 : Statement { $$ = $1; }
1045 | FunctionDeclaration { $$ = $1; }
1048 /* Objective-C Extensions {{{ */
1050 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1055 : SelectorCall { $$ = $1; }
1056 | VariadicCall { $$ = $1; }
1060 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1064 : SelectorCall { $$ = $1; }
1065 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1069 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); }
1072 SelectorExpressionOpt
1073 : SelectorExpression_ { $$ = $1; }
1078 : WordOpt ":" SelectorExpressionOpt { $$ = new CYSelector($1, true, $3); }
1082 : SelectorExpression_ { $$ = $1; }
1083 | Word { $$ = new CYSelector($1, false, NULL); }
1087 : MessageExpression { $$ = $1; }
1088 | "@selector" "(" SelectorExpression ")" { $$ = $3; }
1092 LeftHandSideExpression_
1093 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1097 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }