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_> AssignmentExpression
328 %type <assignment_> AssignmentExpression_
329 %type <expression_> AssignmentExpressionNoBF
330 %type <expression_> AssignmentExpressionNoIn
331 %type <expression_> BitwiseANDExpression
332 %type <expression_> BitwiseANDExpressionNoBF
333 %type <expression_> BitwiseANDExpressionNoIn
334 %type <statement_> Block
335 %type <statement_> Block_
336 %type <boolean_> BooleanLiteral
337 %type <expression_> BitwiseORExpression
338 %type <expression_> BitwiseORExpressionNoBF
339 %type <expression_> BitwiseORExpressionNoIn
340 %type <expression_> BitwiseXORExpression
341 %type <expression_> BitwiseXORExpressionNoBF
342 %type <expression_> BitwiseXORExpressionNoIn
343 %type <statement_> BreakStatement
344 %type <expression_> CallExpression
345 %type <expression_> CallExpressionNoBF
346 %type <clause_> CaseBlock
347 %type <clause_> CaseClause
348 %type <clause_> CaseClausesOpt
349 %type <catch_> CatchOpt
350 %type <comprehension_> ComprehensionList
351 %type <comprehension_> ComprehensionListOpt
352 %type <expression_> ConditionalExpression
353 %type <expression_> ConditionalExpressionNoBF
354 %type <expression_> ConditionalExpressionNoIn
355 %type <statement_> ContinueStatement
356 %type <clause_> DefaultClause
357 %type <statement_> DoWhileStatement
358 %type <expression_> Element
359 %type <expression_> ElementOpt
360 %type <element_> ElementList
361 %type <element_> ElementListOpt
362 %type <statement_> ElseStatementOpt
363 %type <statement_> EmptyStatement
364 %type <expression_> EqualityExpression
365 %type <expression_> EqualityExpressionNoBF
366 %type <expression_> EqualityExpressionNoIn
367 %type <expression_> Expression
368 %type <expression_> ExpressionOpt
369 %type <compound_> Expression_
370 %type <expression_> ExpressionNoBF
371 %type <expression_> ExpressionNoIn
372 %type <compound_> ExpressionNoIn_
373 %type <expression_> ExpressionNoInOpt
374 %type <statement_> ExpressionStatement
375 %type <finally_> FinallyOpt
376 %type <comprehension_> ForComprehension
377 %type <statement_> ForStatement
378 %type <for_> ForStatementInitialiser
379 %type <statement_> ForInStatement
380 %type <forin_> ForInStatementInitialiser
381 %type <functionParameter_> FormalParameterList
382 %type <functionParameter_> FormalParameterList_
383 %type <statement_> FunctionBody
384 %type <statement_> FunctionDeclaration
385 %type <expression_> FunctionExpression
386 %type <identifier_> Identifier
387 %type <identifier_> IdentifierOpt
388 %type <comprehension_> IfComprehension
389 %type <statement_> IfStatement
390 %type <expression_> Initialiser
391 %type <expression_> InitialiserOpt
392 %type <expression_> InitialiserNoIn
393 %type <expression_> InitialiserNoInOpt
394 %type <statement_> IterationStatement
395 %type <statement_> LabelledStatement
396 %type <expression_> LeftHandSideExpression
397 %type <expression_> LeftHandSideExpressionNoBF
398 //%type <statement_> LetStatement
399 %type <literal_> Literal
400 %type <literal_> LiteralNoRE
401 %type <literal_> LiteralRE
402 %type <expression_> LogicalANDExpression
403 %type <expression_> LogicalANDExpressionNoBF
404 %type <expression_> LogicalANDExpressionNoIn
405 %type <expression_> LogicalORExpression
406 %type <expression_> LogicalORExpressionNoBF
407 %type <expression_> LogicalORExpressionNoIn
408 %type <member_> MemberAccess
409 %type <expression_> MemberExpression
410 %type <expression_> MemberExpression_
411 %type <expression_> MemberExpressionNoBF
412 %type <expression_> MultiplicativeExpression
413 %type <expression_> MultiplicativeExpressionNoBF
414 %type <expression_> NewExpression
415 %type <expression_> NewExpression_
416 %type <expression_> NewExpressionNoBF
417 %type <null_> NullLiteral
418 %type <literal_> ObjectLiteral
419 %type <expression_> PostfixExpression
420 %type <expression_> PostfixExpressionNoBF
421 %type <expression_> PrimaryExpression
422 %type <expression_> PrimaryExpressionNo
423 %type <expression_> PrimaryExpressionNoBF
424 %type <expression_> PrimaryExpressionNoRE
425 %type <expression_> PrimaryExpressionBF
426 %type <statement_> Program
427 %type <propertyName_> PropertyName
428 %type <propertyName_> PropertyName_
429 %type <property_> PropertyNameAndValueList
430 %type <property_> PropertyNameAndValueList_
431 %type <property_> PropertyNameAndValueListOpt
432 %type <expression_> RelationalExpression
433 %type <infix_> RelationalExpression_
434 %type <expression_> RelationalExpressionNoBF
435 %type <expression_> RelationalExpressionNoIn
436 %type <infix_> RelationalExpressionNoIn_
437 %type <statement_> ReturnStatement
438 %type <expression_> ShiftExpression
439 %type <expression_> ShiftExpressionNoBF
440 %type <statement_> SourceElement
441 %type <statement_> SourceElement_
442 %type <statement_> SourceElements
443 %type <statement_> Statement
444 %type <statement_> Statement_
445 %type <statement_> StatementList
446 %type <statement_> StatementListOpt
447 %type <statement_> SwitchStatement
448 %type <statement_> ThrowStatement
449 %type <statement_> TryStatement
450 %type <expression_> UnaryExpression
451 %type <expression_> UnaryExpression_
452 %type <expression_> UnaryExpressionNoBF
453 %type <declaration_> VariableDeclaration
454 %type <declaration_> VariableDeclarationNoIn
455 %type <declarations_> VariableDeclarationList
456 %type <declarations_> VariableDeclarationList_
457 %type <declarations_> VariableDeclarationListNoIn
458 %type <declarations_> VariableDeclarationListNoIn_
459 %type <statement_> VariableStatement
460 %type <statement_> WhileStatement
461 %type <statement_> WithStatement
464 %type <expression_> AssigneeExpressionNoRE
465 %type <expression_> CallExpressionNoRE
466 %type <expression_> LeftHandSideExpressionNoRE
467 %type <expression_> MemberExpressionNoRE
468 %type <expression_> NewExpressionNoRE
469 %type <expression_> PostfixExpressionNoRE
470 %type <expression_> UnaryAssigneeExpression
471 %type <expression_> UnaryExpressionNoRE
475 %type <statement_> CategoryStatement
476 %type <expression_> ClassExpression
477 %type <statement_> ClassStatement
478 %type <expression_> ClassSuperOpt
479 %type <field_> ClassFieldList
480 %type <message_> ClassMessageDeclaration
481 %type <message_> ClassMessageDeclarationListOpt
482 %type <className_> ClassName
483 %type <className_> ClassNameOpt
484 %type <expression_> MessageExpression
485 %type <messageParameter_> MessageParameter
486 %type <messageParameter_> MessageParameters
487 %type <messageParameter_> MessageParameterList
488 %type <messageParameter_> MessageParameterListOpt
489 %type <bool_> MessageScope
490 %type <argument_> SelectorCall
491 %type <argument_> SelectorCall_
492 %type <selector_> SelectorExpression
493 %type <selector_> SelectorExpression_
494 %type <selector_> SelectorExpressionOpt
495 %type <argument_> SelectorList
496 %type <expression_> TypeOpt
497 %type <argument_> VariadicCall
499 %type <word_> WordOpt
503 %type <propertyIdentifier_> PropertyIdentifier_
504 %type <selector_> PropertySelector
505 %type <selector_> PropertySelector_
506 %type <identifier_> QualifiedIdentifier
507 %type <identifier_> QualifiedIdentifier_
508 %type <identifier_> WildcardIdentifier
509 %type <identifier_> XMLComment
510 %type <identifier_> XMLCDATA
511 %type <identifier_> XMLElement
512 %type <identifier_> XMLElementContent
513 %type <identifier_> XMLMarkup
514 %type <identifier_> XMLPI
516 %type <attribute_> AttributeIdentifier
517 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
518 %type <expression_> PropertyIdentifier
519 %type <expression_> XMLListInitialiser
520 %type <expression_> XMLInitialiser
523 %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"
533 %left "<<" ">>" ">>>"
534 %left "<" ">" "<=" ">=" "instanceof" "in"
535 %left "==" "!=" "===" "!=="
542 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
548 /* Lexer State {{{ */
550 : { driver.SetCondition(CYDriver::RegExpCondition); }
555 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
565 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
570 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
590 : Identifier { $$ = $1; }
591 | "break" NewLineOpt { $$ = $1; }
592 | "case" { $$ = $1; }
593 | "catch" { $$ = $1; }
594 | "class" { $$ = $1; }
595 | "const" { $$ = $1; }
596 | "continue" NewLineOpt { $$ = $1; }
597 | "debugger" { $$ = $1; }
598 | "default" { $$ = $1; }
599 | "delete" { $$ = $1; }
601 | "else" { $$ = $1; }
602 | "enum" { $$ = $1; }
603 | "export" { $$ = $1; }
604 | "extends" { $$ = $1; }
605 | "false" { $$ = $1; }
606 | "finally" { $$ = $1; }
607 /* XXX: | "for" { $$ = $1; } */
608 | "function" { $$ = $1; }
610 | "import" { $$ = $1; }
611 /* XXX: | "in" { $$ = $1; } */
612 /* XXX: | "instanceof" { $$ = $1; } */
614 | "null" { $$ = $1; }
615 | "return" NewLineOpt { $$ = $1; }
616 | "super" { $$ = $1; }
617 | "switch" { $$ = $1; }
618 | "this" { $$ = $1; }
619 | "throw" NewLineOpt { $$ = $1; }
620 | "true" { $$ = $1; }
622 | "typeof" { $$ = $1; }
624 | "void" { $$ = $1; }
625 | "while" { $$ = $1; }
626 | "with" { $$ = $1; }
631 : Identifier_ { $$ = $1; }
633 | "implements" { $$ = $1; }
634 | "interface" { $$ = $1; }
635 | "package" { $$ = $1; }
636 | "private" { $$ = $1; }
637 | "protected" { $$ = $1; }
638 | "public" { $$ = $1; }
639 | "static" { $$ = $1; }
641 | "abstract" { $$ = $1; }
642 | "boolean" { $$ = $1; }
643 | "byte" { $$ = $1; }
644 | "char" { $$ = $1; }
645 | "double" { $$ = $1; }
646 | "final" { $$ = $1; }
647 | "float" { $$ = $1; }
648 | "goto" { $$ = $1; }
650 | "long" { $$ = $1; }
651 | "native" { $$ = $1; }
652 | "short" { $$ = $1; }
653 | "synchronized" { $$ = $1; }
654 | "throws" { $$ = $1; }
655 | "transient" { $$ = $1; }
656 | "volatile" { $$ = $1; }
659 | "yield" { $$ = $1; }
661 | "each" { $$ = $1; }
665 : Identifier { $$ = $1; }
670 : NullLiteral { $$ = $1; }
671 | BooleanLiteral { $$ = $1; }
672 | NumericLiteral { $$ = $1; }
673 | StringLiteral { $$ = $1; }
674 | "@" StringLiteral { $$ = $2; }
678 : RegularExpressionLiteral { $$ = $1; }
682 : LiteralNoRE { $$ = $1; }
683 | LiteralRE { $$ = $1; }
687 : "null" { $$ = $1; }
691 : "true" { $$ = $1; }
692 | "false" { $$ = $1; }
695 /* 11.1 Primary Expressions {{{ */
697 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
700 PrimaryExpressionNoBF
701 : PrimaryExpressionNo { $$ = $1; }
704 PrimaryExpressionNoRE
705 : PrimaryExpressionBF { $$ = $1; }
706 | PrimaryExpressionNo { $$ = $1; }
710 : "this" { $$ = $1; }
711 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
712 | Literal { $$ = $1; }
713 | ArrayLiteral { $$ = $1; }
714 | "(" Expression ")" { $$ = $2; }
718 : ObjectLiteral { $$ = $1; }
721 /* 11.1.4 Array Initialiser {{{ */
723 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
727 : AssignmentExpression { $$ = $1; }
731 : Element { $$ = $1; }
732 | LexSetRegExp { $$ = NULL; }
736 : ElementList { $$ = $1; }
737 | LexSetRegExp { $$ = NULL; }
741 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
742 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
745 /* 11.1.5 Object Initialiser {{{ */
747 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
750 PropertyNameAndValueList_
751 : "," PropertyNameAndValueList { $$ = $2; }
755 PropertyNameAndValueListOpt
756 : PropertyNameAndValueList { $$ = $1; }
760 PropertyNameAndValueList
761 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
765 : Identifier { $$ = $1; }
766 | StringLiteral { $$ = $1; }
767 | NumericLiteral { $$ = $1; }
771 : LexSetRegExp PropertyName_ { $$ = $2; }
775 /* 11.2 Left-Hand-Side Expressions {{{ */
777 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
781 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
782 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
786 : PrimaryExpression { $$ = $1; }
787 | LexSetRegExp FunctionExpression { $$ = $2; }
788 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
789 | LexSetRegExp MemberExpression_ { $$ = $2; }
793 : PrimaryExpressionNoBF { $$ = $1; }
794 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
795 | MemberExpression_ { $$ = $1; }
800 : PrimaryExpressionNoRE { $$ = $1; }
801 | FunctionExpression { $$ = $1; }
802 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
803 | MemberExpression_ { $$ = $1; }
808 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
812 : MemberExpression { $$ = $1; }
813 | LexSetRegExp NewExpression_ { $$ = $2; }
817 : MemberExpressionNoBF { $$ = $1; }
818 | NewExpression_ { $$ = $1; }
823 : MemberExpressionNoRE { $$ = $1; }
824 | NewExpression_ { $$ = $1; }
829 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
830 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
831 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
835 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
836 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
837 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
842 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
843 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
844 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
849 : "," ArgumentList { $$ = $2; }
854 : ArgumentList { $$ = $1; }
855 | LexSetRegExp { $$ = NULL; }
859 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
863 : "(" ArgumentListOpt ")" { $$ = $2; }
866 LeftHandSideExpression
867 : NewExpression { $$ = $1; }
868 | CallExpression { $$ = $1; }
871 LeftHandSideExpressionNoBF
872 : NewExpressionNoBF { $$ = $1; }
873 | CallExpressionNoBF { $$ = $1; }
877 LeftHandSideExpressionNoRE
878 : NewExpressionNoRE { $$ = $1; }
879 | CallExpressionNoRE { $$ = $1; }
883 /* 11.3 Postfix Expressions {{{ */
885 : AssigneeExpression { $$ = $1; }
886 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
887 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
890 PostfixExpressionNoBF
891 : AssigneeExpressionNoBF { $$ = $1; }
892 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
893 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
897 PostfixExpressionNoRE
898 : AssigneeExpressionNoRE { $$ = $1; }
899 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
900 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
904 /* 11.4 Unary Operators {{{ */
906 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
907 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
908 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
909 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
910 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
911 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
912 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
913 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
914 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
915 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
916 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
920 : PostfixExpression { $$ = $1; }
921 | LexSetRegExp UnaryExpression_ { $$ = $2; }
925 : PostfixExpressionNoBF { $$ = $1; }
926 | UnaryExpression_ { $$ = $1; }
931 : PostfixExpressionNoRE { $$ = $1; }
932 | UnaryExpression_ { $$ = $1; }
936 /* 11.5 Multiplicative Operators {{{ */
937 MultiplicativeExpression
938 : UnaryExpression { $$ = $1; }
939 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
940 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
941 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
944 MultiplicativeExpressionNoBF
945 : UnaryExpressionNoBF { $$ = $1; }
946 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
947 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
948 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
951 /* 11.6 Additive Operators {{{ */
953 : MultiplicativeExpression { $$ = $1; }
954 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
955 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
958 AdditiveExpressionNoBF
959 : MultiplicativeExpressionNoBF { $$ = $1; }
960 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
961 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
964 /* 11.7 Bitwise Shift Operators {{{ */
966 : AdditiveExpression { $$ = $1; }
967 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
968 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
969 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
973 : AdditiveExpressionNoBF { $$ = $1; }
974 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
975 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
976 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
979 /* 11.8 Relational Operators {{{ */
980 RelationalExpressionNoIn_
981 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
982 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
983 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
984 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
985 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
988 RelationalExpression_
989 : RelationalExpressionNoIn_ { $$ = $1; }
990 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
994 : ShiftExpression { $$ = $1; }
995 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
998 RelationalExpressionNoIn
999 : ShiftExpression { $$ = $1; }
1000 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1003 RelationalExpressionNoBF
1004 : ShiftExpressionNoBF { $$ = $1; }
1005 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1008 /* 11.9 Equality Operators {{{ */
1010 : RelationalExpression { $$ = $1; }
1011 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1012 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1013 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1014 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1017 EqualityExpressionNoIn
1018 : RelationalExpressionNoIn { $$ = $1; }
1019 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1020 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1021 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1022 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1025 EqualityExpressionNoBF
1026 : RelationalExpressionNoBF { $$ = $1; }
1027 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1028 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1029 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1030 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1033 /* 11.10 Binary Bitwise Operators {{{ */
1034 BitwiseANDExpression
1035 : EqualityExpression { $$ = $1; }
1036 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1039 BitwiseANDExpressionNoIn
1040 : EqualityExpressionNoIn { $$ = $1; }
1041 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1044 BitwiseANDExpressionNoBF
1045 : EqualityExpressionNoBF { $$ = $1; }
1046 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1049 BitwiseXORExpression
1050 : BitwiseANDExpression { $$ = $1; }
1051 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1054 BitwiseXORExpressionNoIn
1055 : BitwiseANDExpressionNoIn { $$ = $1; }
1056 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1059 BitwiseXORExpressionNoBF
1060 : BitwiseANDExpressionNoBF { $$ = $1; }
1061 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1065 : BitwiseXORExpression { $$ = $1; }
1066 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1069 BitwiseORExpressionNoIn
1070 : BitwiseXORExpressionNoIn { $$ = $1; }
1071 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1074 BitwiseORExpressionNoBF
1075 : BitwiseXORExpressionNoBF { $$ = $1; }
1076 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1079 /* 11.11 Binary Logical Operators {{{ */
1080 LogicalANDExpression
1081 : BitwiseORExpression { $$ = $1; }
1082 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1085 LogicalANDExpressionNoIn
1086 : BitwiseORExpressionNoIn { $$ = $1; }
1087 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1090 LogicalANDExpressionNoBF
1091 : BitwiseORExpressionNoBF { $$ = $1; }
1092 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1096 : LogicalANDExpression { $$ = $1; }
1097 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1100 LogicalORExpressionNoIn
1101 : LogicalANDExpressionNoIn { $$ = $1; }
1102 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1105 LogicalORExpressionNoBF
1106 : LogicalANDExpressionNoBF { $$ = $1; }
1107 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1110 /* 11.12 Conditional Operator ( ? : ) {{{ */
1111 ConditionalExpression
1112 : LogicalORExpression { $$ = $1; }
1113 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1116 ConditionalExpressionNoIn
1117 : LogicalORExpressionNoIn { $$ = $1; }
1118 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1121 ConditionalExpressionNoBF
1122 : LogicalORExpressionNoBF { $$ = $1; }
1123 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1126 /* 11.13 Assignment Operators {{{ */
1127 AssignmentExpression_
1128 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1129 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1130 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1131 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1132 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1133 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1134 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1135 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1136 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1137 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1138 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1139 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1143 : LeftHandSideExpression { $$ = $1; }
1145 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1149 AssigneeExpressionNoBF
1150 : LeftHandSideExpressionNoBF { $$ = $1; }
1152 | UnaryAssigneeExpression { $$ = $1; }
1157 AssigneeExpressionNoRE
1158 : LeftHandSideExpressionNoRE { $$ = $1; }
1159 | UnaryAssigneeExpression { $$ = $1; }
1163 AssignmentExpression
1164 : ConditionalExpression { $$ = $1; }
1165 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1168 AssignmentExpressionNoIn
1169 : ConditionalExpressionNoIn { $$ = $1; }
1170 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1171 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1172 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1173 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1174 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1175 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1176 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1177 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1178 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1179 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1180 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1181 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1184 AssignmentExpressionNoBF
1185 : ConditionalExpressionNoBF { $$ = $1; }
1186 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1189 /* 11.14 Comma Operator {{{ */
1191 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1196 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1201 : Expression { $$ = $1; }
1202 | LexSetRegExp { $$ = NULL; }
1206 : ExpressionNoIn { $$ = $1; }
1207 | LexSetRegExp { $$ = NULL; }
1211 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1215 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1219 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1223 /* 12 Statements {{{ */
1225 : Block { $$ = $1; }
1226 | VariableStatement { $$ = $1; }
1227 | EmptyStatement { $$ = $1; }
1228 | ExpressionStatement { $$ = $1; }
1229 | IfStatement { $$ = $1; }
1230 | IterationStatement { $$ = $1; }
1231 | ContinueStatement { $$ = $1; }
1232 | BreakStatement { $$ = $1; }
1233 | ReturnStatement { $$ = $1; }
1234 | WithStatement { $$ = $1; }
1235 | LabelledStatement { $$ = $1; }
1236 | SwitchStatement { $$ = $1; }
1237 | ThrowStatement { $$ = $1; }
1238 | TryStatement { $$ = $1; }
1242 : LexSetRegExp Statement_ { $$ = $2; }
1245 /* 12.1 Block {{{ */
1247 : "{" StatementListOpt "}" { $$ = $2; }
1251 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1255 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1259 : StatementList { $$ = $1; }
1260 | LexSetRegExp { $$ = NULL; }
1263 /* 12.2 Variable Statement {{{ */
1265 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1268 VariableDeclarationList_
1269 : "," VariableDeclarationList { $$ = $2; }
1273 VariableDeclarationListNoIn_
1274 : "," VariableDeclarationListNoIn { $$ = $2; }
1278 VariableDeclarationList
1279 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1282 VariableDeclarationListNoIn
1283 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1287 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1290 VariableDeclarationNoIn
1291 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1295 : Initialiser { $$ = $1; }
1300 : InitialiserNoIn { $$ = $1; }
1305 : "=" AssignmentExpression { $$ = $2; }
1309 : "=" AssignmentExpressionNoIn { $$ = $2; }
1312 /* 12.3 Empty Statement {{{ */
1314 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1317 /* 12.4 Expression Statement {{{ */
1319 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1322 /* 12.5 The if Statement {{{ */
1324 : "else" Statement { $$ = $2; }
1325 | %prec "if" { $$ = NULL; }
1329 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1333 /* 12.6 Iteration Statements {{{ */
1335 : DoWhileStatement { $$ = $1; }
1336 | WhileStatement { $$ = $1; }
1337 | ForStatement { $$ = $1; }
1338 | ForInStatement { $$ = $1; }
1341 /* 12.6.1 The do-while Statement {{{ */
1343 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1346 /* 12.6.2 The while Statement {{{ */
1348 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1351 /* 12.6.3 The for Statement {{{ */
1353 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1356 ForStatementInitialiser
1357 : ExpressionNoInOpt { $$ = $1; }
1358 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1361 /* 12.6.4 The for-in Statement {{{ */
1363 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1366 ForInStatementInitialiser
1367 : LeftHandSideExpression { $$ = $1; }
1368 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1372 /* 12.7 The continue Statement {{{ */
1374 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1377 /* 12.8 The break Statement {{{ */
1379 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1382 /* 12.9 The return Statement {{{ */
1384 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1387 /* 12.10 The with Statement {{{ */
1389 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1393 /* 12.11 The switch Statement {{{ */
1395 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1399 : "{" CaseClausesOpt "}" { $$ = $2; }
1403 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1404 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1409 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1413 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1416 /* 12.12 Labelled Statements {{{ */
1418 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1421 /* 12.13 The throw Statement {{{ */
1423 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1426 /* 12.14 The try Statement {{{ */
1428 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1432 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1437 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1442 /* 13 Function Definition {{{ */
1444 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1448 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1451 FormalParameterList_
1452 : "," FormalParameterList { $$ = $2; }
1457 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1462 : SourceElements { $$ = $1; }
1465 /* 14 Program {{{ */
1467 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1471 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1472 | LexSetRegExp { $$ = NULL; }
1476 : Statement_ { $$ = $1; }
1477 | FunctionDeclaration { $$ = $1; }
1481 : LexSetRegExp SourceElement_ { $$ = $2; }
1486 /* Cycript (Objective-C): @class Declaration {{{ */
1488 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1489 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1494 : "{" "}" { $$ = NULL; }
1498 : "+" { $$ = false; }
1499 | "-" { $$ = true; }
1503 : "(" Expression ")" { $$ = $2; }
1508 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1511 MessageParameterListOpt
1512 : MessageParameterList { $$ = $1; }
1516 MessageParameterList
1517 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1521 : MessageParameterList { $$ = $1; }
1522 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1525 ClassMessageDeclaration
1526 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1529 ClassMessageDeclarationListOpt
1530 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1535 : Identifier { $$ = $1; }
1536 | "(" AssignmentExpression ")" { $$ = $2; }
1540 : ClassName { $$ = $1; }
1545 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1549 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
1553 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1557 : ClassExpression { $$ = $1; }
1561 : ClassStatement { $$ = $1; }
1562 | CategoryStatement { $$ = $1; }
1565 /* Cycript (Objective-C): Send Message {{{ */
1567 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1572 : SelectorCall { $$ = $1; }
1573 | VariadicCall { $$ = $1; }
1577 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1581 : SelectorCall { $$ = $1; }
1582 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1586 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1587 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1590 SelectorExpressionOpt
1591 : SelectorExpression_ { $$ = $1; }
1596 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1600 : SelectorExpression_ { $$ = $1; }
1601 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1605 : MessageExpression { $$ = $1; }
1606 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1612 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1613 UnaryAssigneeExpression
1614 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1618 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1622 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1623 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1628 /* YUI: Documentation Comments {{{ */
1630 : Comment { $$ = $1; }
1635 /* Lexer State {{{ */
1637 : { driver.PushCondition(CYDriver::RegExpCondition); }
1641 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1645 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1649 : { driver.PopCondition(); }
1653 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1657 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1666 /* 8.1 Context Keywords {{{ */
1668 : "namespace" { $$ = $1; }
1669 | "xml" { $$ = $1; }
1672 /* 8.3 XML Initialiser Input Elements {{{ */
1674 : XMLComment { $$ = $1; }
1675 | XMLCDATA { $$ = $1; }
1676 | XMLPI { $$ = $1; }
1679 /* 11.1 Primary Expressions {{{ */
1681 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1682 | XMLInitialiser { $$ = $1; }
1683 | XMLListInitialiser { $$ = $1; }
1687 : AttributeIdentifier { $$ = $1; }
1688 | QualifiedIdentifier { $$ = $1; }
1689 | WildcardIdentifier { $$ = $1; }
1692 /* 11.1.1 Attribute Identifiers {{{ */
1694 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1698 : PropertySelector { $$ = $1; }
1699 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1703 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1704 | WildcardIdentifier { $$ = $1; }
1707 /* 11.1.2 Qualified Identifiers {{{ */
1708 QualifiedIdentifier_
1709 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1710 | QualifiedIdentifier { $$ = $1; }
1714 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1717 /* 11.1.3 Wildcard Identifiers {{{ */
1719 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1722 /* 11.1.4 XML Initialiser {{{ */
1724 : XMLMarkup { $$ = $1; }
1725 | XMLElement { $$ = $1; }
1729 : "<" XMLTagContent "/>" LexPop
1730 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1734 : LexPushXMLTag XMLTagName XMLAttributes
1738 : "{" LexPushRegExp Expression "}" LexPop
1747 : XMLAttributes_ XMLAttribute
1752 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1753 | XMLAttributes_ XMLWhitespaceOpt
1762 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1766 : XMLExpression XMLElementContentOpt
1767 | XMLMarkup XMLElementContentOpt
1768 | XMLText XMLElementContentOpt
1769 | XMLElement XMLElementContentOpt
1772 XMLElementContentOpt
1777 /* 11.1.5 XMLList Initialiser {{{ */
1779 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1782 /* 11.2 Left-Hand-Side Expressions {{{ */
1784 : Identifier { $$ = $1; }
1785 | PropertyIdentifier { $$ = $1; }
1789 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1790 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1791 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1794 /* 12.1 The default xml namespace Statement {{{ */
1795 /* XXX: DefaultXMLNamespaceStatement
1796 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1800 : DefaultXMLNamespaceStatement { $$ = $1; }
1805 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1806 PropertyNameAndValueList_
1807 : "," { $$ = NULL; }
1810 /* JavaScript 1.7: Array Comprehensions {{{ */
1812 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1816 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1817 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1820 ComprehensionListOpt
1821 : ComprehensionList { $$ = $1; }
1822 | IfComprehension { $$ = $1; }
1827 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1831 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1834 /* JavaScript 1.7: for each {{{ */
1836 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1839 /* JavaScript 1.7: let Statements {{{ *//*
1841 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1848 /* JavaScript FTW: Function Statements {{{ */
1850 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }