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_;
59 CYCompound *compound_;
60 CYDeclaration *declaration_;
61 CYDeclarations *declarations_;
63 CYExpression *expression_;
66 CYForInitialiser *for_;
67 CYForInInitialiser *forin_;
68 CYFunctionParameter *functionParameter_;
69 CYIdentifier *identifier_;
72 CYMessageParameter *messageParameter_;
76 CYProperty *property_;
77 CYSelectorPart *selector_;
79 CYStatement *statement_;
90 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
99 @$.begin.filename = @$.end.filename = &driver.filename_;
107 %parse-param { CYDriver &driver }
108 %lex-param { void *scanner }
111 %token AmpersandAmpersand "&&"
112 %token AmpersandEqual "&="
114 %token CarrotEqual "^="
116 %token EqualEqual "=="
117 %token EqualEqualEqual "==="
118 %token Exclamation "!"
119 %token ExclamationEqual "!="
120 %token ExclamationEqualEqual "!=="
122 %token HyphenEqual "-="
123 %token HyphenHyphen "--"
124 %token HyphenHyphen_ "\n--"
125 %token HyphenRight "->"
127 %token LeftEqual "<="
129 %token LeftLeftEqual "<<="
131 %token PercentEqual "%="
134 %token PipeEqual "|="
137 %token PlusEqual "+="
139 %token PlusPlus_ "\n++"
141 %token RightEqual ">="
142 %token RightRight ">>"
143 %token RightRightEqual ">>="
144 %token RightRightRight ">>>"
145 %token RightRightRightEqual ">>>="
147 %token SlashEqual "/="
149 %token StarEqual "*="
159 %token CloseParen ")"
162 %token CloseBrace "}"
164 %token OpenBracket "["
165 %token CloseBracket "]"
167 %token AtClass "@class"
168 %token AtSelector "@selector"
171 %token <word_> Break "break"
172 %token <word_> Case "case"
173 %token <word_> Catch "catch"
174 %token <word_> Continue "continue"
175 %token <word_> Default "default"
176 %token <word_> Delete "delete"
177 %token <word_> Do "do"
178 %token <word_> Else "else"
179 %token <false_> False "false"
180 %token <word_> Finally "finally"
181 %token <word_> For "for"
182 %token <word_> Function "function"
183 %token <word_> If "if"
184 %token <word_> In "in"
185 %token <word_> InstanceOf "instanceof"
186 %token <word_> New "new"
187 %token <null_> Null "null"
188 %token <word_> Return "return"
189 %token <word_> Switch "switch"
190 %token <this_> This "this"
191 %token <word_> Throw "throw"
192 %token <true_> True "true"
193 %token <word_> Try "try"
194 %token <word_> TypeOf "typeof"
195 %token <word_> Var "var"
196 %token <word_> Void "void"
197 %token <word_> While "while"
198 %token <word_> With "with"
200 %token <word_> Abstract "abstract"
201 %token <word_> Boolean "boolean"
202 %token <word_> Byte "byte"
203 %token <word_> Char "char"
204 %token <word_> Class "class"
205 %token <word_> Const "const"
206 %token <word_> Debugger "debugger"
207 %token <word_> Double "double"
208 %token <word_> Enum "enum"
209 %token <word_> Export "export"
210 %token <word_> Extends "extends"
211 %token <word_> Final "final"
212 %token <word_> Float "float"
213 %token <word_> Goto "goto"
214 %token <word_> Implements "implements"
215 %token <word_> Import "import"
216 %token <word_> Int "int"
217 %token <word_> Interface "interface"
218 %token <word_> Long "long"
219 %token <word_> Native "native"
220 %token <word_> Package "package"
221 %token <word_> Private "private"
222 %token <word_> Protected "protected"
223 %token <word_> Public "public"
224 %token <word_> Short "short"
225 %token <word_> Static "static"
226 %token <word_> Super "super"
227 %token <word_> Synchronized "synchronized"
228 %token <word_> Throws "throws"
229 %token <word_> Transient "transient"
230 %token <word_> Volatile "volatile"
232 %token <identifier_> Identifier
233 %token <number_> NumericLiteral
234 %token <string_> StringLiteral
236 %type <expression_> AdditiveExpression
237 %type <expression_> AdditiveExpressionNoBF
238 %type <argument_> ArgumentList
239 %type <argument_> ArgumentList_
240 %type <argument_> ArgumentListOpt
241 %type <argument_> Arguments
242 %type <literal_> ArrayLiteral
243 %type <expression_> AssignmentExpression
244 %type <expression_> AssignmentExpressionNoBF
245 %type <expression_> AssignmentExpressionNoIn
246 %type <expression_> BitwiseANDExpression
247 %type <expression_> BitwiseANDExpressionNoBF
248 %type <expression_> BitwiseANDExpressionNoIn
249 %type <statement_> Block
250 %type <boolean_> BooleanLiteral
251 %type <expression_> BitwiseORExpression
252 %type <expression_> BitwiseORExpressionNoBF
253 %type <expression_> BitwiseORExpressionNoIn
254 %type <expression_> BitwiseXORExpression
255 %type <expression_> BitwiseXORExpressionNoBF
256 %type <expression_> BitwiseXORExpressionNoIn
257 %type <statement_> BreakStatement
258 %type <expression_> CallExpression
259 %type <expression_> CallExpressionNoBF
260 %type <clause_> CaseBlock
261 %type <clause_> CaseClause
262 %type <clause_> CaseClausesOpt
263 %type <catch_> CatchOpt
264 %type <source_> ClassDeclaration
265 %type <message_> ClassMessageDeclaration
266 %type <message_> ClassMessageDeclarationListOpt
267 %type <expression_> ClassSuperOpt
268 %type <field_> ClassFieldList
269 %type <expression_> ConditionalExpression
270 %type <expression_> ConditionalExpressionNoBF
271 %type <expression_> ConditionalExpressionNoIn
272 %type <statement_> ContinueStatement
273 %type <clause_> DefaultClause
274 %type <statement_> DoWhileStatement
275 %type <expression_> Element
276 %type <expression_> ElementOpt
277 %type <element_> ElementList
278 %type <element_> ElementListOpt
279 %type <statement_> ElseStatementOpt
280 %type <statement_> EmptyStatement
281 %type <expression_> EqualityExpression
282 %type <expression_> EqualityExpressionNoBF
283 %type <expression_> EqualityExpressionNoIn
284 %type <expression_> Expression
285 %type <expression_> ExpressionOpt
286 %type <compound_> Expression_
287 %type <expression_> ExpressionNoBF
288 %type <expression_> ExpressionNoIn
289 %type <compound_> ExpressionNoIn_
290 %type <expression_> ExpressionNoInOpt
291 %type <statement_> ExpressionStatement
292 %type <statement_> FinallyOpt
293 %type <statement_> ForStatement
294 %type <for_> ForStatementInitialiser
295 %type <statement_> ForInStatement
296 %type <forin_> ForInStatementInitialiser
297 %type <functionParameter_> FormalParameterList
298 %type <functionParameter_> FormalParameterList_
299 %type <source_> FunctionBody
300 %type <source_> FunctionDeclaration
301 %type <expression_> FunctionExpression
302 %type <identifier_> IdentifierOpt
303 %type <statement_> IfStatement
304 %type <expression_> Initialiser
305 %type <expression_> InitialiserOpt
306 %type <expression_> InitialiserNoIn
307 %type <expression_> InitialiserNoInOpt
308 %type <statement_> IterationStatement
309 %type <statement_> LabelledStatement
310 %type <expression_> LeftHandSideExpression
311 %type <expression_> LeftHandSideExpression_
312 %type <expression_> LeftHandSideExpressionNoBF
313 %type <literal_> Literal
314 %type <expression_> LogicalANDExpression
315 %type <expression_> LogicalANDExpressionNoBF
316 %type <expression_> LogicalANDExpressionNoIn
317 %type <expression_> LogicalORExpression
318 %type <expression_> LogicalORExpressionNoBF
319 %type <expression_> LogicalORExpressionNoIn
320 %type <expression_> MemberExpression
321 %type <expression_> MemberExpression_
322 %type <expression_> MemberExpressionNoBF
323 %type <messageParameter_> MessageParameter
324 %type <messageParameter_> MessageParameters
325 %type <messageParameter_> MessageParameterList
326 %type <messageParameter_> MessageParameterListOpt
327 %type <bool_> MessageScope
328 %type <expression_> MultiplicativeExpression
329 %type <expression_> MultiplicativeExpressionNoBF
330 %type <expression_> NewExpression
331 %type <expression_> NewExpression_
332 %type <expression_> NewExpressionNoBF
333 %type <null_> NullLiteral
334 %type <literal_> ObjectLiteral
335 %type <expression_> PostfixExpression
336 %type <expression_> PostfixExpressionNoBF
337 %type <expression_> PrimaryExpression
338 %type <expression_> PrimaryExpression_
339 %type <expression_> PrimaryExpressionNoBF
340 %type <source_> Program
341 %type <name_> PropertyName
342 %type <property_> PropertyNameAndValueList
343 %type <property_> PropertyNameAndValueList_
344 %type <property_> PropertyNameAndValueListOpt
345 %type <expression_> RelationalExpression
346 %type <expression_> RelationalExpressionNoBF
347 %type <expression_> RelationalExpressionNoIn
348 %type <statement_> ReturnStatement
349 %type <selector_> SelectorExpression
350 %type <selector_> SelectorExpression_
351 %type <selector_> SelectorExpressionOpt
352 %type <expression_> ShiftExpression
353 %type <expression_> ShiftExpressionNoBF
354 %type <source_> SourceElement
355 %type <source_> SourceElements
356 %type <statement_> Statement
357 %type <statement_> StatementList
358 %type <statement_> StatementListOpt
359 %type <statement_> SwitchStatement
360 %type <statement_> ThrowStatement
361 %type <statement_> TryStatement
362 %type <expression_> TypeOpt
363 %type <expression_> UnaryExpression
364 %type <expression_> UnaryExpression_
365 %type <expression_> UnaryExpressionNoBF
366 %type <declaration_> VariableDeclaration
367 %type <declaration_> VariableDeclarationNoIn
368 %type <declarations_> VariableDeclarationList
369 %type <declarations_> VariableDeclarationList_
370 %type <declarations_> VariableDeclarationListNoIn
371 %type <declarations_> VariableDeclarationListNoIn_
372 %type <statement_> VariableStatement
373 %type <statement_> WhileStatement
374 %type <statement_> WithStatement
376 %type <word_> WordOpt
378 %type <expression_> MessageExpression
379 %type <argument_> SelectorCall
380 %type <argument_> SelectorCall_
381 %type <argument_> SelectorList
382 %type <argument_> VariadicCall
386 %left "<<" ">>" ">>>"
387 %left "<" ">" "<=" ">=" "instanceof" "in"
388 %left "==" "!=" "===" "!=="
395 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
407 | error { yyerrok; driver.errors_.pop_back(); }
413 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
432 : Identifier { $$ = $1; }
433 | "abstract" { $$ = $1; }
434 | "boolean" { $$ = $1; }
435 | "break" NewLineOpt { $$ = $1; }
436 | "byte" { $$ = $1; }
437 | "case" { $$ = $1; }
438 | "catch" { $$ = $1; }
439 | "char" { $$ = $1; }
440 | "class" { $$ = $1; }
441 | "const" { $$ = $1; }
442 | "continue" NewLineOpt { $$ = $1; }
443 | "debugger" { $$ = $1; }
444 | "default" { $$ = $1; }
445 | "delete" { $$ = $1; }
447 | "double" { $$ = $1; }
448 | "else" { $$ = $1; }
449 | "enum" { $$ = $1; }
450 | "export" { $$ = $1; }
451 | "extends" { $$ = $1; }
452 | "false" { $$ = $1; }
453 | "final" { $$ = $1; }
454 | "finally" { $$ = $1; }
455 | "float" { $$ = $1; }
457 | "function" { $$ = $1; }
458 | "goto" { $$ = $1; }
460 | "implements" { $$ = $1; }
461 | "import" { $$ = $1; }
462 /* XXX: | "in" { $$ = $1; } */
463 /* XXX: | "instanceof" { $$ = $1; } */
465 | "interface" { $$ = $1; }
466 | "long" { $$ = $1; }
467 | "native" { $$ = $1; }
469 | "null" { $$ = $1; }
470 | "package" { $$ = $1; }
471 | "private" { $$ = $1; }
472 | "protected" { $$ = $1; }
473 | "public" { $$ = $1; }
474 | "return" NewLineOpt { $$ = $1; }
475 | "short" { $$ = $1; }
476 | "static" { $$ = $1; }
477 | "super" { $$ = $1; }
478 | "switch" { $$ = $1; }
479 | "synchronized" { $$ = $1; }
480 | "this" { $$ = $1; }
481 | "throw" NewLineOpt { $$ = $1; }
482 | "throws" { $$ = $1; }
483 | "transient" { $$ = $1; }
484 | "true" { $$ = $1; }
486 | "typeof" { $$ = $1; }
488 | "void" { $$ = $1; }
489 | "volatile" { $$ = $1; }
490 | "while" { $$ = $1; }
491 | "with" { $$ = $1; }
495 : Identifier { $$ = $1; }
500 : NullLiteral { $$ = $1; }
501 | BooleanLiteral { $$ = $1; }
502 | NumericLiteral { $$ = $1; }
503 | StringLiteral { $$ = $1; }
507 : "null" { $$ = $1; }
511 : "true" { $$ = $1; }
512 | "false" { $$ = $1; }
515 /* 11.1 Primary Expressions {{{ */
517 : "this" { $$ = $1; }
518 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
519 | Literal { $$ = $1; }
520 | ArrayLiteral { $$ = $1; }
521 | "(" Expression ")" { $$ = $2; }
525 : ObjectLiteral { $$ = $1; }
526 | PrimaryExpression_ { $$ = $1; }
529 PrimaryExpressionNoBF
530 : PrimaryExpression_ { $$ = $1; }
533 /* 11.1.4 Array Initialiser {{{ */
535 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
539 : AssignmentExpression { $$ = $1; }
543 : Element { $$ = $1; }
548 : ElementList { $$ = $1; }
553 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
554 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
557 /* 11.1.5 Object Initialiser {{{ */
559 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
562 PropertyNameAndValueList_
563 : "," PropertyNameAndValueList { $$ = $2; }
564 | CommaOpt { $$ = NULL; }
567 PropertyNameAndValueListOpt
568 : PropertyNameAndValueList { $$ = $1; }
572 PropertyNameAndValueList
573 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
577 : Identifier { $$ = $1; }
578 | StringLiteral { $$ = $1; }
579 | NumericLiteral { $$ = $1; }
584 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
588 : PrimaryExpression { $$ = $1; }
589 | FunctionExpression { $$ = $1; }
590 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
591 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
592 | MemberExpression_ { $$ = $1; }
596 : PrimaryExpressionNoBF { $$ = $1; }
597 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
598 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
599 | MemberExpression_ { $$ = $1; }
603 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
607 : MemberExpression { $$ = $1; }
608 | NewExpression_ { $$ = $1; }
612 : MemberExpressionNoBF { $$ = $1; }
613 | NewExpression_ { $$ = $1; }
617 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
618 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
619 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
620 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
624 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
625 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
626 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
627 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
631 : "," ArgumentList { $$ = $2; }
636 : ArgumentList { $$ = $1; }
641 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
645 : "(" ArgumentListOpt ")" { $$ = $2; }
648 LeftHandSideExpression
649 : NewExpression { $$ = $1; }
650 | CallExpression { $$ = $1; }
651 | LeftHandSideExpression_ { $$ = $1; }
654 LeftHandSideExpressionNoBF
655 : NewExpressionNoBF { $$ = $1; }
656 | CallExpressionNoBF { $$ = $1; }
657 | LeftHandSideExpression_ { $$ = $1; }
661 : LeftHandSideExpression { $$ = $1; }
662 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
663 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
666 PostfixExpressionNoBF
667 : LeftHandSideExpressionNoBF { $$ = $1; }
668 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
669 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
673 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
674 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
675 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
676 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
677 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
678 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
679 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
680 | "+" UnaryExpression { $$ = $2; }
681 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
682 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
683 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
687 : PostfixExpression { $$ = $1; }
688 | UnaryExpression_ { $$ = $1; }
692 : PostfixExpressionNoBF { $$ = $1; }
693 | UnaryExpression_ { $$ = $1; }
696 MultiplicativeExpression
697 : UnaryExpression { $$ = $1; }
698 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
699 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
700 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
703 MultiplicativeExpressionNoBF
704 : UnaryExpressionNoBF { $$ = $1; }
705 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
706 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
707 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
711 : MultiplicativeExpression { $$ = $1; }
712 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
713 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
716 AdditiveExpressionNoBF
717 : MultiplicativeExpressionNoBF { $$ = $1; }
718 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
719 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
723 : AdditiveExpression { $$ = $1; }
724 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
725 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
726 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
730 : AdditiveExpressionNoBF { $$ = $1; }
731 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
732 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
733 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
737 : ShiftExpression { $$ = $1; }
738 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
739 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
740 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
741 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
742 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
743 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
746 RelationalExpressionNoIn
747 : ShiftExpression { $$ = $1; }
748 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
749 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
750 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
751 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
752 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
755 RelationalExpressionNoBF
756 : ShiftExpressionNoBF { $$ = $1; }
757 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
758 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
759 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
760 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
761 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
762 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
766 : RelationalExpression { $$ = $1; }
767 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
768 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
769 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
770 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
773 EqualityExpressionNoIn
774 : RelationalExpressionNoIn { $$ = $1; }
775 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
776 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
777 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
778 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
781 EqualityExpressionNoBF
782 : RelationalExpressionNoBF { $$ = $1; }
783 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
784 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
785 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
786 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
790 : EqualityExpression { $$ = $1; }
791 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
794 BitwiseANDExpressionNoIn
795 : EqualityExpressionNoIn { $$ = $1; }
796 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
799 BitwiseANDExpressionNoBF
800 : EqualityExpressionNoBF { $$ = $1; }
801 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
805 : BitwiseANDExpression { $$ = $1; }
806 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
809 BitwiseXORExpressionNoIn
810 : BitwiseANDExpressionNoIn { $$ = $1; }
811 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
814 BitwiseXORExpressionNoBF
815 : BitwiseANDExpressionNoBF { $$ = $1; }
816 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
820 : BitwiseXORExpression { $$ = $1; }
821 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
824 BitwiseORExpressionNoIn
825 : BitwiseXORExpressionNoIn { $$ = $1; }
826 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
829 BitwiseORExpressionNoBF
830 : BitwiseXORExpressionNoBF { $$ = $1; }
831 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
835 : BitwiseORExpression { $$ = $1; }
836 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
839 LogicalANDExpressionNoIn
840 : BitwiseORExpressionNoIn { $$ = $1; }
841 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
844 LogicalANDExpressionNoBF
845 : BitwiseORExpressionNoBF { $$ = $1; }
846 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
850 : LogicalANDExpression { $$ = $1; }
851 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
854 LogicalORExpressionNoIn
855 : LogicalANDExpressionNoIn { $$ = $1; }
856 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
859 LogicalORExpressionNoBF
860 : LogicalANDExpressionNoBF { $$ = $1; }
861 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
864 ConditionalExpression
865 : LogicalORExpression { $$ = $1; }
866 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
869 ConditionalExpressionNoIn
870 : LogicalORExpressionNoIn { $$ = $1; }
871 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
874 ConditionalExpressionNoBF
875 : LogicalORExpressionNoBF { $$ = $1; }
876 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
880 : ConditionalExpression { $$ = $1; }
881 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
882 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
883 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
884 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
885 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
886 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
887 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
888 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
889 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
890 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
891 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
892 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
895 AssignmentExpressionNoIn
896 : ConditionalExpressionNoIn { $$ = $1; }
897 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
898 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
899 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
900 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
901 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
902 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
903 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
904 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
905 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
906 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
907 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
908 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
911 AssignmentExpressionNoBF
912 : ConditionalExpressionNoBF { $$ = $1; }
913 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
914 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
915 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
916 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
917 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
918 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
919 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
920 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
921 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
922 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
923 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
924 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
928 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
933 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
938 : Expression { $$ = $1; }
943 : ExpressionNoIn { $$ = $1; }
948 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
952 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
956 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
961 | VariableStatement { $$ = $1; }
962 | EmptyStatement { $$ = $1; }
963 | ExpressionStatement { $$ = $1; }
964 | IfStatement { $$ = $1; }
965 | IterationStatement { $$ = $1; }
966 | ContinueStatement { $$ = $1; }
967 | BreakStatement { $$ = $1; }
968 | ReturnStatement { $$ = $1; }
969 | WithStatement { $$ = $1; }
970 | LabelledStatement { $$ = $1; }
971 | SwitchStatement { $$ = $1; }
972 | ThrowStatement { $$ = $1; }
973 | TryStatement { $$ = $1; }
977 : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
981 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
985 : StatementList { $$ = $1; }
990 : "var" VariableDeclarationList Terminator { $$ = $2; }
993 VariableDeclarationList_
994 : "," VariableDeclarationList { $$ = $2; }
998 VariableDeclarationListNoIn_
999 : "," VariableDeclarationListNoIn { $$ = $2; }
1003 VariableDeclarationList
1004 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1007 VariableDeclarationListNoIn
1008 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1012 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1015 VariableDeclarationNoIn
1016 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1020 : Initialiser { $$ = $1; }
1025 : InitialiserNoIn { $$ = $1; }
1030 : "=" AssignmentExpression { $$ = $2; }
1034 : "=" AssignmentExpressionNoIn { $$ = $2; }
1038 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1042 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1046 : "else" Statement { $$ = $2; }
1047 | %prec "if" { $$ = NULL; }
1051 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1055 : DoWhileStatement { $$ = $1; }
1056 | WhileStatement { $$ = $1; }
1057 | ForStatement { $$ = $1; }
1058 | ForInStatement { $$ = $1; }
1062 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1066 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1070 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1073 ForStatementInitialiser
1074 : ExpressionNoInOpt { $$ = $1; }
1075 | "var" VariableDeclarationListNoIn { $$ = $2; }
1079 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1082 ForInStatementInitialiser
1083 : LeftHandSideExpression { $$ = $1; }
1084 | "var" VariableDeclarationNoIn { $$ = $2; }
1088 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1092 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1096 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1100 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1104 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1108 : "{" CaseClausesOpt "}" { $$ = $2; }
1112 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1113 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1118 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1122 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1126 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1130 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1134 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1138 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1143 : "finally" Block { $$ = $2; }
1148 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1152 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1155 FormalParameterList_
1156 : "," FormalParameterList { $$ = $2; }
1161 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1166 : SourceElements { $$ = $1; }
1170 : SourceElements { driver.source_ = $1; }
1174 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1179 : Statement { $$ = $1; }
1180 | FunctionDeclaration { $$ = $1; }
1183 /* Objective-C Extensions {{{ */
1185 : ":" MemberExpressionNoBF { $$ = $2; }
1190 : "{" "}" { $$ = NULL; }
1194 : "+" { $$ = false; }
1195 | "-" { $$ = true; }
1199 : "(" Expression ")" { $$ = $2; }
1204 : Word ":" TypeOpt Identifier { $$ = new CYMessageParameter($1, $3, $4); }
1207 MessageParameterListOpt
1208 : MessageParameterList { $$ = $1; }
1212 MessageParameterList
1213 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1217 : MessageParameterList { $$ = $1; }
1218 | Word { $$ = new CYMessageParameter($1, NULL, NULL); }
1221 ClassMessageDeclaration
1222 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new CYMessage($1, $2, $3, $5); }
1225 ClassMessageDeclarationListOpt
1226 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1231 : "@class" Identifier ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new CYClass($2, $3, $4, $5); }
1235 : ClassDeclaration { $$ = $1; }
1239 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1244 : SelectorCall { $$ = $1; }
1245 | VariadicCall { $$ = $1; }
1249 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1253 : SelectorCall { $$ = $1; }
1254 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1258 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1261 SelectorExpressionOpt
1262 : SelectorExpression_ { $$ = $1; }
1267 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1271 : SelectorExpression_ { $$ = $1; }
1272 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1276 : MessageExpression { $$ = $1; }
1277 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1281 LeftHandSideExpression_
1282 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1286 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }