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 CYCompound *compound_;
63 CYDeclaration *declaration_;
64 CYDeclarations *declarations_;
66 CYExpression *expression_;
69 CYForInitialiser *for_;
70 CYForInInitialiser *forin_;
71 CYFunctionParameter *functionParameter_;
72 CYIdentifier *identifier_;
77 CYMessageParameter *messageParameter_;
80 CYProperty *property_;
81 CYPropertyName *propertyName_;
82 CYSelectorPart *selector_;
84 CYStatement *statement_;
95 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
104 @$.begin.filename = @$.end.filename = &driver.filename_;
112 %parse-param { CYDriver &driver }
113 %lex-param { void *scanner }
116 %token AmpersandAmpersand "&&"
117 %token AmpersandEqual "&="
119 %token CarrotEqual "^="
121 %token EqualEqual "=="
122 %token EqualEqualEqual "==="
123 %token Exclamation "!"
124 %token ExclamationEqual "!="
125 %token ExclamationEqualEqual "!=="
127 %token HyphenEqual "-="
128 %token HyphenHyphen "--"
129 %token HyphenHyphen_ "\n--"
130 %token HyphenRight "->"
132 %token LeftEqual "<="
134 %token LeftLeftEqual "<<="
136 %token PercentEqual "%="
139 %token PipeEqual "|="
142 %token PlusEqual "+="
144 %token PlusPlus_ "\n++"
146 %token RightEqual ">="
147 %token RightRight ">>"
148 %token RightRightEqual ">>="
149 %token RightRightRight ">>>"
150 %token RightRightRightEqual ">>>="
152 %token SlashEqual "/="
154 %token StarEqual "*="
164 %token CloseParen ")"
167 %token CloseBrace "}"
169 %token OpenBracket "["
170 %token CloseBracket "]"
172 %token AtClass "@class"
173 %token AtSelector "@selector"
176 %token <word_> Break "break"
177 %token <word_> Case "case"
178 %token <word_> Catch "catch"
179 %token <word_> Continue "continue"
180 %token <word_> Default "default"
181 %token <word_> Delete "delete"
182 %token <word_> Do "do"
183 %token <word_> Else "else"
184 %token <false_> False "false"
185 %token <word_> Finally "finally"
186 %token <word_> For "for"
187 %token <word_> Function "function"
188 %token <word_> If "if"
189 %token <word_> In "in"
190 %token <word_> InstanceOf "instanceof"
191 %token <word_> New "new"
192 %token <null_> Null "null"
193 %token <word_> Return "return"
194 %token <word_> Switch "switch"
195 %token <this_> This "this"
196 %token <word_> Throw "throw"
197 %token <true_> True "true"
198 %token <word_> Try "try"
199 %token <word_> TypeOf "typeof"
200 %token <word_> Var "var"
201 %token <word_> Void "void"
202 %token <word_> While "while"
203 %token <word_> With "with"
205 %token <word_> Abstract "abstract"
206 %token <word_> Boolean "boolean"
207 %token <word_> Byte "byte"
208 %token <word_> Char "char"
209 %token <word_> Class "class"
210 %token <word_> Const "const"
211 %token <word_> Debugger "debugger"
212 %token <word_> Double "double"
213 %token <word_> Enum "enum"
214 %token <word_> Export "export"
215 %token <word_> Extends "extends"
216 %token <word_> Final "final"
217 %token <word_> Float "float"
218 %token <word_> Goto "goto"
219 %token <word_> Implements "implements"
220 %token <word_> Import "import"
221 %token <word_> Int "int"
222 %token <word_> Interface "interface"
223 %token <word_> Long "long"
224 %token <word_> Native "native"
225 %token <word_> Package "package"
226 %token <word_> Private "private"
227 %token <word_> Protected "protected"
228 %token <word_> Public "public"
229 %token <word_> Short "short"
230 %token <word_> Static "static"
231 %token <word_> Super "super"
232 %token <word_> Synchronized "synchronized"
233 %token <word_> Throws "throws"
234 %token <word_> Transient "transient"
235 %token <word_> Volatile "volatile"
237 %token <identifier_> Identifier
238 %token <number_> NumericLiteral
239 %token <string_> StringLiteral
241 %type <expression_> AdditiveExpression
242 %type <expression_> AdditiveExpressionNoBF
243 %type <argument_> ArgumentList
244 %type <argument_> ArgumentList_
245 %type <argument_> ArgumentListOpt
246 %type <argument_> Arguments
247 %type <literal_> ArrayLiteral
248 %type <expression_> AssigneeExpression
249 %type <expression_> AssigneeExpression_
250 %type <expression_> AssigneeExpressionNoBF
251 %type <expression_> AssignmentExpression
252 %type <assignment_> AssignmentExpression_
253 %type <expression_> AssignmentExpressionNoBF
254 %type <expression_> AssignmentExpressionNoIn
255 %type <expression_> BitwiseANDExpression
256 %type <expression_> BitwiseANDExpressionNoBF
257 %type <expression_> BitwiseANDExpressionNoIn
258 %type <statement_> Block
259 %type <boolean_> BooleanLiteral
260 %type <expression_> BitwiseORExpression
261 %type <expression_> BitwiseORExpressionNoBF
262 %type <expression_> BitwiseORExpressionNoIn
263 %type <expression_> BitwiseXORExpression
264 %type <expression_> BitwiseXORExpressionNoBF
265 %type <expression_> BitwiseXORExpressionNoIn
266 %type <statement_> BreakStatement
267 %type <expression_> CallExpression
268 %type <expression_> CallExpressionNoBF
269 %type <clause_> CaseBlock
270 %type <clause_> CaseClause
271 %type <clause_> CaseClausesOpt
272 %type <catch_> CatchOpt
273 %type <statement_> CategoryStatement
274 %type <class_> ClassDefinition
275 %type <message_> ClassMessageDeclaration
276 %type <message_> ClassMessageDeclarationListOpt
277 %type <className_> ClassName
278 %type <className_> ClassNameOpt
279 %type <expression_> ClassSuperOpt
280 %type <field_> ClassFieldList
281 %type <expression_> ConditionalExpression
282 %type <expression_> ConditionalExpressionNoBF
283 %type <expression_> ConditionalExpressionNoIn
284 %type <statement_> ContinueStatement
285 %type <clause_> DefaultClause
286 %type <statement_> DoWhileStatement
287 %type <expression_> Element
288 %type <expression_> ElementOpt
289 %type <element_> ElementList
290 %type <element_> ElementListOpt
291 %type <statement_> ElseStatementOpt
292 %type <statement_> EmptyStatement
293 %type <expression_> EqualityExpression
294 %type <expression_> EqualityExpressionNoBF
295 %type <expression_> EqualityExpressionNoIn
296 %type <expression_> Expression
297 %type <expression_> ExpressionOpt
298 %type <compound_> Expression_
299 %type <expression_> ExpressionNoBF
300 %type <expression_> ExpressionNoIn
301 %type <compound_> ExpressionNoIn_
302 %type <expression_> ExpressionNoInOpt
303 %type <statement_> ExpressionStatement
304 %type <statement_> FinallyOpt
305 %type <statement_> ForStatement
306 %type <for_> ForStatementInitialiser
307 %type <statement_> ForInStatement
308 %type <forin_> ForInStatementInitialiser
309 %type <functionParameter_> FormalParameterList
310 %type <functionParameter_> FormalParameterList_
311 %type <source_> FunctionBody
312 %type <source_> FunctionDeclaration
313 %type <expression_> FunctionExpression
314 %type <identifier_> IdentifierOpt
315 %type <statement_> IfStatement
316 %type <expression_> Initialiser
317 %type <expression_> InitialiserOpt
318 %type <expression_> InitialiserNoIn
319 %type <expression_> InitialiserNoInOpt
320 %type <statement_> IterationStatement
321 %type <statement_> LabelledStatement
322 %type <expression_> LeftHandSideExpression
323 %type <expression_> LeftHandSideExpressionNoBF
324 %type <literal_> Literal
325 %type <expression_> LogicalANDExpression
326 %type <expression_> LogicalANDExpressionNoBF
327 %type <expression_> LogicalANDExpressionNoIn
328 %type <expression_> LogicalORExpression
329 %type <expression_> LogicalORExpressionNoBF
330 %type <expression_> LogicalORExpressionNoIn
331 %type <member_> MemberAccess
332 %type <expression_> MemberExpression
333 %type <expression_> MemberExpression_
334 %type <expression_> MemberExpressionNoBF
335 %type <messageParameter_> MessageParameter
336 %type <messageParameter_> MessageParameters
337 %type <messageParameter_> MessageParameterList
338 %type <messageParameter_> MessageParameterListOpt
339 %type <bool_> MessageScope
340 %type <expression_> MultiplicativeExpression
341 %type <expression_> MultiplicativeExpressionNoBF
342 %type <expression_> NewExpression
343 %type <expression_> NewExpression_
344 %type <expression_> NewExpressionNoBF
345 %type <null_> NullLiteral
346 %type <literal_> ObjectLiteral
347 %type <expression_> PostfixExpression
348 %type <expression_> PostfixExpressionNoBF
349 %type <expression_> PrimaryExpression
350 %type <expression_> PrimaryExpression_
351 %type <expression_> PrimaryExpressionNoBF
352 %type <source_> Program
353 %type <propertyName_> PropertyName
354 %type <property_> PropertyNameAndValueList
355 %type <property_> PropertyNameAndValueList_
356 %type <property_> PropertyNameAndValueListOpt
357 %type <expression_> RelationalExpression
358 %type <infix_> RelationalExpression_
359 %type <expression_> RelationalExpressionNoBF
360 %type <expression_> RelationalExpressionNoIn
361 %type <infix_> RelationalExpressionNoIn_
362 %type <statement_> ReturnStatement
363 %type <selector_> SelectorExpression
364 %type <selector_> SelectorExpression_
365 %type <selector_> SelectorExpressionOpt
366 %type <expression_> ShiftExpression
367 %type <expression_> ShiftExpressionNoBF
368 %type <source_> SourceElement
369 %type <source_> SourceElements
370 %type <statement_> Statement
371 %type <statement_> StatementList
372 %type <statement_> StatementListOpt
373 %type <statement_> SwitchStatement
374 %type <statement_> ThrowStatement
375 %type <statement_> TryStatement
376 %type <expression_> TypeOpt
377 %type <expression_> UnaryExpression
378 %type <expression_> UnaryExpression_
379 %type <expression_> UnaryExpressionNoBF
380 %type <declaration_> VariableDeclaration
381 %type <declaration_> VariableDeclarationNoIn
382 %type <declarations_> VariableDeclarationList
383 %type <declarations_> VariableDeclarationList_
384 %type <declarations_> VariableDeclarationListNoIn
385 %type <declarations_> VariableDeclarationListNoIn_
386 %type <statement_> VariableStatement
387 %type <statement_> WhileStatement
388 %type <statement_> WithStatement
390 %type <word_> WordOpt
392 %type <expression_> MessageExpression
393 %type <argument_> SelectorCall
394 %type <argument_> SelectorCall_
395 %type <argument_> SelectorList
396 %type <argument_> VariadicCall
400 %left "<<" ">>" ">>>"
401 %left "<" ">" "<=" ">=" "instanceof" "in"
402 %left "==" "!=" "===" "!=="
409 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
421 | error { yyerrok; driver.errors_.pop_back(); }
427 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
446 : Identifier { $$ = $1; }
447 | "abstract" { $$ = $1; }
448 | "boolean" { $$ = $1; }
449 | "break" NewLineOpt { $$ = $1; }
450 | "byte" { $$ = $1; }
451 | "case" { $$ = $1; }
452 | "catch" { $$ = $1; }
453 | "char" { $$ = $1; }
454 | "class" { $$ = $1; }
455 | "const" { $$ = $1; }
456 | "continue" NewLineOpt { $$ = $1; }
457 | "debugger" { $$ = $1; }
458 | "default" { $$ = $1; }
459 | "delete" { $$ = $1; }
461 | "double" { $$ = $1; }
462 | "else" { $$ = $1; }
463 | "enum" { $$ = $1; }
464 | "export" { $$ = $1; }
465 | "extends" { $$ = $1; }
466 | "false" { $$ = $1; }
467 | "final" { $$ = $1; }
468 | "finally" { $$ = $1; }
469 | "float" { $$ = $1; }
471 | "function" { $$ = $1; }
472 | "goto" { $$ = $1; }
474 | "implements" { $$ = $1; }
475 | "import" { $$ = $1; }
476 /* XXX: | "in" { $$ = $1; } */
477 /* XXX: | "instanceof" { $$ = $1; } */
479 | "interface" { $$ = $1; }
480 | "long" { $$ = $1; }
481 | "native" { $$ = $1; }
483 | "null" { $$ = $1; }
484 | "package" { $$ = $1; }
485 | "private" { $$ = $1; }
486 | "protected" { $$ = $1; }
487 | "public" { $$ = $1; }
488 | "return" NewLineOpt { $$ = $1; }
489 | "short" { $$ = $1; }
490 | "static" { $$ = $1; }
491 | "super" { $$ = $1; }
492 | "switch" { $$ = $1; }
493 | "synchronized" { $$ = $1; }
494 | "this" { $$ = $1; }
495 | "throw" NewLineOpt { $$ = $1; }
496 | "throws" { $$ = $1; }
497 | "transient" { $$ = $1; }
498 | "true" { $$ = $1; }
500 | "typeof" { $$ = $1; }
502 | "void" { $$ = $1; }
503 | "volatile" { $$ = $1; }
504 | "while" { $$ = $1; }
505 | "with" { $$ = $1; }
509 : Identifier { $$ = $1; }
514 : NullLiteral { $$ = $1; }
515 | BooleanLiteral { $$ = $1; }
516 | NumericLiteral { $$ = $1; }
517 | StringLiteral { $$ = $1; }
521 : "null" { $$ = $1; }
525 : "true" { $$ = $1; }
526 | "false" { $$ = $1; }
529 /* 11.1 Primary Expressions {{{ */
531 : "this" { $$ = $1; }
532 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
533 | Literal { $$ = $1; }
534 | ArrayLiteral { $$ = $1; }
535 | "(" Expression ")" { $$ = $2; }
539 : ObjectLiteral { $$ = $1; }
540 | PrimaryExpression_ { $$ = $1; }
543 PrimaryExpressionNoBF
544 : PrimaryExpression_ { $$ = $1; }
547 /* 11.1.4 Array Initialiser {{{ */
549 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
553 : AssignmentExpression { $$ = $1; }
557 : Element { $$ = $1; }
562 : ElementList { $$ = $1; }
567 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
568 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
571 /* 11.1.5 Object Initialiser {{{ */
573 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
576 PropertyNameAndValueList_
577 : "," PropertyNameAndValueList { $$ = $2; }
578 | CommaOpt { $$ = NULL; }
581 PropertyNameAndValueListOpt
582 : PropertyNameAndValueList { $$ = $1; }
586 PropertyNameAndValueList
587 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
591 : Identifier { $$ = $1; }
592 | StringLiteral { $$ = $1; }
593 | NumericLiteral { $$ = $1; }
598 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
602 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
603 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
607 : PrimaryExpression { $$ = $1; }
608 | FunctionExpression { $$ = $1; }
609 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
610 | MemberExpression_ { $$ = $1; }
614 : PrimaryExpressionNoBF { $$ = $1; }
615 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
616 | MemberExpression_ { $$ = $1; }
620 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
624 : MemberExpression { $$ = $1; }
625 | NewExpression_ { $$ = $1; }
629 : MemberExpressionNoBF { $$ = $1; }
630 | NewExpression_ { $$ = $1; }
634 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
635 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
636 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
640 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
641 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
642 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
646 : "," ArgumentList { $$ = $2; }
651 : ArgumentList { $$ = $1; }
656 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
660 : "(" ArgumentListOpt ")" { $$ = $2; }
663 LeftHandSideExpression
664 : NewExpression { $$ = $1; }
665 | CallExpression { $$ = $1; }
668 LeftHandSideExpressionNoBF
669 : NewExpressionNoBF { $$ = $1; }
670 | CallExpressionNoBF { $$ = $1; }
674 : AssigneeExpression { $$ = $1; }
675 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
676 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
679 PostfixExpressionNoBF
680 : AssigneeExpressionNoBF { $$ = $1; }
681 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
682 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
686 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
687 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
688 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
689 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
690 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
691 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
692 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
693 | "+" UnaryExpression { $$ = $2; }
694 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
695 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
696 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
700 : PostfixExpression { $$ = $1; }
701 | UnaryExpression_ { $$ = $1; }
705 : PostfixExpressionNoBF { $$ = $1; }
706 | UnaryExpression_ { $$ = $1; }
709 MultiplicativeExpression
710 : UnaryExpression { $$ = $1; }
711 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
712 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
713 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
716 MultiplicativeExpressionNoBF
717 : UnaryExpressionNoBF { $$ = $1; }
718 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
719 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
720 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
724 : MultiplicativeExpression { $$ = $1; }
725 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
726 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
729 AdditiveExpressionNoBF
730 : MultiplicativeExpressionNoBF { $$ = $1; }
731 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
732 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
736 : AdditiveExpression { $$ = $1; }
737 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
738 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
739 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
743 : AdditiveExpressionNoBF { $$ = $1; }
744 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
745 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
746 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
749 RelationalExpressionNoIn_
750 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
751 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
752 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
753 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
754 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
757 RelationalExpression_
758 : RelationalExpressionNoIn_ { $$ = $1; }
759 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
763 : ShiftExpression { $$ = $1; }
764 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
767 RelationalExpressionNoIn
768 : ShiftExpression { $$ = $1; }
769 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
772 RelationalExpressionNoBF
773 : ShiftExpressionNoBF { $$ = $1; }
774 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
778 : RelationalExpression { $$ = $1; }
779 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
780 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
781 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
782 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
785 EqualityExpressionNoIn
786 : RelationalExpressionNoIn { $$ = $1; }
787 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
788 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
789 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
790 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
793 EqualityExpressionNoBF
794 : RelationalExpressionNoBF { $$ = $1; }
795 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
796 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
797 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
798 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
802 : EqualityExpression { $$ = $1; }
803 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
806 BitwiseANDExpressionNoIn
807 : EqualityExpressionNoIn { $$ = $1; }
808 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
811 BitwiseANDExpressionNoBF
812 : EqualityExpressionNoBF { $$ = $1; }
813 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
817 : BitwiseANDExpression { $$ = $1; }
818 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
821 BitwiseXORExpressionNoIn
822 : BitwiseANDExpressionNoIn { $$ = $1; }
823 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
826 BitwiseXORExpressionNoBF
827 : BitwiseANDExpressionNoBF { $$ = $1; }
828 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
832 : BitwiseXORExpression { $$ = $1; }
833 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
836 BitwiseORExpressionNoIn
837 : BitwiseXORExpressionNoIn { $$ = $1; }
838 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
841 BitwiseORExpressionNoBF
842 : BitwiseXORExpressionNoBF { $$ = $1; }
843 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
847 : BitwiseORExpression { $$ = $1; }
848 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
851 LogicalANDExpressionNoIn
852 : BitwiseORExpressionNoIn { $$ = $1; }
853 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
856 LogicalANDExpressionNoBF
857 : BitwiseORExpressionNoBF { $$ = $1; }
858 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
862 : LogicalANDExpression { $$ = $1; }
863 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
866 LogicalORExpressionNoIn
867 : LogicalANDExpressionNoIn { $$ = $1; }
868 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
871 LogicalORExpressionNoBF
872 : LogicalANDExpressionNoBF { $$ = $1; }
873 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
876 ConditionalExpression
877 : LogicalORExpression { $$ = $1; }
878 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
881 ConditionalExpressionNoIn
882 : LogicalORExpressionNoIn { $$ = $1; }
883 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
886 ConditionalExpressionNoBF
887 : LogicalORExpressionNoBF { $$ = $1; }
888 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
891 AssignmentExpression_
892 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
893 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
894 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
895 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
896 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
897 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
898 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
899 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
900 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
901 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
902 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
903 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
907 : LeftHandSideExpression { $$ = $1; }
908 | AssigneeExpression_ { $$ = $1; }
911 AssigneeExpressionNoBF
912 : LeftHandSideExpressionNoBF { $$ = $1; }
913 | AssigneeExpression_ { $$ = $1; }
917 : ConditionalExpression { $$ = $1; }
918 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
921 AssignmentExpressionNoIn
922 : ConditionalExpressionNoIn { $$ = $1; }
923 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
924 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
925 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
926 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
927 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
928 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
929 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
930 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
931 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
932 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
933 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
934 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
937 AssignmentExpressionNoBF
938 : ConditionalExpressionNoBF { $$ = $1; }
939 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
943 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
948 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
953 : Expression { $$ = $1; }
958 : ExpressionNoIn { $$ = $1; }
963 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
967 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
971 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
976 | VariableStatement { $$ = $1; }
977 | EmptyStatement { $$ = $1; }
978 | ExpressionStatement { $$ = $1; }
979 | IfStatement { $$ = $1; }
980 | IterationStatement { $$ = $1; }
981 | ContinueStatement { $$ = $1; }
982 | BreakStatement { $$ = $1; }
983 | ReturnStatement { $$ = $1; }
984 | WithStatement { $$ = $1; }
985 | LabelledStatement { $$ = $1; }
986 | SwitchStatement { $$ = $1; }
987 | ThrowStatement { $$ = $1; }
988 | TryStatement { $$ = $1; }
992 : "{" StatementListOpt "}" { if ($2) $$ = new(driver.pool_) CYBlock($2); else $$ = new(driver.pool_) CYEmpty(); }
996 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1000 : StatementList { $$ = $1; }
1005 : "var" VariableDeclarationList Terminator { $$ = $2; }
1008 VariableDeclarationList_
1009 : "," VariableDeclarationList { $$ = $2; }
1013 VariableDeclarationListNoIn_
1014 : "," VariableDeclarationListNoIn { $$ = $2; }
1018 VariableDeclarationList
1019 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1022 VariableDeclarationListNoIn
1023 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1027 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1030 VariableDeclarationNoIn
1031 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1035 : Initialiser { $$ = $1; }
1040 : InitialiserNoIn { $$ = $1; }
1045 : "=" AssignmentExpression { $$ = $2; }
1049 : "=" AssignmentExpressionNoIn { $$ = $2; }
1053 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1057 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1061 : "else" Statement { $$ = $2; }
1062 | %prec "if" { $$ = NULL; }
1066 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1070 : DoWhileStatement { $$ = $1; }
1071 | WhileStatement { $$ = $1; }
1072 | ForStatement { $$ = $1; }
1073 | ForInStatement { $$ = $1; }
1077 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1081 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1085 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1088 ForStatementInitialiser
1089 : ExpressionNoInOpt { $$ = $1; }
1090 | "var" VariableDeclarationListNoIn { $$ = $2; }
1094 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1097 ForInStatementInitialiser
1098 : LeftHandSideExpression { $$ = $1; }
1099 | "var" VariableDeclarationNoIn { $$ = $2; }
1103 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1107 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1111 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1115 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1119 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1123 : "{" CaseClausesOpt "}" { $$ = $2; }
1127 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1128 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1133 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1137 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1141 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1145 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1149 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1153 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1158 : "finally" Block { $$ = $2; }
1163 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1167 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1170 FormalParameterList_
1171 : "," FormalParameterList { $$ = $2; }
1176 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1181 : SourceElements { $$ = $1; }
1185 : SourceElements { driver.source_ = $1; }
1189 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1194 : Statement { $$ = $1; }
1195 | FunctionDeclaration { $$ = $1; }
1198 /* Objective-C Extensions {{{ */
1200 : ":" MemberExpressionNoBF { $$ = $2; }
1205 : "{" "}" { $$ = NULL; }
1209 : "+" { $$ = false; }
1210 | "-" { $$ = true; }
1214 : "(" Expression ")" { $$ = $2; }
1219 : Word ":" TypeOpt Identifier { $$ = new CYMessageParameter($1, $3, $4); }
1222 MessageParameterListOpt
1223 : MessageParameterList { $$ = $1; }
1227 MessageParameterList
1228 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1232 : MessageParameterList { $$ = $1; }
1233 | Word { $$ = new CYMessageParameter($1, NULL, NULL); }
1236 ClassMessageDeclaration
1237 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new CYMessage($1, $2, $3, $5); }
1240 ClassMessageDeclarationListOpt
1241 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1246 : Identifier { $$ = $1; }
1247 | "(" AssignmentExpression ")" { $$ = $2; }
1251 : ClassName { $$ = $1; }
1256 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new CYClass($2, $3, $4, $5); }
1260 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new CYCategory($2, $3); }
1264 : ClassDefinition { $$ = $1; }
1268 : ClassDefinition { $$ = $1; }
1269 | CategoryStatement { $$ = $1; }
1273 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1278 : SelectorCall { $$ = $1; }
1279 | VariadicCall { $$ = $1; }
1283 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1287 : SelectorCall { $$ = $1; }
1288 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1292 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1295 SelectorExpressionOpt
1296 : SelectorExpression_ { $$ = $1; }
1301 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1305 : SelectorExpression_ { $$ = $1; }
1306 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1310 : MessageExpression { $$ = $1; }
1311 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1316 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
1320 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1324 : "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1330 : "if" "(" Expression ")"
1334 : "for" "(" ForInStatementInitialiser "in" Expression ")"
1337 ComprehensionListOpt
1344 : ForComprehension ComprehensionListOpt
1348 : "[" AssignmentExpression ComprehensionList "]"