1 /* Cycript - Remove Execution Server and Disassembler
2 * Copyright (C) 2009 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include "Cycript.tab.hh"
42 #define scanner driver.scanner_
43 #define YYSTACKEXPANDABLE 1
55 CYArgument *argument_;
56 CYAssignment *assignment_;
61 CYClassName *className_;
62 CYComprehension *comprehension_;
63 CYCompound *compound_;
64 CYDeclaration *declaration_;
65 CYDeclarations *declarations_;
67 CYExpression *expression_;
70 CYForInitialiser *for_;
71 CYForInInitialiser *forin_;
72 CYFunctionParameter *functionParameter_;
73 CYIdentifier *identifier_;
78 CYMessageParameter *messageParameter_;
81 CYProperty *property_;
82 CYPropertyName *propertyName_;
83 CYSelectorPart *selector_;
85 CYStatement *statement_;
96 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
105 @$.begin.filename = @$.end.filename = &driver.filename_;
113 %parse-param { CYDriver &driver }
114 %lex-param { void *scanner }
117 %token AmpersandAmpersand "&&"
118 %token AmpersandEqual "&="
120 %token CarrotEqual "^="
122 %token EqualEqual "=="
123 %token EqualEqualEqual "==="
124 %token Exclamation "!"
125 %token ExclamationEqual "!="
126 %token ExclamationEqualEqual "!=="
128 %token HyphenEqual "-="
129 %token HyphenHyphen "--"
130 %token HyphenHyphen_ "\n--"
131 %token HyphenRight "->"
133 %token LeftEqual "<="
135 %token LeftLeftEqual "<<="
137 %token PercentEqual "%="
140 %token PipeEqual "|="
143 %token PlusEqual "+="
145 %token PlusPlus_ "\n++"
147 %token RightEqual ">="
148 %token RightRight ">>"
149 %token RightRightEqual ">>="
150 %token RightRightRight ">>>"
151 %token RightRightRightEqual ">>>="
153 %token SlashEqual "/="
155 %token StarEqual "*="
165 %token CloseParen ")"
168 %token CloseBrace "}"
170 %token OpenBracket "["
171 %token CloseBracket "]"
173 %token AtClass "@class"
174 %token AtSelector "@selector"
177 %token <word_> Break "break"
178 %token <word_> Case "case"
179 %token <word_> Catch "catch"
180 %token <word_> Continue "continue"
181 %token <word_> Default "default"
182 %token <word_> Delete "delete"
183 %token <word_> Do "do"
184 %token <word_> Else "else"
185 %token <false_> False "false"
186 %token <word_> Finally "finally"
187 %token <word_> For "for"
188 %token <word_> Function "function"
189 %token <word_> If "if"
190 %token <word_> In "in"
191 %token <word_> InstanceOf "instanceof"
192 %token <word_> New "new"
193 %token <null_> Null "null"
194 %token <word_> Return "return"
195 %token <word_> Switch "switch"
196 %token <this_> This "this"
197 %token <word_> Throw "throw"
198 %token <true_> True "true"
199 %token <word_> Try "try"
200 %token <word_> TypeOf "typeof"
201 %token <word_> Var "var"
202 %token <word_> Void "void"
203 %token <word_> While "while"
204 %token <word_> With "with"
206 %token <word_> Abstract "abstract"
207 %token <word_> Boolean "boolean"
208 %token <word_> Byte "byte"
209 %token <word_> Char "char"
210 %token <word_> Class "class"
211 %token <word_> Const "const"
212 %token <word_> Debugger "debugger"
213 %token <word_> Double "double"
214 %token <word_> Enum "enum"
215 %token <word_> Export "export"
216 %token <word_> Extends "extends"
217 %token <word_> Final "final"
218 %token <word_> Float "float"
219 %token <word_> Goto "goto"
220 %token <word_> Implements "implements"
221 %token <word_> Import "import"
222 %token <word_> Int "int"
223 %token <word_> Interface "interface"
224 %token <word_> Long "long"
225 %token <word_> Native "native"
226 %token <word_> Package "package"
227 %token <word_> Private "private"
228 %token <word_> Protected "protected"
229 %token <word_> Public "public"
230 %token <word_> Short "short"
231 %token <word_> Static "static"
232 %token <word_> Super "super"
233 %token <word_> Synchronized "synchronized"
234 %token <word_> Throws "throws"
235 %token <word_> Transient "transient"
236 %token <word_> Volatile "volatile"
238 %token <identifier_> Each "each"
240 %token <identifier_> Identifier_
241 %token <number_> NumericLiteral
242 %token <string_> StringLiteral
244 %type <expression_> AdditiveExpression
245 %type <expression_> AdditiveExpressionNoBF
246 %type <argument_> ArgumentList
247 %type <argument_> ArgumentList_
248 %type <argument_> ArgumentListOpt
249 %type <argument_> Arguments
250 %type <literal_> ArrayLiteral
251 %type <expression_> AssigneeExpression
252 %type <expression_> AssigneeExpression_
253 %type <expression_> AssigneeExpressionNoBF
254 %type <expression_> AssignmentExpression
255 %type <assignment_> AssignmentExpression_
256 %type <expression_> AssignmentExpressionNoBF
257 %type <expression_> AssignmentExpressionNoIn
258 %type <expression_> BitwiseANDExpression
259 %type <expression_> BitwiseANDExpressionNoBF
260 %type <expression_> BitwiseANDExpressionNoIn
261 %type <statement_> Block
262 %type <boolean_> BooleanLiteral
263 %type <expression_> BitwiseORExpression
264 %type <expression_> BitwiseORExpressionNoBF
265 %type <expression_> BitwiseORExpressionNoIn
266 %type <expression_> BitwiseXORExpression
267 %type <expression_> BitwiseXORExpressionNoBF
268 %type <expression_> BitwiseXORExpressionNoIn
269 %type <statement_> BreakStatement
270 %type <expression_> CallExpression
271 %type <expression_> CallExpressionNoBF
272 %type <clause_> CaseBlock
273 %type <clause_> CaseClause
274 %type <clause_> CaseClausesOpt
275 %type <catch_> CatchOpt
276 %type <statement_> CategoryStatement
277 %type <class_> ClassDefinition
278 %type <message_> ClassMessageDeclaration
279 %type <message_> ClassMessageDeclarationListOpt
280 %type <className_> ClassName
281 %type <className_> ClassNameOpt
282 %type <expression_> ClassSuperOpt
283 %type <field_> ClassFieldList
284 %type <comprehension_> ComprehensionList
285 %type <comprehension_> ComprehensionListOpt
286 %type <expression_> ConditionalExpression
287 %type <expression_> ConditionalExpressionNoBF
288 %type <expression_> ConditionalExpressionNoIn
289 %type <statement_> ContinueStatement
290 %type <clause_> DefaultClause
291 %type <statement_> DoWhileStatement
292 %type <expression_> Element
293 %type <expression_> ElementOpt
294 %type <element_> ElementList
295 %type <element_> ElementListOpt
296 %type <statement_> ElseStatementOpt
297 %type <statement_> EmptyStatement
298 %type <expression_> EqualityExpression
299 %type <expression_> EqualityExpressionNoBF
300 %type <expression_> EqualityExpressionNoIn
301 %type <expression_> Expression
302 %type <expression_> ExpressionOpt
303 %type <compound_> Expression_
304 %type <expression_> ExpressionNoBF
305 %type <expression_> ExpressionNoIn
306 %type <compound_> ExpressionNoIn_
307 %type <expression_> ExpressionNoInOpt
308 %type <statement_> ExpressionStatement
309 %type <statement_> FinallyOpt
310 %type <comprehension_> ForComprehension
311 %type <statement_> ForStatement
312 %type <for_> ForStatementInitialiser
313 %type <statement_> ForInStatement
314 %type <forin_> ForInStatementInitialiser
315 %type <functionParameter_> FormalParameterList
316 %type <functionParameter_> FormalParameterList_
317 %type <source_> FunctionBody
318 %type <source_> FunctionDeclaration
319 %type <expression_> FunctionExpression
320 %type <identifier_> Identifier
321 %type <identifier_> IdentifierOpt
322 %type <comprehension_> IfComprehension
323 %type <statement_> IfStatement
324 %type <expression_> Initialiser
325 %type <expression_> InitialiserOpt
326 %type <expression_> InitialiserNoIn
327 %type <expression_> InitialiserNoInOpt
328 %type <statement_> IterationStatement
329 %type <statement_> LabelledStatement
330 %type <expression_> LeftHandSideExpression
331 %type <expression_> LeftHandSideExpressionNoBF
332 %type <literal_> Literal
333 %type <expression_> LogicalANDExpression
334 %type <expression_> LogicalANDExpressionNoBF
335 %type <expression_> LogicalANDExpressionNoIn
336 %type <expression_> LogicalORExpression
337 %type <expression_> LogicalORExpressionNoBF
338 %type <expression_> LogicalORExpressionNoIn
339 %type <member_> MemberAccess
340 %type <expression_> MemberExpression
341 %type <expression_> MemberExpression_
342 %type <expression_> MemberExpressionNoBF
343 %type <messageParameter_> MessageParameter
344 %type <messageParameter_> MessageParameters
345 %type <messageParameter_> MessageParameterList
346 %type <messageParameter_> MessageParameterListOpt
347 %type <bool_> MessageScope
348 %type <expression_> MultiplicativeExpression
349 %type <expression_> MultiplicativeExpressionNoBF
350 %type <expression_> NewExpression
351 %type <expression_> NewExpression_
352 %type <expression_> NewExpressionNoBF
353 %type <null_> NullLiteral
354 %type <literal_> ObjectLiteral
355 %type <expression_> PostfixExpression
356 %type <expression_> PostfixExpressionNoBF
357 %type <expression_> PrimaryExpression
358 %type <expression_> PrimaryExpression_
359 %type <expression_> PrimaryExpressionNoBF
360 %type <source_> Program
361 %type <propertyName_> PropertyName
362 %type <property_> PropertyNameAndValueList
363 %type <property_> PropertyNameAndValueList_
364 %type <property_> PropertyNameAndValueListOpt
365 %type <expression_> RelationalExpression
366 %type <infix_> RelationalExpression_
367 %type <expression_> RelationalExpressionNoBF
368 %type <expression_> RelationalExpressionNoIn
369 %type <infix_> RelationalExpressionNoIn_
370 %type <statement_> ReturnStatement
371 %type <selector_> SelectorExpression
372 %type <selector_> SelectorExpression_
373 %type <selector_> SelectorExpressionOpt
374 %type <expression_> ShiftExpression
375 %type <expression_> ShiftExpressionNoBF
376 %type <source_> SourceElement
377 %type <source_> SourceElements
378 %type <statement_> Statement
379 %type <statement_> StatementList
380 %type <statement_> StatementListOpt
381 %type <statement_> SwitchStatement
382 %type <statement_> ThrowStatement
383 %type <statement_> TryStatement
384 %type <expression_> TypeOpt
385 %type <expression_> UnaryExpression
386 %type <expression_> UnaryExpression_
387 %type <expression_> UnaryExpressionNoBF
388 %type <declaration_> VariableDeclaration
389 %type <declaration_> VariableDeclarationNoIn
390 %type <declarations_> VariableDeclarationList
391 %type <declarations_> VariableDeclarationList_
392 %type <declarations_> VariableDeclarationListNoIn
393 %type <declarations_> VariableDeclarationListNoIn_
394 %type <statement_> VariableStatement
395 %type <statement_> WhileStatement
396 %type <statement_> WithStatement
398 %type <word_> WordOpt
400 %type <expression_> MessageExpression
401 %type <argument_> SelectorCall
402 %type <argument_> SelectorCall_
403 %type <argument_> SelectorList
404 %type <argument_> VariadicCall
408 %left "<<" ">>" ">>>"
409 %left "<" ">" "<=" ">=" "instanceof" "in"
410 %left "==" "!=" "===" "!=="
417 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
429 | error { yyerrok; driver.errors_.pop_back(); }
435 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
454 : Identifier { $$ = $1; }
455 | "abstract" { $$ = $1; }
456 | "boolean" { $$ = $1; }
457 | "break" NewLineOpt { $$ = $1; }
458 | "byte" { $$ = $1; }
459 | "case" { $$ = $1; }
460 | "catch" { $$ = $1; }
461 | "char" { $$ = $1; }
462 | "class" { $$ = $1; }
463 | "const" { $$ = $1; }
464 | "continue" NewLineOpt { $$ = $1; }
465 | "debugger" { $$ = $1; }
466 | "default" { $$ = $1; }
467 | "delete" { $$ = $1; }
469 | "double" { $$ = $1; }
470 | "else" { $$ = $1; }
471 | "enum" { $$ = $1; }
472 | "export" { $$ = $1; }
473 | "extends" { $$ = $1; }
474 | "false" { $$ = $1; }
475 | "final" { $$ = $1; }
476 | "finally" { $$ = $1; }
477 | "float" { $$ = $1; }
479 | "function" { $$ = $1; }
480 | "goto" { $$ = $1; }
482 | "implements" { $$ = $1; }
483 | "import" { $$ = $1; }
484 /* XXX: | "in" { $$ = $1; } */
485 /* XXX: | "instanceof" { $$ = $1; } */
487 | "interface" { $$ = $1; }
488 | "long" { $$ = $1; }
489 | "native" { $$ = $1; }
491 | "null" { $$ = $1; }
492 | "package" { $$ = $1; }
493 | "private" { $$ = $1; }
494 | "protected" { $$ = $1; }
495 | "public" { $$ = $1; }
496 | "return" NewLineOpt { $$ = $1; }
497 | "short" { $$ = $1; }
498 | "static" { $$ = $1; }
499 | "super" { $$ = $1; }
500 | "switch" { $$ = $1; }
501 | "synchronized" { $$ = $1; }
502 | "this" { $$ = $1; }
503 | "throw" NewLineOpt { $$ = $1; }
504 | "throws" { $$ = $1; }
505 | "transient" { $$ = $1; }
506 | "true" { $$ = $1; }
508 | "typeof" { $$ = $1; }
510 | "void" { $$ = $1; }
511 | "volatile" { $$ = $1; }
512 | "while" { $$ = $1; }
513 | "with" { $$ = $1; }
517 : Identifier_ { $$ = $1; }
518 | "each" { $$ = $1; }
522 : Identifier { $$ = $1; }
527 : NullLiteral { $$ = $1; }
528 | BooleanLiteral { $$ = $1; }
529 | NumericLiteral { $$ = $1; }
530 | StringLiteral { $$ = $1; }
534 : "null" { $$ = $1; }
538 : "true" { $$ = $1; }
539 | "false" { $$ = $1; }
542 /* 11.1 Primary Expressions {{{ */
544 : "this" { $$ = $1; }
545 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
546 | Literal { $$ = $1; }
547 | ArrayLiteral { $$ = $1; }
548 | "(" Expression ")" { $$ = $2; }
552 : ObjectLiteral { $$ = $1; }
553 | PrimaryExpression_ { $$ = $1; }
556 PrimaryExpressionNoBF
557 : PrimaryExpression_ { $$ = $1; }
560 /* 11.1.4 Array Initialiser {{{ */
562 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
566 : AssignmentExpression { $$ = $1; }
570 : Element { $$ = $1; }
575 : ElementList { $$ = $1; }
580 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
581 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
584 /* 11.1.5 Object Initialiser {{{ */
586 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
589 PropertyNameAndValueList_
590 : "," PropertyNameAndValueList { $$ = $2; }
591 | CommaOpt { $$ = NULL; }
594 PropertyNameAndValueListOpt
595 : PropertyNameAndValueList { $$ = $1; }
599 PropertyNameAndValueList
600 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
604 : Identifier { $$ = $1; }
605 | StringLiteral { $$ = $1; }
606 | NumericLiteral { $$ = $1; }
611 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
615 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
616 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
620 : PrimaryExpression { $$ = $1; }
621 | FunctionExpression { $$ = $1; }
622 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
623 | MemberExpression_ { $$ = $1; }
627 : PrimaryExpressionNoBF { $$ = $1; }
628 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
629 | MemberExpression_ { $$ = $1; }
633 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
637 : MemberExpression { $$ = $1; }
638 | NewExpression_ { $$ = $1; }
642 : MemberExpressionNoBF { $$ = $1; }
643 | NewExpression_ { $$ = $1; }
647 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
648 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
649 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
653 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
654 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
655 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
659 : "," ArgumentList { $$ = $2; }
664 : ArgumentList { $$ = $1; }
669 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
673 : "(" ArgumentListOpt ")" { $$ = $2; }
676 LeftHandSideExpression
677 : NewExpression { $$ = $1; }
678 | CallExpression { $$ = $1; }
681 LeftHandSideExpressionNoBF
682 : NewExpressionNoBF { $$ = $1; }
683 | CallExpressionNoBF { $$ = $1; }
687 : AssigneeExpression { $$ = $1; }
688 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
689 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
692 PostfixExpressionNoBF
693 : AssigneeExpressionNoBF { $$ = $1; }
694 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
695 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
699 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
700 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
701 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
702 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
703 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
704 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
705 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
706 | "+" UnaryExpression { $$ = $2; }
707 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
708 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
709 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
713 : PostfixExpression { $$ = $1; }
714 | UnaryExpression_ { $$ = $1; }
718 : PostfixExpressionNoBF { $$ = $1; }
719 | UnaryExpression_ { $$ = $1; }
722 MultiplicativeExpression
723 : UnaryExpression { $$ = $1; }
724 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
725 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
726 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
729 MultiplicativeExpressionNoBF
730 : UnaryExpressionNoBF { $$ = $1; }
731 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
732 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
733 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
737 : MultiplicativeExpression { $$ = $1; }
738 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
739 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
742 AdditiveExpressionNoBF
743 : MultiplicativeExpressionNoBF { $$ = $1; }
744 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
745 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
749 : AdditiveExpression { $$ = $1; }
750 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
751 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
752 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
756 : AdditiveExpressionNoBF { $$ = $1; }
757 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
758 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
759 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
762 RelationalExpressionNoIn_
763 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
764 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
765 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
766 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
767 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
770 RelationalExpression_
771 : RelationalExpressionNoIn_ { $$ = $1; }
772 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
776 : ShiftExpression { $$ = $1; }
777 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
780 RelationalExpressionNoIn
781 : ShiftExpression { $$ = $1; }
782 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
785 RelationalExpressionNoBF
786 : ShiftExpressionNoBF { $$ = $1; }
787 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
791 : RelationalExpression { $$ = $1; }
792 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
793 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
794 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
795 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
798 EqualityExpressionNoIn
799 : RelationalExpressionNoIn { $$ = $1; }
800 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
801 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
802 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
803 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
806 EqualityExpressionNoBF
807 : RelationalExpressionNoBF { $$ = $1; }
808 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
809 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
810 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
811 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
815 : EqualityExpression { $$ = $1; }
816 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
819 BitwiseANDExpressionNoIn
820 : EqualityExpressionNoIn { $$ = $1; }
821 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
824 BitwiseANDExpressionNoBF
825 : EqualityExpressionNoBF { $$ = $1; }
826 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
830 : BitwiseANDExpression { $$ = $1; }
831 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
834 BitwiseXORExpressionNoIn
835 : BitwiseANDExpressionNoIn { $$ = $1; }
836 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
839 BitwiseXORExpressionNoBF
840 : BitwiseANDExpressionNoBF { $$ = $1; }
841 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
845 : BitwiseXORExpression { $$ = $1; }
846 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
849 BitwiseORExpressionNoIn
850 : BitwiseXORExpressionNoIn { $$ = $1; }
851 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
854 BitwiseORExpressionNoBF
855 : BitwiseXORExpressionNoBF { $$ = $1; }
856 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
860 : BitwiseORExpression { $$ = $1; }
861 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
864 LogicalANDExpressionNoIn
865 : BitwiseORExpressionNoIn { $$ = $1; }
866 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
869 LogicalANDExpressionNoBF
870 : BitwiseORExpressionNoBF { $$ = $1; }
871 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
875 : LogicalANDExpression { $$ = $1; }
876 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
879 LogicalORExpressionNoIn
880 : LogicalANDExpressionNoIn { $$ = $1; }
881 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
884 LogicalORExpressionNoBF
885 : LogicalANDExpressionNoBF { $$ = $1; }
886 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
889 ConditionalExpression
890 : LogicalORExpression { $$ = $1; }
891 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
894 ConditionalExpressionNoIn
895 : LogicalORExpressionNoIn { $$ = $1; }
896 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
899 ConditionalExpressionNoBF
900 : LogicalORExpressionNoBF { $$ = $1; }
901 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
904 AssignmentExpression_
905 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
906 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
907 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
908 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
909 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
910 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
911 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
912 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
913 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
914 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
915 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
916 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
920 : LeftHandSideExpression { $$ = $1; }
921 | AssigneeExpression_ { $$ = $1; }
924 AssigneeExpressionNoBF
925 : LeftHandSideExpressionNoBF { $$ = $1; }
926 | AssigneeExpression_ { $$ = $1; }
930 : ConditionalExpression { $$ = $1; }
931 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
934 AssignmentExpressionNoIn
935 : ConditionalExpressionNoIn { $$ = $1; }
936 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
937 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
938 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
939 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
940 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
941 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
942 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
943 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
944 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
945 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
946 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
947 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
950 AssignmentExpressionNoBF
951 : ConditionalExpressionNoBF { $$ = $1; }
952 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
956 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
961 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
966 : Expression { $$ = $1; }
971 : ExpressionNoIn { $$ = $1; }
976 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
980 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
984 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
989 | VariableStatement { $$ = $1; }
990 | EmptyStatement { $$ = $1; }
991 | ExpressionStatement { $$ = $1; }
992 | IfStatement { $$ = $1; }
993 | IterationStatement { $$ = $1; }
994 | ContinueStatement { $$ = $1; }
995 | BreakStatement { $$ = $1; }
996 | ReturnStatement { $$ = $1; }
997 | WithStatement { $$ = $1; }
998 | LabelledStatement { $$ = $1; }
999 | SwitchStatement { $$ = $1; }
1000 | ThrowStatement { $$ = $1; }
1001 | TryStatement { $$ = $1; }
1005 : "{" StatementListOpt "}" { if ($2) $$ = new(driver.pool_) CYBlock($2); else $$ = new(driver.pool_) CYEmpty(); }
1009 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1013 : StatementList { $$ = $1; }
1018 : "var" VariableDeclarationList Terminator { $$ = $2; }
1021 VariableDeclarationList_
1022 : "," VariableDeclarationList { $$ = $2; }
1026 VariableDeclarationListNoIn_
1027 : "," VariableDeclarationListNoIn { $$ = $2; }
1031 VariableDeclarationList
1032 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1035 VariableDeclarationListNoIn
1036 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1040 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1043 VariableDeclarationNoIn
1044 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1048 : Initialiser { $$ = $1; }
1053 : InitialiserNoIn { $$ = $1; }
1058 : "=" AssignmentExpression { $$ = $2; }
1062 : "=" AssignmentExpressionNoIn { $$ = $2; }
1066 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1070 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1074 : "else" Statement { $$ = $2; }
1075 | %prec "if" { $$ = NULL; }
1079 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1083 : DoWhileStatement { $$ = $1; }
1084 | WhileStatement { $$ = $1; }
1085 | ForStatement { $$ = $1; }
1086 | ForInStatement { $$ = $1; }
1090 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1094 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1098 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1101 ForStatementInitialiser
1102 : ExpressionNoInOpt { $$ = $1; }
1103 | "var" VariableDeclarationListNoIn { $$ = $2; }
1107 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1108 | "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1111 ForInStatementInitialiser
1112 : LeftHandSideExpression { $$ = $1; }
1113 | "var" VariableDeclarationNoIn { $$ = $2; }
1117 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1121 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1125 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1129 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1133 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1137 : "{" CaseClausesOpt "}" { $$ = $2; }
1141 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1142 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1147 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1151 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1155 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1159 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1163 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1167 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1172 : "finally" Block { $$ = $2; }
1177 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1181 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1184 FormalParameterList_
1185 : "," FormalParameterList { $$ = $2; }
1190 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1195 : SourceElements { $$ = $1; }
1199 : SourceElements { driver.source_ = $1; }
1203 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1208 : Statement { $$ = $1; }
1209 | FunctionDeclaration { $$ = $1; }
1212 /* Objective-C Extensions {{{ */
1214 : ":" MemberExpressionNoBF { $$ = $2; }
1219 : "{" "}" { $$ = NULL; }
1223 : "+" { $$ = false; }
1224 | "-" { $$ = true; }
1228 : "(" Expression ")" { $$ = $2; }
1233 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1236 MessageParameterListOpt
1237 : MessageParameterList { $$ = $1; }
1241 MessageParameterList
1242 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1246 : MessageParameterList { $$ = $1; }
1247 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1250 ClassMessageDeclaration
1251 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1254 ClassMessageDeclarationListOpt
1255 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1260 : Identifier { $$ = $1; }
1261 | "(" AssignmentExpression ")" { $$ = $2; }
1265 : ClassName { $$ = $1; }
1270 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClass($2, $3, $4, $5); }
1274 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1278 : ClassDefinition { $$ = $1; }
1282 : ClassDefinition { $$ = $1; }
1283 | CategoryStatement { $$ = $1; }
1287 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1292 : SelectorCall { $$ = $1; }
1293 | VariadicCall { $$ = $1; }
1297 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1301 : SelectorCall { $$ = $1; }
1302 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1306 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1309 SelectorExpressionOpt
1310 : SelectorExpression_ { $$ = $1; }
1315 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1319 : SelectorExpression_ { $$ = $1; }
1320 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1324 : MessageExpression { $$ = $1; }
1325 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1330 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
1334 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1338 : "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1342 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1346 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1347 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1350 ComprehensionListOpt
1351 : ComprehensionList { $$ = $1; }
1352 | IfComprehension { $$ = $1; }
1357 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1361 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }