1 /* Cycript - Inlining/Optimizing JavaScript Compiler
2 * Copyright (C) 2009 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include "Cycript.tab.hh"
42 #define scanner driver.scanner_
43 #define YYSTACKEXPANDABLE 1
50 #include "ObjectiveC/Syntax.hpp"
54 #include "E4X/Syntax.hpp"
63 CYDriver::Condition condition_;
65 CYArgument *argument_;
66 CYAssignment *assignment_;
69 cy::Syntax::Catch *catch_;
70 CYComprehension *comprehension_;
71 CYCompound *compound_;
72 CYDeclaration *declaration_;
73 CYDeclarations *declarations_;
75 CYExpression *expression_;
78 CYForInitialiser *for_;
79 CYForInInitialiser *forin_;
80 CYFunctionParameter *functionParameter_;
81 CYIdentifier *identifier_;
88 CYProperty *property_;
89 CYPropertyName *propertyName_;
90 CYStatement *statement_;
97 CYClassName *className_;
100 CYMessageParameter *messageParameter_;
101 CYSelectorPart *selector_;
105 CYAttribute *attribute_;
106 CYPropertyIdentifier *propertyIdentifier_;
107 CYSelector *selector_;
115 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
124 @$.begin.filename = @$.end.filename = &driver.filename_;
134 %parse-param { CYDriver &driver }
135 %lex-param { void *scanner }
142 %token XMLAttributeValue
144 %token XMLTagCharacters
150 %token LeftRight "<>"
151 %token LeftSlashRight "</>"
153 %token SlashRight "/>"
154 %token LeftSlash "</"
156 %token ColonColon "::"
157 %token PeriodPeriod ".."
160 @begin E4X ObjectiveC
165 %token AmpersandAmpersand "&&"
166 %token AmpersandEqual "&="
168 %token CarrotEqual "^="
170 %token EqualEqual "=="
171 %token EqualEqualEqual "==="
172 %token Exclamation "!"
173 %token ExclamationEqual "!="
174 %token ExclamationEqualEqual "!=="
176 %token HyphenEqual "-="
177 %token HyphenHyphen "--"
178 %token HyphenHyphen_ "\n--"
179 %token HyphenRight "->"
181 %token LeftEqual "<="
183 %token LeftLeftEqual "<<="
185 %token PercentEqual "%="
188 %token PipeEqual "|="
191 %token PlusEqual "+="
193 %token PlusPlus_ "\n++"
195 %token RightEqual ">="
196 %token RightRight ">>"
197 %token RightRightEqual ">>="
198 %token RightRightRight ">>>"
199 %token RightRightRightEqual ">>>="
201 %token SlashEqual "/="
203 %token StarEqual "*="
213 %token CloseParen ")"
216 %token CloseBrace "}"
218 %token OpenBracket "["
219 %token CloseBracket "]"
221 %token AtClass "@class"
222 %token AtSelector "@selector"
225 %token <false_> False "false"
226 %token <null_> Null "null"
227 %token <true_> True "true"
229 // ES3/ES5/WIE/JSC Reserved
230 %token <word_> Break "break"
231 %token <word_> Case "case"
232 %token <word_> Catch "catch"
233 %token <word_> Continue "continue"
234 %token <word_> Default "default"
235 %token <word_> Delete "delete"
236 %token <word_> Do "do"
237 %token <word_> Else "else"
238 %token <word_> Finally "finally"
239 %token <word_> For "for"
240 %token <word_> Function "function"
241 %token <word_> If "if"
242 %token <word_> In "in"
243 %token <word_> InstanceOf "instanceof"
244 %token <word_> New "new"
245 %token <word_> Return "return"
246 %token <word_> Switch "switch"
247 %token <this_> This "this"
248 %token <word_> Throw "throw"
249 %token <word_> Try "try"
250 %token <word_> TypeOf "typeof"
251 %token <word_> Var "var"
252 %token <word_> Void "void"
253 %token <word_> While "while"
254 %token <word_> With "with"
256 // ES3/IE6 Future, ES5/JSC Reserved
257 %token <word_> Debugger "debugger"
259 // ES3/ES5/IE6 Future, JSC Reserved
260 %token <word_> Const "const"
262 // ES3/ES5/IE6/JSC Future
263 %token <word_> Class "class"
264 %token <word_> Enum "enum"
265 %token <word_> Export "export"
266 %token <word_> Extends "extends"
267 %token <word_> Import "import"
268 %token <word_> Super "super"
270 // ES3 Future, ES5 Strict Future
271 %token <identifier_> Implements "implements"
272 %token <identifier_> Interface "interface"
273 %token <identifier_> Package "package"
274 %token <identifier_> Private "private"
275 %token <identifier_> Protected "protected"
276 %token <identifier_> Public "public"
277 %token <identifier_> Static "static"
280 %token <identifier_> Abstract "abstract"
281 %token <identifier_> Boolean "boolean"
282 %token <identifier_> Byte "byte"
283 %token <identifier_> Char "char"
284 %token <identifier_> Double "double"
285 %token <identifier_> Final "final"
286 %token <identifier_> Float "float"
287 %token <identifier_> Goto "goto"
288 %token <identifier_> Int "int"
289 %token <identifier_> Long "long"
290 %token <identifier_> Native "native"
291 %token <identifier_> Short "short"
292 %token <identifier_> Synchronized "synchronized"
293 %token <identifier_> Throws "throws"
294 %token <identifier_> Transient "transient"
295 %token <identifier_> Volatile "volatile"
298 %token <identifier_> Let "let"
299 %token <identifier_> Yield "yield"
302 %token <identifier_> Each "each"
306 %token <identifier_> Namespace "namespace"
307 %token <identifier_> XML "xml"
310 %token <identifier_> Identifier_
311 %token <number_> NumericLiteral
312 %token <string_> StringLiteral
313 %token <literal_> RegularExpressionLiteral
315 %type <expression_> AdditiveExpression
316 %type <expression_> AdditiveExpressionNoBF
317 %type <expression_> AdditiveExpressionNoWC
318 %type <argument_> ArgumentList
319 %type <argument_> ArgumentList_
320 %type <argument_> ArgumentListOpt
321 %type <argument_> Arguments
322 %type <literal_> ArrayLiteral
323 %type <expression_> AssigneeExpression
324 %type <expression_> AssigneeExpressionNoBF
325 %type <expression_> AssigneeExpressionNoRE
326 %type <expression_> AssigneeExpressionNoWC
327 %type <expression_> AssignmentExpression
328 %type <assignment_> AssignmentExpression_
329 %type <expression_> AssignmentExpressionNoBF
330 %type <expression_> AssignmentExpressionNoIn
331 %type <expression_> AssignmentExpressionNoWC
332 %type <expression_> BitwiseANDExpression
333 %type <expression_> BitwiseANDExpressionNoBF
334 %type <expression_> BitwiseANDExpressionNoIn
335 %type <expression_> BitwiseANDExpressionNoWC
336 %type <statement_> Block
337 %type <statement_> Block_
338 %type <boolean_> BooleanLiteral
339 %type <expression_> BitwiseORExpression
340 %type <expression_> BitwiseORExpressionNoBF
341 %type <expression_> BitwiseORExpressionNoIn
342 %type <expression_> BitwiseORExpressionNoWC
343 %type <expression_> BitwiseXORExpression
344 %type <expression_> BitwiseXORExpressionNoBF
345 %type <expression_> BitwiseXORExpressionNoIn
346 %type <expression_> BitwiseXORExpressionNoWC
347 %type <statement_> BreakStatement
348 %type <expression_> CallExpression
349 %type <expression_> CallExpressionNoBF
350 %type <expression_> CallExpressionNoRE
351 %type <clause_> CaseBlock
352 %type <clause_> CaseClause
353 %type <clause_> CaseClausesOpt
354 %type <catch_> CatchOpt
355 %type <comprehension_> ComprehensionList
356 %type <comprehension_> ComprehensionListOpt
357 %type <expression_> ConditionalExpression
358 %type <expression_> ConditionalExpressionNoBF
359 %type <expression_> ConditionalExpressionNoIn
360 %type <expression_> ConditionalExpressionNoWC
361 %type <statement_> ContinueStatement
362 %type <clause_> DefaultClause
363 %type <statement_> DoWhileStatement
364 %type <expression_> Element
365 %type <expression_> ElementOpt
366 %type <element_> ElementList
367 %type <element_> ElementListOpt
368 %type <statement_> ElseStatementOpt
369 %type <statement_> EmptyStatement
370 %type <expression_> EqualityExpression
371 %type <expression_> EqualityExpressionNoBF
372 %type <expression_> EqualityExpressionNoIn
373 %type <expression_> EqualityExpressionNoWC
374 %type <expression_> Expression
375 %type <expression_> ExpressionOpt
376 %type <compound_> Expression_
377 %type <expression_> ExpressionNoBF
378 %type <expression_> ExpressionNoIn
379 %type <compound_> ExpressionNoIn_
380 %type <expression_> ExpressionNoInOpt
381 %type <statement_> ExpressionStatement
382 %type <finally_> FinallyOpt
383 %type <comprehension_> ForComprehension
384 %type <statement_> ForStatement
385 %type <for_> ForStatementInitialiser
386 %type <statement_> ForInStatement
387 %type <forin_> ForInStatementInitialiser
388 %type <functionParameter_> FormalParameterList
389 %type <functionParameter_> FormalParameterList_
390 %type <statement_> FunctionBody
391 %type <statement_> FunctionDeclaration
392 %type <expression_> FunctionExpression
393 %type <identifier_> Identifier
394 %type <identifier_> IdentifierOpt
395 %type <comprehension_> IfComprehension
396 %type <statement_> IfStatement
397 %type <expression_> Initialiser
398 %type <expression_> InitialiserOpt
399 %type <expression_> InitialiserNoIn
400 %type <expression_> InitialiserNoInOpt
401 %type <statement_> IterationStatement
402 %type <statement_> LabelledStatement
403 %type <expression_> LeftHandSideExpression
404 %type <expression_> LeftHandSideExpressionNoBF
405 %type <expression_> LeftHandSideExpressionNoRE
406 %type <expression_> LeftHandSideExpressionNoWC
407 //%type <statement_> LetStatement
408 %type <literal_> Literal
409 %type <literal_> LiteralNoRE
410 %type <literal_> LiteralRE
411 %type <expression_> LogicalANDExpression
412 %type <expression_> LogicalANDExpressionNoBF
413 %type <expression_> LogicalANDExpressionNoIn
414 %type <expression_> LogicalANDExpressionNoWC
415 %type <expression_> LogicalORExpression
416 %type <expression_> LogicalORExpressionNoBF
417 %type <expression_> LogicalORExpressionNoIn
418 %type <expression_> LogicalORExpressionNoWC
419 %type <member_> MemberAccess
420 %type <expression_> MemberExpression
421 %type <expression_> MemberExpression_
422 %type <expression_> MemberExpressionNoBF
423 %type <expression_> MemberExpressionNoRE
424 %type <expression_> MemberExpressionNoWC
425 %type <expression_> MultiplicativeExpression
426 %type <expression_> MultiplicativeExpressionNoBF
427 %type <expression_> MultiplicativeExpressionNoWC
428 %type <expression_> NewExpression
429 %type <expression_> NewExpression_
430 %type <expression_> NewExpressionNoBF
431 %type <expression_> NewExpressionNoRE
432 %type <expression_> NewExpressionNoWC
433 %type <null_> NullLiteral
434 %type <literal_> ObjectLiteral
435 %type <expression_> PostfixExpression
436 %type <expression_> PostfixExpressionNoBF
437 %type <expression_> PostfixExpressionNoRE
438 %type <expression_> PostfixExpressionNoWC
439 %type <expression_> PrimaryExpression
440 %type <expression_> PrimaryExpressionNo
441 %type <expression_> PrimaryExpressionNoBF
442 %type <expression_> PrimaryExpressionNoRE
443 %type <expression_> PrimaryExpressionNoWC
444 %type <expression_> PrimaryExpressionNoWC_
446 %type <expression_> PrimaryExpressionWC
448 %type <expression_> PrimaryExpressionBF
449 %type <statement_> Program
450 %type <propertyName_> PropertyName
451 %type <propertyName_> PropertyName_
452 %type <property_> PropertyNameAndValueList
453 %type <property_> PropertyNameAndValueList_
454 %type <property_> PropertyNameAndValueListOpt
455 %type <expression_> RelationalExpression
456 %type <infix_> RelationalExpression_
457 %type <expression_> RelationalExpressionNoBF
458 %type <expression_> RelationalExpressionNoIn
459 %type <expression_> RelationalExpressionNoWC
460 %type <infix_> RelationalExpressionNoIn_
461 %type <statement_> ReturnStatement
462 %type <expression_> ShiftExpression
463 %type <expression_> ShiftExpressionNoBF
464 %type <expression_> ShiftExpressionNoWC
465 %type <statement_> SourceElement
466 %type <statement_> SourceElement_
467 %type <statement_> SourceElements
468 %type <statement_> Statement
469 %type <statement_> Statement_
470 %type <statement_> StatementList
471 %type <statement_> StatementListOpt
472 %type <statement_> SwitchStatement
473 %type <statement_> ThrowStatement
474 %type <statement_> TryStatement
475 %type <expression_> UnaryAssigneeExpression
476 %type <expression_> UnaryExpression
477 %type <expression_> UnaryExpression_
478 %type <expression_> UnaryExpressionNoBF
479 %type <expression_> UnaryExpressionNoRE
480 %type <expression_> UnaryExpressionNoWC
481 %type <declaration_> VariableDeclaration
482 %type <declaration_> VariableDeclarationNoIn
483 %type <declarations_> VariableDeclarationList
484 %type <declarations_> VariableDeclarationList_
485 %type <declarations_> VariableDeclarationListNoIn
486 %type <declarations_> VariableDeclarationListNoIn_
487 %type <statement_> VariableStatement
488 %type <statement_> WhileStatement
489 %type <statement_> WithStatement
492 %type <statement_> CategoryStatement
493 %type <expression_> ClassExpression
494 %type <statement_> ClassStatement
495 %type <expression_> ClassSuperOpt
496 %type <field_> ClassFieldList
497 %type <message_> ClassMessageDeclaration
498 %type <message_> ClassMessageDeclarationListOpt
499 %type <className_> ClassName
500 %type <className_> ClassNameOpt
501 %type <expression_> MessageExpression
502 %type <messageParameter_> MessageParameter
503 %type <messageParameter_> MessageParameters
504 %type <messageParameter_> MessageParameterList
505 %type <messageParameter_> MessageParameterListOpt
506 %type <bool_> MessageScope
507 %type <argument_> SelectorCall
508 %type <argument_> SelectorCall_
509 %type <selector_> SelectorExpression
510 %type <selector_> SelectorExpression_
511 %type <selector_> SelectorExpressionOpt
512 %type <argument_> SelectorList
513 %type <expression_> TypeOpt
514 %type <argument_> VariadicCall
516 %type <word_> WordOpt
520 %type <propertyIdentifier_> PropertyIdentifier_
521 %type <selector_> PropertySelector
522 %type <selector_> PropertySelector_
523 %type <identifier_> QualifiedIdentifier
524 %type <identifier_> QualifiedIdentifier_
525 %type <identifier_> WildcardIdentifier
526 %type <identifier_> XMLComment
527 %type <identifier_> XMLCDATA
528 %type <identifier_> XMLElement
529 %type <identifier_> XMLElementContent
530 %type <identifier_> XMLMarkup
531 %type <identifier_> XMLPI
533 %type <attribute_> AttributeIdentifier
534 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
535 %type <expression_> PropertyIdentifier
536 %type <expression_> XMLListInitialiser
537 %type <expression_> XMLInitialiser
542 %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"
552 %left "<<" ">>" ">>>"
553 %left "<" ">" "<=" ">=" "instanceof" "in"
554 %left "==" "!=" "===" "!=="
561 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
567 /* Lexer State {{{ */
569 : { driver.SetCondition(CYDriver::RegExpCondition); }
574 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
584 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
589 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
609 : Identifier { $$ = $1; }
610 | "break" NewLineOpt { $$ = $1; }
611 | "case" { $$ = $1; }
612 | "catch" { $$ = $1; }
613 | "class" { $$ = $1; }
614 | "const" { $$ = $1; }
615 | "continue" NewLineOpt { $$ = $1; }
616 | "debugger" { $$ = $1; }
617 | "default" { $$ = $1; }
618 | "delete" { $$ = $1; }
620 | "else" { $$ = $1; }
621 | "enum" { $$ = $1; }
622 | "export" { $$ = $1; }
623 | "extends" { $$ = $1; }
624 | "false" { $$ = $1; }
625 | "finally" { $$ = $1; }
626 /* XXX: | "for" { $$ = $1; } */
627 | "function" { $$ = $1; }
629 | "import" { $$ = $1; }
630 /* XXX: | "in" { $$ = $1; } */
631 /* XXX: | "instanceof" { $$ = $1; } */
633 | "null" { $$ = $1; }
634 | "return" NewLineOpt { $$ = $1; }
635 | "super" { $$ = $1; }
636 | "switch" { $$ = $1; }
637 | "this" { $$ = $1; }
638 | "throw" NewLineOpt { $$ = $1; }
639 | "true" { $$ = $1; }
641 | "typeof" { $$ = $1; }
643 | "void" { $$ = $1; }
644 | "while" { $$ = $1; }
645 | "with" { $$ = $1; }
650 : Identifier_ { $$ = $1; }
652 | "implements" { $$ = $1; }
653 | "interface" { $$ = $1; }
654 | "package" { $$ = $1; }
655 | "private" { $$ = $1; }
656 | "protected" { $$ = $1; }
657 | "public" { $$ = $1; }
658 | "static" { $$ = $1; }
660 | "abstract" { $$ = $1; }
661 | "boolean" { $$ = $1; }
662 | "byte" { $$ = $1; }
663 | "char" { $$ = $1; }
664 | "double" { $$ = $1; }
665 | "final" { $$ = $1; }
666 | "float" { $$ = $1; }
667 | "goto" { $$ = $1; }
669 | "long" { $$ = $1; }
670 | "native" { $$ = $1; }
671 | "short" { $$ = $1; }
672 | "synchronized" { $$ = $1; }
673 | "throws" { $$ = $1; }
674 | "transient" { $$ = $1; }
675 | "volatile" { $$ = $1; }
678 | "yield" { $$ = $1; }
680 | "each" { $$ = $1; }
684 : Identifier { $$ = $1; }
689 : NullLiteral { $$ = $1; }
690 | BooleanLiteral { $$ = $1; }
691 | NumericLiteral { $$ = $1; }
692 | StringLiteral { $$ = $1; }
693 | "@" StringLiteral { $$ = $2; }
697 : RegularExpressionLiteral { $$ = $1; }
701 : LiteralNoRE { $$ = $1; }
702 | LiteralRE { $$ = $1; }
706 : "null" { $$ = $1; }
710 : "true" { $$ = $1; }
711 | "false" { $$ = $1; }
714 /* 11.1 Primary Expressions {{{ */
716 : PrimaryExpressionNoWC { $$ = $1; }
718 | LexSetRegExp PrimaryExpressionWC { $$ = $2; }
722 PrimaryExpressionNoBF
723 : PrimaryExpressionNo { $$ = $1; }
725 | PrimaryExpressionWC { $$ = $1; }
729 PrimaryExpressionNoRE
730 : PrimaryExpressionNoWC_ { $$ = $1; }
732 | PrimaryExpressionWC { $$ = $1; }
736 PrimaryExpressionNoWC_
737 : PrimaryExpressionBF { $$ = $1; }
738 | PrimaryExpressionNo { $$ = $1; }
741 PrimaryExpressionNoWC
742 : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; }
746 : "this" { $$ = $1; }
747 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
748 | Literal { $$ = $1; }
749 | ArrayLiteral { $$ = $1; }
750 | "(" Expression ")" { $$ = $2; }
754 : ObjectLiteral { $$ = $1; }
757 /* 11.1.4 Array Initialiser {{{ */
759 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
763 : AssignmentExpression { $$ = $1; }
767 : Element { $$ = $1; }
768 | LexSetRegExp { $$ = NULL; }
772 : ElementList { $$ = $1; }
773 | LexSetRegExp { $$ = NULL; }
777 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
778 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
781 /* 11.1.5 Object Initialiser {{{ */
783 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
786 PropertyNameAndValueList_
787 : "," PropertyNameAndValueList { $$ = $2; }
791 PropertyNameAndValueListOpt
792 : PropertyNameAndValueList { $$ = $1; }
796 PropertyNameAndValueList
797 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
801 : Identifier { $$ = $1; }
802 | StringLiteral { $$ = $1; }
803 | NumericLiteral { $$ = $1; }
807 : LexSetRegExp PropertyName_ { $$ = $2; }
811 /* 11.2 Left-Hand-Side Expressions {{{ */
813 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
817 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
818 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
822 : PrimaryExpression { $$ = $1; }
823 | LexSetRegExp FunctionExpression { $$ = $2; }
824 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
825 | LexSetRegExp MemberExpression_ { $$ = $2; }
829 : PrimaryExpressionNoBF { $$ = $1; }
830 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
831 | MemberExpression_ { $$ = $1; }
835 : PrimaryExpressionNoRE { $$ = $1; }
836 | FunctionExpression { $$ = $1; }
837 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
838 | MemberExpression_ { $$ = $1; }
842 : PrimaryExpression { $$ = $1; }
843 | LexSetRegExp FunctionExpression { $$ = $2; }
844 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
845 | LexSetRegExp MemberExpression_ { $$ = $2; }
849 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
853 : MemberExpression { $$ = $1; }
854 | LexSetRegExp NewExpression_ { $$ = $2; }
858 : MemberExpressionNoBF { $$ = $1; }
859 | NewExpression_ { $$ = $1; }
863 : MemberExpressionNoRE { $$ = $1; }
864 | NewExpression_ { $$ = $1; }
868 : MemberExpressionNoWC { $$ = $1; }
869 | LexSetRegExp NewExpression_ { $$ = $2; }
873 : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
874 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
875 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
879 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
880 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
881 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
885 : PrimaryExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
886 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
887 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
891 : "," ArgumentList { $$ = $2; }
896 : ArgumentList { $$ = $1; }
897 | LexSetRegExp { $$ = NULL; }
901 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
905 : "(" ArgumentListOpt ")" { $$ = $2; }
908 LeftHandSideExpression
909 : NewExpression { $$ = $1; }
910 | CallExpression { $$ = $1; }
913 LeftHandSideExpressionNoBF
914 : NewExpressionNoBF { $$ = $1; }
915 | CallExpressionNoBF { $$ = $1; }
918 LeftHandSideExpressionNoRE
919 : NewExpressionNoRE { $$ = $1; }
920 | CallExpressionNoRE { $$ = $1; }
923 LeftHandSideExpressionNoWC
924 : NewExpressionNoWC { $$ = $1; }
925 | CallExpression { $$ = $1; }
928 /* 11.3 Postfix Expressions {{{ */
930 : AssigneeExpression { $$ = $1; }
931 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
932 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
935 PostfixExpressionNoBF
936 : AssigneeExpressionNoBF { $$ = $1; }
937 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
938 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
941 PostfixExpressionNoRE
942 : AssigneeExpressionNoRE { $$ = $1; }
943 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
944 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
947 PostfixExpressionNoWC
948 : AssigneeExpressionNoWC { $$ = $1; }
949 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
950 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
953 /* 11.4 Unary Operators {{{ */
955 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
956 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
957 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
958 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
959 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
960 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
961 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
962 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
963 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
964 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
965 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
969 : PostfixExpression { $$ = $1; }
970 | LexSetRegExp UnaryExpression_ { $$ = $2; }
974 : PostfixExpressionNoBF { $$ = $1; }
975 | UnaryExpression_ { $$ = $1; }
979 : PostfixExpressionNoRE { $$ = $1; }
980 | UnaryExpression_ { $$ = $1; }
984 : PostfixExpressionNoWC { $$ = $1; }
985 | LexSetRegExp UnaryExpression_ { $$ = $2; }
988 /* 11.5 Multiplicative Operators {{{ */
989 MultiplicativeExpression
990 : UnaryExpression { $$ = $1; }
991 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
992 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
993 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
996 MultiplicativeExpressionNoBF
997 : UnaryExpressionNoBF { $$ = $1; }
998 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
999 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
1000 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
1003 MultiplicativeExpressionNoWC
1004 : UnaryExpressionNoWC { $$ = $1; }
1005 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
1006 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
1007 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
1010 /* 11.6 Additive Operators {{{ */
1012 : MultiplicativeExpression { $$ = $1; }
1013 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
1014 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1017 AdditiveExpressionNoBF
1018 : MultiplicativeExpressionNoBF { $$ = $1; }
1019 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
1020 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1023 AdditiveExpressionNoWC
1024 : MultiplicativeExpressionNoWC { $$ = $1; }
1025 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
1026 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1029 /* 11.7 Bitwise Shift Operators {{{ */
1031 : AdditiveExpression { $$ = $1; }
1032 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1033 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1034 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1038 : AdditiveExpressionNoBF { $$ = $1; }
1039 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1040 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1041 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1045 : AdditiveExpressionNoWC { $$ = $1; }
1046 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1047 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1048 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1051 /* 11.8 Relational Operators {{{ */
1052 RelationalExpressionNoIn_
1053 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
1054 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
1055 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
1056 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
1057 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
1060 RelationalExpression_
1061 : RelationalExpressionNoIn_ { $$ = $1; }
1062 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1065 RelationalExpression
1066 : ShiftExpression { $$ = $1; }
1067 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1070 RelationalExpressionNoIn
1071 : ShiftExpression { $$ = $1; }
1072 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1075 RelationalExpressionNoBF
1076 : ShiftExpressionNoBF { $$ = $1; }
1077 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1080 RelationalExpressionNoWC
1081 : ShiftExpressionNoWC { $$ = $1; }
1082 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1085 /* 11.9 Equality Operators {{{ */
1087 : RelationalExpression { $$ = $1; }
1088 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1089 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1090 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1091 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1094 EqualityExpressionNoIn
1095 : RelationalExpressionNoIn { $$ = $1; }
1096 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1097 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1098 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1099 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1102 EqualityExpressionNoBF
1103 : RelationalExpressionNoBF { $$ = $1; }
1104 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1105 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1106 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1107 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1110 EqualityExpressionNoWC
1111 : RelationalExpressionNoWC { $$ = $1; }
1112 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1113 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1114 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1115 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1118 /* 11.10 Binary Bitwise Operators {{{ */
1119 BitwiseANDExpression
1120 : EqualityExpression { $$ = $1; }
1121 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1124 BitwiseANDExpressionNoIn
1125 : EqualityExpressionNoIn { $$ = $1; }
1126 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1129 BitwiseANDExpressionNoBF
1130 : EqualityExpressionNoBF { $$ = $1; }
1131 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1134 BitwiseANDExpressionNoWC
1135 : EqualityExpressionNoWC { $$ = $1; }
1136 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1139 BitwiseXORExpression
1140 : BitwiseANDExpression { $$ = $1; }
1141 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1144 BitwiseXORExpressionNoIn
1145 : BitwiseANDExpressionNoIn { $$ = $1; }
1146 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1149 BitwiseXORExpressionNoBF
1150 : BitwiseANDExpressionNoBF { $$ = $1; }
1151 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1154 BitwiseXORExpressionNoWC
1155 : BitwiseANDExpressionNoWC { $$ = $1; }
1156 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1160 : BitwiseXORExpression { $$ = $1; }
1161 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1164 BitwiseORExpressionNoIn
1165 : BitwiseXORExpressionNoIn { $$ = $1; }
1166 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1169 BitwiseORExpressionNoBF
1170 : BitwiseXORExpressionNoBF { $$ = $1; }
1171 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1174 BitwiseORExpressionNoWC
1175 : BitwiseXORExpressionNoWC { $$ = $1; }
1176 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1179 /* 11.11 Binary Logical Operators {{{ */
1180 LogicalANDExpression
1181 : BitwiseORExpression { $$ = $1; }
1182 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1185 LogicalANDExpressionNoIn
1186 : BitwiseORExpressionNoIn { $$ = $1; }
1187 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1190 LogicalANDExpressionNoBF
1191 : BitwiseORExpressionNoBF { $$ = $1; }
1192 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1195 LogicalANDExpressionNoWC
1196 : BitwiseORExpressionNoWC { $$ = $1; }
1197 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1201 : LogicalANDExpression { $$ = $1; }
1202 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1205 LogicalORExpressionNoIn
1206 : LogicalANDExpressionNoIn { $$ = $1; }
1207 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1210 LogicalORExpressionNoBF
1211 : LogicalANDExpressionNoBF { $$ = $1; }
1212 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1215 LogicalORExpressionNoWC
1216 : LogicalANDExpressionNoWC { $$ = $1; }
1217 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1220 /* 11.12 Conditional Operator ( ? : ) {{{ */
1221 ConditionalExpression
1222 : LogicalORExpression { $$ = $1; }
1223 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1226 ConditionalExpressionNoIn
1227 : LogicalORExpressionNoIn { $$ = $1; }
1228 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1231 ConditionalExpressionNoBF
1232 : LogicalORExpressionNoBF { $$ = $1; }
1233 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1236 ConditionalExpressionNoWC
1237 : LogicalORExpressionNoWC { $$ = $1; }
1238 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1241 /* 11.13 Assignment Operators {{{ */
1242 AssignmentExpression_
1243 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1244 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1245 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1246 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1247 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1248 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1249 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1250 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1251 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1252 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1253 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1254 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1258 : LeftHandSideExpression { $$ = $1; }
1259 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1262 AssigneeExpressionNoBF
1263 : LeftHandSideExpressionNoBF { $$ = $1; }
1264 | UnaryAssigneeExpression { $$ = $1; }
1267 AssigneeExpressionNoRE
1268 : LeftHandSideExpressionNoRE { $$ = $1; }
1269 | UnaryAssigneeExpression { $$ = $1; }
1272 AssigneeExpressionNoWC
1273 : LeftHandSideExpressionNoWC { $$ = $1; }
1274 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1277 AssignmentExpression
1278 : ConditionalExpression { $$ = $1; }
1279 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1282 AssignmentExpressionNoIn
1283 : ConditionalExpressionNoIn { $$ = $1; }
1284 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1285 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1286 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1287 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1288 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1289 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1290 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1291 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1292 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1293 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1294 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1295 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1298 AssignmentExpressionNoBF
1299 : ConditionalExpressionNoBF { $$ = $1; }
1300 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1303 AssignmentExpressionNoWC
1304 : ConditionalExpressionNoWC { $$ = $1; }
1305 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1308 /* 11.14 Comma Operator {{{ */
1310 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1315 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1320 : Expression { $$ = $1; }
1321 | LexSetRegExp { $$ = NULL; }
1325 : ExpressionNoIn { $$ = $1; }
1326 | LexSetRegExp { $$ = NULL; }
1330 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1334 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1338 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1342 /* 12 Statements {{{ */
1344 : Block { $$ = $1; }
1345 | VariableStatement { $$ = $1; }
1346 | EmptyStatement { $$ = $1; }
1347 | ExpressionStatement { $$ = $1; }
1348 | IfStatement { $$ = $1; }
1349 | IterationStatement { $$ = $1; }
1350 | ContinueStatement { $$ = $1; }
1351 | BreakStatement { $$ = $1; }
1352 | ReturnStatement { $$ = $1; }
1353 | WithStatement { $$ = $1; }
1354 | LabelledStatement { $$ = $1; }
1355 | SwitchStatement { $$ = $1; }
1356 | ThrowStatement { $$ = $1; }
1357 | TryStatement { $$ = $1; }
1361 : LexSetRegExp Statement_ { $$ = $2; }
1364 /* 12.1 Block {{{ */
1366 : "{" StatementListOpt "}" { $$ = $2; }
1370 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1374 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1378 : StatementList { $$ = $1; }
1379 | LexSetRegExp { $$ = NULL; }
1382 /* 12.2 Variable Statement {{{ */
1384 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1387 VariableDeclarationList_
1388 : "," VariableDeclarationList { $$ = $2; }
1392 VariableDeclarationListNoIn_
1393 : "," VariableDeclarationListNoIn { $$ = $2; }
1397 VariableDeclarationList
1398 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1401 VariableDeclarationListNoIn
1402 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1406 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1409 VariableDeclarationNoIn
1410 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1414 : Initialiser { $$ = $1; }
1419 : InitialiserNoIn { $$ = $1; }
1424 : "=" AssignmentExpression { $$ = $2; }
1428 : "=" AssignmentExpressionNoIn { $$ = $2; }
1431 /* 12.3 Empty Statement {{{ */
1433 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1436 /* 12.4 Expression Statement {{{ */
1438 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1441 /* 12.5 The if Statement {{{ */
1443 : "else" Statement { $$ = $2; }
1444 | %prec "if" { $$ = NULL; }
1448 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1452 /* 12.6 Iteration Statements {{{ */
1454 : DoWhileStatement { $$ = $1; }
1455 | WhileStatement { $$ = $1; }
1456 | ForStatement { $$ = $1; }
1457 | ForInStatement { $$ = $1; }
1460 /* 12.6.1 The do-while Statement {{{ */
1462 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1465 /* 12.6.2 The while Statement {{{ */
1467 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1470 /* 12.6.3 The for Statement {{{ */
1472 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1475 ForStatementInitialiser
1476 : ExpressionNoInOpt { $$ = $1; }
1477 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1480 /* 12.6.4 The for-in Statement {{{ */
1482 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1485 ForInStatementInitialiser
1486 : LeftHandSideExpression { $$ = $1; }
1487 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1491 /* 12.7 The continue Statement {{{ */
1493 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1496 /* 12.8 The break Statement {{{ */
1498 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1501 /* 12.9 The return Statement {{{ */
1503 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1506 /* 12.10 The with Statement {{{ */
1508 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1512 /* 12.11 The switch Statement {{{ */
1514 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1518 : "{" CaseClausesOpt "}" { $$ = $2; }
1522 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1523 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1528 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1532 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1535 /* 12.12 Labelled Statements {{{ */
1537 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1540 /* 12.13 The throw Statement {{{ */
1542 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1545 /* 12.14 The try Statement {{{ */
1547 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1551 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1556 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1561 /* 13 Function Definition {{{ */
1563 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1567 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1570 FormalParameterList_
1571 : "," FormalParameterList { $$ = $2; }
1576 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1581 : SourceElements { $$ = $1; }
1584 /* 14 Program {{{ */
1586 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1590 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1591 | LexSetRegExp { $$ = NULL; }
1595 : Statement_ { $$ = $1; }
1596 | FunctionDeclaration { $$ = $1; }
1600 : LexSetRegExp SourceElement_ { $$ = $2; }
1605 /* Cycript (Objective-C): @class Declaration {{{ */
1607 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1608 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1613 : "{" "}" { $$ = NULL; }
1617 : "+" { $$ = false; }
1618 | "-" { $$ = true; }
1622 : "(" Expression ")" { $$ = $2; }
1627 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1630 MessageParameterListOpt
1631 : MessageParameterList { $$ = $1; }
1635 MessageParameterList
1636 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1640 : MessageParameterList { $$ = $1; }
1641 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1644 ClassMessageDeclaration
1645 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1648 ClassMessageDeclarationListOpt
1649 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1654 : Identifier { $$ = $1; }
1655 | "(" AssignmentExpression ")" { $$ = $2; }
1659 : ClassName { $$ = $1; }
1664 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1668 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1672 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1676 : ClassExpression { $$ = $1; }
1680 : ClassStatement { $$ = $1; }
1681 | CategoryStatement { $$ = $1; }
1684 /* Cycript (Objective-C): Send Message {{{ */
1686 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1691 : SelectorCall { $$ = $1; }
1692 | VariadicCall { $$ = $1; }
1696 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1700 : SelectorCall { $$ = $1; }
1701 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1705 : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1706 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1709 SelectorExpressionOpt
1710 : SelectorExpression_ { $$ = $1; }
1715 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1719 : SelectorExpression_ { $$ = $1; }
1720 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1724 : MessageExpression { $$ = $1; }
1725 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1731 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1732 UnaryAssigneeExpression
1733 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1737 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1741 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1742 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1748 /* Lexer State {{{ */
1750 : { driver.PushCondition(CYDriver::RegExpCondition); }
1754 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1758 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1762 : { driver.PopCondition(); }
1766 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1770 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1779 /* 8.1 Context Keywords {{{ */
1781 : "namespace" { $$ = $1; }
1782 | "xml" { $$ = $1; }
1785 /* 8.3 XML Initialiser Input Elements {{{ */
1787 : XMLComment { $$ = $1; }
1788 | XMLCDATA { $$ = $1; }
1789 | XMLPI { $$ = $1; }
1792 /* 11.1 Primary Expressions {{{ */
1794 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1795 | XMLInitialiser { $$ = $1; }
1796 | XMLListInitialiser { $$ = $1; }
1800 : AttributeIdentifier { $$ = $1; }
1801 | QualifiedIdentifier { $$ = $1; }
1802 | WildcardIdentifier { $$ = $1; }
1805 /* 11.1.1 Attribute Identifiers {{{ */
1807 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1811 : PropertySelector { $$ = $1; }
1812 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1816 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1817 | WildcardIdentifier { $$ = $1; }
1820 /* 11.1.2 Qualified Identifiers {{{ */
1821 QualifiedIdentifier_
1822 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1823 | QualifiedIdentifier { $$ = $1; }
1827 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1830 /* 11.1.3 Wildcard Identifiers {{{ */
1832 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1835 /* 11.1.4 XML Initialiser {{{ */
1837 : XMLMarkup { $$ = $1; }
1838 | XMLElement { $$ = $1; }
1842 : "<" XMLTagContent "/>" LexPop
1843 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1847 : LexPushXMLTag XMLTagName XMLAttributes
1851 : "{" LexPushRegExp Expression "}" LexPop
1860 : XMLAttributes_ XMLAttribute
1865 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1866 | XMLAttributes_ XMLWhitespaceOpt
1875 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1879 : XMLExpression XMLElementContentOpt
1880 | XMLMarkup XMLElementContentOpt
1881 | XMLText XMLElementContentOpt
1882 | XMLElement XMLElementContentOpt
1885 XMLElementContentOpt
1890 /* 11.1.5 XMLList Initialiser {{{ */
1892 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1895 /* 11.2 Left-Hand-Side Expressions {{{ */
1897 : Identifier { $$ = $1; }
1898 | PropertyIdentifier { $$ = $1; }
1902 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1903 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1904 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1907 /* 12.1 The default xml namespace Statement {{{ */
1908 /* XXX: DefaultXMLNamespaceStatement
1909 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1913 : DefaultXMLNamespaceStatement { $$ = $1; }
1918 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1919 PropertyNameAndValueList_
1920 : "," { $$ = NULL; }
1923 /* JavaScript 1.7: Array Comprehensions {{{ */
1925 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1929 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1930 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1933 ComprehensionListOpt
1934 : ComprehensionList { $$ = $1; }
1935 | IfComprehension { $$ = $1; }
1940 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1944 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1947 /* JavaScript 1.7: for each {{{ */
1949 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1952 /* JavaScript 1.7: let Statements {{{ *//*
1954 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1961 /* JavaScript FTW: Function Statements {{{ */
1963 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }