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"
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_;
113 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
122 @$.begin.filename = @$.end.filename = &driver.filename_;
132 %parse-param { CYDriver &driver }
133 %lex-param { void *scanner }
140 %token XMLAttributeValue
142 %token XMLTagCharacters
148 %token LeftRight "<>"
149 %token LeftSlashRight "</>"
151 %token SlashRight "/>"
152 %token LeftSlash "</"
155 %token ColonColon "::"
156 %token PeriodPeriod ".."
160 %token AmpersandAmpersand "&&"
161 %token AmpersandEqual "&="
163 %token CarrotEqual "^="
165 %token EqualEqual "=="
166 %token EqualEqualEqual "==="
167 %token Exclamation "!"
168 %token ExclamationEqual "!="
169 %token ExclamationEqualEqual "!=="
171 %token HyphenEqual "-="
172 %token HyphenHyphen "--"
173 %token HyphenHyphen_ "\n--"
174 %token HyphenRight "->"
176 %token LeftEqual "<="
178 %token LeftLeftEqual "<<="
180 %token PercentEqual "%="
183 %token PipeEqual "|="
186 %token PlusEqual "+="
188 %token PlusPlus_ "\n++"
190 %token RightEqual ">="
191 %token RightRight ">>"
192 %token RightRightEqual ">>="
193 %token RightRightRight ">>>"
194 %token RightRightRightEqual ">>>="
196 %token SlashEqual "/="
198 %token StarEqual "*="
208 %token CloseParen ")"
211 %token CloseBrace "}"
213 %token OpenBracket "["
214 %token CloseBracket "]"
216 %token AtClass "@class"
217 %token AtSelector "@selector"
220 %token <false_> False "false"
221 %token <null_> Null "null"
222 %token <true_> True "true"
224 // ES3/ES5/WIE/JSC Reserved
225 %token <word_> Break "break"
226 %token <word_> Case "case"
227 %token <word_> Catch "catch"
228 %token <word_> Continue "continue"
229 %token <word_> Default "default"
230 %token <word_> Delete "delete"
231 %token <word_> Do "do"
232 %token <word_> Else "else"
233 %token <word_> Finally "finally"
234 %token <word_> For "for"
235 %token <word_> Function "function"
236 %token <word_> If "if"
237 %token <word_> In "in"
238 %token <word_> InstanceOf "instanceof"
239 %token <word_> New "new"
240 %token <word_> Return "return"
241 %token <word_> Switch "switch"
242 %token <this_> This "this"
243 %token <word_> Throw "throw"
244 %token <word_> Try "try"
245 %token <word_> TypeOf "typeof"
246 %token <word_> Var "var"
247 %token <word_> Void "void"
248 %token <word_> While "while"
249 %token <word_> With "with"
251 // ES3/IE6 Future, ES5/JSC Reserved
252 %token <word_> Debugger "debugger"
254 // ES3/ES5/IE6 Future, JSC Reserved
255 %token <word_> Const "const"
257 // ES3/ES5/IE6/JSC Future
258 %token <word_> Class "class"
259 %token <word_> Enum "enum"
260 %token <word_> Export "export"
261 %token <word_> Extends "extends"
262 %token <word_> Import "import"
263 %token <word_> Super "super"
265 // ES3 Future, ES5 Strict Future
266 %token <identifier_> Implements "implements"
267 %token <identifier_> Interface "interface"
268 %token <identifier_> Package "package"
269 %token <identifier_> Private "private"
270 %token <identifier_> Protected "protected"
271 %token <identifier_> Public "public"
272 %token <identifier_> Static "static"
275 %token <identifier_> Abstract "abstract"
276 %token <identifier_> Boolean "boolean"
277 %token <identifier_> Byte "byte"
278 %token <identifier_> Char "char"
279 %token <identifier_> Double "double"
280 %token <identifier_> Final "final"
281 %token <identifier_> Float "float"
282 %token <identifier_> Goto "goto"
283 %token <identifier_> Int "int"
284 %token <identifier_> Long "long"
285 %token <identifier_> Native "native"
286 %token <identifier_> Short "short"
287 %token <identifier_> Synchronized "synchronized"
288 %token <identifier_> Throws "throws"
289 %token <identifier_> Transient "transient"
290 %token <identifier_> Volatile "volatile"
293 %token <identifier_> Let "let"
294 %token <identifier_> Yield "yield"
297 %token <identifier_> Each "each"
301 %token <identifier_> Namespace "namespace"
302 %token <identifier_> XML "xml"
305 %token <identifier_> Identifier_
306 %token <number_> NumericLiteral
307 %token <string_> StringLiteral
308 %token <literal_> RegularExpressionLiteral
310 %type <expression_> AdditiveExpression
311 %type <expression_> AdditiveExpressionNoBF
312 %type <expression_> AdditiveExpressionNoWC
313 %type <argument_> ArgumentList
314 %type <argument_> ArgumentList_
315 %type <argument_> ArgumentListOpt
316 %type <argument_> Arguments
317 %type <literal_> ArrayLiteral
318 %type <expression_> AssigneeExpression
319 %type <expression_> AssigneeExpressionNoBF
320 %type <expression_> AssigneeExpressionNoWC
321 %type <expression_> AssignmentExpression
322 %type <assignment_> AssignmentExpression_
323 %type <expression_> AssignmentExpressionNoBF
324 %type <expression_> AssignmentExpressionNoIn
325 %type <expression_> AssignmentExpressionNoWC
326 %type <expression_> BitwiseANDExpression
327 %type <expression_> BitwiseANDExpressionNoBF
328 %type <expression_> BitwiseANDExpressionNoIn
329 %type <expression_> BitwiseANDExpressionNoWC
330 %type <statement_> Block
331 %type <statement_> Block_
332 %type <boolean_> BooleanLiteral
333 %type <expression_> BitwiseORExpression
334 %type <expression_> BitwiseORExpressionNoBF
335 %type <expression_> BitwiseORExpressionNoIn
336 %type <expression_> BitwiseORExpressionNoWC
337 %type <expression_> BitwiseXORExpression
338 %type <expression_> BitwiseXORExpressionNoBF
339 %type <expression_> BitwiseXORExpressionNoIn
340 %type <expression_> BitwiseXORExpressionNoWC
341 %type <statement_> BreakStatement
342 %type <expression_> CallExpression
343 %type <expression_> CallExpressionNoBF
344 %type <clause_> CaseBlock
345 %type <clause_> CaseClause
346 %type <clause_> CaseClausesOpt
347 %type <catch_> CatchOpt
348 %type <comprehension_> ComprehensionList
349 %type <comprehension_> ComprehensionListOpt
350 %type <expression_> ConditionalExpression
351 %type <expression_> ConditionalExpressionNoBF
352 %type <expression_> ConditionalExpressionNoIn
353 %type <expression_> ConditionalExpressionNoWC
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_> EqualityExpressionNoWC
367 %type <expression_> Expression
368 %type <expression_> ExpressionOpt
369 %type <compound_> Expression_
370 %type <expression_> ExpressionNoBF
371 %type <expression_> ExpressionNoIn
372 %type <compound_> ExpressionNoIn_
373 %type <expression_> ExpressionNoInOpt
374 %type <statement_> ExpressionStatement
375 %type <finally_> FinallyOpt
376 %type <comprehension_> ForComprehension
377 %type <statement_> ForStatement
378 %type <for_> ForStatementInitialiser
379 %type <statement_> ForInStatement
380 %type <forin_> ForInStatementInitialiser
381 %type <functionParameter_> FormalParameterList
382 %type <functionParameter_> FormalParameterList_
383 %type <statement_> FunctionBody
384 %type <statement_> FunctionDeclaration
385 %type <expression_> FunctionExpression
386 %type <expression_> FunctionExpression_
387 %type <identifier_> Identifier
388 %type <identifier_> IdentifierOpt
389 %type <comprehension_> IfComprehension
390 %type <statement_> IfStatement
391 %type <expression_> Initialiser
392 %type <expression_> InitialiserOpt
393 %type <expression_> InitialiserNoIn
394 %type <expression_> InitialiserNoInOpt
395 %type <statement_> IterationStatement
396 %type <statement_> LabelledStatement
397 %type <expression_> LeftHandSideExpression
398 %type <expression_> LeftHandSideExpressionNoBF
399 %type <expression_> LeftHandSideExpressionNoWC
400 //%type <statement_> LetStatement
401 %type <literal_> Literal
402 %type <literal_> LiteralNoRE
403 %type <literal_> LiteralRE
404 %type <expression_> LogicalANDExpression
405 %type <expression_> LogicalANDExpressionNoBF
406 %type <expression_> LogicalANDExpressionNoIn
407 %type <expression_> LogicalANDExpressionNoWC
408 %type <expression_> LogicalORExpression
409 %type <expression_> LogicalORExpressionNoBF
410 %type <expression_> LogicalORExpressionNoIn
411 %type <expression_> LogicalORExpressionNoWC
412 %type <member_> MemberAccess
413 %type <expression_> MemberExpression
414 %type <expression_> MemberExpression_
415 %type <expression_> MemberExpressionNoBF
416 %type <expression_> MemberExpressionNoWC
417 %type <expression_> MultiplicativeExpression
418 %type <expression_> MultiplicativeExpressionNoBF
419 %type <expression_> MultiplicativeExpressionNoWC
420 %type <expression_> NewExpression
421 %type <expression_> NewExpression_
422 %type <expression_> NewExpressionNoBF
423 %type <expression_> NewExpressionNoWC
424 %type <null_> NullLiteral
425 %type <literal_> ObjectLiteral
426 %type <expression_> PostfixExpression
427 %type <expression_> PostfixExpressionNoBF
428 %type <expression_> PostfixExpressionNoWC
429 %type <expression_> PrimaryExpression
430 %type <expression_> PrimaryExpressionNo
431 %type <expression_> PrimaryExpressionNoBF
432 %type <expression_> PrimaryExpressionNoWC
433 %type <expression_> PrimaryExpressionNoWC_
435 %type <expression_> PrimaryExpressionWC
437 %type <expression_> PrimaryExpressionBF
438 %type <statement_> Program
439 %type <propertyName_> PropertyName
440 %type <property_> PropertyNameAndValueList
441 %type <property_> PropertyNameAndValueList_
442 %type <property_> PropertyNameAndValueListOpt
443 %type <expression_> RelationalExpression
444 %type <infix_> RelationalExpression_
445 %type <expression_> RelationalExpressionNoBF
446 %type <expression_> RelationalExpressionNoIn
447 %type <expression_> RelationalExpressionNoWC
448 %type <infix_> RelationalExpressionNoIn_
449 %type <statement_> ReturnStatement
450 %type <expression_> ShiftExpression
451 %type <expression_> ShiftExpressionNoBF
452 %type <expression_> ShiftExpressionNoWC
453 %type <statement_> SourceElement
454 %type <statement_> SourceElement_
455 %type <statement_> SourceElements
456 %type <statement_> Statement
457 %type <statement_> Statement_
458 %type <statement_> StatementList
459 %type <statement_> StatementListOpt
460 %type <statement_> SwitchStatement
461 %type <statement_> ThrowStatement
462 %type <statement_> TryStatement
463 %type <expression_> UnaryAssigneeExpression
464 %type <expression_> UnaryExpression
465 %type <expression_> UnaryExpression_
466 %type <expression_> UnaryExpressionNoBF
467 %type <expression_> UnaryExpressionNoWC
468 %type <declaration_> VariableDeclaration
469 %type <declaration_> VariableDeclarationNoIn
470 %type <declarations_> VariableDeclarationList
471 %type <declarations_> VariableDeclarationList_
472 %type <declarations_> VariableDeclarationListNoIn
473 %type <declarations_> VariableDeclarationListNoIn_
474 %type <statement_> VariableStatement
475 %type <statement_> WhileStatement
476 %type <statement_> WithStatement
479 %type <statement_> CategoryStatement
480 %type <expression_> ClassExpression
481 %type <statement_> ClassStatement
482 %type <expression_> ClassSuperOpt
483 %type <field_> ClassFieldList
484 %type <message_> ClassMessageDeclaration
485 %type <message_> ClassMessageDeclarationListOpt
486 %type <className_> ClassName
487 %type <className_> ClassNameOpt
488 %type <expression_> MessageExpression
489 %type <messageParameter_> MessageParameter
490 %type <messageParameter_> MessageParameters
491 %type <messageParameter_> MessageParameterList
492 %type <messageParameter_> MessageParameterListOpt
493 %type <bool_> MessageScope
494 %type <argument_> SelectorCall
495 %type <argument_> SelectorCall_
496 %type <selector_> SelectorExpression
497 %type <selector_> SelectorExpression_
498 %type <selector_> SelectorExpressionOpt
499 %type <argument_> SelectorList
500 %type <expression_> TypeOpt
501 %type <argument_> VariadicCall
503 %type <word_> WordOpt
507 %type <identifier_> PropertyIdentifier_
508 %type <identifier_> PropertySelector
509 %type <identifier_> PropertySelector_
510 %type <identifier_> QualifiedIdentifier
511 %type <identifier_> QualifiedIdentifier_
512 %type <identifier_> WildcardIdentifier
513 %type <identifier_> XMLComment
514 %type <identifier_> XMLCDATA
515 %type <identifier_> XMLElement
516 %type <identifier_> XMLElementContent
517 %type <identifier_> XMLMarkup
518 %type <identifier_> XMLPI
520 %type <attribute_> AttributeIdentifier
521 %type <statement_> DefaultXMLNamespaceStatement
522 %type <expression_> PropertyIdentifier
523 %type <expression_> XMLListInitialiser
524 %type <expression_> XMLInitialiser
530 %left "<<" ">>" ">>>"
531 %left "<" ">" "<=" ">=" "instanceof" "in"
532 %left "==" "!=" "===" "!=="
539 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
549 /* Lexer State {{{ */
551 : { driver.SetCondition(CYDriver::RegExpCondition); }
556 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
566 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
571 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
591 : Identifier { $$ = $1; }
592 | "break" NewLineOpt { $$ = $1; }
593 | "case" { $$ = $1; }
594 | "catch" { $$ = $1; }
595 | "class" { $$ = $1; }
596 | "const" { $$ = $1; }
597 | "continue" NewLineOpt { $$ = $1; }
598 | "debugger" { $$ = $1; }
599 | "default" { $$ = $1; }
600 | "delete" { $$ = $1; }
602 | "else" { $$ = $1; }
603 | "enum" { $$ = $1; }
604 | "export" { $$ = $1; }
605 | "extends" { $$ = $1; }
606 | "false" { $$ = $1; }
607 | "finally" { $$ = $1; }
608 /* XXX: | "for" { $$ = $1; } */
609 | "function" { $$ = $1; }
611 | "import" { $$ = $1; }
612 /* XXX: | "in" { $$ = $1; } */
613 /* XXX: | "instanceof" { $$ = $1; } */
615 | "null" { $$ = $1; }
616 | "return" NewLineOpt { $$ = $1; }
617 | "super" { $$ = $1; }
618 | "switch" { $$ = $1; }
619 | "this" { $$ = $1; }
620 | "throw" NewLineOpt { $$ = $1; }
621 | "true" { $$ = $1; }
623 | "typeof" { $$ = $1; }
625 | "void" { $$ = $1; }
626 | "while" { $$ = $1; }
627 | "with" { $$ = $1; }
632 : Identifier_ { $$ = $1; }
634 | "implements" { $$ = $1; }
635 | "interface" { $$ = $1; }
636 | "package" { $$ = $1; }
637 | "private" { $$ = $1; }
638 | "protected" { $$ = $1; }
639 | "public" { $$ = $1; }
640 | "static" { $$ = $1; }
642 | "abstract" { $$ = $1; }
643 | "boolean" { $$ = $1; }
644 | "byte" { $$ = $1; }
645 | "char" { $$ = $1; }
646 | "double" { $$ = $1; }
647 | "final" { $$ = $1; }
648 | "float" { $$ = $1; }
649 | "goto" { $$ = $1; }
651 | "long" { $$ = $1; }
652 | "native" { $$ = $1; }
653 | "short" { $$ = $1; }
654 | "synchronized" { $$ = $1; }
655 | "throws" { $$ = $1; }
656 | "transient" { $$ = $1; }
657 | "volatile" { $$ = $1; }
660 | "yield" { $$ = $1; }
662 | "each" { $$ = $1; }
666 : Identifier { $$ = $1; }
671 : NullLiteral { $$ = $1; }
672 | BooleanLiteral { $$ = $1; }
673 | NumericLiteral { $$ = $1; }
674 | StringLiteral { $$ = $1; }
678 : RegularExpressionLiteral { $$ = $1; }
682 : LiteralNoRE { $$ = $1; }
683 | LiteralRE { $$ = $1; }
687 : "null" { $$ = $1; }
691 : "true" { $$ = $1; }
692 | "false" { $$ = $1; }
695 /* 11.1 Primary Expressions {{{ */
697 : PrimaryExpressionNoWC { $$ = $1; }
699 | LexSetRegExp PrimaryExpressionWC { $$ = $2; }
703 PrimaryExpressionNoBF
704 : PrimaryExpressionNo { $$ = $1; }
706 | PrimaryExpressionWC { $$ = $1; }
710 PrimaryExpressionNoWC_
711 : PrimaryExpressionBF { $$ = $1; }
712 | PrimaryExpressionNo { $$ = $1; }
715 PrimaryExpressionNoWC
716 : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; }
720 : "this" { $$ = $1; }
721 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
722 | Literal { $$ = $1; }
723 | ArrayLiteral { $$ = $1; }
724 | "(" Expression ")" { $$ = $2; }
728 : ObjectLiteral { $$ = $1; }
731 /* 11.1.4 Array Initialiser {{{ */
733 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
737 : AssignmentExpression { $$ = $1; }
741 : Element { $$ = $1; }
742 | LexSetRegExp { $$ = NULL; }
746 : ElementList { $$ = $1; }
747 | LexSetRegExp { $$ = NULL; }
751 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
752 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
755 /* 11.1.5 Object Initialiser {{{ */
757 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
760 PropertyNameAndValueList_
761 : "," PropertyNameAndValueList { $$ = $2; }
765 PropertyNameAndValueListOpt
766 : PropertyNameAndValueList { $$ = $1; }
770 PropertyNameAndValueList
771 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
775 : Identifier { $$ = $1; }
776 | StringLiteral { $$ = $1; }
777 | NumericLiteral { $$ = $1; }
781 /* 11.2 Left-Hand-Side Expressions {{{ */
783 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
787 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
788 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
792 : PrimaryExpression { $$ = $1; }
793 | FunctionExpression { $$ = $1; }
794 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
795 | LexSetRegExp MemberExpression_ { $$ = $2; }
799 : PrimaryExpressionNoBF { $$ = $1; }
800 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
801 | MemberExpression_ { $$ = $1; }
805 : PrimaryExpressionNoWC { $$ = $1; }
806 | FunctionExpression { $$ = $1; }
807 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
808 | LexSetRegExp MemberExpression_ { $$ = $2; }
812 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
816 : MemberExpression { $$ = $1; }
817 | LexSetRegExp NewExpression_ { $$ = $2; }
821 : MemberExpressionNoBF { $$ = $1; }
822 | NewExpression_ { $$ = $1; }
826 : MemberExpressionNoWC { $$ = $1; }
827 | LexSetRegExp NewExpression_ { $$ = $2; }
831 : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
832 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
833 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
837 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
838 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
839 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
843 : "," ArgumentList { $$ = $2; }
848 : ArgumentList { $$ = $1; }
849 | LexSetRegExp { $$ = NULL; }
853 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
857 : "(" ArgumentListOpt ")" { $$ = $2; }
860 LeftHandSideExpression
861 : NewExpression { $$ = $1; }
862 | CallExpression { $$ = $1; }
865 LeftHandSideExpressionNoBF
866 : NewExpressionNoBF { $$ = $1; }
867 | CallExpressionNoBF { $$ = $1; }
870 LeftHandSideExpressionNoWC
871 : NewExpressionNoWC { $$ = $1; }
872 | CallExpression { $$ = $1; }
875 /* 11.3 Postfix Expressions {{{ */
877 : AssigneeExpression { $$ = $1; }
878 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
879 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
882 PostfixExpressionNoBF
883 : AssigneeExpressionNoBF { $$ = $1; }
884 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
885 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
888 PostfixExpressionNoWC
889 : AssigneeExpressionNoWC { $$ = $1; }
890 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
891 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
894 /* 11.4 Unary Operators {{{ */
896 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
897 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
898 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
899 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
900 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
901 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
902 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
903 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
904 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
905 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
906 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
910 : PostfixExpression { $$ = $1; }
911 | LexSetRegExp UnaryExpression_ { $$ = $2; }
915 : PostfixExpressionNoBF { $$ = $1; }
916 | UnaryExpression_ { $$ = $1; }
920 : PostfixExpressionNoWC { $$ = $1; }
921 | LexSetRegExp UnaryExpression_ { $$ = $2; }
924 /* 11.5 Multiplicative Operators {{{ */
925 MultiplicativeExpression
926 : UnaryExpression { $$ = $1; }
927 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
928 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
929 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
932 MultiplicativeExpressionNoBF
933 : UnaryExpressionNoBF { $$ = $1; }
934 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
935 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
936 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
939 MultiplicativeExpressionNoWC
940 : UnaryExpressionNoWC { $$ = $1; }
941 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
942 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
943 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
946 /* 11.6 Additive Operators {{{ */
948 : MultiplicativeExpression { $$ = $1; }
949 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
950 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
953 AdditiveExpressionNoBF
954 : MultiplicativeExpressionNoBF { $$ = $1; }
955 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
956 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
959 AdditiveExpressionNoWC
960 : MultiplicativeExpressionNoWC{ $$ = $1; }
961 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
962 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
965 /* 11.7 Bitwise Shift Operators {{{ */
967 : AdditiveExpression { $$ = $1; }
968 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
969 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
970 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
974 : AdditiveExpressionNoBF { $$ = $1; }
975 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
976 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
977 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
981 : AdditiveExpressionNoWC { $$ = $1; }
982 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
983 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
984 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
987 /* 11.8 Relational Operators {{{ */
988 RelationalExpressionNoIn_
989 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
990 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
991 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
992 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
993 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
996 RelationalExpression_
997 : RelationalExpressionNoIn_ { $$ = $1; }
998 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1001 RelationalExpression
1002 : ShiftExpression { $$ = $1; }
1003 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1006 RelationalExpressionNoIn
1007 : ShiftExpression { $$ = $1; }
1008 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1011 RelationalExpressionNoBF
1012 : ShiftExpressionNoBF { $$ = $1; }
1013 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1016 RelationalExpressionNoWC
1017 : ShiftExpressionNoWC { $$ = $1; }
1018 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1021 /* 11.9 Equality Operators {{{ */
1023 : RelationalExpression { $$ = $1; }
1024 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1025 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1026 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1027 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1030 EqualityExpressionNoIn
1031 : RelationalExpressionNoIn { $$ = $1; }
1032 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1033 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1034 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1035 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1038 EqualityExpressionNoBF
1039 : RelationalExpressionNoBF { $$ = $1; }
1040 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1041 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1042 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1043 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1046 EqualityExpressionNoWC
1047 : RelationalExpressionNoWC { $$ = $1; }
1048 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1049 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1050 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1051 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1054 /* 11.10 Binary Bitwise Operators {{{ */
1055 BitwiseANDExpression
1056 : EqualityExpression { $$ = $1; }
1057 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1060 BitwiseANDExpressionNoIn
1061 : EqualityExpressionNoIn { $$ = $1; }
1062 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1065 BitwiseANDExpressionNoBF
1066 : EqualityExpressionNoBF { $$ = $1; }
1067 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1070 BitwiseANDExpressionNoWC
1071 : EqualityExpressionNoWC { $$ = $1; }
1072 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1075 BitwiseXORExpression
1076 : BitwiseANDExpression { $$ = $1; }
1077 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1080 BitwiseXORExpressionNoIn
1081 : BitwiseANDExpressionNoIn { $$ = $1; }
1082 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1085 BitwiseXORExpressionNoBF
1086 : BitwiseANDExpressionNoBF { $$ = $1; }
1087 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1090 BitwiseXORExpressionNoWC
1091 : BitwiseANDExpressionNoWC { $$ = $1; }
1092 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1096 : BitwiseXORExpression { $$ = $1; }
1097 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1100 BitwiseORExpressionNoIn
1101 : BitwiseXORExpressionNoIn { $$ = $1; }
1102 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1105 BitwiseORExpressionNoBF
1106 : BitwiseXORExpressionNoBF { $$ = $1; }
1107 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1110 BitwiseORExpressionNoWC
1111 : BitwiseXORExpressionNoWC { $$ = $1; }
1112 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1115 /* 11.11 Binary Logical Operators {{{ */
1116 LogicalANDExpression
1117 : BitwiseORExpression { $$ = $1; }
1118 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1121 LogicalANDExpressionNoIn
1122 : BitwiseORExpressionNoIn { $$ = $1; }
1123 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1126 LogicalANDExpressionNoBF
1127 : BitwiseORExpressionNoBF { $$ = $1; }
1128 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1131 LogicalANDExpressionNoWC
1132 : BitwiseORExpressionNoWC { $$ = $1; }
1133 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1137 : LogicalANDExpression { $$ = $1; }
1138 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1141 LogicalORExpressionNoIn
1142 : LogicalANDExpressionNoIn { $$ = $1; }
1143 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1146 LogicalORExpressionNoBF
1147 : LogicalANDExpressionNoBF { $$ = $1; }
1148 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1151 LogicalORExpressionNoWC
1152 : LogicalANDExpressionNoWC { $$ = $1; }
1153 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1156 /* 11.12 Conditional Operator ( ? : ) {{{ */
1157 ConditionalExpression
1158 : LogicalORExpression { $$ = $1; }
1159 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1162 ConditionalExpressionNoIn
1163 : LogicalORExpressionNoIn { $$ = $1; }
1164 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1167 ConditionalExpressionNoBF
1168 : LogicalORExpressionNoBF { $$ = $1; }
1169 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1172 ConditionalExpressionNoWC
1173 : LogicalORExpressionNoWC { $$ = $1; }
1174 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1177 /* 11.13 Assignment Operators {{{ */
1178 AssignmentExpression_
1179 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1180 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1181 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1182 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1183 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1184 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1185 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1186 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1187 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1188 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1189 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1190 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1194 : LeftHandSideExpression { $$ = $1; }
1195 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1198 AssigneeExpressionNoBF
1199 : LeftHandSideExpressionNoBF { $$ = $1; }
1200 | UnaryAssigneeExpression { $$ = $1; }
1203 AssigneeExpressionNoWC
1204 : LeftHandSideExpressionNoWC { $$ = $1; }
1205 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1208 AssignmentExpression
1209 : ConditionalExpression { $$ = $1; }
1210 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1213 AssignmentExpressionNoIn
1214 : ConditionalExpressionNoIn { $$ = $1; }
1215 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1216 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1217 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1218 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1219 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1220 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1221 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1222 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1223 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1224 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1225 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1226 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1229 AssignmentExpressionNoBF
1230 : ConditionalExpressionNoBF { $$ = $1; }
1231 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1234 AssignmentExpressionNoWC
1235 : ConditionalExpressionNoWC { $$ = $1; }
1236 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1239 /* 11.14 Comma Operator {{{ */
1241 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1246 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1251 : Expression { $$ = $1; }
1252 | LexSetRegExp { $$ = NULL; }
1256 : ExpressionNoIn { $$ = $1; }
1257 | LexSetRegExp { $$ = NULL; }
1261 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1265 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1269 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1273 /* 12 Statements {{{ */
1275 : Block { $$ = $1; }
1276 | VariableStatement { $$ = $1; }
1277 | EmptyStatement { $$ = $1; }
1278 | ExpressionStatement { $$ = $1; }
1279 | IfStatement { $$ = $1; }
1280 | IterationStatement { $$ = $1; }
1281 | ContinueStatement { $$ = $1; }
1282 | BreakStatement { $$ = $1; }
1283 | ReturnStatement { $$ = $1; }
1284 | WithStatement { $$ = $1; }
1285 | LabelledStatement { $$ = $1; }
1286 | SwitchStatement { $$ = $1; }
1287 | ThrowStatement { $$ = $1; }
1288 | TryStatement { $$ = $1; }
1292 : LexSetRegExp Statement_ { $$ = $2; }
1295 /* 12.1 Block {{{ */
1297 : "{" StatementListOpt "}" { $$ = $2; }
1301 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1305 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1309 : StatementList { $$ = $1; }
1310 | LexSetRegExp { $$ = NULL; }
1313 /* 12.2 Variable Statement {{{ */
1315 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1318 VariableDeclarationList_
1319 : "," VariableDeclarationList { $$ = $2; }
1323 VariableDeclarationListNoIn_
1324 : "," VariableDeclarationListNoIn { $$ = $2; }
1328 VariableDeclarationList
1329 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1332 VariableDeclarationListNoIn
1333 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1337 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1340 VariableDeclarationNoIn
1341 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1345 : Initialiser { $$ = $1; }
1350 : InitialiserNoIn { $$ = $1; }
1355 : "=" AssignmentExpression { $$ = $2; }
1359 : "=" AssignmentExpressionNoIn { $$ = $2; }
1362 /* 12.3 Empty Statement {{{ */
1364 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1367 /* 12.4 Expression Statement {{{ */
1369 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1372 /* 12.5 The if Statement {{{ */
1374 : "else" Statement { $$ = $2; }
1375 | %prec "if" { $$ = NULL; }
1379 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1383 /* 12.6 Iteration Statements {{{ */
1385 : DoWhileStatement { $$ = $1; }
1386 | WhileStatement { $$ = $1; }
1387 | ForStatement { $$ = $1; }
1388 | ForInStatement { $$ = $1; }
1391 /* 12.6.1 The do-while Statement {{{ */
1393 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1396 /* 12.6.2 The while Statement {{{ */
1398 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1401 /* 12.6.3 The for Statement {{{ */
1403 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1406 ForStatementInitialiser
1407 : ExpressionNoInOpt { $$ = $1; }
1408 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1411 /* 12.6.4 The for-in Statement {{{ */
1413 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1416 ForInStatementInitialiser
1417 : LeftHandSideExpression { $$ = $1; }
1418 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1422 /* 12.7 The continue Statement {{{ */
1424 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1427 /* 12.8 The break Statement {{{ */
1429 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1432 /* 12.9 The return Statement {{{ */
1434 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1437 /* 12.10 The with Statement {{{ */
1439 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1443 /* 12.11 The switch Statement {{{ */
1445 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1449 : "{" CaseClausesOpt "}" { $$ = $2; }
1453 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1454 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1459 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1463 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1466 /* 12.12 Labelled Statements {{{ */
1468 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1471 /* 12.13 The throw Statement {{{ */
1473 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1476 /* 12.14 The try Statement {{{ */
1478 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1482 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1487 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1492 /* 13 Function Definition {{{ */
1494 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1498 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1502 : LexSetRegExp FunctionExpression_ { $$ = $2; }
1505 FormalParameterList_
1506 : "," FormalParameterList { $$ = $2; }
1511 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1516 : SourceElements { $$ = $1; }
1519 /* 14 Program {{{ */
1521 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1525 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1526 | LexSetRegExp { $$ = NULL; }
1530 : Statement_ { $$ = $1; }
1531 | FunctionDeclaration { $$ = $1; }
1535 : LexSetRegExp SourceElement_ { $$ = $2; }
1540 /* Cycript (Objective-C): @class Declaration {{{ */
1542 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1543 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1548 : "{" "}" { $$ = NULL; }
1552 : "+" { $$ = false; }
1553 | "-" { $$ = true; }
1557 : "(" Expression ")" { $$ = $2; }
1562 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1565 MessageParameterListOpt
1566 : MessageParameterList { $$ = $1; }
1570 MessageParameterList
1571 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1575 : MessageParameterList { $$ = $1; }
1576 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1579 ClassMessageDeclaration
1580 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1583 ClassMessageDeclarationListOpt
1584 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1589 : Identifier { $$ = $1; }
1590 | "(" AssignmentExpression ")" { $$ = $2; }
1594 : ClassName { $$ = $1; }
1599 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1603 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1607 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1611 : ClassExpression { $$ = $1; }
1615 : ClassStatement { $$ = $1; }
1616 | CategoryStatement { $$ = $1; }
1619 /* Cycript (Objective-C): Send Message {{{ */
1621 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1626 : SelectorCall { $$ = $1; }
1627 | VariadicCall { $$ = $1; }
1631 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1635 : SelectorCall { $$ = $1; }
1636 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1640 : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1641 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1644 SelectorExpressionOpt
1645 : SelectorExpression_ { $$ = $1; }
1650 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1654 : SelectorExpression_ { $$ = $1; }
1655 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1659 : MessageExpression { $$ = $1; }
1660 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1666 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1667 UnaryAssigneeExpression
1668 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
1672 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1676 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1677 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1683 /* Lexer State {{{ */
1685 : { driver.PushCondition(CYDriver::RegExpCondition); }
1689 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1693 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1697 : { driver.PopCondition(); }
1701 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1705 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1714 /* 8.1 Context Keywords {{{ */
1716 : "namespace" { $$ = $1; }
1717 | "xml" { $$ = $1; }
1720 /* 8.3 XML Initialiser Input Elements {{{ */
1722 : XMLComment { $$ = $1; }
1723 | XMLCDATA { $$ = $1; }
1724 | XMLPI { $$ = $1; }
1727 /* 11.1 Primary Expressions {{{ */
1729 : PropertyIdentifier { $$ = $1; }
1730 | XMLInitialiser { $$ = $1; }
1731 | XMLListInitialiser { $$ = $1; }
1735 : AttributeIdentifier { $$ = $1; }
1736 | QualifiedIdentifier { $$ = $1; }
1737 | WildcardIdentifier { $$ = $1; }
1740 /* 11.1.1 Attribute Identifiers {{{ */
1742 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1747 | "[" Expression "]"
1751 : Identifier { $$ = $1; }
1752 | WildcardIdentifier { $$ = $1; }
1755 /* 11.1.2 Qualified Identifiers {{{ */
1756 QualifiedIdentifier_
1757 : PropertySelector_ { $$ = $1; }
1758 | QualifiedIdentifier { $$ = $1; }
1762 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQName($1, $3); }
1765 /* 11.1.3 Wildcard Identifiers {{{ */
1767 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1770 /* 11.1.4 XML Initialiser {{{ */
1772 : XMLMarkup { $$ = $1; }
1773 | XMLElement { $$ = $1; }
1777 : "<" XMLTagContent "/>" LexPop
1778 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1782 : LexPushXMLTag XMLTagName XMLAttributes
1786 : "{" LexPushRegExp Expression "}" LexPop
1795 : XMLAttributes_ XMLAttribute
1800 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1801 | XMLAttributes_ XMLWhitespaceOpt
1810 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1814 : XMLExpression XMLElementContentOpt
1815 | XMLMarkup XMLElementContentOpt
1816 | XMLText XMLElementContentOpt
1817 | XMLElement XMLElementContentOpt
1820 XMLElementContentOpt
1825 /* 11.1.5 XMLList Initialiser {{{ */
1827 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1830 /* 11.2 Left-Hand-Side Expressions {{{ */
1832 : Identifier { $$ = $1; }
1833 | PropertyIdentifier { $$ = $1; }
1837 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1838 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1839 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1842 /* 12.1 The default xml namespace Statement {{{ */
1843 DefaultXMLNamespaceStatement
1844 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1848 : DefaultXMLNamespaceStatement { $$ = $1; }
1853 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1854 PropertyNameAndValueList_
1855 : "," { $$ = NULL; }
1858 /* JavaScript 1.7: Array Comprehensions {{{ */
1860 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1864 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1865 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1868 ComprehensionListOpt
1869 : ComprehensionList { $$ = $1; }
1870 | IfComprehension { $$ = $1; }
1875 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1879 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1882 /* JavaScript 1.7: for each {{{ */
1884 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1887 /* JavaScript 1.7: let Statements {{{ *//*
1889 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1896 /* JavaScript FTW: Function Statements {{{ */
1898 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }