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_;
60 CYClassName *className_;
61 CYCompound *compound_;
62 CYDeclaration *declaration_;
63 CYDeclarations *declarations_;
65 CYExpression *expression_;
68 CYForInitialiser *for_;
69 CYForInInitialiser *forin_;
70 CYFunctionParameter *functionParameter_;
71 CYIdentifier *identifier_;
75 CYMessageParameter *messageParameter_;
78 CYProperty *property_;
79 CYPropertyName *propertyName_;
80 CYSelectorPart *selector_;
82 CYStatement *statement_;
93 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
102 @$.begin.filename = @$.end.filename = &driver.filename_;
110 %parse-param { CYDriver &driver }
111 %lex-param { void *scanner }
114 %token AmpersandAmpersand "&&"
115 %token AmpersandEqual "&="
117 %token CarrotEqual "^="
119 %token EqualEqual "=="
120 %token EqualEqualEqual "==="
121 %token Exclamation "!"
122 %token ExclamationEqual "!="
123 %token ExclamationEqualEqual "!=="
125 %token HyphenEqual "-="
126 %token HyphenHyphen "--"
127 %token HyphenHyphen_ "\n--"
128 %token HyphenRight "->"
130 %token LeftEqual "<="
132 %token LeftLeftEqual "<<="
134 %token PercentEqual "%="
137 %token PipeEqual "|="
140 %token PlusEqual "+="
142 %token PlusPlus_ "\n++"
144 %token RightEqual ">="
145 %token RightRight ">>"
146 %token RightRightEqual ">>="
147 %token RightRightRight ">>>"
148 %token RightRightRightEqual ">>>="
150 %token SlashEqual "/="
152 %token StarEqual "*="
162 %token CloseParen ")"
165 %token CloseBrace "}"
167 %token OpenBracket "["
168 %token CloseBracket "]"
170 %token AtClass "@class"
171 %token AtSelector "@selector"
174 %token <word_> Break "break"
175 %token <word_> Case "case"
176 %token <word_> Catch "catch"
177 %token <word_> Continue "continue"
178 %token <word_> Default "default"
179 %token <word_> Delete "delete"
180 %token <word_> Do "do"
181 %token <word_> Else "else"
182 %token <false_> False "false"
183 %token <word_> Finally "finally"
184 %token <word_> For "for"
185 %token <word_> Function "function"
186 %token <word_> If "if"
187 %token <word_> In "in"
188 %token <word_> InstanceOf "instanceof"
189 %token <word_> New "new"
190 %token <null_> Null "null"
191 %token <word_> Return "return"
192 %token <word_> Switch "switch"
193 %token <this_> This "this"
194 %token <word_> Throw "throw"
195 %token <true_> True "true"
196 %token <word_> Try "try"
197 %token <word_> TypeOf "typeof"
198 %token <word_> Var "var"
199 %token <word_> Void "void"
200 %token <word_> While "while"
201 %token <word_> With "with"
203 %token <word_> Abstract "abstract"
204 %token <word_> Boolean "boolean"
205 %token <word_> Byte "byte"
206 %token <word_> Char "char"
207 %token <word_> Class "class"
208 %token <word_> Const "const"
209 %token <word_> Debugger "debugger"
210 %token <word_> Double "double"
211 %token <word_> Enum "enum"
212 %token <word_> Export "export"
213 %token <word_> Extends "extends"
214 %token <word_> Final "final"
215 %token <word_> Float "float"
216 %token <word_> Goto "goto"
217 %token <word_> Implements "implements"
218 %token <word_> Import "import"
219 %token <word_> Int "int"
220 %token <word_> Interface "interface"
221 %token <word_> Long "long"
222 %token <word_> Native "native"
223 %token <word_> Package "package"
224 %token <word_> Private "private"
225 %token <word_> Protected "protected"
226 %token <word_> Public "public"
227 %token <word_> Short "short"
228 %token <word_> Static "static"
229 %token <word_> Super "super"
230 %token <word_> Synchronized "synchronized"
231 %token <word_> Throws "throws"
232 %token <word_> Transient "transient"
233 %token <word_> Volatile "volatile"
235 %token <identifier_> Identifier
236 %token <number_> NumericLiteral
237 %token <string_> StringLiteral
239 %type <expression_> AdditiveExpression
240 %type <expression_> AdditiveExpressionNoBF
241 %type <argument_> ArgumentList
242 %type <argument_> ArgumentList_
243 %type <argument_> ArgumentListOpt
244 %type <argument_> Arguments
245 %type <literal_> ArrayLiteral
246 %type <expression_> AssignmentExpression
247 %type <assignment_> AssignmentExpression_
248 %type <expression_> AssignmentExpressionNoBF
249 %type <expression_> AssignmentExpressionNoIn
250 %type <expression_> BitwiseANDExpression
251 %type <expression_> BitwiseANDExpressionNoBF
252 %type <expression_> BitwiseANDExpressionNoIn
253 %type <statement_> Block
254 %type <boolean_> BooleanLiteral
255 %type <expression_> BitwiseORExpression
256 %type <expression_> BitwiseORExpressionNoBF
257 %type <expression_> BitwiseORExpressionNoIn
258 %type <expression_> BitwiseXORExpression
259 %type <expression_> BitwiseXORExpressionNoBF
260 %type <expression_> BitwiseXORExpressionNoIn
261 %type <statement_> BreakStatement
262 %type <expression_> CallExpression
263 %type <expression_> CallExpressionNoBF
264 %type <clause_> CaseBlock
265 %type <clause_> CaseClause
266 %type <clause_> CaseClausesOpt
267 %type <catch_> CatchOpt
268 %type <source_> ClassDeclaration
269 %type <message_> ClassMessageDeclaration
270 %type <message_> ClassMessageDeclarationListOpt
271 %type <className_> ClassName
272 %type <expression_> ClassSuperOpt
273 %type <field_> ClassFieldList
274 %type <expression_> ConditionalExpression
275 %type <expression_> ConditionalExpressionNoBF
276 %type <expression_> ConditionalExpressionNoIn
277 %type <statement_> ContinueStatement
278 %type <clause_> DefaultClause
279 %type <statement_> DoWhileStatement
280 %type <expression_> Element
281 %type <expression_> ElementOpt
282 %type <element_> ElementList
283 %type <element_> ElementListOpt
284 %type <statement_> ElseStatementOpt
285 %type <statement_> EmptyStatement
286 %type <expression_> EqualityExpression
287 %type <expression_> EqualityExpressionNoBF
288 %type <expression_> EqualityExpressionNoIn
289 %type <expression_> Expression
290 %type <expression_> ExpressionOpt
291 %type <compound_> Expression_
292 %type <expression_> ExpressionNoBF
293 %type <expression_> ExpressionNoIn
294 %type <compound_> ExpressionNoIn_
295 %type <expression_> ExpressionNoInOpt
296 %type <statement_> ExpressionStatement
297 %type <statement_> FinallyOpt
298 %type <statement_> ForStatement
299 %type <for_> ForStatementInitialiser
300 %type <statement_> ForInStatement
301 %type <forin_> ForInStatementInitialiser
302 %type <functionParameter_> FormalParameterList
303 %type <functionParameter_> FormalParameterList_
304 %type <source_> FunctionBody
305 %type <source_> FunctionDeclaration
306 %type <expression_> FunctionExpression
307 %type <identifier_> IdentifierOpt
308 %type <statement_> IfStatement
309 %type <expression_> Initialiser
310 %type <expression_> InitialiserOpt
311 %type <expression_> InitialiserNoIn
312 %type <expression_> InitialiserNoInOpt
313 %type <statement_> IterationStatement
314 %type <statement_> LabelledStatement
315 %type <expression_> LeftHandSideExpression
316 %type <expression_> LeftHandSideExpression_
317 %type <expression_> LeftHandSideExpressionNoBF
318 %type <literal_> Literal
319 %type <expression_> LogicalANDExpression
320 %type <expression_> LogicalANDExpressionNoBF
321 %type <expression_> LogicalANDExpressionNoIn
322 %type <expression_> LogicalORExpression
323 %type <expression_> LogicalORExpressionNoBF
324 %type <expression_> LogicalORExpressionNoIn
325 %type <expression_> MemberExpression
326 %type <expression_> MemberExpression_
327 %type <expression_> MemberExpressionNoBF
328 %type <messageParameter_> MessageParameter
329 %type <messageParameter_> MessageParameters
330 %type <messageParameter_> MessageParameterList
331 %type <messageParameter_> MessageParameterListOpt
332 %type <bool_> MessageScope
333 %type <expression_> MultiplicativeExpression
334 %type <expression_> MultiplicativeExpressionNoBF
335 %type <expression_> NewExpression
336 %type <expression_> NewExpression_
337 %type <expression_> NewExpressionNoBF
338 %type <null_> NullLiteral
339 %type <literal_> ObjectLiteral
340 %type <expression_> PostfixExpression
341 %type <expression_> PostfixExpressionNoBF
342 %type <expression_> PrimaryExpression
343 %type <expression_> PrimaryExpression_
344 %type <expression_> PrimaryExpressionNoBF
345 %type <source_> Program
346 %type <propertyName_> PropertyName
347 %type <property_> PropertyNameAndValueList
348 %type <property_> PropertyNameAndValueList_
349 %type <property_> PropertyNameAndValueListOpt
350 %type <expression_> RelationalExpression
351 %type <infix_> RelationalExpression_
352 %type <expression_> RelationalExpressionNoBF
353 %type <expression_> RelationalExpressionNoIn
354 %type <infix_> RelationalExpressionNoIn_
355 %type <statement_> ReturnStatement
356 %type <selector_> SelectorExpression
357 %type <selector_> SelectorExpression_
358 %type <selector_> SelectorExpressionOpt
359 %type <expression_> ShiftExpression
360 %type <expression_> ShiftExpressionNoBF
361 %type <source_> SourceElement
362 %type <source_> SourceElements
363 %type <statement_> Statement
364 %type <statement_> StatementList
365 %type <statement_> StatementListOpt
366 %type <statement_> SwitchStatement
367 %type <statement_> ThrowStatement
368 %type <statement_> TryStatement
369 %type <expression_> TypeOpt
370 %type <expression_> UnaryExpression
371 %type <expression_> UnaryExpression_
372 %type <expression_> UnaryExpressionNoBF
373 %type <declaration_> VariableDeclaration
374 %type <declaration_> VariableDeclarationNoIn
375 %type <declarations_> VariableDeclarationList
376 %type <declarations_> VariableDeclarationList_
377 %type <declarations_> VariableDeclarationListNoIn
378 %type <declarations_> VariableDeclarationListNoIn_
379 %type <statement_> VariableStatement
380 %type <statement_> WhileStatement
381 %type <statement_> WithStatement
383 %type <word_> WordOpt
385 %type <expression_> MessageExpression
386 %type <argument_> SelectorCall
387 %type <argument_> SelectorCall_
388 %type <argument_> SelectorList
389 %type <argument_> VariadicCall
393 %left "<<" ">>" ">>>"
394 %left "<" ">" "<=" ">=" "instanceof" "in"
395 %left "==" "!=" "===" "!=="
402 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
414 | error { yyerrok; driver.errors_.pop_back(); }
420 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
439 : Identifier { $$ = $1; }
440 | "abstract" { $$ = $1; }
441 | "boolean" { $$ = $1; }
442 | "break" NewLineOpt { $$ = $1; }
443 | "byte" { $$ = $1; }
444 | "case" { $$ = $1; }
445 | "catch" { $$ = $1; }
446 | "char" { $$ = $1; }
447 | "class" { $$ = $1; }
448 | "const" { $$ = $1; }
449 | "continue" NewLineOpt { $$ = $1; }
450 | "debugger" { $$ = $1; }
451 | "default" { $$ = $1; }
452 | "delete" { $$ = $1; }
454 | "double" { $$ = $1; }
455 | "else" { $$ = $1; }
456 | "enum" { $$ = $1; }
457 | "export" { $$ = $1; }
458 | "extends" { $$ = $1; }
459 | "false" { $$ = $1; }
460 | "final" { $$ = $1; }
461 | "finally" { $$ = $1; }
462 | "float" { $$ = $1; }
464 | "function" { $$ = $1; }
465 | "goto" { $$ = $1; }
467 | "implements" { $$ = $1; }
468 | "import" { $$ = $1; }
469 /* XXX: | "in" { $$ = $1; } */
470 /* XXX: | "instanceof" { $$ = $1; } */
472 | "interface" { $$ = $1; }
473 | "long" { $$ = $1; }
474 | "native" { $$ = $1; }
476 | "null" { $$ = $1; }
477 | "package" { $$ = $1; }
478 | "private" { $$ = $1; }
479 | "protected" { $$ = $1; }
480 | "public" { $$ = $1; }
481 | "return" NewLineOpt { $$ = $1; }
482 | "short" { $$ = $1; }
483 | "static" { $$ = $1; }
484 | "super" { $$ = $1; }
485 | "switch" { $$ = $1; }
486 | "synchronized" { $$ = $1; }
487 | "this" { $$ = $1; }
488 | "throw" NewLineOpt { $$ = $1; }
489 | "throws" { $$ = $1; }
490 | "transient" { $$ = $1; }
491 | "true" { $$ = $1; }
493 | "typeof" { $$ = $1; }
495 | "void" { $$ = $1; }
496 | "volatile" { $$ = $1; }
497 | "while" { $$ = $1; }
498 | "with" { $$ = $1; }
502 : Identifier { $$ = $1; }
507 : NullLiteral { $$ = $1; }
508 | BooleanLiteral { $$ = $1; }
509 | NumericLiteral { $$ = $1; }
510 | StringLiteral { $$ = $1; }
514 : "null" { $$ = $1; }
518 : "true" { $$ = $1; }
519 | "false" { $$ = $1; }
522 /* 11.1 Primary Expressions {{{ */
524 : "this" { $$ = $1; }
525 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
526 | Literal { $$ = $1; }
527 | ArrayLiteral { $$ = $1; }
528 | "(" Expression ")" { $$ = $2; }
532 : ObjectLiteral { $$ = $1; }
533 | PrimaryExpression_ { $$ = $1; }
536 PrimaryExpressionNoBF
537 : PrimaryExpression_ { $$ = $1; }
540 /* 11.1.4 Array Initialiser {{{ */
542 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
546 : AssignmentExpression { $$ = $1; }
550 : Element { $$ = $1; }
555 : ElementList { $$ = $1; }
560 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
561 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
564 /* 11.1.5 Object Initialiser {{{ */
566 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
569 PropertyNameAndValueList_
570 : "," PropertyNameAndValueList { $$ = $2; }
571 | CommaOpt { $$ = NULL; }
574 PropertyNameAndValueListOpt
575 : PropertyNameAndValueList { $$ = $1; }
579 PropertyNameAndValueList
580 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
584 : Identifier { $$ = $1; }
585 | StringLiteral { $$ = $1; }
586 | NumericLiteral { $$ = $1; }
591 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
595 : PrimaryExpression { $$ = $1; }
596 | FunctionExpression { $$ = $1; }
597 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
598 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
599 | MemberExpression_ { $$ = $1; }
603 : PrimaryExpressionNoBF { $$ = $1; }
604 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
605 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
606 | MemberExpression_ { $$ = $1; }
610 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
614 : MemberExpression { $$ = $1; }
615 | NewExpression_ { $$ = $1; }
619 : MemberExpressionNoBF { $$ = $1; }
620 | NewExpression_ { $$ = $1; }
624 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
625 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
626 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
627 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
631 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
632 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
633 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
634 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
638 : "," ArgumentList { $$ = $2; }
643 : ArgumentList { $$ = $1; }
648 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
652 : "(" ArgumentListOpt ")" { $$ = $2; }
655 LeftHandSideExpression
656 : NewExpression { $$ = $1; }
657 | CallExpression { $$ = $1; }
658 | LeftHandSideExpression_ { $$ = $1; }
661 LeftHandSideExpressionNoBF
662 : NewExpressionNoBF { $$ = $1; }
663 | CallExpressionNoBF { $$ = $1; }
664 | LeftHandSideExpression_ { $$ = $1; }
668 : LeftHandSideExpression { $$ = $1; }
669 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
670 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
673 PostfixExpressionNoBF
674 : LeftHandSideExpressionNoBF { $$ = $1; }
675 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
676 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
680 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
681 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
682 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
683 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
684 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
685 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
686 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
687 | "+" UnaryExpression { $$ = $2; }
688 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
689 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
690 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
694 : PostfixExpression { $$ = $1; }
695 | UnaryExpression_ { $$ = $1; }
699 : PostfixExpressionNoBF { $$ = $1; }
700 | UnaryExpression_ { $$ = $1; }
703 MultiplicativeExpression
704 : UnaryExpression { $$ = $1; }
705 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
706 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
707 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
710 MultiplicativeExpressionNoBF
711 : UnaryExpressionNoBF { $$ = $1; }
712 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
713 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
714 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
718 : MultiplicativeExpression { $$ = $1; }
719 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
720 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
723 AdditiveExpressionNoBF
724 : MultiplicativeExpressionNoBF { $$ = $1; }
725 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
726 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
730 : AdditiveExpression { $$ = $1; }
731 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
732 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
733 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
737 : AdditiveExpressionNoBF { $$ = $1; }
738 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
739 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
740 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
743 RelationalExpressionNoIn_
744 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
745 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
746 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
747 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
748 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
751 RelationalExpression_
752 : RelationalExpressionNoIn_ { $$ = $1; }
753 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
757 : ShiftExpression { $$ = $1; }
758 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
761 RelationalExpressionNoIn
762 : ShiftExpression { $$ = $1; }
763 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
766 RelationalExpressionNoBF
767 : ShiftExpressionNoBF { $$ = $1; }
768 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
772 : RelationalExpression { $$ = $1; }
773 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
774 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
775 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
776 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
779 EqualityExpressionNoIn
780 : RelationalExpressionNoIn { $$ = $1; }
781 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
782 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
783 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
784 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
787 EqualityExpressionNoBF
788 : RelationalExpressionNoBF { $$ = $1; }
789 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
790 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
791 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
792 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
796 : EqualityExpression { $$ = $1; }
797 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
800 BitwiseANDExpressionNoIn
801 : EqualityExpressionNoIn { $$ = $1; }
802 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
805 BitwiseANDExpressionNoBF
806 : EqualityExpressionNoBF { $$ = $1; }
807 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
811 : BitwiseANDExpression { $$ = $1; }
812 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
815 BitwiseXORExpressionNoIn
816 : BitwiseANDExpressionNoIn { $$ = $1; }
817 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
820 BitwiseXORExpressionNoBF
821 : BitwiseANDExpressionNoBF { $$ = $1; }
822 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
826 : BitwiseXORExpression { $$ = $1; }
827 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
830 BitwiseORExpressionNoIn
831 : BitwiseXORExpressionNoIn { $$ = $1; }
832 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
835 BitwiseORExpressionNoBF
836 : BitwiseXORExpressionNoBF { $$ = $1; }
837 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
841 : BitwiseORExpression { $$ = $1; }
842 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
845 LogicalANDExpressionNoIn
846 : BitwiseORExpressionNoIn { $$ = $1; }
847 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
850 LogicalANDExpressionNoBF
851 : BitwiseORExpressionNoBF { $$ = $1; }
852 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
856 : LogicalANDExpression { $$ = $1; }
857 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
860 LogicalORExpressionNoIn
861 : LogicalANDExpressionNoIn { $$ = $1; }
862 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
865 LogicalORExpressionNoBF
866 : LogicalANDExpressionNoBF { $$ = $1; }
867 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
870 ConditionalExpression
871 : LogicalORExpression { $$ = $1; }
872 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
875 ConditionalExpressionNoIn
876 : LogicalORExpressionNoIn { $$ = $1; }
877 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
880 ConditionalExpressionNoBF
881 : LogicalORExpressionNoBF { $$ = $1; }
882 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
885 AssignmentExpression_
886 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
887 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
888 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
889 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
890 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
891 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
892 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
893 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
894 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
895 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
896 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
897 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
901 : ConditionalExpression { $$ = $1; }
902 | LeftHandSideExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
905 AssignmentExpressionNoIn
906 : ConditionalExpressionNoIn { $$ = $1; }
907 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
908 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
909 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
910 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
911 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
912 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
913 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
914 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
915 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
916 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
917 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
918 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
921 AssignmentExpressionNoBF
922 : ConditionalExpressionNoBF { $$ = $1; }
923 | LeftHandSideExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
927 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
932 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
937 : Expression { $$ = $1; }
942 : ExpressionNoIn { $$ = $1; }
947 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
951 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
955 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
960 | VariableStatement { $$ = $1; }
961 | EmptyStatement { $$ = $1; }
962 | ExpressionStatement { $$ = $1; }
963 | IfStatement { $$ = $1; }
964 | IterationStatement { $$ = $1; }
965 | ContinueStatement { $$ = $1; }
966 | BreakStatement { $$ = $1; }
967 | ReturnStatement { $$ = $1; }
968 | WithStatement { $$ = $1; }
969 | LabelledStatement { $$ = $1; }
970 | SwitchStatement { $$ = $1; }
971 | ThrowStatement { $$ = $1; }
972 | TryStatement { $$ = $1; }
976 : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
980 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
984 : StatementList { $$ = $1; }
989 : "var" VariableDeclarationList Terminator { $$ = $2; }
992 VariableDeclarationList_
993 : "," VariableDeclarationList { $$ = $2; }
997 VariableDeclarationListNoIn_
998 : "," VariableDeclarationListNoIn { $$ = $2; }
1002 VariableDeclarationList
1003 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1006 VariableDeclarationListNoIn
1007 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1011 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1014 VariableDeclarationNoIn
1015 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1019 : Initialiser { $$ = $1; }
1024 : InitialiserNoIn { $$ = $1; }
1029 : "=" AssignmentExpression { $$ = $2; }
1033 : "=" AssignmentExpressionNoIn { $$ = $2; }
1037 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1041 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1045 : "else" Statement { $$ = $2; }
1046 | %prec "if" { $$ = NULL; }
1050 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1054 : DoWhileStatement { $$ = $1; }
1055 | WhileStatement { $$ = $1; }
1056 | ForStatement { $$ = $1; }
1057 | ForInStatement { $$ = $1; }
1061 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1065 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1069 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1072 ForStatementInitialiser
1073 : ExpressionNoInOpt { $$ = $1; }
1074 | "var" VariableDeclarationListNoIn { $$ = $2; }
1078 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1081 ForInStatementInitialiser
1082 : LeftHandSideExpression { $$ = $1; }
1083 | "var" VariableDeclarationNoIn { $$ = $2; }
1087 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1091 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1095 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1099 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1103 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1107 : "{" CaseClausesOpt "}" { $$ = $2; }
1111 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1112 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1117 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1121 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1125 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1129 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1133 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1137 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1142 : "finally" Block { $$ = $2; }
1147 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1151 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1154 FormalParameterList_
1155 : "," FormalParameterList { $$ = $2; }
1160 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1165 : SourceElements { $$ = $1; }
1169 : SourceElements { driver.source_ = $1; }
1173 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1178 : Statement { $$ = $1; }
1179 | FunctionDeclaration { $$ = $1; }
1182 /* Objective-C Extensions {{{ */
1184 : ":" MemberExpressionNoBF { $$ = $2; }
1189 : "{" "}" { $$ = NULL; }
1193 : "+" { $$ = false; }
1194 | "-" { $$ = true; }
1198 : "(" Expression ")" { $$ = $2; }
1203 : Word ":" TypeOpt Identifier { $$ = new CYMessageParameter($1, $3, $4); }
1206 MessageParameterListOpt
1207 : MessageParameterList { $$ = $1; }
1211 MessageParameterList
1212 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1216 : MessageParameterList { $$ = $1; }
1217 | Word { $$ = new CYMessageParameter($1, NULL, NULL); }
1220 ClassMessageDeclaration
1221 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new CYMessage($1, $2, $3, $5); }
1224 ClassMessageDeclarationListOpt
1225 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1230 : Identifier { $$ = $1; }
1231 | "(" AssignmentExpression ")" { $$ = $2; }
1235 : "@class" Identifier ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new CYClass($2, $3, $4, $5); }
1236 | "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new CYCategory($2, $3); }
1240 : ClassDeclaration { $$ = $1; }
1244 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1249 : SelectorCall { $$ = $1; }
1250 | VariadicCall { $$ = $1; }
1254 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1258 : SelectorCall { $$ = $1; }
1259 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1263 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1266 SelectorExpressionOpt
1267 : SelectorExpression_ { $$ = $1; }
1272 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1276 : SelectorExpression_ { $$ = $1; }
1277 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1281 : MessageExpression { $$ = $1; }
1282 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1286 LeftHandSideExpression_
1287 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1291 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }