1 /* Cycript - Inlining/Optimizing JavaScript Compiler
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
50 #include "ObjectiveC/Syntax.hpp"
54 #include "E4X/Syntax.hpp"
63 CYDriver::Condition condition_;
65 CYArgument *argument_;
66 CYAssignment *assignment_;
69 cy::Syntax::Catch *catch_;
70 CYComprehension *comprehension_;
71 CYCompound *compound_;
72 CYDeclaration *declaration_;
73 CYDeclarations *declarations_;
75 CYExpression *expression_;
78 CYForInitialiser *for_;
79 CYForInInitialiser *forin_;
80 CYFunctionParameter *functionParameter_;
81 CYIdentifier *identifier_;
88 CYProperty *property_;
89 CYPropertyName *propertyName_;
90 CYStatement *statement_;
97 CYClassName *className_;
100 CYMessageParameter *messageParameter_;
101 CYSelectorPart *selector_;
105 CYAttribute *attribute_;
106 CYPropertyIdentifier *propertyIdentifier_;
107 CYSelector *selector_;
115 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
124 @$.begin.filename = @$.end.filename = &driver.filename_;
134 %parse-param { CYDriver &driver }
135 %lex-param { void *scanner }
142 %token XMLAttributeValue
144 %token XMLTagCharacters
150 %token LeftRight "<>"
151 %token LeftSlashRight "</>"
153 %token SlashRight "/>"
154 %token LeftSlash "</"
156 %token ColonColon "::"
157 %token PeriodPeriod ".."
160 @begin E4X ObjectiveC
165 %token AmpersandAmpersand "&&"
166 %token AmpersandEqual "&="
168 %token CarrotEqual "^="
170 %token EqualEqual "=="
171 %token EqualEqualEqual "==="
172 %token Exclamation "!"
173 %token ExclamationEqual "!="
174 %token ExclamationEqualEqual "!=="
176 %token HyphenEqual "-="
177 %token HyphenHyphen "--"
178 %token HyphenHyphen_ "\n--"
179 %token HyphenRight "->"
181 %token LeftEqual "<="
183 %token LeftLeftEqual "<<="
185 %token PercentEqual "%="
188 %token PipeEqual "|="
191 %token PlusEqual "+="
193 %token PlusPlus_ "\n++"
195 %token RightEqual ">="
196 %token RightRight ">>"
197 %token RightRightEqual ">>="
198 %token RightRightRight ">>>"
199 %token RightRightRightEqual ">>>="
201 %token SlashEqual "/="
203 %token StarEqual "*="
213 %token CloseParen ")"
216 %token CloseBrace "}"
218 %token OpenBracket "["
219 %token CloseBracket "]"
221 %token AtClass "@class"
222 %token AtSelector "@selector"
225 %token <false_> False "false"
226 %token <null_> Null "null"
227 %token <true_> True "true"
229 // ES3/ES5/WIE/JSC Reserved
230 %token <word_> Break "break"
231 %token <word_> Case "case"
232 %token <word_> Catch "catch"
233 %token <word_> Continue "continue"
234 %token <word_> Default "default"
235 %token <word_> Delete "delete"
236 %token <word_> Do "do"
237 %token <word_> Else "else"
238 %token <word_> Finally "finally"
239 %token <word_> For "for"
240 %token <word_> Function "function"
241 %token <word_> If "if"
242 %token <word_> In "in"
243 %token <word_> InstanceOf "instanceof"
244 %token <word_> New "new"
245 %token <word_> Return "return"
246 %token <word_> Switch "switch"
247 %token <this_> This "this"
248 %token <word_> Throw "throw"
249 %token <word_> Try "try"
250 %token <word_> TypeOf "typeof"
251 %token <word_> Var "var"
252 %token <word_> Void "void"
253 %token <word_> While "while"
254 %token <word_> With "with"
256 // ES3/IE6 Future, ES5/JSC Reserved
257 %token <word_> Debugger "debugger"
259 // ES3/ES5/IE6 Future, JSC Reserved
260 %token <word_> Const "const"
262 // ES3/ES5/IE6/JSC Future
263 %token <word_> Class "class"
264 %token <word_> Enum "enum"
265 %token <word_> Export "export"
266 %token <word_> Extends "extends"
267 %token <word_> Import "import"
268 %token <word_> Super "super"
270 // ES3 Future, ES5 Strict Future
271 %token <identifier_> Implements "implements"
272 %token <identifier_> Interface "interface"
273 %token <identifier_> Package "package"
274 %token <identifier_> Private "private"
275 %token <identifier_> Protected "protected"
276 %token <identifier_> Public "public"
277 %token <identifier_> Static "static"
280 %token <identifier_> Abstract "abstract"
281 %token <identifier_> Boolean "boolean"
282 %token <identifier_> Byte "byte"
283 %token <identifier_> Char "char"
284 %token <identifier_> Double "double"
285 %token <identifier_> Final "final"
286 %token <identifier_> Float "float"
287 %token <identifier_> Goto "goto"
288 %token <identifier_> Int "int"
289 %token <identifier_> Long "long"
290 %token <identifier_> Native "native"
291 %token <identifier_> Short "short"
292 %token <identifier_> Synchronized "synchronized"
293 %token <identifier_> Throws "throws"
294 %token <identifier_> Transient "transient"
295 %token <identifier_> Volatile "volatile"
298 %token <identifier_> Let "let"
299 %token <identifier_> Yield "yield"
302 %token <identifier_> Each "each"
306 %token <identifier_> Namespace "namespace"
307 %token <identifier_> XML "xml"
310 %token <identifier_> Identifier_
311 %token <number_> NumericLiteral
312 %token <string_> StringLiteral
313 %token <literal_> RegularExpressionLiteral
315 %type <expression_> AdditiveExpression
316 %type <expression_> AdditiveExpressionNoBF
317 %type <argument_> ArgumentList
318 %type <argument_> ArgumentList_
319 %type <argument_> ArgumentListOpt
320 %type <argument_> Arguments
321 %type <literal_> ArrayLiteral
322 %type <expression_> AssigneeExpression
323 %type <expression_> AssigneeExpressionNoBF
324 %type <expression_> AssigneeExpressionNoRE
325 %type <expression_> AssignmentExpression
326 %type <assignment_> AssignmentExpression_
327 %type <expression_> AssignmentExpressionNoBF
328 %type <expression_> AssignmentExpressionNoIn
329 %type <expression_> BitwiseANDExpression
330 %type <expression_> BitwiseANDExpressionNoBF
331 %type <expression_> BitwiseANDExpressionNoIn
332 %type <statement_> Block
333 %type <statement_> Block_
334 %type <boolean_> BooleanLiteral
335 %type <expression_> BitwiseORExpression
336 %type <expression_> BitwiseORExpressionNoBF
337 %type <expression_> BitwiseORExpressionNoIn
338 %type <expression_> BitwiseXORExpression
339 %type <expression_> BitwiseXORExpressionNoBF
340 %type <expression_> BitwiseXORExpressionNoIn
341 %type <statement_> BreakStatement
342 %type <expression_> CallExpression
343 %type <expression_> CallExpressionNoBF
344 %type <expression_> CallExpressionNoRE
345 %type <clause_> CaseBlock
346 %type <clause_> CaseClause
347 %type <clause_> CaseClausesOpt
348 %type <catch_> CatchOpt
349 %type <comprehension_> ComprehensionList
350 %type <comprehension_> ComprehensionListOpt
351 %type <expression_> ConditionalExpression
352 %type <expression_> ConditionalExpressionNoBF
353 %type <expression_> ConditionalExpressionNoIn
354 %type <statement_> ContinueStatement
355 %type <clause_> DefaultClause
356 %type <statement_> DoWhileStatement
357 %type <expression_> Element
358 %type <expression_> ElementOpt
359 %type <element_> ElementList
360 %type <element_> ElementListOpt
361 %type <statement_> ElseStatementOpt
362 %type <statement_> EmptyStatement
363 %type <expression_> EqualityExpression
364 %type <expression_> EqualityExpressionNoBF
365 %type <expression_> EqualityExpressionNoIn
366 %type <expression_> Expression
367 %type <expression_> ExpressionOpt
368 %type <compound_> Expression_
369 %type <expression_> ExpressionNoBF
370 %type <expression_> ExpressionNoIn
371 %type <compound_> ExpressionNoIn_
372 %type <expression_> ExpressionNoInOpt
373 %type <statement_> ExpressionStatement
374 %type <finally_> FinallyOpt
375 %type <comprehension_> ForComprehension
376 %type <statement_> ForStatement
377 %type <for_> ForStatementInitialiser
378 %type <statement_> ForInStatement
379 %type <forin_> ForInStatementInitialiser
380 %type <functionParameter_> FormalParameterList
381 %type <functionParameter_> FormalParameterList_
382 %type <statement_> FunctionBody
383 %type <statement_> FunctionDeclaration
384 %type <expression_> FunctionExpression
385 %type <identifier_> Identifier
386 %type <identifier_> IdentifierOpt
387 %type <comprehension_> IfComprehension
388 %type <statement_> IfStatement
389 %type <expression_> Initialiser
390 %type <expression_> InitialiserOpt
391 %type <expression_> InitialiserNoIn
392 %type <expression_> InitialiserNoInOpt
393 %type <statement_> IterationStatement
394 %type <statement_> LabelledStatement
395 %type <expression_> LeftHandSideExpression
396 %type <expression_> LeftHandSideExpressionNoBF
397 %type <expression_> LeftHandSideExpressionNoRE
398 //%type <statement_> LetStatement
399 %type <literal_> Literal
400 %type <literal_> LiteralNoRE
401 %type <literal_> LiteralRE
402 %type <expression_> LogicalANDExpression
403 %type <expression_> LogicalANDExpressionNoBF
404 %type <expression_> LogicalANDExpressionNoIn
405 %type <expression_> LogicalORExpression
406 %type <expression_> LogicalORExpressionNoBF
407 %type <expression_> LogicalORExpressionNoIn
408 %type <member_> MemberAccess
409 %type <expression_> MemberExpression
410 %type <expression_> MemberExpression_
411 %type <expression_> MemberExpressionNoBF
412 %type <expression_> MemberExpressionNoRE
413 %type <expression_> MultiplicativeExpression
414 %type <expression_> MultiplicativeExpressionNoBF
415 %type <expression_> NewExpression
416 %type <expression_> NewExpression_
417 %type <expression_> NewExpressionNoBF
418 %type <expression_> NewExpressionNoRE
419 %type <null_> NullLiteral
420 %type <literal_> ObjectLiteral
421 %type <expression_> PostfixExpression
422 %type <expression_> PostfixExpressionNoBF
423 %type <expression_> PostfixExpressionNoRE
424 %type <expression_> PrimaryExpression
425 %type <expression_> PrimaryExpressionNo
426 %type <expression_> PrimaryExpressionNoBF
427 %type <expression_> PrimaryExpressionNoRE
428 %type <expression_> PrimaryExpressionBF
429 %type <statement_> Program
430 %type <propertyName_> PropertyName
431 %type <propertyName_> PropertyName_
432 %type <property_> PropertyNameAndValueList
433 %type <property_> PropertyNameAndValueList_
434 %type <property_> PropertyNameAndValueListOpt
435 %type <expression_> RelationalExpression
436 %type <infix_> RelationalExpression_
437 %type <expression_> RelationalExpressionNoBF
438 %type <expression_> RelationalExpressionNoIn
439 %type <infix_> RelationalExpressionNoIn_
440 %type <statement_> ReturnStatement
441 %type <expression_> ShiftExpression
442 %type <expression_> ShiftExpressionNoBF
443 %type <statement_> SourceElement
444 %type <statement_> SourceElement_
445 %type <statement_> SourceElements
446 %type <statement_> Statement
447 %type <statement_> Statement_
448 %type <statement_> StatementList
449 %type <statement_> StatementListOpt
450 %type <statement_> SwitchStatement
451 %type <statement_> ThrowStatement
452 %type <statement_> TryStatement
453 %type <expression_> UnaryAssigneeExpression
454 %type <expression_> UnaryExpression
455 %type <expression_> UnaryExpression_
456 %type <expression_> UnaryExpressionNoBF
457 %type <expression_> UnaryExpressionNoRE
458 %type <declaration_> VariableDeclaration
459 %type <declaration_> VariableDeclarationNoIn
460 %type <declarations_> VariableDeclarationList
461 %type <declarations_> VariableDeclarationList_
462 %type <declarations_> VariableDeclarationListNoIn
463 %type <declarations_> VariableDeclarationListNoIn_
464 %type <statement_> VariableStatement
465 %type <statement_> WhileStatement
466 %type <statement_> WithStatement
469 %type <statement_> CategoryStatement
470 %type <expression_> ClassExpression
471 %type <statement_> ClassStatement
472 %type <expression_> ClassSuperOpt
473 %type <field_> ClassFieldList
474 %type <message_> ClassMessageDeclaration
475 %type <message_> ClassMessageDeclarationListOpt
476 %type <className_> ClassName
477 %type <className_> ClassNameOpt
478 %type <expression_> MessageExpression
479 %type <messageParameter_> MessageParameter
480 %type <messageParameter_> MessageParameters
481 %type <messageParameter_> MessageParameterList
482 %type <messageParameter_> MessageParameterListOpt
483 %type <bool_> MessageScope
484 %type <argument_> SelectorCall
485 %type <argument_> SelectorCall_
486 %type <selector_> SelectorExpression
487 %type <selector_> SelectorExpression_
488 %type <selector_> SelectorExpressionOpt
489 %type <argument_> SelectorList
490 %type <expression_> TypeOpt
491 %type <argument_> VariadicCall
493 %type <word_> WordOpt
497 %type <propertyIdentifier_> PropertyIdentifier_
498 %type <selector_> PropertySelector
499 %type <selector_> PropertySelector_
500 %type <identifier_> QualifiedIdentifier
501 %type <identifier_> QualifiedIdentifier_
502 %type <identifier_> WildcardIdentifier
503 %type <identifier_> XMLComment
504 %type <identifier_> XMLCDATA
505 %type <identifier_> XMLElement
506 %type <identifier_> XMLElementContent
507 %type <identifier_> XMLMarkup
508 %type <identifier_> XMLPI
510 %type <attribute_> AttributeIdentifier
511 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
512 %type <expression_> PropertyIdentifier
513 %type <expression_> XMLListInitialiser
514 %type <expression_> XMLInitialiser
517 %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield"
527 %left "<<" ">>" ">>>"
528 %left "<" ">" "<=" ">=" "instanceof" "in"
529 %left "==" "!=" "===" "!=="
536 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
542 /* Lexer State {{{ */
544 : { driver.SetCondition(CYDriver::RegExpCondition); }
549 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
559 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
564 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
584 : Identifier { $$ = $1; }
585 | "break" NewLineOpt { $$ = $1; }
586 | "case" { $$ = $1; }
587 | "catch" { $$ = $1; }
588 | "class" { $$ = $1; }
589 | "const" { $$ = $1; }
590 | "continue" NewLineOpt { $$ = $1; }
591 | "debugger" { $$ = $1; }
592 | "default" { $$ = $1; }
593 | "delete" { $$ = $1; }
595 | "else" { $$ = $1; }
596 | "enum" { $$ = $1; }
597 | "export" { $$ = $1; }
598 | "extends" { $$ = $1; }
599 | "false" { $$ = $1; }
600 | "finally" { $$ = $1; }
601 /* XXX: | "for" { $$ = $1; } */
602 | "function" { $$ = $1; }
604 | "import" { $$ = $1; }
605 /* XXX: | "in" { $$ = $1; } */
606 /* XXX: | "instanceof" { $$ = $1; } */
608 | "null" { $$ = $1; }
609 | "return" NewLineOpt { $$ = $1; }
610 | "super" { $$ = $1; }
611 | "switch" { $$ = $1; }
612 | "this" { $$ = $1; }
613 | "throw" NewLineOpt { $$ = $1; }
614 | "true" { $$ = $1; }
616 | "typeof" { $$ = $1; }
618 | "void" { $$ = $1; }
619 | "while" { $$ = $1; }
620 | "with" { $$ = $1; }
625 : Identifier_ { $$ = $1; }
627 | "implements" { $$ = $1; }
628 | "interface" { $$ = $1; }
629 | "package" { $$ = $1; }
630 | "private" { $$ = $1; }
631 | "protected" { $$ = $1; }
632 | "public" { $$ = $1; }
633 | "static" { $$ = $1; }
635 | "abstract" { $$ = $1; }
636 | "boolean" { $$ = $1; }
637 | "byte" { $$ = $1; }
638 | "char" { $$ = $1; }
639 | "double" { $$ = $1; }
640 | "final" { $$ = $1; }
641 | "float" { $$ = $1; }
642 | "goto" { $$ = $1; }
644 | "long" { $$ = $1; }
645 | "native" { $$ = $1; }
646 | "short" { $$ = $1; }
647 | "synchronized" { $$ = $1; }
648 | "throws" { $$ = $1; }
649 | "transient" { $$ = $1; }
650 | "volatile" { $$ = $1; }
653 | "yield" { $$ = $1; }
655 | "each" { $$ = $1; }
659 : Identifier { $$ = $1; }
664 : NullLiteral { $$ = $1; }
665 | BooleanLiteral { $$ = $1; }
666 | NumericLiteral { $$ = $1; }
667 | StringLiteral { $$ = $1; }
668 | "@" StringLiteral { $$ = $2; }
672 : RegularExpressionLiteral { $$ = $1; }
676 : LiteralNoRE { $$ = $1; }
677 | LiteralRE { $$ = $1; }
681 : "null" { $$ = $1; }
685 : "true" { $$ = $1; }
686 | "false" { $$ = $1; }
689 /* 11.1 Primary Expressions {{{ */
691 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
694 PrimaryExpressionNoBF
695 : PrimaryExpressionNo { $$ = $1; }
698 PrimaryExpressionNoRE
699 : PrimaryExpressionBF { $$ = $1; }
700 | PrimaryExpressionNo { $$ = $1; }
704 : "this" { $$ = $1; }
705 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
706 | Literal { $$ = $1; }
707 | ArrayLiteral { $$ = $1; }
708 | "(" Expression ")" { $$ = $2; }
712 : ObjectLiteral { $$ = $1; }
715 /* 11.1.4 Array Initialiser {{{ */
717 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
721 : AssignmentExpression { $$ = $1; }
725 : Element { $$ = $1; }
726 | LexSetRegExp { $$ = NULL; }
730 : ElementList { $$ = $1; }
731 | LexSetRegExp { $$ = NULL; }
735 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
736 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
739 /* 11.1.5 Object Initialiser {{{ */
741 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
744 PropertyNameAndValueList_
745 : "," PropertyNameAndValueList { $$ = $2; }
749 PropertyNameAndValueListOpt
750 : PropertyNameAndValueList { $$ = $1; }
754 PropertyNameAndValueList
755 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
759 : Identifier { $$ = $1; }
760 | StringLiteral { $$ = $1; }
761 | NumericLiteral { $$ = $1; }
765 : LexSetRegExp PropertyName_ { $$ = $2; }
769 /* 11.2 Left-Hand-Side Expressions {{{ */
771 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
775 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
776 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
780 : PrimaryExpression { $$ = $1; }
781 | LexSetRegExp FunctionExpression { $$ = $2; }
782 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
783 | LexSetRegExp MemberExpression_ { $$ = $2; }
787 : PrimaryExpressionNoBF { $$ = $1; }
788 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
789 | MemberExpression_ { $$ = $1; }
793 : PrimaryExpressionNoRE { $$ = $1; }
794 | FunctionExpression { $$ = $1; }
795 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
796 | MemberExpression_ { $$ = $1; }
800 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
804 : MemberExpression { $$ = $1; }
805 | LexSetRegExp NewExpression_ { $$ = $2; }
809 : MemberExpressionNoBF { $$ = $1; }
810 | NewExpression_ { $$ = $1; }
814 : MemberExpressionNoRE { $$ = $1; }
815 | NewExpression_ { $$ = $1; }
819 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
820 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
821 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
825 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
826 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
827 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
831 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
832 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
833 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
837 : "," ArgumentList { $$ = $2; }
842 : ArgumentList { $$ = $1; }
843 | LexSetRegExp { $$ = NULL; }
847 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
851 : "(" ArgumentListOpt ")" { $$ = $2; }
854 LeftHandSideExpression
855 : NewExpression { $$ = $1; }
856 | CallExpression { $$ = $1; }
859 LeftHandSideExpressionNoBF
860 : NewExpressionNoBF { $$ = $1; }
861 | CallExpressionNoBF { $$ = $1; }
864 LeftHandSideExpressionNoRE
865 : NewExpressionNoRE { $$ = $1; }
866 | CallExpressionNoRE { $$ = $1; }
869 /* 11.3 Postfix Expressions {{{ */
871 : AssigneeExpression { $$ = $1; }
872 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
873 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
876 PostfixExpressionNoBF
877 : AssigneeExpressionNoBF { $$ = $1; }
878 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
879 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
882 PostfixExpressionNoRE
883 : AssigneeExpressionNoRE { $$ = $1; }
884 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
885 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
888 /* 11.4 Unary Operators {{{ */
890 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
891 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
892 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
893 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
894 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
895 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
896 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
897 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
898 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
899 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
900 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
904 : PostfixExpression { $$ = $1; }
905 | LexSetRegExp UnaryExpression_ { $$ = $2; }
909 : PostfixExpressionNoBF { $$ = $1; }
910 | UnaryExpression_ { $$ = $1; }
914 : PostfixExpressionNoRE { $$ = $1; }
915 | UnaryExpression_ { $$ = $1; }
918 /* 11.5 Multiplicative Operators {{{ */
919 MultiplicativeExpression
920 : UnaryExpression { $$ = $1; }
921 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
922 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
923 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
926 MultiplicativeExpressionNoBF
927 : UnaryExpressionNoBF { $$ = $1; }
928 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
929 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
930 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
933 /* 11.6 Additive Operators {{{ */
935 : MultiplicativeExpression { $$ = $1; }
936 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
937 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
940 AdditiveExpressionNoBF
941 : MultiplicativeExpressionNoBF { $$ = $1; }
942 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
943 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
946 /* 11.7 Bitwise Shift Operators {{{ */
948 : AdditiveExpression { $$ = $1; }
949 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
950 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
951 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
955 : AdditiveExpressionNoBF { $$ = $1; }
956 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
957 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
958 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
961 /* 11.8 Relational Operators {{{ */
962 RelationalExpressionNoIn_
963 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
964 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
965 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
966 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
967 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
970 RelationalExpression_
971 : RelationalExpressionNoIn_ { $$ = $1; }
972 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
976 : ShiftExpression { $$ = $1; }
977 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
980 RelationalExpressionNoIn
981 : ShiftExpression { $$ = $1; }
982 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
985 RelationalExpressionNoBF
986 : ShiftExpressionNoBF { $$ = $1; }
987 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
990 /* 11.9 Equality Operators {{{ */
992 : RelationalExpression { $$ = $1; }
993 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
994 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
995 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
996 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
999 EqualityExpressionNoIn
1000 : RelationalExpressionNoIn { $$ = $1; }
1001 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1002 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1003 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1004 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1007 EqualityExpressionNoBF
1008 : RelationalExpressionNoBF { $$ = $1; }
1009 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1010 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1011 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1012 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1015 /* 11.10 Binary Bitwise Operators {{{ */
1016 BitwiseANDExpression
1017 : EqualityExpression { $$ = $1; }
1018 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1021 BitwiseANDExpressionNoIn
1022 : EqualityExpressionNoIn { $$ = $1; }
1023 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1026 BitwiseANDExpressionNoBF
1027 : EqualityExpressionNoBF { $$ = $1; }
1028 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1031 BitwiseXORExpression
1032 : BitwiseANDExpression { $$ = $1; }
1033 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1036 BitwiseXORExpressionNoIn
1037 : BitwiseANDExpressionNoIn { $$ = $1; }
1038 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1041 BitwiseXORExpressionNoBF
1042 : BitwiseANDExpressionNoBF { $$ = $1; }
1043 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1047 : BitwiseXORExpression { $$ = $1; }
1048 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1051 BitwiseORExpressionNoIn
1052 : BitwiseXORExpressionNoIn { $$ = $1; }
1053 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1056 BitwiseORExpressionNoBF
1057 : BitwiseXORExpressionNoBF { $$ = $1; }
1058 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1061 /* 11.11 Binary Logical Operators {{{ */
1062 LogicalANDExpression
1063 : BitwiseORExpression { $$ = $1; }
1064 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1067 LogicalANDExpressionNoIn
1068 : BitwiseORExpressionNoIn { $$ = $1; }
1069 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1072 LogicalANDExpressionNoBF
1073 : BitwiseORExpressionNoBF { $$ = $1; }
1074 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1078 : LogicalANDExpression { $$ = $1; }
1079 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1082 LogicalORExpressionNoIn
1083 : LogicalANDExpressionNoIn { $$ = $1; }
1084 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1087 LogicalORExpressionNoBF
1088 : LogicalANDExpressionNoBF { $$ = $1; }
1089 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1092 /* 11.12 Conditional Operator ( ? : ) {{{ */
1093 ConditionalExpression
1094 : LogicalORExpression { $$ = $1; }
1095 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1098 ConditionalExpressionNoIn
1099 : LogicalORExpressionNoIn { $$ = $1; }
1100 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1103 ConditionalExpressionNoBF
1104 : LogicalORExpressionNoBF { $$ = $1; }
1105 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1108 /* 11.13 Assignment Operators {{{ */
1109 AssignmentExpression_
1110 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1111 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1112 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1113 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1114 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1115 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1116 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1117 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1118 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1119 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1120 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1121 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1125 : LeftHandSideExpression { $$ = $1; }
1126 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1129 AssigneeExpressionNoBF
1130 : LeftHandSideExpressionNoBF { $$ = $1; }
1131 | UnaryAssigneeExpression { $$ = $1; }
1134 AssigneeExpressionNoRE
1135 : LeftHandSideExpressionNoRE { $$ = $1; }
1136 | UnaryAssigneeExpression { $$ = $1; }
1139 AssignmentExpression
1140 : ConditionalExpression { $$ = $1; }
1141 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1144 AssignmentExpressionNoIn
1145 : ConditionalExpressionNoIn { $$ = $1; }
1146 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1147 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1148 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1149 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1150 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1151 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1152 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1153 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1154 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1155 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1156 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1157 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1160 AssignmentExpressionNoBF
1161 : ConditionalExpressionNoBF { $$ = $1; }
1162 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1165 /* 11.14 Comma Operator {{{ */
1167 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1172 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1177 : Expression { $$ = $1; }
1178 | LexSetRegExp { $$ = NULL; }
1182 : ExpressionNoIn { $$ = $1; }
1183 | LexSetRegExp { $$ = NULL; }
1187 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1191 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1195 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1199 /* 12 Statements {{{ */
1201 : Block { $$ = $1; }
1202 | VariableStatement { $$ = $1; }
1203 | EmptyStatement { $$ = $1; }
1204 | ExpressionStatement { $$ = $1; }
1205 | IfStatement { $$ = $1; }
1206 | IterationStatement { $$ = $1; }
1207 | ContinueStatement { $$ = $1; }
1208 | BreakStatement { $$ = $1; }
1209 | ReturnStatement { $$ = $1; }
1210 | WithStatement { $$ = $1; }
1211 | LabelledStatement { $$ = $1; }
1212 | SwitchStatement { $$ = $1; }
1213 | ThrowStatement { $$ = $1; }
1214 | TryStatement { $$ = $1; }
1218 : LexSetRegExp Statement_ { $$ = $2; }
1221 /* 12.1 Block {{{ */
1223 : "{" StatementListOpt "}" { $$ = $2; }
1227 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1231 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1235 : StatementList { $$ = $1; }
1236 | LexSetRegExp { $$ = NULL; }
1239 /* 12.2 Variable Statement {{{ */
1241 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1244 VariableDeclarationList_
1245 : "," VariableDeclarationList { $$ = $2; }
1249 VariableDeclarationListNoIn_
1250 : "," VariableDeclarationListNoIn { $$ = $2; }
1254 VariableDeclarationList
1255 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1258 VariableDeclarationListNoIn
1259 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1263 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1266 VariableDeclarationNoIn
1267 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1271 : Initialiser { $$ = $1; }
1276 : InitialiserNoIn { $$ = $1; }
1281 : "=" AssignmentExpression { $$ = $2; }
1285 : "=" AssignmentExpressionNoIn { $$ = $2; }
1288 /* 12.3 Empty Statement {{{ */
1290 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1293 /* 12.4 Expression Statement {{{ */
1295 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1298 /* 12.5 The if Statement {{{ */
1300 : "else" Statement { $$ = $2; }
1301 | %prec "if" { $$ = NULL; }
1305 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1309 /* 12.6 Iteration Statements {{{ */
1311 : DoWhileStatement { $$ = $1; }
1312 | WhileStatement { $$ = $1; }
1313 | ForStatement { $$ = $1; }
1314 | ForInStatement { $$ = $1; }
1317 /* 12.6.1 The do-while Statement {{{ */
1319 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1322 /* 12.6.2 The while Statement {{{ */
1324 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1327 /* 12.6.3 The for Statement {{{ */
1329 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1332 ForStatementInitialiser
1333 : ExpressionNoInOpt { $$ = $1; }
1334 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1337 /* 12.6.4 The for-in Statement {{{ */
1339 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1342 ForInStatementInitialiser
1343 : LeftHandSideExpression { $$ = $1; }
1344 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1348 /* 12.7 The continue Statement {{{ */
1350 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1353 /* 12.8 The break Statement {{{ */
1355 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1358 /* 12.9 The return Statement {{{ */
1360 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1363 /* 12.10 The with Statement {{{ */
1365 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1369 /* 12.11 The switch Statement {{{ */
1371 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1375 : "{" CaseClausesOpt "}" { $$ = $2; }
1379 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1380 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1385 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1389 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1392 /* 12.12 Labelled Statements {{{ */
1394 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1397 /* 12.13 The throw Statement {{{ */
1399 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1402 /* 12.14 The try Statement {{{ */
1404 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1408 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1413 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1418 /* 13 Function Definition {{{ */
1420 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1424 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1427 FormalParameterList_
1428 : "," FormalParameterList { $$ = $2; }
1433 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1438 : SourceElements { $$ = $1; }
1441 /* 14 Program {{{ */
1443 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1447 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1448 | LexSetRegExp { $$ = NULL; }
1452 : Statement_ { $$ = $1; }
1453 | FunctionDeclaration { $$ = $1; }
1457 : LexSetRegExp SourceElement_ { $$ = $2; }
1462 /* Cycript (Objective-C): @class Declaration {{{ */
1464 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1465 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1470 : "{" "}" { $$ = NULL; }
1474 : "+" { $$ = false; }
1475 | "-" { $$ = true; }
1479 : "(" Expression ")" { $$ = $2; }
1484 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1487 MessageParameterListOpt
1488 : MessageParameterList { $$ = $1; }
1492 MessageParameterList
1493 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1497 : MessageParameterList { $$ = $1; }
1498 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1501 ClassMessageDeclaration
1502 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1505 ClassMessageDeclarationListOpt
1506 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1511 : Identifier { $$ = $1; }
1512 | "(" AssignmentExpression ")" { $$ = $2; }
1516 : ClassName { $$ = $1; }
1521 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1525 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1529 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1533 : ClassExpression { $$ = $1; }
1537 : ClassStatement { $$ = $1; }
1538 | CategoryStatement { $$ = $1; }
1541 /* Cycript (Objective-C): Send Message {{{ */
1543 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1548 : SelectorCall { $$ = $1; }
1549 | VariadicCall { $$ = $1; }
1553 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1557 : SelectorCall { $$ = $1; }
1558 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1562 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1563 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1566 SelectorExpressionOpt
1567 : SelectorExpression_ { $$ = $1; }
1572 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1576 : SelectorExpression_ { $$ = $1; }
1577 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1581 : MessageExpression { $$ = $1; }
1582 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1588 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1589 UnaryAssigneeExpression
1590 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1594 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1598 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1599 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1605 /* Lexer State {{{ */
1607 : { driver.PushCondition(CYDriver::RegExpCondition); }
1611 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1615 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1619 : { driver.PopCondition(); }
1623 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1627 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1636 /* 8.1 Context Keywords {{{ */
1638 : "namespace" { $$ = $1; }
1639 | "xml" { $$ = $1; }
1642 /* 8.3 XML Initialiser Input Elements {{{ */
1644 : XMLComment { $$ = $1; }
1645 | XMLCDATA { $$ = $1; }
1646 | XMLPI { $$ = $1; }
1649 /* 11.1 Primary Expressions {{{ */
1651 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1652 | XMLInitialiser { $$ = $1; }
1653 | XMLListInitialiser { $$ = $1; }
1657 : AttributeIdentifier { $$ = $1; }
1658 | QualifiedIdentifier { $$ = $1; }
1659 | WildcardIdentifier { $$ = $1; }
1662 /* 11.1.1 Attribute Identifiers {{{ */
1664 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1668 : PropertySelector { $$ = $1; }
1669 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1673 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1674 | WildcardIdentifier { $$ = $1; }
1677 /* 11.1.2 Qualified Identifiers {{{ */
1678 QualifiedIdentifier_
1679 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1680 | QualifiedIdentifier { $$ = $1; }
1684 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1687 /* 11.1.3 Wildcard Identifiers {{{ */
1689 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1692 /* 11.1.4 XML Initialiser {{{ */
1694 : XMLMarkup { $$ = $1; }
1695 | XMLElement { $$ = $1; }
1699 : "<" XMLTagContent "/>" LexPop
1700 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1704 : LexPushXMLTag XMLTagName XMLAttributes
1708 : "{" LexPushRegExp Expression "}" LexPop
1717 : XMLAttributes_ XMLAttribute
1722 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1723 | XMLAttributes_ XMLWhitespaceOpt
1732 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1736 : XMLExpression XMLElementContentOpt
1737 | XMLMarkup XMLElementContentOpt
1738 | XMLText XMLElementContentOpt
1739 | XMLElement XMLElementContentOpt
1742 XMLElementContentOpt
1747 /* 11.1.5 XMLList Initialiser {{{ */
1749 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1752 /* 11.2 Left-Hand-Side Expressions {{{ */
1754 : Identifier { $$ = $1; }
1755 | PropertyIdentifier { $$ = $1; }
1759 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1760 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1761 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1764 /* 12.1 The default xml namespace Statement {{{ */
1765 /* XXX: DefaultXMLNamespaceStatement
1766 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1770 : DefaultXMLNamespaceStatement { $$ = $1; }
1775 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1776 PropertyNameAndValueList_
1777 : "," { $$ = NULL; }
1780 /* JavaScript 1.7: Array Comprehensions {{{ */
1782 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1786 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1787 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1790 ComprehensionListOpt
1791 : ComprehensionList { $$ = $1; }
1792 | IfComprehension { $$ = $1; }
1797 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1801 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1804 /* JavaScript 1.7: for each {{{ */
1806 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1809 /* JavaScript 1.7: let Statements {{{ *//*
1811 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1818 /* JavaScript FTW: Function Statements {{{ */
1820 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }