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_;
71 CYComprehension *comprehension_;
72 CYCompound *compound_;
73 CYDeclaration *declaration_;
74 CYDeclarations *declarations_;
76 CYExpression *expression_;
79 CYForInitialiser *for_;
80 CYForInInitialiser *forin_;
81 CYFunctionParameter *functionParameter_;
82 CYIdentifier *identifier_;
89 CYProperty *property_;
90 CYPropertyName *propertyName_;
91 CYStatement *statement_;
98 CYClassName *className_;
101 CYMessageParameter *messageParameter_;
102 CYSelectorPart *selector_;
106 CYAttribute *attribute_;
107 CYPropertyIdentifier *propertyIdentifier_;
108 CYSelector *selector_;
116 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
125 @$.begin.filename = @$.end.filename = &driver.filename_;
135 %parse-param { CYDriver &driver }
136 %lex-param { void *scanner }
143 %token XMLAttributeValue
145 %token XMLTagCharacters
151 %token LeftRight "<>"
152 %token LeftSlashRight "</>"
154 %token SlashRight "/>"
155 %token LeftSlash "</"
157 %token ColonColon "::"
158 %token PeriodPeriod ".."
161 @begin E4X ObjectiveC
166 %token AmpersandAmpersand "&&"
167 %token AmpersandEqual "&="
169 %token CarrotEqual "^="
171 %token EqualEqual "=="
172 %token EqualEqualEqual "==="
173 %token Exclamation "!"
174 %token ExclamationEqual "!="
175 %token ExclamationEqualEqual "!=="
177 %token HyphenEqual "-="
178 %token HyphenHyphen "--"
179 %token HyphenHyphen_ "\n--"
180 %token HyphenRight "->"
182 %token LeftEqual "<="
184 %token LeftLeftEqual "<<="
186 %token PercentEqual "%="
189 %token PipeEqual "|="
192 %token PlusEqual "+="
194 %token PlusPlus_ "\n++"
196 %token RightEqual ">="
197 %token RightRight ">>"
198 %token RightRightEqual ">>="
199 %token RightRightRight ">>>"
200 %token RightRightRightEqual ">>>="
202 %token SlashEqual "/="
204 %token StarEqual "*="
213 %token <comment_> Comment
216 %token CloseParen ")"
219 %token CloseBrace "}"
221 %token OpenBracket "["
222 %token CloseBracket "]"
224 %token AtClass "@class"
225 %token AtSelector "@selector"
228 %token <false_> False "false"
229 %token <null_> Null "null"
230 %token <true_> True "true"
232 // ES3/ES5/WIE/JSC Reserved
233 %token <word_> Break "break"
234 %token <word_> Case "case"
235 %token <word_> Catch "catch"
236 %token <word_> Continue "continue"
237 %token <word_> Default "default"
238 %token <word_> Delete "delete"
239 %token <word_> Do "do"
240 %token <word_> Else "else"
241 %token <word_> Finally "finally"
242 %token <word_> For "for"
243 %token <word_> Function "function"
244 %token <word_> If "if"
245 %token <word_> In "in"
246 %token <word_> InstanceOf "instanceof"
247 %token <word_> New "new"
248 %token <word_> Return "return"
249 %token <word_> Switch "switch"
250 %token <this_> This "this"
251 %token <word_> Throw "throw"
252 %token <word_> Try "try"
253 %token <word_> TypeOf "typeof"
254 %token <word_> Var "var"
255 %token <word_> Void "void"
256 %token <word_> While "while"
257 %token <word_> With "with"
259 // ES3/IE6 Future, ES5/JSC Reserved
260 %token <word_> Debugger "debugger"
262 // ES3/ES5/IE6 Future, JSC Reserved
263 %token <word_> Const "const"
265 // ES3/ES5/IE6/JSC Future
266 %token <word_> Class "class"
267 %token <word_> Enum "enum"
268 %token <word_> Export "export"
269 %token <word_> Extends "extends"
270 %token <word_> Import "import"
271 %token <word_> Super "super"
273 // ES3 Future, ES5 Strict Future
274 %token <identifier_> Implements "implements"
275 %token <identifier_> Interface "interface"
276 %token <identifier_> Package "package"
277 %token <identifier_> Private "private"
278 %token <identifier_> Protected "protected"
279 %token <identifier_> Public "public"
280 %token <identifier_> Static "static"
283 %token <identifier_> Abstract "abstract"
284 %token <identifier_> Boolean "boolean"
285 %token <identifier_> Byte "byte"
286 %token <identifier_> Char "char"
287 %token <identifier_> Double "double"
288 %token <identifier_> Final "final"
289 %token <identifier_> Float "float"
290 %token <identifier_> Goto "goto"
291 %token <identifier_> Int "int"
292 %token <identifier_> Long "long"
293 %token <identifier_> Native "native"
294 %token <identifier_> Short "short"
295 %token <identifier_> Synchronized "synchronized"
296 %token <identifier_> Throws "throws"
297 %token <identifier_> Transient "transient"
298 %token <identifier_> Volatile "volatile"
301 %token <identifier_> Let "let"
302 %token <identifier_> Yield "yield"
305 %token <identifier_> Each "each"
309 %token <identifier_> Namespace "namespace"
310 %token <identifier_> XML "xml"
313 %token <identifier_> Identifier_
314 %token <number_> NumericLiteral
315 %token <string_> StringLiteral
316 %token <literal_> RegularExpressionLiteral
318 %type <expression_> AdditiveExpression
319 %type <expression_> AdditiveExpressionNoBF
320 %type <argument_> ArgumentList
321 %type <argument_> ArgumentList_
322 %type <argument_> ArgumentListOpt
323 %type <argument_> Arguments
324 %type <literal_> ArrayLiteral
325 %type <expression_> AssigneeExpression
326 %type <expression_> AssigneeExpressionNoBF
327 %type <expression_> AssigneeExpressionNoRE
328 %type <expression_> AssignmentExpression
329 %type <assignment_> AssignmentExpression_
330 %type <expression_> AssignmentExpressionNoBF
331 %type <expression_> AssignmentExpressionNoIn
332 %type <expression_> BitwiseANDExpression
333 %type <expression_> BitwiseANDExpressionNoBF
334 %type <expression_> BitwiseANDExpressionNoIn
335 %type <statement_> Block
336 %type <statement_> Block_
337 %type <boolean_> BooleanLiteral
338 %type <expression_> BitwiseORExpression
339 %type <expression_> BitwiseORExpressionNoBF
340 %type <expression_> BitwiseORExpressionNoIn
341 %type <expression_> BitwiseXORExpression
342 %type <expression_> BitwiseXORExpressionNoBF
343 %type <expression_> BitwiseXORExpressionNoIn
344 %type <statement_> BreakStatement
345 %type <expression_> CallExpression
346 %type <expression_> CallExpressionNoBF
347 %type <expression_> CallExpressionNoRE
348 %type <clause_> CaseBlock
349 %type <clause_> CaseClause
350 %type <clause_> CaseClausesOpt
351 %type <catch_> CatchOpt
352 %type <comprehension_> ComprehensionList
353 %type <comprehension_> ComprehensionListOpt
354 %type <expression_> ConditionalExpression
355 %type <expression_> ConditionalExpressionNoBF
356 %type <expression_> ConditionalExpressionNoIn
357 %type <statement_> ContinueStatement
358 %type <clause_> DefaultClause
359 %type <statement_> DoWhileStatement
360 %type <expression_> Element
361 %type <expression_> ElementOpt
362 %type <element_> ElementList
363 %type <element_> ElementListOpt
364 %type <statement_> ElseStatementOpt
365 %type <statement_> EmptyStatement
366 %type <expression_> EqualityExpression
367 %type <expression_> EqualityExpressionNoBF
368 %type <expression_> EqualityExpressionNoIn
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 <identifier_> Identifier
389 %type <identifier_> IdentifierOpt
390 %type <comprehension_> IfComprehension
391 %type <statement_> IfStatement
392 %type <expression_> Initialiser
393 %type <expression_> InitialiserOpt
394 %type <expression_> InitialiserNoIn
395 %type <expression_> InitialiserNoInOpt
396 %type <statement_> IterationStatement
397 %type <statement_> LabelledStatement
398 %type <expression_> LeftHandSideExpression
399 %type <expression_> LeftHandSideExpressionNoBF
400 %type <expression_> LeftHandSideExpressionNoRE
401 //%type <statement_> LetStatement
402 %type <literal_> Literal
403 %type <literal_> LiteralNoRE
404 %type <literal_> LiteralRE
405 %type <expression_> LogicalANDExpression
406 %type <expression_> LogicalANDExpressionNoBF
407 %type <expression_> LogicalANDExpressionNoIn
408 %type <expression_> LogicalORExpression
409 %type <expression_> LogicalORExpressionNoBF
410 %type <expression_> LogicalORExpressionNoIn
411 %type <member_> MemberAccess
412 %type <expression_> MemberExpression
413 %type <expression_> MemberExpression_
414 %type <expression_> MemberExpressionNoBF
415 %type <expression_> MemberExpressionNoRE
416 %type <expression_> MultiplicativeExpression
417 %type <expression_> MultiplicativeExpressionNoBF
418 %type <expression_> NewExpression
419 %type <expression_> NewExpression_
420 %type <expression_> NewExpressionNoBF
421 %type <expression_> NewExpressionNoRE
422 %type <null_> NullLiteral
423 %type <literal_> ObjectLiteral
424 %type <expression_> PostfixExpression
425 %type <expression_> PostfixExpressionNoBF
426 %type <expression_> PostfixExpressionNoRE
427 %type <expression_> PrimaryExpression
428 %type <expression_> PrimaryExpressionNo
429 %type <expression_> PrimaryExpressionNoBF
430 %type <expression_> PrimaryExpressionNoRE
431 %type <expression_> PrimaryExpressionBF
432 %type <statement_> Program
433 %type <propertyName_> PropertyName
434 %type <propertyName_> PropertyName_
435 %type <property_> PropertyNameAndValueList
436 %type <property_> PropertyNameAndValueList_
437 %type <property_> PropertyNameAndValueListOpt
438 %type <expression_> RelationalExpression
439 %type <infix_> RelationalExpression_
440 %type <expression_> RelationalExpressionNoBF
441 %type <expression_> RelationalExpressionNoIn
442 %type <infix_> RelationalExpressionNoIn_
443 %type <statement_> ReturnStatement
444 %type <expression_> ShiftExpression
445 %type <expression_> ShiftExpressionNoBF
446 %type <statement_> SourceElement
447 %type <statement_> SourceElement_
448 %type <statement_> SourceElements
449 %type <statement_> Statement
450 %type <statement_> Statement_
451 %type <statement_> StatementList
452 %type <statement_> StatementListOpt
453 %type <statement_> SwitchStatement
454 %type <statement_> ThrowStatement
455 %type <statement_> TryStatement
456 %type <expression_> UnaryAssigneeExpression
457 %type <expression_> UnaryExpression
458 %type <expression_> UnaryExpression_
459 %type <expression_> UnaryExpressionNoBF
460 %type <expression_> UnaryExpressionNoRE
461 %type <declaration_> VariableDeclaration
462 %type <declaration_> VariableDeclarationNoIn
463 %type <declarations_> VariableDeclarationList
464 %type <declarations_> VariableDeclarationList_
465 %type <declarations_> VariableDeclarationListNoIn
466 %type <declarations_> VariableDeclarationListNoIn_
467 %type <statement_> VariableStatement
468 %type <statement_> WhileStatement
469 %type <statement_> WithStatement
472 %type <statement_> CategoryStatement
473 %type <expression_> ClassExpression
474 %type <statement_> ClassStatement
475 %type <expression_> ClassSuperOpt
476 %type <field_> ClassFieldList
477 %type <message_> ClassMessageDeclaration
478 %type <message_> ClassMessageDeclarationListOpt
479 %type <className_> ClassName
480 %type <className_> ClassNameOpt
481 %type <expression_> MessageExpression
482 %type <messageParameter_> MessageParameter
483 %type <messageParameter_> MessageParameters
484 %type <messageParameter_> MessageParameterList
485 %type <messageParameter_> MessageParameterListOpt
486 %type <bool_> MessageScope
487 %type <argument_> SelectorCall
488 %type <argument_> SelectorCall_
489 %type <selector_> SelectorExpression
490 %type <selector_> SelectorExpression_
491 %type <selector_> SelectorExpressionOpt
492 %type <argument_> SelectorList
493 %type <expression_> TypeOpt
494 %type <argument_> VariadicCall
496 %type <word_> WordOpt
500 %type <propertyIdentifier_> PropertyIdentifier_
501 %type <selector_> PropertySelector
502 %type <selector_> PropertySelector_
503 %type <identifier_> QualifiedIdentifier
504 %type <identifier_> QualifiedIdentifier_
505 %type <identifier_> WildcardIdentifier
506 %type <identifier_> XMLComment
507 %type <identifier_> XMLCDATA
508 %type <identifier_> XMLElement
509 %type <identifier_> XMLElementContent
510 %type <identifier_> XMLMarkup
511 %type <identifier_> XMLPI
513 %type <attribute_> AttributeIdentifier
514 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
515 %type <expression_> PropertyIdentifier
516 %type <expression_> XMLListInitialiser
517 %type <expression_> XMLInitialiser
520 %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"
530 %left "<<" ">>" ">>>"
531 %left "<" ">" "<=" ">=" "instanceof" "in"
532 %left "==" "!=" "===" "!=="
539 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
545 /* Lexer State {{{ */
547 : { driver.SetCondition(CYDriver::RegExpCondition); }
552 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
562 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
567 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
587 : Identifier { $$ = $1; }
588 | "break" NewLineOpt { $$ = $1; }
589 | "case" { $$ = $1; }
590 | "catch" { $$ = $1; }
591 | "class" { $$ = $1; }
592 | "const" { $$ = $1; }
593 | "continue" NewLineOpt { $$ = $1; }
594 | "debugger" { $$ = $1; }
595 | "default" { $$ = $1; }
596 | "delete" { $$ = $1; }
598 | "else" { $$ = $1; }
599 | "enum" { $$ = $1; }
600 | "export" { $$ = $1; }
601 | "extends" { $$ = $1; }
602 | "false" { $$ = $1; }
603 | "finally" { $$ = $1; }
604 /* XXX: | "for" { $$ = $1; } */
605 | "function" { $$ = $1; }
607 | "import" { $$ = $1; }
608 /* XXX: | "in" { $$ = $1; } */
609 /* XXX: | "instanceof" { $$ = $1; } */
611 | "null" { $$ = $1; }
612 | "return" NewLineOpt { $$ = $1; }
613 | "super" { $$ = $1; }
614 | "switch" { $$ = $1; }
615 | "this" { $$ = $1; }
616 | "throw" NewLineOpt { $$ = $1; }
617 | "true" { $$ = $1; }
619 | "typeof" { $$ = $1; }
621 | "void" { $$ = $1; }
622 | "while" { $$ = $1; }
623 | "with" { $$ = $1; }
628 : Identifier_ { $$ = $1; }
630 | "implements" { $$ = $1; }
631 | "interface" { $$ = $1; }
632 | "package" { $$ = $1; }
633 | "private" { $$ = $1; }
634 | "protected" { $$ = $1; }
635 | "public" { $$ = $1; }
636 | "static" { $$ = $1; }
638 | "abstract" { $$ = $1; }
639 | "boolean" { $$ = $1; }
640 | "byte" { $$ = $1; }
641 | "char" { $$ = $1; }
642 | "double" { $$ = $1; }
643 | "final" { $$ = $1; }
644 | "float" { $$ = $1; }
645 | "goto" { $$ = $1; }
647 | "long" { $$ = $1; }
648 | "native" { $$ = $1; }
649 | "short" { $$ = $1; }
650 | "synchronized" { $$ = $1; }
651 | "throws" { $$ = $1; }
652 | "transient" { $$ = $1; }
653 | "volatile" { $$ = $1; }
656 | "yield" { $$ = $1; }
658 | "each" { $$ = $1; }
662 : Identifier { $$ = $1; }
667 : NullLiteral { $$ = $1; }
668 | BooleanLiteral { $$ = $1; }
669 | NumericLiteral { $$ = $1; }
670 | StringLiteral { $$ = $1; }
671 | "@" StringLiteral { $$ = $2; }
675 : RegularExpressionLiteral { $$ = $1; }
679 : LiteralNoRE { $$ = $1; }
680 | LiteralRE { $$ = $1; }
684 : "null" { $$ = $1; }
688 : "true" { $$ = $1; }
689 | "false" { $$ = $1; }
692 /* 11.1 Primary Expressions {{{ */
694 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
697 PrimaryExpressionNoBF
698 : PrimaryExpressionNo { $$ = $1; }
701 PrimaryExpressionNoRE
702 : PrimaryExpressionBF { $$ = $1; }
703 | PrimaryExpressionNo { $$ = $1; }
707 : "this" { $$ = $1; }
708 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
709 | Literal { $$ = $1; }
710 | ArrayLiteral { $$ = $1; }
711 | "(" Expression ")" { $$ = $2; }
715 : ObjectLiteral { $$ = $1; }
718 /* 11.1.4 Array Initialiser {{{ */
720 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
724 : AssignmentExpression { $$ = $1; }
728 : Element { $$ = $1; }
729 | LexSetRegExp { $$ = NULL; }
733 : ElementList { $$ = $1; }
734 | LexSetRegExp { $$ = NULL; }
738 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
739 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
742 /* 11.1.5 Object Initialiser {{{ */
744 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
747 PropertyNameAndValueList_
748 : "," PropertyNameAndValueList { $$ = $2; }
752 PropertyNameAndValueListOpt
753 : PropertyNameAndValueList { $$ = $1; }
757 PropertyNameAndValueList
758 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
762 : Identifier { $$ = $1; }
763 | StringLiteral { $$ = $1; }
764 | NumericLiteral { $$ = $1; }
768 : LexSetRegExp PropertyName_ { $$ = $2; }
772 /* 11.2 Left-Hand-Side Expressions {{{ */
774 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
778 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
779 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
783 : PrimaryExpression { $$ = $1; }
784 | LexSetRegExp FunctionExpression { $$ = $2; }
785 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
786 | LexSetRegExp MemberExpression_ { $$ = $2; }
790 : PrimaryExpressionNoBF { $$ = $1; }
791 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
792 | MemberExpression_ { $$ = $1; }
796 : PrimaryExpressionNoRE { $$ = $1; }
797 | FunctionExpression { $$ = $1; }
798 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
799 | MemberExpression_ { $$ = $1; }
803 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
807 : MemberExpression { $$ = $1; }
808 | LexSetRegExp NewExpression_ { $$ = $2; }
812 : MemberExpressionNoBF { $$ = $1; }
813 | NewExpression_ { $$ = $1; }
817 : MemberExpressionNoRE { $$ = $1; }
818 | NewExpression_ { $$ = $1; }
822 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
823 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
824 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
828 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
829 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
830 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
834 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
835 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
836 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
840 : "," ArgumentList { $$ = $2; }
845 : ArgumentList { $$ = $1; }
846 | LexSetRegExp { $$ = NULL; }
850 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
854 : "(" ArgumentListOpt ")" { $$ = $2; }
857 LeftHandSideExpression
858 : NewExpression { $$ = $1; }
859 | CallExpression { $$ = $1; }
862 LeftHandSideExpressionNoBF
863 : NewExpressionNoBF { $$ = $1; }
864 | CallExpressionNoBF { $$ = $1; }
867 LeftHandSideExpressionNoRE
868 : NewExpressionNoRE { $$ = $1; }
869 | CallExpressionNoRE { $$ = $1; }
872 /* 11.3 Postfix Expressions {{{ */
874 : AssigneeExpression { $$ = $1; }
875 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
876 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
879 PostfixExpressionNoBF
880 : AssigneeExpressionNoBF { $$ = $1; }
881 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
882 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
885 PostfixExpressionNoRE
886 : AssigneeExpressionNoRE { $$ = $1; }
887 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
888 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
891 /* 11.4 Unary Operators {{{ */
893 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
894 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
895 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
896 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
897 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
898 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
899 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
900 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
901 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
902 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
903 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
907 : PostfixExpression { $$ = $1; }
908 | LexSetRegExp UnaryExpression_ { $$ = $2; }
912 : PostfixExpressionNoBF { $$ = $1; }
913 | UnaryExpression_ { $$ = $1; }
917 : PostfixExpressionNoRE { $$ = $1; }
918 | UnaryExpression_ { $$ = $1; }
921 /* 11.5 Multiplicative Operators {{{ */
922 MultiplicativeExpression
923 : UnaryExpression { $$ = $1; }
924 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
925 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
926 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
929 MultiplicativeExpressionNoBF
930 : UnaryExpressionNoBF { $$ = $1; }
931 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
932 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
933 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
936 /* 11.6 Additive Operators {{{ */
938 : MultiplicativeExpression { $$ = $1; }
939 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
940 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
943 AdditiveExpressionNoBF
944 : MultiplicativeExpressionNoBF { $$ = $1; }
945 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
946 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
949 /* 11.7 Bitwise Shift Operators {{{ */
951 : AdditiveExpression { $$ = $1; }
952 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
953 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
954 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
958 : AdditiveExpressionNoBF { $$ = $1; }
959 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
960 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
961 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
964 /* 11.8 Relational Operators {{{ */
965 RelationalExpressionNoIn_
966 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
967 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
968 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
969 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
970 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
973 RelationalExpression_
974 : RelationalExpressionNoIn_ { $$ = $1; }
975 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
979 : ShiftExpression { $$ = $1; }
980 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
983 RelationalExpressionNoIn
984 : ShiftExpression { $$ = $1; }
985 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
988 RelationalExpressionNoBF
989 : ShiftExpressionNoBF { $$ = $1; }
990 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
993 /* 11.9 Equality Operators {{{ */
995 : RelationalExpression { $$ = $1; }
996 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
997 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
998 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
999 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1002 EqualityExpressionNoIn
1003 : RelationalExpressionNoIn { $$ = $1; }
1004 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1005 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1006 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1007 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1010 EqualityExpressionNoBF
1011 : RelationalExpressionNoBF { $$ = $1; }
1012 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1013 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1014 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1015 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1018 /* 11.10 Binary Bitwise Operators {{{ */
1019 BitwiseANDExpression
1020 : EqualityExpression { $$ = $1; }
1021 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1024 BitwiseANDExpressionNoIn
1025 : EqualityExpressionNoIn { $$ = $1; }
1026 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1029 BitwiseANDExpressionNoBF
1030 : EqualityExpressionNoBF { $$ = $1; }
1031 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1034 BitwiseXORExpression
1035 : BitwiseANDExpression { $$ = $1; }
1036 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1039 BitwiseXORExpressionNoIn
1040 : BitwiseANDExpressionNoIn { $$ = $1; }
1041 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1044 BitwiseXORExpressionNoBF
1045 : BitwiseANDExpressionNoBF { $$ = $1; }
1046 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1050 : BitwiseXORExpression { $$ = $1; }
1051 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1054 BitwiseORExpressionNoIn
1055 : BitwiseXORExpressionNoIn { $$ = $1; }
1056 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1059 BitwiseORExpressionNoBF
1060 : BitwiseXORExpressionNoBF { $$ = $1; }
1061 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1064 /* 11.11 Binary Logical Operators {{{ */
1065 LogicalANDExpression
1066 : BitwiseORExpression { $$ = $1; }
1067 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1070 LogicalANDExpressionNoIn
1071 : BitwiseORExpressionNoIn { $$ = $1; }
1072 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1075 LogicalANDExpressionNoBF
1076 : BitwiseORExpressionNoBF { $$ = $1; }
1077 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1081 : LogicalANDExpression { $$ = $1; }
1082 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1085 LogicalORExpressionNoIn
1086 : LogicalANDExpressionNoIn { $$ = $1; }
1087 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1090 LogicalORExpressionNoBF
1091 : LogicalANDExpressionNoBF { $$ = $1; }
1092 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1095 /* 11.12 Conditional Operator ( ? : ) {{{ */
1096 ConditionalExpression
1097 : LogicalORExpression { $$ = $1; }
1098 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1101 ConditionalExpressionNoIn
1102 : LogicalORExpressionNoIn { $$ = $1; }
1103 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1106 ConditionalExpressionNoBF
1107 : LogicalORExpressionNoBF { $$ = $1; }
1108 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1111 /* 11.13 Assignment Operators {{{ */
1112 AssignmentExpression_
1113 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1114 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1115 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1116 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1117 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1118 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1119 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1120 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1121 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1122 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1123 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1124 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1128 : LeftHandSideExpression { $$ = $1; }
1129 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1132 AssigneeExpressionNoBF
1133 : LeftHandSideExpressionNoBF { $$ = $1; }
1134 | UnaryAssigneeExpression { $$ = $1; }
1137 AssigneeExpressionNoRE
1138 : LeftHandSideExpressionNoRE { $$ = $1; }
1139 | UnaryAssigneeExpression { $$ = $1; }
1142 AssignmentExpression
1143 : ConditionalExpression { $$ = $1; }
1144 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1147 AssignmentExpressionNoIn
1148 : ConditionalExpressionNoIn { $$ = $1; }
1149 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1150 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1151 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1152 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1153 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1154 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1155 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1156 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1157 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1158 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1159 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1160 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1163 AssignmentExpressionNoBF
1164 : ConditionalExpressionNoBF { $$ = $1; }
1165 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1168 /* 11.14 Comma Operator {{{ */
1170 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1175 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1180 : Expression { $$ = $1; }
1181 | LexSetRegExp { $$ = NULL; }
1185 : ExpressionNoIn { $$ = $1; }
1186 | LexSetRegExp { $$ = NULL; }
1190 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1194 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1198 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1202 /* 12 Statements {{{ */
1204 : Block { $$ = $1; }
1205 | VariableStatement { $$ = $1; }
1206 | EmptyStatement { $$ = $1; }
1207 | ExpressionStatement { $$ = $1; }
1208 | IfStatement { $$ = $1; }
1209 | IterationStatement { $$ = $1; }
1210 | ContinueStatement { $$ = $1; }
1211 | BreakStatement { $$ = $1; }
1212 | ReturnStatement { $$ = $1; }
1213 | WithStatement { $$ = $1; }
1214 | LabelledStatement { $$ = $1; }
1215 | SwitchStatement { $$ = $1; }
1216 | ThrowStatement { $$ = $1; }
1217 | TryStatement { $$ = $1; }
1221 : LexSetRegExp Statement_ { $$ = $2; }
1224 /* 12.1 Block {{{ */
1226 : "{" StatementListOpt "}" { $$ = $2; }
1230 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1234 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1238 : StatementList { $$ = $1; }
1239 | LexSetRegExp { $$ = NULL; }
1242 /* 12.2 Variable Statement {{{ */
1244 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1247 VariableDeclarationList_
1248 : "," VariableDeclarationList { $$ = $2; }
1252 VariableDeclarationListNoIn_
1253 : "," VariableDeclarationListNoIn { $$ = $2; }
1257 VariableDeclarationList
1258 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1261 VariableDeclarationListNoIn
1262 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1266 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1269 VariableDeclarationNoIn
1270 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1274 : Initialiser { $$ = $1; }
1279 : InitialiserNoIn { $$ = $1; }
1284 : "=" AssignmentExpression { $$ = $2; }
1288 : "=" AssignmentExpressionNoIn { $$ = $2; }
1291 /* 12.3 Empty Statement {{{ */
1293 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1296 /* 12.4 Expression Statement {{{ */
1298 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1301 /* 12.5 The if Statement {{{ */
1303 : "else" Statement { $$ = $2; }
1304 | %prec "if" { $$ = NULL; }
1308 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1312 /* 12.6 Iteration Statements {{{ */
1314 : DoWhileStatement { $$ = $1; }
1315 | WhileStatement { $$ = $1; }
1316 | ForStatement { $$ = $1; }
1317 | ForInStatement { $$ = $1; }
1320 /* 12.6.1 The do-while Statement {{{ */
1322 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1325 /* 12.6.2 The while Statement {{{ */
1327 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1330 /* 12.6.3 The for Statement {{{ */
1332 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1335 ForStatementInitialiser
1336 : ExpressionNoInOpt { $$ = $1; }
1337 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1340 /* 12.6.4 The for-in Statement {{{ */
1342 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1345 ForInStatementInitialiser
1346 : LeftHandSideExpression { $$ = $1; }
1347 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1351 /* 12.7 The continue Statement {{{ */
1353 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1356 /* 12.8 The break Statement {{{ */
1358 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1361 /* 12.9 The return Statement {{{ */
1363 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1366 /* 12.10 The with Statement {{{ */
1368 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1372 /* 12.11 The switch Statement {{{ */
1374 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1378 : "{" CaseClausesOpt "}" { $$ = $2; }
1382 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1383 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1388 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1392 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1395 /* 12.12 Labelled Statements {{{ */
1397 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1400 /* 12.13 The throw Statement {{{ */
1402 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1405 /* 12.14 The try Statement {{{ */
1407 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1411 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1416 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1421 /* 13 Function Definition {{{ */
1423 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1427 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1430 FormalParameterList_
1431 : "," FormalParameterList { $$ = $2; }
1436 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1441 : SourceElements { $$ = $1; }
1444 /* 14 Program {{{ */
1446 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1450 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1451 | LexSetRegExp { $$ = NULL; }
1455 : Statement_ { $$ = $1; }
1456 | FunctionDeclaration { $$ = $1; }
1460 : LexSetRegExp SourceElement_ { $$ = $2; }
1465 /* Cycript (Objective-C): @class Declaration {{{ */
1467 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1468 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1473 : "{" "}" { $$ = NULL; }
1477 : "+" { $$ = false; }
1478 | "-" { $$ = true; }
1482 : "(" Expression ")" { $$ = $2; }
1487 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1490 MessageParameterListOpt
1491 : MessageParameterList { $$ = $1; }
1495 MessageParameterList
1496 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1500 : MessageParameterList { $$ = $1; }
1501 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1504 ClassMessageDeclaration
1505 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1508 ClassMessageDeclarationListOpt
1509 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1514 : Identifier { $$ = $1; }
1515 | "(" AssignmentExpression ")" { $$ = $2; }
1519 : ClassName { $$ = $1; }
1524 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1528 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1532 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1536 : ClassExpression { $$ = $1; }
1540 : ClassStatement { $$ = $1; }
1541 | CategoryStatement { $$ = $1; }
1544 /* Cycript (Objective-C): Send Message {{{ */
1546 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1551 : SelectorCall { $$ = $1; }
1552 | VariadicCall { $$ = $1; }
1556 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1560 : SelectorCall { $$ = $1; }
1561 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1565 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1566 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1569 SelectorExpressionOpt
1570 : SelectorExpression_ { $$ = $1; }
1575 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1579 : SelectorExpression_ { $$ = $1; }
1580 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1584 : MessageExpression { $$ = $1; }
1585 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1591 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1592 UnaryAssigneeExpression
1593 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1597 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1601 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1602 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1607 /* YUI: Documentation Comments {{{ */
1609 : Comment { $$ = $1; }
1614 /* Lexer State {{{ */
1616 : { driver.PushCondition(CYDriver::RegExpCondition); }
1620 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1624 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1628 : { driver.PopCondition(); }
1632 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1636 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1645 /* 8.1 Context Keywords {{{ */
1647 : "namespace" { $$ = $1; }
1648 | "xml" { $$ = $1; }
1651 /* 8.3 XML Initialiser Input Elements {{{ */
1653 : XMLComment { $$ = $1; }
1654 | XMLCDATA { $$ = $1; }
1655 | XMLPI { $$ = $1; }
1658 /* 11.1 Primary Expressions {{{ */
1660 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1661 | XMLInitialiser { $$ = $1; }
1662 | XMLListInitialiser { $$ = $1; }
1666 : AttributeIdentifier { $$ = $1; }
1667 | QualifiedIdentifier { $$ = $1; }
1668 | WildcardIdentifier { $$ = $1; }
1671 /* 11.1.1 Attribute Identifiers {{{ */
1673 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1677 : PropertySelector { $$ = $1; }
1678 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1682 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1683 | WildcardIdentifier { $$ = $1; }
1686 /* 11.1.2 Qualified Identifiers {{{ */
1687 QualifiedIdentifier_
1688 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1689 | QualifiedIdentifier { $$ = $1; }
1693 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1696 /* 11.1.3 Wildcard Identifiers {{{ */
1698 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1701 /* 11.1.4 XML Initialiser {{{ */
1703 : XMLMarkup { $$ = $1; }
1704 | XMLElement { $$ = $1; }
1708 : "<" XMLTagContent "/>" LexPop
1709 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1713 : LexPushXMLTag XMLTagName XMLAttributes
1717 : "{" LexPushRegExp Expression "}" LexPop
1726 : XMLAttributes_ XMLAttribute
1731 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1732 | XMLAttributes_ XMLWhitespaceOpt
1741 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1745 : XMLExpression XMLElementContentOpt
1746 | XMLMarkup XMLElementContentOpt
1747 | XMLText XMLElementContentOpt
1748 | XMLElement XMLElementContentOpt
1751 XMLElementContentOpt
1756 /* 11.1.5 XMLList Initialiser {{{ */
1758 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1761 /* 11.2 Left-Hand-Side Expressions {{{ */
1763 : Identifier { $$ = $1; }
1764 | PropertyIdentifier { $$ = $1; }
1768 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1769 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1770 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1773 /* 12.1 The default xml namespace Statement {{{ */
1774 /* XXX: DefaultXMLNamespaceStatement
1775 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1779 : DefaultXMLNamespaceStatement { $$ = $1; }
1784 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1785 PropertyNameAndValueList_
1786 : "," { $$ = NULL; }
1789 /* JavaScript 1.7: Array Comprehensions {{{ */
1791 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1795 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1796 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1799 ComprehensionListOpt
1800 : ComprehensionList { $$ = $1; }
1801 | IfComprehension { $$ = $1; }
1806 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1810 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1813 /* JavaScript 1.7: for each {{{ */
1815 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1818 /* JavaScript 1.7: let Statements {{{ *//*
1820 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1827 /* JavaScript FTW: Function Statements {{{ */
1829 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }