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 "</"
157 %token ColonColon "::"
158 %token PeriodPeriod ".."
162 %token AmpersandAmpersand "&&"
163 %token AmpersandEqual "&="
165 %token CarrotEqual "^="
167 %token EqualEqual "=="
168 %token EqualEqualEqual "==="
169 %token Exclamation "!"
170 %token ExclamationEqual "!="
171 %token ExclamationEqualEqual "!=="
173 %token HyphenEqual "-="
174 %token HyphenHyphen "--"
175 %token HyphenHyphen_ "\n--"
176 %token HyphenRight "->"
178 %token LeftEqual "<="
180 %token LeftLeftEqual "<<="
182 %token PercentEqual "%="
185 %token PipeEqual "|="
188 %token PlusEqual "+="
190 %token PlusPlus_ "\n++"
192 %token RightEqual ">="
193 %token RightRight ">>"
194 %token RightRightEqual ">>="
195 %token RightRightRight ">>>"
196 %token RightRightRightEqual ">>>="
198 %token SlashEqual "/="
200 %token StarEqual "*="
210 %token CloseParen ")"
213 %token CloseBrace "}"
215 %token OpenBracket "["
216 %token CloseBracket "]"
218 %token AtClass "@class"
219 %token AtSelector "@selector"
222 %token <false_> False "false"
223 %token <null_> Null "null"
224 %token <true_> True "true"
226 // ES3/ES5/WIE/JSC Reserved
227 %token <word_> Break "break"
228 %token <word_> Case "case"
229 %token <word_> Catch "catch"
230 %token <word_> Continue "continue"
231 %token <word_> Default "default"
232 %token <word_> Delete "delete"
233 %token <word_> Do "do"
234 %token <word_> Else "else"
235 %token <word_> Finally "finally"
236 %token <word_> For "for"
237 %token <word_> Function "function"
238 %token <word_> If "if"
239 %token <word_> In "in"
240 %token <word_> InstanceOf "instanceof"
241 %token <word_> New "new"
242 %token <word_> Return "return"
243 %token <word_> Switch "switch"
244 %token <this_> This "this"
245 %token <word_> Throw "throw"
246 %token <word_> Try "try"
247 %token <word_> TypeOf "typeof"
248 %token <word_> Var "var"
249 %token <word_> Void "void"
250 %token <word_> While "while"
251 %token <word_> With "with"
253 // ES3/IE6 Future, ES5/JSC Reserved
254 %token <word_> Debugger "debugger"
256 // ES3/ES5/IE6 Future, JSC Reserved
257 %token <word_> Const "const"
259 // ES3/ES5/IE6/JSC Future
260 %token <word_> Class "class"
261 %token <word_> Enum "enum"
262 %token <word_> Export "export"
263 %token <word_> Extends "extends"
264 %token <word_> Import "import"
265 %token <word_> Super "super"
267 // ES3 Future, ES5 Strict Future
268 %token <identifier_> Implements "implements"
269 %token <identifier_> Interface "interface"
270 %token <identifier_> Package "package"
271 %token <identifier_> Private "private"
272 %token <identifier_> Protected "protected"
273 %token <identifier_> Public "public"
274 %token <identifier_> Static "static"
277 %token <identifier_> Abstract "abstract"
278 %token <identifier_> Boolean "boolean"
279 %token <identifier_> Byte "byte"
280 %token <identifier_> Char "char"
281 %token <identifier_> Double "double"
282 %token <identifier_> Final "final"
283 %token <identifier_> Float "float"
284 %token <identifier_> Goto "goto"
285 %token <identifier_> Int "int"
286 %token <identifier_> Long "long"
287 %token <identifier_> Native "native"
288 %token <identifier_> Short "short"
289 %token <identifier_> Synchronized "synchronized"
290 %token <identifier_> Throws "throws"
291 %token <identifier_> Transient "transient"
292 %token <identifier_> Volatile "volatile"
295 %token <identifier_> Let "let"
296 %token <identifier_> Yield "yield"
299 %token <identifier_> Each "each"
303 %token <identifier_> Namespace "namespace"
304 %token <identifier_> XML "xml"
307 %token <identifier_> Identifier_
308 %token <number_> NumericLiteral
309 %token <string_> StringLiteral
310 %token <literal_> RegularExpressionLiteral
312 %type <expression_> AdditiveExpression
313 %type <expression_> AdditiveExpressionNoBF
314 %type <expression_> AdditiveExpressionNoWC
315 %type <argument_> ArgumentList
316 %type <argument_> ArgumentList_
317 %type <argument_> ArgumentListOpt
318 %type <argument_> Arguments
319 %type <literal_> ArrayLiteral
320 %type <expression_> AssigneeExpression
321 %type <expression_> AssigneeExpressionNoBF
322 %type <expression_> AssigneeExpressionNoWC
323 %type <expression_> AssignmentExpression
324 %type <assignment_> AssignmentExpression_
325 %type <expression_> AssignmentExpressionNoBF
326 %type <expression_> AssignmentExpressionNoIn
327 %type <expression_> AssignmentExpressionNoWC
328 %type <expression_> BitwiseANDExpression
329 %type <expression_> BitwiseANDExpressionNoBF
330 %type <expression_> BitwiseANDExpressionNoIn
331 %type <expression_> BitwiseANDExpressionNoWC
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_> BitwiseORExpressionNoWC
339 %type <expression_> BitwiseXORExpression
340 %type <expression_> BitwiseXORExpressionNoBF
341 %type <expression_> BitwiseXORExpressionNoIn
342 %type <expression_> BitwiseXORExpressionNoWC
343 %type <statement_> BreakStatement
344 %type <expression_> CallExpression
345 %type <expression_> CallExpressionNoBF
346 %type <clause_> CaseBlock
347 %type <clause_> CaseClause
348 %type <clause_> CaseClausesOpt
349 %type <catch_> CatchOpt
350 %type <comprehension_> ComprehensionList
351 %type <comprehension_> ComprehensionListOpt
352 %type <expression_> ConditionalExpression
353 %type <expression_> ConditionalExpressionNoBF
354 %type <expression_> ConditionalExpressionNoIn
355 %type <expression_> ConditionalExpressionNoWC
356 %type <statement_> ContinueStatement
357 %type <clause_> DefaultClause
358 %type <statement_> DoWhileStatement
359 %type <expression_> Element
360 %type <expression_> ElementOpt
361 %type <element_> ElementList
362 %type <element_> ElementListOpt
363 %type <statement_> ElseStatementOpt
364 %type <statement_> EmptyStatement
365 %type <expression_> EqualityExpression
366 %type <expression_> EqualityExpressionNoBF
367 %type <expression_> EqualityExpressionNoIn
368 %type <expression_> EqualityExpressionNoWC
369 %type <expression_> Expression
370 %type <expression_> ExpressionOpt
371 %type <compound_> Expression_
372 %type <expression_> ExpressionNoBF
373 %type <expression_> ExpressionNoIn
374 %type <compound_> ExpressionNoIn_
375 %type <expression_> ExpressionNoInOpt
376 %type <statement_> ExpressionStatement
377 %type <finally_> FinallyOpt
378 %type <comprehension_> ForComprehension
379 %type <statement_> ForStatement
380 %type <for_> ForStatementInitialiser
381 %type <statement_> ForInStatement
382 %type <forin_> ForInStatementInitialiser
383 %type <functionParameter_> FormalParameterList
384 %type <functionParameter_> FormalParameterList_
385 %type <statement_> FunctionBody
386 %type <statement_> FunctionDeclaration
387 %type <expression_> FunctionExpression
388 %type <expression_> FunctionExpression_
389 %type <identifier_> Identifier
390 %type <identifier_> IdentifierOpt
391 %type <comprehension_> IfComprehension
392 %type <statement_> IfStatement
393 %type <expression_> Initialiser
394 %type <expression_> InitialiserOpt
395 %type <expression_> InitialiserNoIn
396 %type <expression_> InitialiserNoInOpt
397 %type <statement_> IterationStatement
398 %type <statement_> LabelledStatement
399 %type <expression_> LeftHandSideExpression
400 %type <expression_> LeftHandSideExpressionNoBF
401 %type <expression_> LeftHandSideExpressionNoWC
402 //%type <statement_> LetStatement
403 %type <literal_> Literal
404 %type <literal_> LiteralNoRE
405 %type <literal_> LiteralRE
406 %type <expression_> LogicalANDExpression
407 %type <expression_> LogicalANDExpressionNoBF
408 %type <expression_> LogicalANDExpressionNoIn
409 %type <expression_> LogicalANDExpressionNoWC
410 %type <expression_> LogicalORExpression
411 %type <expression_> LogicalORExpressionNoBF
412 %type <expression_> LogicalORExpressionNoIn
413 %type <expression_> LogicalORExpressionNoWC
414 %type <member_> MemberAccess
415 %type <expression_> MemberExpression
416 %type <expression_> MemberExpression_
417 %type <expression_> MemberExpressionNoBF
418 %type <expression_> MemberExpressionNoWC
419 %type <expression_> MultiplicativeExpression
420 %type <expression_> MultiplicativeExpressionNoBF
421 %type <expression_> MultiplicativeExpressionNoWC
422 %type <expression_> NewExpression
423 %type <expression_> NewExpression_
424 %type <expression_> NewExpressionNoBF
425 %type <expression_> NewExpressionNoWC
426 %type <null_> NullLiteral
427 %type <literal_> ObjectLiteral
428 %type <expression_> PostfixExpression
429 %type <expression_> PostfixExpressionNoBF
430 %type <expression_> PostfixExpressionNoWC
431 %type <expression_> PrimaryExpression
432 %type <expression_> PrimaryExpressionNo
433 %type <expression_> PrimaryExpressionNoBF
434 %type <expression_> PrimaryExpressionNoWC
435 %type <expression_> PrimaryExpressionNoWC_
437 %type <expression_> PrimaryExpressionWC
439 %type <expression_> PrimaryExpressionBF
440 %type <statement_> Program
441 %type <propertyName_> PropertyName
442 %type <propertyName_> PropertyName_
443 %type <property_> PropertyNameAndValueList
444 %type <property_> PropertyNameAndValueList_
445 %type <property_> PropertyNameAndValueListOpt
446 %type <expression_> RelationalExpression
447 %type <infix_> RelationalExpression_
448 %type <expression_> RelationalExpressionNoBF
449 %type <expression_> RelationalExpressionNoIn
450 %type <expression_> RelationalExpressionNoWC
451 %type <infix_> RelationalExpressionNoIn_
452 %type <statement_> ReturnStatement
453 %type <expression_> ShiftExpression
454 %type <expression_> ShiftExpressionNoBF
455 %type <expression_> ShiftExpressionNoWC
456 %type <statement_> SourceElement
457 %type <statement_> SourceElement_
458 %type <statement_> SourceElements
459 %type <statement_> Statement
460 %type <statement_> Statement_
461 %type <statement_> StatementList
462 %type <statement_> StatementListOpt
463 %type <statement_> SwitchStatement
464 %type <statement_> ThrowStatement
465 %type <statement_> TryStatement
466 %type <expression_> UnaryAssigneeExpression
467 %type <expression_> UnaryExpression
468 %type <expression_> UnaryExpression_
469 %type <expression_> UnaryExpressionNoBF
470 %type <expression_> UnaryExpressionNoWC
471 %type <declaration_> VariableDeclaration
472 %type <declaration_> VariableDeclarationNoIn
473 %type <declarations_> VariableDeclarationList
474 %type <declarations_> VariableDeclarationList_
475 %type <declarations_> VariableDeclarationListNoIn
476 %type <declarations_> VariableDeclarationListNoIn_
477 %type <statement_> VariableStatement
478 %type <statement_> WhileStatement
479 %type <statement_> WithStatement
482 %type <statement_> CategoryStatement
483 %type <expression_> ClassExpression
484 %type <statement_> ClassStatement
485 %type <expression_> ClassSuperOpt
486 %type <field_> ClassFieldList
487 %type <message_> ClassMessageDeclaration
488 %type <message_> ClassMessageDeclarationListOpt
489 %type <className_> ClassName
490 %type <className_> ClassNameOpt
491 %type <expression_> MessageExpression
492 %type <messageParameter_> MessageParameter
493 %type <messageParameter_> MessageParameters
494 %type <messageParameter_> MessageParameterList
495 %type <messageParameter_> MessageParameterListOpt
496 %type <bool_> MessageScope
497 %type <argument_> SelectorCall
498 %type <argument_> SelectorCall_
499 %type <selector_> SelectorExpression
500 %type <selector_> SelectorExpression_
501 %type <selector_> SelectorExpressionOpt
502 %type <argument_> SelectorList
503 %type <expression_> TypeOpt
504 %type <argument_> VariadicCall
506 %type <word_> WordOpt
510 %type <propertyIdentifier_> PropertyIdentifier_
511 %type <selector_> PropertySelector
512 %type <selector_> PropertySelector_
513 %type <identifier_> QualifiedIdentifier
514 %type <identifier_> QualifiedIdentifier_
515 %type <identifier_> WildcardIdentifier
516 %type <identifier_> XMLComment
517 %type <identifier_> XMLCDATA
518 %type <identifier_> XMLElement
519 %type <identifier_> XMLElementContent
520 %type <identifier_> XMLMarkup
521 %type <identifier_> XMLPI
523 %type <attribute_> AttributeIdentifier
524 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
525 %type <expression_> PropertyIdentifier
526 %type <expression_> XMLListInitialiser
527 %type <expression_> XMLInitialiser
532 %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"
542 %left "<<" ">>" ">>>"
543 %left "<" ">" "<=" ">=" "instanceof" "in"
544 %left "==" "!=" "===" "!=="
551 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
557 /* Lexer State {{{ */
559 : { driver.SetCondition(CYDriver::RegExpCondition); }
564 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
574 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
579 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
599 : Identifier { $$ = $1; }
600 | "break" NewLineOpt { $$ = $1; }
601 | "case" { $$ = $1; }
602 | "catch" { $$ = $1; }
603 | "class" { $$ = $1; }
604 | "const" { $$ = $1; }
605 | "continue" NewLineOpt { $$ = $1; }
606 | "debugger" { $$ = $1; }
607 | "default" { $$ = $1; }
608 | "delete" { $$ = $1; }
610 | "else" { $$ = $1; }
611 | "enum" { $$ = $1; }
612 | "export" { $$ = $1; }
613 | "extends" { $$ = $1; }
614 | "false" { $$ = $1; }
615 | "finally" { $$ = $1; }
616 /* XXX: | "for" { $$ = $1; } */
617 | "function" { $$ = $1; }
619 | "import" { $$ = $1; }
620 /* XXX: | "in" { $$ = $1; } */
621 /* XXX: | "instanceof" { $$ = $1; } */
623 | "null" { $$ = $1; }
624 | "return" NewLineOpt { $$ = $1; }
625 | "super" { $$ = $1; }
626 | "switch" { $$ = $1; }
627 | "this" { $$ = $1; }
628 | "throw" NewLineOpt { $$ = $1; }
629 | "true" { $$ = $1; }
631 | "typeof" { $$ = $1; }
633 | "void" { $$ = $1; }
634 | "while" { $$ = $1; }
635 | "with" { $$ = $1; }
640 : Identifier_ { $$ = $1; }
642 | "implements" { $$ = $1; }
643 | "interface" { $$ = $1; }
644 | "package" { $$ = $1; }
645 | "private" { $$ = $1; }
646 | "protected" { $$ = $1; }
647 | "public" { $$ = $1; }
648 | "static" { $$ = $1; }
650 | "abstract" { $$ = $1; }
651 | "boolean" { $$ = $1; }
652 | "byte" { $$ = $1; }
653 | "char" { $$ = $1; }
654 | "double" { $$ = $1; }
655 | "final" { $$ = $1; }
656 | "float" { $$ = $1; }
657 | "goto" { $$ = $1; }
659 | "long" { $$ = $1; }
660 | "native" { $$ = $1; }
661 | "short" { $$ = $1; }
662 | "synchronized" { $$ = $1; }
663 | "throws" { $$ = $1; }
664 | "transient" { $$ = $1; }
665 | "volatile" { $$ = $1; }
668 | "yield" { $$ = $1; }
670 | "each" { $$ = $1; }
674 : Identifier { $$ = $1; }
679 : NullLiteral { $$ = $1; }
680 | BooleanLiteral { $$ = $1; }
681 | NumericLiteral { $$ = $1; }
682 | StringLiteral { $$ = $1; }
683 | "@" StringLiteral { $$ = $2; }
687 : RegularExpressionLiteral { $$ = $1; }
691 : LiteralNoRE { $$ = $1; }
692 | LiteralRE { $$ = $1; }
696 : "null" { $$ = $1; }
700 : "true" { $$ = $1; }
701 | "false" { $$ = $1; }
704 /* 11.1 Primary Expressions {{{ */
706 : PrimaryExpressionNoWC { $$ = $1; }
708 | LexSetRegExp PrimaryExpressionWC { $$ = $2; }
712 PrimaryExpressionNoBF
713 : PrimaryExpressionNo { $$ = $1; }
715 | PrimaryExpressionWC { $$ = $1; }
719 PrimaryExpressionNoWC_
720 : PrimaryExpressionBF { $$ = $1; }
721 | PrimaryExpressionNo { $$ = $1; }
724 PrimaryExpressionNoWC
725 : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; }
729 : "this" { $$ = $1; }
730 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
731 | Literal { $$ = $1; }
732 | ArrayLiteral { $$ = $1; }
733 | "(" Expression ")" { $$ = $2; }
737 : ObjectLiteral { $$ = $1; }
740 /* 11.1.4 Array Initialiser {{{ */
742 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
746 : AssignmentExpression { $$ = $1; }
750 : Element { $$ = $1; }
751 | LexSetRegExp { $$ = NULL; }
755 : ElementList { $$ = $1; }
756 | LexSetRegExp { $$ = NULL; }
760 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
761 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
764 /* 11.1.5 Object Initialiser {{{ */
766 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
769 PropertyNameAndValueList_
770 : "," PropertyNameAndValueList { $$ = $2; }
774 PropertyNameAndValueListOpt
775 : PropertyNameAndValueList { $$ = $1; }
779 PropertyNameAndValueList
780 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
784 : Identifier { $$ = $1; }
785 | StringLiteral { $$ = $1; }
786 | NumericLiteral { $$ = $1; }
790 : LexSetRegExp PropertyName_ { $$ = $2; }
794 /* 11.2 Left-Hand-Side Expressions {{{ */
796 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
800 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
801 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
805 : PrimaryExpression { $$ = $1; }
806 | FunctionExpression { $$ = $1; }
807 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
808 | LexSetRegExp MemberExpression_ { $$ = $2; }
812 : PrimaryExpressionNoBF { $$ = $1; }
813 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
814 | MemberExpression_ { $$ = $1; }
818 : PrimaryExpression { $$ = $1; }
819 | FunctionExpression { $$ = $1; }
820 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
821 | LexSetRegExp MemberExpression_ { $$ = $2; }
825 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
829 : MemberExpression { $$ = $1; }
830 | LexSetRegExp NewExpression_ { $$ = $2; }
834 : MemberExpressionNoBF { $$ = $1; }
835 | NewExpression_ { $$ = $1; }
839 : MemberExpressionNoWC { $$ = $1; }
840 | LexSetRegExp NewExpression_ { $$ = $2; }
844 : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
845 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
846 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
850 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
851 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
852 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
856 : "," ArgumentList { $$ = $2; }
861 : ArgumentList { $$ = $1; }
862 | LexSetRegExp { $$ = NULL; }
866 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
870 : "(" ArgumentListOpt ")" { $$ = $2; }
873 LeftHandSideExpression
874 : NewExpression { $$ = $1; }
875 | CallExpression { $$ = $1; }
878 LeftHandSideExpressionNoBF
879 : NewExpressionNoBF { $$ = $1; }
880 | CallExpressionNoBF { $$ = $1; }
883 LeftHandSideExpressionNoWC
884 : NewExpressionNoWC { $$ = $1; }
885 | CallExpression { $$ = $1; }
888 /* 11.3 Postfix Expressions {{{ */
890 : AssigneeExpression { $$ = $1; }
891 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
892 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
895 PostfixExpressionNoBF
896 : AssigneeExpressionNoBF { $$ = $1; }
897 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
898 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
901 PostfixExpressionNoWC
902 : AssigneeExpressionNoWC { $$ = $1; }
903 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
904 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
907 /* 11.4 Unary Operators {{{ */
909 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
910 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
911 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
912 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
913 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
914 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
915 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
916 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
917 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
918 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
919 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
923 : PostfixExpression { $$ = $1; }
924 | LexSetRegExp UnaryExpression_ { $$ = $2; }
928 : PostfixExpressionNoBF { $$ = $1; }
929 | UnaryExpression_ { $$ = $1; }
933 : PostfixExpressionNoWC { $$ = $1; }
934 | LexSetRegExp UnaryExpression_ { $$ = $2; }
937 /* 11.5 Multiplicative Operators {{{ */
938 MultiplicativeExpression
939 : UnaryExpression { $$ = $1; }
940 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
941 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
942 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
945 MultiplicativeExpressionNoBF
946 : UnaryExpressionNoBF { $$ = $1; }
947 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
948 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
949 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
952 MultiplicativeExpressionNoWC
953 : UnaryExpressionNoWC { $$ = $1; }
954 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
955 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
956 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
959 /* 11.6 Additive Operators {{{ */
961 : MultiplicativeExpression { $$ = $1; }
962 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
963 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
966 AdditiveExpressionNoBF
967 : MultiplicativeExpressionNoBF { $$ = $1; }
968 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
969 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
972 AdditiveExpressionNoWC
973 : MultiplicativeExpressionNoWC { $$ = $1; }
974 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
975 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
978 /* 11.7 Bitwise Shift Operators {{{ */
980 : AdditiveExpression { $$ = $1; }
981 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
982 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
983 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
987 : AdditiveExpressionNoBF { $$ = $1; }
988 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
989 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
990 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
994 : AdditiveExpressionNoWC { $$ = $1; }
995 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
996 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
997 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1000 /* 11.8 Relational Operators {{{ */
1001 RelationalExpressionNoIn_
1002 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
1003 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
1004 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
1005 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
1006 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
1009 RelationalExpression_
1010 : RelationalExpressionNoIn_ { $$ = $1; }
1011 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1014 RelationalExpression
1015 : ShiftExpression { $$ = $1; }
1016 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1019 RelationalExpressionNoIn
1020 : ShiftExpression { $$ = $1; }
1021 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1024 RelationalExpressionNoBF
1025 : ShiftExpressionNoBF { $$ = $1; }
1026 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1029 RelationalExpressionNoWC
1030 : ShiftExpressionNoWC { $$ = $1; }
1031 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1034 /* 11.9 Equality Operators {{{ */
1036 : RelationalExpression { $$ = $1; }
1037 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1038 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1039 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1040 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1043 EqualityExpressionNoIn
1044 : RelationalExpressionNoIn { $$ = $1; }
1045 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1046 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1047 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1048 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1051 EqualityExpressionNoBF
1052 : RelationalExpressionNoBF { $$ = $1; }
1053 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1054 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1055 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1056 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1059 EqualityExpressionNoWC
1060 : RelationalExpressionNoWC { $$ = $1; }
1061 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1062 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1063 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1064 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1067 /* 11.10 Binary Bitwise Operators {{{ */
1068 BitwiseANDExpression
1069 : EqualityExpression { $$ = $1; }
1070 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1073 BitwiseANDExpressionNoIn
1074 : EqualityExpressionNoIn { $$ = $1; }
1075 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1078 BitwiseANDExpressionNoBF
1079 : EqualityExpressionNoBF { $$ = $1; }
1080 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1083 BitwiseANDExpressionNoWC
1084 : EqualityExpressionNoWC { $$ = $1; }
1085 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1088 BitwiseXORExpression
1089 : BitwiseANDExpression { $$ = $1; }
1090 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1093 BitwiseXORExpressionNoIn
1094 : BitwiseANDExpressionNoIn { $$ = $1; }
1095 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1098 BitwiseXORExpressionNoBF
1099 : BitwiseANDExpressionNoBF { $$ = $1; }
1100 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1103 BitwiseXORExpressionNoWC
1104 : BitwiseANDExpressionNoWC { $$ = $1; }
1105 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1109 : BitwiseXORExpression { $$ = $1; }
1110 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1113 BitwiseORExpressionNoIn
1114 : BitwiseXORExpressionNoIn { $$ = $1; }
1115 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1118 BitwiseORExpressionNoBF
1119 : BitwiseXORExpressionNoBF { $$ = $1; }
1120 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1123 BitwiseORExpressionNoWC
1124 : BitwiseXORExpressionNoWC { $$ = $1; }
1125 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1128 /* 11.11 Binary Logical Operators {{{ */
1129 LogicalANDExpression
1130 : BitwiseORExpression { $$ = $1; }
1131 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1134 LogicalANDExpressionNoIn
1135 : BitwiseORExpressionNoIn { $$ = $1; }
1136 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1139 LogicalANDExpressionNoBF
1140 : BitwiseORExpressionNoBF { $$ = $1; }
1141 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1144 LogicalANDExpressionNoWC
1145 : BitwiseORExpressionNoWC { $$ = $1; }
1146 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1150 : LogicalANDExpression { $$ = $1; }
1151 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1154 LogicalORExpressionNoIn
1155 : LogicalANDExpressionNoIn { $$ = $1; }
1156 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1159 LogicalORExpressionNoBF
1160 : LogicalANDExpressionNoBF { $$ = $1; }
1161 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1164 LogicalORExpressionNoWC
1165 : LogicalANDExpressionNoWC { $$ = $1; }
1166 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1169 /* 11.12 Conditional Operator ( ? : ) {{{ */
1170 ConditionalExpression
1171 : LogicalORExpression { $$ = $1; }
1172 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1175 ConditionalExpressionNoIn
1176 : LogicalORExpressionNoIn { $$ = $1; }
1177 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1180 ConditionalExpressionNoBF
1181 : LogicalORExpressionNoBF { $$ = $1; }
1182 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1185 ConditionalExpressionNoWC
1186 : LogicalORExpressionNoWC { $$ = $1; }
1187 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1190 /* 11.13 Assignment Operators {{{ */
1191 AssignmentExpression_
1192 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1193 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1194 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1195 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1196 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1197 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1198 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1199 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1200 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1201 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1202 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1203 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1207 : LeftHandSideExpression { $$ = $1; }
1208 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1211 AssigneeExpressionNoBF
1212 : LeftHandSideExpressionNoBF { $$ = $1; }
1213 | UnaryAssigneeExpression { $$ = $1; }
1216 AssigneeExpressionNoWC
1217 : LeftHandSideExpressionNoWC { $$ = $1; }
1218 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1221 AssignmentExpression
1222 : ConditionalExpression { $$ = $1; }
1223 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1226 AssignmentExpressionNoIn
1227 : ConditionalExpressionNoIn { $$ = $1; }
1228 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1229 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1230 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1231 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1232 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1233 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1234 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1235 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1236 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1237 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1238 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1239 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1242 AssignmentExpressionNoBF
1243 : ConditionalExpressionNoBF { $$ = $1; }
1244 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1247 AssignmentExpressionNoWC
1248 : ConditionalExpressionNoWC { $$ = $1; }
1249 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1252 /* 11.14 Comma Operator {{{ */
1254 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1259 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1264 : Expression { $$ = $1; }
1265 | LexSetRegExp { $$ = NULL; }
1269 : ExpressionNoIn { $$ = $1; }
1270 | LexSetRegExp { $$ = NULL; }
1274 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1278 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1282 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1286 /* 12 Statements {{{ */
1288 : Block { $$ = $1; }
1289 | VariableStatement { $$ = $1; }
1290 | EmptyStatement { $$ = $1; }
1291 | ExpressionStatement { $$ = $1; }
1292 | IfStatement { $$ = $1; }
1293 | IterationStatement { $$ = $1; }
1294 | ContinueStatement { $$ = $1; }
1295 | BreakStatement { $$ = $1; }
1296 | ReturnStatement { $$ = $1; }
1297 | WithStatement { $$ = $1; }
1298 | LabelledStatement { $$ = $1; }
1299 | SwitchStatement { $$ = $1; }
1300 | ThrowStatement { $$ = $1; }
1301 | TryStatement { $$ = $1; }
1305 : LexSetRegExp Statement_ { $$ = $2; }
1308 /* 12.1 Block {{{ */
1310 : "{" StatementListOpt "}" { $$ = $2; }
1314 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1318 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1322 : StatementList { $$ = $1; }
1323 | LexSetRegExp { $$ = NULL; }
1326 /* 12.2 Variable Statement {{{ */
1328 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1331 VariableDeclarationList_
1332 : "," VariableDeclarationList { $$ = $2; }
1336 VariableDeclarationListNoIn_
1337 : "," VariableDeclarationListNoIn { $$ = $2; }
1341 VariableDeclarationList
1342 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1345 VariableDeclarationListNoIn
1346 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1350 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1353 VariableDeclarationNoIn
1354 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1358 : Initialiser { $$ = $1; }
1363 : InitialiserNoIn { $$ = $1; }
1368 : "=" AssignmentExpression { $$ = $2; }
1372 : "=" AssignmentExpressionNoIn { $$ = $2; }
1375 /* 12.3 Empty Statement {{{ */
1377 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1380 /* 12.4 Expression Statement {{{ */
1382 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1385 /* 12.5 The if Statement {{{ */
1387 : "else" Statement { $$ = $2; }
1388 | %prec "if" { $$ = NULL; }
1392 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1396 /* 12.6 Iteration Statements {{{ */
1398 : DoWhileStatement { $$ = $1; }
1399 | WhileStatement { $$ = $1; }
1400 | ForStatement { $$ = $1; }
1401 | ForInStatement { $$ = $1; }
1404 /* 12.6.1 The do-while Statement {{{ */
1406 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1409 /* 12.6.2 The while Statement {{{ */
1411 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1414 /* 12.6.3 The for Statement {{{ */
1416 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1419 ForStatementInitialiser
1420 : ExpressionNoInOpt { $$ = $1; }
1421 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1424 /* 12.6.4 The for-in Statement {{{ */
1426 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1429 ForInStatementInitialiser
1430 : LeftHandSideExpression { $$ = $1; }
1431 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1435 /* 12.7 The continue Statement {{{ */
1437 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1440 /* 12.8 The break Statement {{{ */
1442 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1445 /* 12.9 The return Statement {{{ */
1447 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1450 /* 12.10 The with Statement {{{ */
1452 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1456 /* 12.11 The switch Statement {{{ */
1458 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1462 : "{" CaseClausesOpt "}" { $$ = $2; }
1466 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1467 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1472 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1476 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1479 /* 12.12 Labelled Statements {{{ */
1481 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1484 /* 12.13 The throw Statement {{{ */
1486 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1489 /* 12.14 The try Statement {{{ */
1491 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1495 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1500 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1505 /* 13 Function Definition {{{ */
1507 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1511 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1515 : LexSetRegExp FunctionExpression_ { $$ = $2; }
1518 FormalParameterList_
1519 : "," FormalParameterList { $$ = $2; }
1524 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1529 : SourceElements { $$ = $1; }
1532 /* 14 Program {{{ */
1534 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1538 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1539 | LexSetRegExp { $$ = NULL; }
1543 : Statement_ { $$ = $1; }
1544 | FunctionDeclaration { $$ = $1; }
1548 : LexSetRegExp SourceElement_ { $$ = $2; }
1553 /* Cycript (Objective-C): @class Declaration {{{ */
1555 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1556 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1561 : "{" "}" { $$ = NULL; }
1565 : "+" { $$ = false; }
1566 | "-" { $$ = true; }
1570 : "(" Expression ")" { $$ = $2; }
1575 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1578 MessageParameterListOpt
1579 : MessageParameterList { $$ = $1; }
1583 MessageParameterList
1584 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1588 : MessageParameterList { $$ = $1; }
1589 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1592 ClassMessageDeclaration
1593 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1596 ClassMessageDeclarationListOpt
1597 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1602 : Identifier { $$ = $1; }
1603 | "(" AssignmentExpression ")" { $$ = $2; }
1607 : ClassName { $$ = $1; }
1612 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1616 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1620 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1624 : ClassExpression { $$ = $1; }
1628 : ClassStatement { $$ = $1; }
1629 | CategoryStatement { $$ = $1; }
1632 /* Cycript (Objective-C): Send Message {{{ */
1634 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1639 : SelectorCall { $$ = $1; }
1640 | VariadicCall { $$ = $1; }
1644 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1648 : SelectorCall { $$ = $1; }
1649 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1653 : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1654 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1657 SelectorExpressionOpt
1658 : SelectorExpression_ { $$ = $1; }
1663 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1667 : SelectorExpression_ { $$ = $1; }
1668 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1672 : MessageExpression { $$ = $1; }
1673 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1679 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1680 UnaryAssigneeExpression
1681 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
1685 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1689 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1690 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1696 /* Lexer State {{{ */
1698 : { driver.PushCondition(CYDriver::RegExpCondition); }
1702 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1706 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1710 : { driver.PopCondition(); }
1714 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1718 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1727 /* 8.1 Context Keywords {{{ */
1729 : "namespace" { $$ = $1; }
1730 | "xml" { $$ = $1; }
1733 /* 8.3 XML Initialiser Input Elements {{{ */
1735 : XMLComment { $$ = $1; }
1736 | XMLCDATA { $$ = $1; }
1737 | XMLPI { $$ = $1; }
1740 /* 11.1 Primary Expressions {{{ */
1742 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1743 | XMLInitialiser { $$ = $1; }
1744 | XMLListInitialiser { $$ = $1; }
1748 : AttributeIdentifier { $$ = $1; }
1749 | QualifiedIdentifier { $$ = $1; }
1750 | WildcardIdentifier { $$ = $1; }
1753 /* 11.1.1 Attribute Identifiers {{{ */
1755 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1759 : PropertySelector { $$ = $1; }
1760 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1764 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1765 | WildcardIdentifier { $$ = $1; }
1768 /* 11.1.2 Qualified Identifiers {{{ */
1769 QualifiedIdentifier_
1770 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1771 | QualifiedIdentifier { $$ = $1; }
1775 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1778 /* 11.1.3 Wildcard Identifiers {{{ */
1780 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1783 /* 11.1.4 XML Initialiser {{{ */
1785 : XMLMarkup { $$ = $1; }
1786 | XMLElement { $$ = $1; }
1790 : "<" XMLTagContent "/>" LexPop
1791 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1795 : LexPushXMLTag XMLTagName XMLAttributes
1799 : "{" LexPushRegExp Expression "}" LexPop
1808 : XMLAttributes_ XMLAttribute
1813 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1814 | XMLAttributes_ XMLWhitespaceOpt
1823 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1827 : XMLExpression XMLElementContentOpt
1828 | XMLMarkup XMLElementContentOpt
1829 | XMLText XMLElementContentOpt
1830 | XMLElement XMLElementContentOpt
1833 XMLElementContentOpt
1838 /* 11.1.5 XMLList Initialiser {{{ */
1840 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1843 /* 11.2 Left-Hand-Side Expressions {{{ */
1845 : Identifier { $$ = $1; }
1846 | PropertyIdentifier { $$ = $1; }
1850 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1851 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1852 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1855 /* 12.1 The default xml namespace Statement {{{ */
1856 /* XXX: DefaultXMLNamespaceStatement
1857 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1861 : DefaultXMLNamespaceStatement { $$ = $1; }
1866 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1867 PropertyNameAndValueList_
1868 : "," { $$ = NULL; }
1871 /* JavaScript 1.7: Array Comprehensions {{{ */
1873 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1877 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1878 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1881 ComprehensionListOpt
1882 : ComprehensionList { $$ = $1; }
1883 | IfComprehension { $$ = $1; }
1888 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1892 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1895 /* JavaScript 1.7: for each {{{ */
1897 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1900 /* JavaScript 1.7: let Statements {{{ *//*
1902 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1909 /* JavaScript FTW: Function Statements {{{ */
1911 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }