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_;
76 CYMessageParameter *messageParameter_;
79 CYProperty *property_;
80 CYPropertyName *propertyName_;
81 CYSelectorPart *selector_;
83 CYStatement *statement_;
94 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
103 @$.begin.filename = @$.end.filename = &driver.filename_;
111 %parse-param { CYDriver &driver }
112 %lex-param { void *scanner }
115 %token AmpersandAmpersand "&&"
116 %token AmpersandEqual "&="
118 %token CarrotEqual "^="
120 %token EqualEqual "=="
121 %token EqualEqualEqual "==="
122 %token Exclamation "!"
123 %token ExclamationEqual "!="
124 %token ExclamationEqualEqual "!=="
126 %token HyphenEqual "-="
127 %token HyphenHyphen "--"
128 %token HyphenHyphen_ "\n--"
129 %token HyphenRight "->"
131 %token LeftEqual "<="
133 %token LeftLeftEqual "<<="
135 %token PercentEqual "%="
138 %token PipeEqual "|="
141 %token PlusEqual "+="
143 %token PlusPlus_ "\n++"
145 %token RightEqual ">="
146 %token RightRight ">>"
147 %token RightRightEqual ">>="
148 %token RightRightRight ">>>"
149 %token RightRightRightEqual ">>>="
151 %token SlashEqual "/="
153 %token StarEqual "*="
163 %token CloseParen ")"
166 %token CloseBrace "}"
168 %token OpenBracket "["
169 %token CloseBracket "]"
171 %token AtClass "@class"
172 %token AtSelector "@selector"
175 %token <word_> Break "break"
176 %token <word_> Case "case"
177 %token <word_> Catch "catch"
178 %token <word_> Continue "continue"
179 %token <word_> Default "default"
180 %token <word_> Delete "delete"
181 %token <word_> Do "do"
182 %token <word_> Else "else"
183 %token <false_> False "false"
184 %token <word_> Finally "finally"
185 %token <word_> For "for"
186 %token <word_> Function "function"
187 %token <word_> If "if"
188 %token <word_> In "in"
189 %token <word_> InstanceOf "instanceof"
190 %token <word_> New "new"
191 %token <null_> Null "null"
192 %token <word_> Return "return"
193 %token <word_> Switch "switch"
194 %token <this_> This "this"
195 %token <word_> Throw "throw"
196 %token <true_> True "true"
197 %token <word_> Try "try"
198 %token <word_> TypeOf "typeof"
199 %token <word_> Var "var"
200 %token <word_> Void "void"
201 %token <word_> While "while"
202 %token <word_> With "with"
204 %token <word_> Abstract "abstract"
205 %token <word_> Boolean "boolean"
206 %token <word_> Byte "byte"
207 %token <word_> Char "char"
208 %token <word_> Class "class"
209 %token <word_> Const "const"
210 %token <word_> Debugger "debugger"
211 %token <word_> Double "double"
212 %token <word_> Enum "enum"
213 %token <word_> Export "export"
214 %token <word_> Extends "extends"
215 %token <word_> Final "final"
216 %token <word_> Float "float"
217 %token <word_> Goto "goto"
218 %token <word_> Implements "implements"
219 %token <word_> Import "import"
220 %token <word_> Int "int"
221 %token <word_> Interface "interface"
222 %token <word_> Long "long"
223 %token <word_> Native "native"
224 %token <word_> Package "package"
225 %token <word_> Private "private"
226 %token <word_> Protected "protected"
227 %token <word_> Public "public"
228 %token <word_> Short "short"
229 %token <word_> Static "static"
230 %token <word_> Super "super"
231 %token <word_> Synchronized "synchronized"
232 %token <word_> Throws "throws"
233 %token <word_> Transient "transient"
234 %token <word_> Volatile "volatile"
236 %token <identifier_> Identifier
237 %token <number_> NumericLiteral
238 %token <string_> StringLiteral
240 %type <expression_> AdditiveExpression
241 %type <expression_> AdditiveExpressionNoBF
242 %type <argument_> ArgumentList
243 %type <argument_> ArgumentList_
244 %type <argument_> ArgumentListOpt
245 %type <argument_> Arguments
246 %type <literal_> ArrayLiteral
247 %type <expression_> AssigneeExpression
248 %type <expression_> AssigneeExpression_
249 %type <expression_> AssigneeExpressionNoBF
250 %type <expression_> AssignmentExpression
251 %type <assignment_> AssignmentExpression_
252 %type <expression_> AssignmentExpressionNoBF
253 %type <expression_> AssignmentExpressionNoIn
254 %type <expression_> BitwiseANDExpression
255 %type <expression_> BitwiseANDExpressionNoBF
256 %type <expression_> BitwiseANDExpressionNoIn
257 %type <statement_> Block
258 %type <boolean_> BooleanLiteral
259 %type <expression_> BitwiseORExpression
260 %type <expression_> BitwiseORExpressionNoBF
261 %type <expression_> BitwiseORExpressionNoIn
262 %type <expression_> BitwiseXORExpression
263 %type <expression_> BitwiseXORExpressionNoBF
264 %type <expression_> BitwiseXORExpressionNoIn
265 %type <statement_> BreakStatement
266 %type <expression_> CallExpression
267 %type <expression_> CallExpressionNoBF
268 %type <clause_> CaseBlock
269 %type <clause_> CaseClause
270 %type <clause_> CaseClausesOpt
271 %type <catch_> CatchOpt
272 %type <source_> ClassDeclaration
273 %type <message_> ClassMessageDeclaration
274 %type <message_> ClassMessageDeclarationListOpt
275 %type <className_> ClassName
276 %type <expression_> ClassSuperOpt
277 %type <field_> ClassFieldList
278 %type <expression_> ConditionalExpression
279 %type <expression_> ConditionalExpressionNoBF
280 %type <expression_> ConditionalExpressionNoIn
281 %type <statement_> ContinueStatement
282 %type <clause_> DefaultClause
283 %type <statement_> DoWhileStatement
284 %type <expression_> Element
285 %type <expression_> ElementOpt
286 %type <element_> ElementList
287 %type <element_> ElementListOpt
288 %type <statement_> ElseStatementOpt
289 %type <statement_> EmptyStatement
290 %type <expression_> EqualityExpression
291 %type <expression_> EqualityExpressionNoBF
292 %type <expression_> EqualityExpressionNoIn
293 %type <expression_> Expression
294 %type <expression_> ExpressionOpt
295 %type <compound_> Expression_
296 %type <expression_> ExpressionNoBF
297 %type <expression_> ExpressionNoIn
298 %type <compound_> ExpressionNoIn_
299 %type <expression_> ExpressionNoInOpt
300 %type <statement_> ExpressionStatement
301 %type <statement_> FinallyOpt
302 %type <statement_> ForStatement
303 %type <for_> ForStatementInitialiser
304 %type <statement_> ForInStatement
305 %type <forin_> ForInStatementInitialiser
306 %type <functionParameter_> FormalParameterList
307 %type <functionParameter_> FormalParameterList_
308 %type <source_> FunctionBody
309 %type <source_> FunctionDeclaration
310 %type <expression_> FunctionExpression
311 %type <identifier_> IdentifierOpt
312 %type <statement_> IfStatement
313 %type <expression_> Initialiser
314 %type <expression_> InitialiserOpt
315 %type <expression_> InitialiserNoIn
316 %type <expression_> InitialiserNoInOpt
317 %type <statement_> IterationStatement
318 %type <statement_> LabelledStatement
319 %type <expression_> LeftHandSideExpression
320 %type <expression_> LeftHandSideExpressionNoBF
321 %type <literal_> Literal
322 %type <expression_> LogicalANDExpression
323 %type <expression_> LogicalANDExpressionNoBF
324 %type <expression_> LogicalANDExpressionNoIn
325 %type <expression_> LogicalORExpression
326 %type <expression_> LogicalORExpressionNoBF
327 %type <expression_> LogicalORExpressionNoIn
328 %type <member_> MemberAccess
329 %type <expression_> MemberExpression
330 %type <expression_> MemberExpression_
331 %type <expression_> MemberExpressionNoBF
332 %type <messageParameter_> MessageParameter
333 %type <messageParameter_> MessageParameters
334 %type <messageParameter_> MessageParameterList
335 %type <messageParameter_> MessageParameterListOpt
336 %type <bool_> MessageScope
337 %type <expression_> MultiplicativeExpression
338 %type <expression_> MultiplicativeExpressionNoBF
339 %type <expression_> NewExpression
340 %type <expression_> NewExpression_
341 %type <expression_> NewExpressionNoBF
342 %type <null_> NullLiteral
343 %type <literal_> ObjectLiteral
344 %type <expression_> PostfixExpression
345 %type <expression_> PostfixExpressionNoBF
346 %type <expression_> PrimaryExpression
347 %type <expression_> PrimaryExpression_
348 %type <expression_> PrimaryExpressionNoBF
349 %type <source_> Program
350 %type <propertyName_> PropertyName
351 %type <property_> PropertyNameAndValueList
352 %type <property_> PropertyNameAndValueList_
353 %type <property_> PropertyNameAndValueListOpt
354 %type <expression_> RelationalExpression
355 %type <infix_> RelationalExpression_
356 %type <expression_> RelationalExpressionNoBF
357 %type <expression_> RelationalExpressionNoIn
358 %type <infix_> RelationalExpressionNoIn_
359 %type <statement_> ReturnStatement
360 %type <selector_> SelectorExpression
361 %type <selector_> SelectorExpression_
362 %type <selector_> SelectorExpressionOpt
363 %type <expression_> ShiftExpression
364 %type <expression_> ShiftExpressionNoBF
365 %type <source_> SourceElement
366 %type <source_> SourceElements
367 %type <statement_> Statement
368 %type <statement_> StatementList
369 %type <statement_> StatementListOpt
370 %type <statement_> SwitchStatement
371 %type <statement_> ThrowStatement
372 %type <statement_> TryStatement
373 %type <expression_> TypeOpt
374 %type <expression_> UnaryExpression
375 %type <expression_> UnaryExpression_
376 %type <expression_> UnaryExpressionNoBF
377 %type <declaration_> VariableDeclaration
378 %type <declaration_> VariableDeclarationNoIn
379 %type <declarations_> VariableDeclarationList
380 %type <declarations_> VariableDeclarationList_
381 %type <declarations_> VariableDeclarationListNoIn
382 %type <declarations_> VariableDeclarationListNoIn_
383 %type <statement_> VariableStatement
384 %type <statement_> WhileStatement
385 %type <statement_> WithStatement
387 %type <word_> WordOpt
389 %type <expression_> MessageExpression
390 %type <argument_> SelectorCall
391 %type <argument_> SelectorCall_
392 %type <argument_> SelectorList
393 %type <argument_> VariadicCall
397 %left "<<" ">>" ">>>"
398 %left "<" ">" "<=" ">=" "instanceof" "in"
399 %left "==" "!=" "===" "!=="
406 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
418 | error { yyerrok; driver.errors_.pop_back(); }
424 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
443 : Identifier { $$ = $1; }
444 | "abstract" { $$ = $1; }
445 | "boolean" { $$ = $1; }
446 | "break" NewLineOpt { $$ = $1; }
447 | "byte" { $$ = $1; }
448 | "case" { $$ = $1; }
449 | "catch" { $$ = $1; }
450 | "char" { $$ = $1; }
451 | "class" { $$ = $1; }
452 | "const" { $$ = $1; }
453 | "continue" NewLineOpt { $$ = $1; }
454 | "debugger" { $$ = $1; }
455 | "default" { $$ = $1; }
456 | "delete" { $$ = $1; }
458 | "double" { $$ = $1; }
459 | "else" { $$ = $1; }
460 | "enum" { $$ = $1; }
461 | "export" { $$ = $1; }
462 | "extends" { $$ = $1; }
463 | "false" { $$ = $1; }
464 | "final" { $$ = $1; }
465 | "finally" { $$ = $1; }
466 | "float" { $$ = $1; }
468 | "function" { $$ = $1; }
469 | "goto" { $$ = $1; }
471 | "implements" { $$ = $1; }
472 | "import" { $$ = $1; }
473 /* XXX: | "in" { $$ = $1; } */
474 /* XXX: | "instanceof" { $$ = $1; } */
476 | "interface" { $$ = $1; }
477 | "long" { $$ = $1; }
478 | "native" { $$ = $1; }
480 | "null" { $$ = $1; }
481 | "package" { $$ = $1; }
482 | "private" { $$ = $1; }
483 | "protected" { $$ = $1; }
484 | "public" { $$ = $1; }
485 | "return" NewLineOpt { $$ = $1; }
486 | "short" { $$ = $1; }
487 | "static" { $$ = $1; }
488 | "super" { $$ = $1; }
489 | "switch" { $$ = $1; }
490 | "synchronized" { $$ = $1; }
491 | "this" { $$ = $1; }
492 | "throw" NewLineOpt { $$ = $1; }
493 | "throws" { $$ = $1; }
494 | "transient" { $$ = $1; }
495 | "true" { $$ = $1; }
497 | "typeof" { $$ = $1; }
499 | "void" { $$ = $1; }
500 | "volatile" { $$ = $1; }
501 | "while" { $$ = $1; }
502 | "with" { $$ = $1; }
506 : Identifier { $$ = $1; }
511 : NullLiteral { $$ = $1; }
512 | BooleanLiteral { $$ = $1; }
513 | NumericLiteral { $$ = $1; }
514 | StringLiteral { $$ = $1; }
518 : "null" { $$ = $1; }
522 : "true" { $$ = $1; }
523 | "false" { $$ = $1; }
526 /* 11.1 Primary Expressions {{{ */
528 : "this" { $$ = $1; }
529 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
530 | Literal { $$ = $1; }
531 | ArrayLiteral { $$ = $1; }
532 | "(" Expression ")" { $$ = $2; }
536 : ObjectLiteral { $$ = $1; }
537 | PrimaryExpression_ { $$ = $1; }
540 PrimaryExpressionNoBF
541 : PrimaryExpression_ { $$ = $1; }
544 /* 11.1.4 Array Initialiser {{{ */
546 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
550 : AssignmentExpression { $$ = $1; }
554 : Element { $$ = $1; }
559 : ElementList { $$ = $1; }
564 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
565 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
568 /* 11.1.5 Object Initialiser {{{ */
570 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
573 PropertyNameAndValueList_
574 : "," PropertyNameAndValueList { $$ = $2; }
575 | CommaOpt { $$ = NULL; }
578 PropertyNameAndValueListOpt
579 : PropertyNameAndValueList { $$ = $1; }
583 PropertyNameAndValueList
584 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
588 : Identifier { $$ = $1; }
589 | StringLiteral { $$ = $1; }
590 | NumericLiteral { $$ = $1; }
595 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
599 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
600 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
604 : PrimaryExpression { $$ = $1; }
605 | FunctionExpression { $$ = $1; }
606 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
607 | MemberExpression_ { $$ = $1; }
611 : PrimaryExpressionNoBF { $$ = $1; }
612 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
613 | MemberExpression_ { $$ = $1; }
617 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
621 : MemberExpression { $$ = $1; }
622 | NewExpression_ { $$ = $1; }
626 : MemberExpressionNoBF { $$ = $1; }
627 | NewExpression_ { $$ = $1; }
631 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
632 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
633 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
637 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
638 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
639 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
643 : "," ArgumentList { $$ = $2; }
648 : ArgumentList { $$ = $1; }
653 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
657 : "(" ArgumentListOpt ")" { $$ = $2; }
660 LeftHandSideExpression
661 : NewExpression { $$ = $1; }
662 | CallExpression { $$ = $1; }
665 LeftHandSideExpressionNoBF
666 : NewExpressionNoBF { $$ = $1; }
667 | CallExpressionNoBF { $$ = $1; }
671 : AssigneeExpression { $$ = $1; }
672 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
673 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
676 PostfixExpressionNoBF
677 : AssigneeExpressionNoBF { $$ = $1; }
678 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
679 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
683 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
684 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
685 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
686 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
687 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
688 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
689 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
690 | "+" UnaryExpression { $$ = $2; }
691 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
692 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
693 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
697 : PostfixExpression { $$ = $1; }
698 | UnaryExpression_ { $$ = $1; }
702 : PostfixExpressionNoBF { $$ = $1; }
703 | UnaryExpression_ { $$ = $1; }
706 MultiplicativeExpression
707 : UnaryExpression { $$ = $1; }
708 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
709 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
710 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
713 MultiplicativeExpressionNoBF
714 : UnaryExpressionNoBF { $$ = $1; }
715 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
716 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
717 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
721 : MultiplicativeExpression { $$ = $1; }
722 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
723 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
726 AdditiveExpressionNoBF
727 : MultiplicativeExpressionNoBF { $$ = $1; }
728 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
729 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
733 : AdditiveExpression { $$ = $1; }
734 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
735 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
736 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
740 : AdditiveExpressionNoBF { $$ = $1; }
741 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
742 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
743 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
746 RelationalExpressionNoIn_
747 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
748 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
749 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
750 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
751 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
754 RelationalExpression_
755 : RelationalExpressionNoIn_ { $$ = $1; }
756 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
760 : ShiftExpression { $$ = $1; }
761 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
764 RelationalExpressionNoIn
765 : ShiftExpression { $$ = $1; }
766 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
769 RelationalExpressionNoBF
770 : ShiftExpressionNoBF { $$ = $1; }
771 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
775 : RelationalExpression { $$ = $1; }
776 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
777 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
778 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
779 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
782 EqualityExpressionNoIn
783 : RelationalExpressionNoIn { $$ = $1; }
784 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
785 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
786 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
787 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
790 EqualityExpressionNoBF
791 : RelationalExpressionNoBF { $$ = $1; }
792 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
793 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
794 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
795 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
799 : EqualityExpression { $$ = $1; }
800 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
803 BitwiseANDExpressionNoIn
804 : EqualityExpressionNoIn { $$ = $1; }
805 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
808 BitwiseANDExpressionNoBF
809 : EqualityExpressionNoBF { $$ = $1; }
810 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
814 : BitwiseANDExpression { $$ = $1; }
815 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
818 BitwiseXORExpressionNoIn
819 : BitwiseANDExpressionNoIn { $$ = $1; }
820 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
823 BitwiseXORExpressionNoBF
824 : BitwiseANDExpressionNoBF { $$ = $1; }
825 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
829 : BitwiseXORExpression { $$ = $1; }
830 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
833 BitwiseORExpressionNoIn
834 : BitwiseXORExpressionNoIn { $$ = $1; }
835 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
838 BitwiseORExpressionNoBF
839 : BitwiseXORExpressionNoBF { $$ = $1; }
840 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
844 : BitwiseORExpression { $$ = $1; }
845 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
848 LogicalANDExpressionNoIn
849 : BitwiseORExpressionNoIn { $$ = $1; }
850 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
853 LogicalANDExpressionNoBF
854 : BitwiseORExpressionNoBF { $$ = $1; }
855 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
859 : LogicalANDExpression { $$ = $1; }
860 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
863 LogicalORExpressionNoIn
864 : LogicalANDExpressionNoIn { $$ = $1; }
865 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
868 LogicalORExpressionNoBF
869 : LogicalANDExpressionNoBF { $$ = $1; }
870 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
873 ConditionalExpression
874 : LogicalORExpression { $$ = $1; }
875 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
878 ConditionalExpressionNoIn
879 : LogicalORExpressionNoIn { $$ = $1; }
880 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
883 ConditionalExpressionNoBF
884 : LogicalORExpressionNoBF { $$ = $1; }
885 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
888 AssignmentExpression_
889 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
890 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
891 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
892 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
893 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
894 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
895 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
896 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
897 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
898 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
899 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
900 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
904 : LeftHandSideExpression { $$ = $1; }
905 | AssigneeExpression_ { $$ = $1; }
908 AssigneeExpressionNoBF
909 : LeftHandSideExpressionNoBF { $$ = $1; }
910 | AssigneeExpression_ { $$ = $1; }
914 : ConditionalExpression { $$ = $1; }
915 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
918 AssignmentExpressionNoIn
919 : ConditionalExpressionNoIn { $$ = $1; }
920 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
921 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
922 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
923 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
924 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
925 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
926 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
927 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
928 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
929 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
930 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
931 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
934 AssignmentExpressionNoBF
935 : ConditionalExpressionNoBF { $$ = $1; }
936 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
940 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
945 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
950 : Expression { $$ = $1; }
955 : ExpressionNoIn { $$ = $1; }
960 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
964 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
968 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
973 | VariableStatement { $$ = $1; }
974 | EmptyStatement { $$ = $1; }
975 | ExpressionStatement { $$ = $1; }
976 | IfStatement { $$ = $1; }
977 | IterationStatement { $$ = $1; }
978 | ContinueStatement { $$ = $1; }
979 | BreakStatement { $$ = $1; }
980 | ReturnStatement { $$ = $1; }
981 | WithStatement { $$ = $1; }
982 | LabelledStatement { $$ = $1; }
983 | SwitchStatement { $$ = $1; }
984 | ThrowStatement { $$ = $1; }
985 | TryStatement { $$ = $1; }
989 : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
993 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
997 : StatementList { $$ = $1; }
1002 : "var" VariableDeclarationList Terminator { $$ = $2; }
1005 VariableDeclarationList_
1006 : "," VariableDeclarationList { $$ = $2; }
1010 VariableDeclarationListNoIn_
1011 : "," VariableDeclarationListNoIn { $$ = $2; }
1015 VariableDeclarationList
1016 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1019 VariableDeclarationListNoIn
1020 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1024 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1027 VariableDeclarationNoIn
1028 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1032 : Initialiser { $$ = $1; }
1037 : InitialiserNoIn { $$ = $1; }
1042 : "=" AssignmentExpression { $$ = $2; }
1046 : "=" AssignmentExpressionNoIn { $$ = $2; }
1050 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1054 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1058 : "else" Statement { $$ = $2; }
1059 | %prec "if" { $$ = NULL; }
1063 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1067 : DoWhileStatement { $$ = $1; }
1068 | WhileStatement { $$ = $1; }
1069 | ForStatement { $$ = $1; }
1070 | ForInStatement { $$ = $1; }
1074 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1078 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1082 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1085 ForStatementInitialiser
1086 : ExpressionNoInOpt { $$ = $1; }
1087 | "var" VariableDeclarationListNoIn { $$ = $2; }
1091 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1094 ForInStatementInitialiser
1095 : LeftHandSideExpression { $$ = $1; }
1096 | "var" VariableDeclarationNoIn { $$ = $2; }
1100 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1104 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1108 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1112 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1116 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1120 : "{" CaseClausesOpt "}" { $$ = $2; }
1124 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1125 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1130 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1134 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1138 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1142 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1146 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1150 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1155 : "finally" Block { $$ = $2; }
1160 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1164 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1167 FormalParameterList_
1168 : "," FormalParameterList { $$ = $2; }
1173 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1178 : SourceElements { $$ = $1; }
1182 : SourceElements { driver.source_ = $1; }
1186 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1191 : Statement { $$ = $1; }
1192 | FunctionDeclaration { $$ = $1; }
1195 /* Objective-C Extensions {{{ */
1197 : ":" MemberExpressionNoBF { $$ = $2; }
1202 : "{" "}" { $$ = NULL; }
1206 : "+" { $$ = false; }
1207 | "-" { $$ = true; }
1211 : "(" Expression ")" { $$ = $2; }
1216 : Word ":" TypeOpt Identifier { $$ = new CYMessageParameter($1, $3, $4); }
1219 MessageParameterListOpt
1220 : MessageParameterList { $$ = $1; }
1224 MessageParameterList
1225 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1229 : MessageParameterList { $$ = $1; }
1230 | Word { $$ = new CYMessageParameter($1, NULL, NULL); }
1233 ClassMessageDeclaration
1234 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new CYMessage($1, $2, $3, $5); }
1237 ClassMessageDeclarationListOpt
1238 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1243 : Identifier { $$ = $1; }
1244 | "(" AssignmentExpression ")" { $$ = $2; }
1248 : "@class" Identifier ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new CYClass($2, $3, $4, $5); }
1249 | "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new CYCategory($2, $3); }
1253 : ClassDeclaration { $$ = $1; }
1257 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1262 : SelectorCall { $$ = $1; }
1263 | VariadicCall { $$ = $1; }
1267 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1271 : SelectorCall { $$ = $1; }
1272 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1276 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1279 SelectorExpressionOpt
1280 : SelectorExpression_ { $$ = $1; }
1285 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1289 : SelectorExpression_ { $$ = $1; }
1290 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1294 : MessageExpression { $$ = $1; }
1295 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1300 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
1304 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1308 : "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }