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 CYProtocol *protocol_;
103 CYSelectorPart *selector_;
107 CYAttribute *attribute_;
108 CYPropertyIdentifier *propertyIdentifier_;
109 CYSelector *selector_;
117 int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
126 @$.begin.filename = @$.end.filename = &driver.filename_;
136 %parse-param { CYDriver &driver }
137 %lex-param { void *scanner }
144 %token XMLAttributeValue
146 %token XMLTagCharacters
152 %token LeftRight "<>"
153 %token LeftSlashRight "</>"
155 %token SlashRight "/>"
156 %token LeftSlash "</"
158 %token ColonColon "::"
159 %token PeriodPeriod ".."
162 @begin E4X ObjectiveC
167 %token AmpersandAmpersand "&&"
168 %token AmpersandEqual "&="
170 %token CarrotEqual "^="
172 %token EqualEqual "=="
173 %token EqualEqualEqual "==="
174 %token Exclamation "!"
175 %token ExclamationEqual "!="
176 %token ExclamationEqualEqual "!=="
178 %token HyphenEqual "-="
179 %token HyphenHyphen "--"
180 %token HyphenHyphen_ "\n--"
181 %token HyphenRight "->"
183 %token LeftEqual "<="
185 %token LeftLeftEqual "<<="
187 %token PercentEqual "%="
190 %token PipeEqual "|="
193 %token PlusEqual "+="
195 %token PlusPlus_ "\n++"
197 %token RightEqual ">="
198 %token RightRight ">>"
199 %token RightRightEqual ">>="
200 %token RightRightRight ">>>"
201 %token RightRightRightEqual ">>>="
203 %token SlashEqual "/="
205 %token StarEqual "*="
214 %token <comment_> Comment
217 %token CloseParen ")"
220 %token CloseBrace "}"
222 %token OpenBracket "["
223 %token CloseBracket "]"
225 %token AtClass "@class"
226 %token AtSelector "@selector"
229 %token <false_> False "false"
230 %token <null_> Null "null"
231 %token <true_> True "true"
233 // ES3/ES5/WIE/JSC Reserved
234 %token <word_> Break "break"
235 %token <word_> Case "case"
236 %token <word_> Catch "catch"
237 %token <word_> Continue "continue"
238 %token <word_> Default "default"
239 %token <word_> Delete "delete"
240 %token <word_> Do "do"
241 %token <word_> Else "else"
242 %token <word_> Finally "finally"
243 %token <word_> For "for"
244 %token <word_> Function "function"
245 %token <word_> If "if"
246 %token <word_> In "in"
247 %token <word_> InstanceOf "instanceof"
248 %token <word_> New "new"
249 %token <word_> Return "return"
250 %token <word_> Switch "switch"
251 %token <this_> This "this"
252 %token <word_> Throw "throw"
253 %token <word_> Try "try"
254 %token <word_> TypeOf "typeof"
255 %token <word_> Var "var"
256 %token <word_> Void "void"
257 %token <word_> While "while"
258 %token <word_> With "with"
260 // ES3/IE6 Future, ES5/JSC Reserved
261 %token <word_> Debugger "debugger"
263 // ES3/ES5/IE6 Future, JSC Reserved
264 %token <word_> Const "const"
266 // ES3/ES5/IE6/JSC Future
267 %token <word_> Class "class"
268 %token <word_> Enum "enum"
269 %token <word_> Export "export"
270 %token <word_> Extends "extends"
271 %token <word_> Import "import"
272 %token <word_> Super "super"
274 // ES3 Future, ES5 Strict Future
275 %token <identifier_> Implements "implements"
276 %token <identifier_> Interface "interface"
277 %token <identifier_> Package "package"
278 %token <identifier_> Private "private"
279 %token <identifier_> Protected "protected"
280 %token <identifier_> Public "public"
281 %token <identifier_> Static "static"
284 %token <identifier_> Abstract "abstract"
285 %token <identifier_> Boolean "boolean"
286 %token <identifier_> Byte "byte"
287 %token <identifier_> Char "char"
288 %token <identifier_> Double "double"
289 %token <identifier_> Final "final"
290 %token <identifier_> Float "float"
291 %token <identifier_> Goto "goto"
292 %token <identifier_> Int "int"
293 %token <identifier_> Long "long"
294 %token <identifier_> Native "native"
295 %token <identifier_> Short "short"
296 %token <identifier_> Synchronized "synchronized"
297 %token <identifier_> Throws "throws"
298 %token <identifier_> Transient "transient"
299 %token <identifier_> Volatile "volatile"
302 %token <identifier_> Let "let"
303 %token <identifier_> Yield "yield"
306 %token <identifier_> Each "each"
310 %token <identifier_> Namespace "namespace"
311 %token <identifier_> XML "xml"
314 %token <identifier_> Identifier_
315 %token <number_> NumericLiteral
316 %token <string_> StringLiteral
317 %token <literal_> RegularExpressionLiteral
319 %type <expression_> AdditiveExpression
320 %type <expression_> AdditiveExpressionNoBF
321 %type <argument_> ArgumentList
322 %type <argument_> ArgumentList_
323 %type <argument_> ArgumentListOpt
324 %type <argument_> Arguments
325 %type <literal_> ArrayLiteral
326 %type <expression_> AssigneeExpression
327 %type <expression_> AssigneeExpressionNoBF
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 <clause_> CaseBlock
348 %type <clause_> CaseClause
349 %type <clause_> CaseClausesOpt
350 %type <catch_> CatchOpt
351 %type <comprehension_> ComprehensionList
352 %type <comprehension_> ComprehensionListOpt
353 %type <expression_> ConditionalExpression
354 %type <expression_> ConditionalExpressionNoBF
355 %type <expression_> ConditionalExpressionNoIn
356 %type <statement_> ContinueStatement
357 %type <clause_> DefaultClause
358 %type <statement_> DoWhileStatement
359 %type <expression_> Element
360 %type <expression_> ElementOpt
361 %type <element_> ElementList
362 %type <element_> ElementListOpt
363 %type <statement_> ElseStatementOpt
364 %type <statement_> EmptyStatement
365 %type <expression_> EqualityExpression
366 %type <expression_> EqualityExpressionNoBF
367 %type <expression_> EqualityExpressionNoIn
368 %type <expression_> Expression
369 %type <expression_> ExpressionOpt
370 %type <compound_> Expression_
371 %type <expression_> ExpressionNoBF
372 %type <expression_> ExpressionNoIn
373 %type <compound_> ExpressionNoIn_
374 %type <expression_> ExpressionNoInOpt
375 %type <statement_> ExpressionStatement
376 %type <finally_> FinallyOpt
377 %type <comprehension_> ForComprehension
378 %type <statement_> ForStatement
379 %type <for_> ForStatementInitialiser
380 %type <statement_> ForInStatement
381 %type <forin_> ForInStatementInitialiser
382 %type <functionParameter_> FormalParameterList
383 %type <functionParameter_> FormalParameterList_
384 %type <statement_> FunctionBody
385 %type <statement_> FunctionDeclaration
386 %type <expression_> FunctionExpression
387 %type <identifier_> Identifier
388 %type <identifier_> IdentifierOpt
389 %type <comprehension_> IfComprehension
390 %type <statement_> IfStatement
391 %type <expression_> Initialiser
392 %type <expression_> InitialiserOpt
393 %type <expression_> InitialiserNoIn
394 %type <expression_> InitialiserNoInOpt
395 %type <statement_> IterationStatement
396 %type <statement_> LabelledStatement
397 %type <expression_> LeftHandSideExpression
398 %type <expression_> LeftHandSideExpressionNoBF
399 //%type <statement_> LetStatement
400 %type <literal_> Literal
401 %type <literal_> LiteralNoRE
402 %type <literal_> LiteralRE
403 %type <expression_> LogicalANDExpression
404 %type <expression_> LogicalANDExpressionNoBF
405 %type <expression_> LogicalANDExpressionNoIn
406 %type <expression_> LogicalORExpression
407 %type <expression_> LogicalORExpressionNoBF
408 %type <expression_> LogicalORExpressionNoIn
409 %type <member_> MemberAccess
410 %type <expression_> MemberExpression
411 %type <expression_> MemberExpression_
412 %type <expression_> MemberExpressionNoBF
413 %type <expression_> MultiplicativeExpression
414 %type <expression_> MultiplicativeExpressionNoBF
415 %type <expression_> NewExpression
416 %type <expression_> NewExpression_
417 %type <expression_> NewExpressionNoBF
418 %type <null_> NullLiteral
419 %type <literal_> ObjectLiteral
420 %type <expression_> PostfixExpression
421 %type <expression_> PostfixExpressionNoBF
422 %type <expression_> PrimaryExpression
423 %type <expression_> PrimaryExpressionNo
424 %type <expression_> PrimaryExpressionNoBF
425 %type <expression_> PrimaryExpressionNoRE
426 %type <expression_> PrimaryExpressionBF
427 %type <statement_> Program
428 %type <propertyName_> PropertyName
429 %type <propertyName_> PropertyName_
430 %type <property_> PropertyNameAndValueList
431 %type <property_> PropertyNameAndValueList_
432 %type <property_> PropertyNameAndValueListOpt
433 %type <expression_> RelationalExpression
434 %type <infix_> RelationalExpression_
435 %type <expression_> RelationalExpressionNoBF
436 %type <expression_> RelationalExpressionNoIn
437 %type <infix_> RelationalExpressionNoIn_
438 %type <statement_> ReturnStatement
439 %type <expression_> ShiftExpression
440 %type <expression_> ShiftExpressionNoBF
441 %type <statement_> SourceElement
442 %type <statement_> SourceElement_
443 %type <statement_> SourceElements
444 %type <statement_> Statement
445 %type <statement_> Statement_
446 %type <statement_> StatementList
447 %type <statement_> StatementListOpt
448 %type <statement_> SwitchStatement
449 %type <statement_> ThrowStatement
450 %type <statement_> TryStatement
451 %type <expression_> UnaryExpression
452 %type <expression_> UnaryExpression_
453 %type <expression_> UnaryExpressionNoBF
454 %type <declaration_> VariableDeclaration
455 %type <declaration_> VariableDeclarationNoIn
456 %type <declarations_> VariableDeclarationList
457 %type <declarations_> VariableDeclarationList_
458 %type <declarations_> VariableDeclarationListNoIn
459 %type <declarations_> VariableDeclarationListNoIn_
460 %type <statement_> VariableStatement
461 %type <statement_> WhileStatement
462 %type <statement_> WithStatement
465 %type <expression_> AssigneeExpressionNoRE
466 %type <expression_> CallExpressionNoRE
467 %type <expression_> LeftHandSideExpressionNoRE
468 %type <expression_> MemberExpressionNoRE
469 %type <expression_> NewExpressionNoRE
470 %type <expression_> PostfixExpressionNoRE
471 %type <expression_> UnaryAssigneeExpression
472 %type <expression_> UnaryExpressionNoRE
476 %type <statement_> CategoryStatement
477 %type <expression_> ClassExpression
478 %type <statement_> ClassStatement
479 %type <expression_> ClassSuperOpt
480 %type <field_> ClassFieldList
481 %type <message_> ClassMessageDeclaration
482 %type <message_> ClassMessageDeclarationListOpt
483 %type <className_> ClassName
484 %type <className_> ClassNameOpt
485 %type <protocol_> ClassProtocolListOpt
486 %type <protocol_> ClassProtocols
487 %type <protocol_> ClassProtocolsOpt
488 %type <expression_> MessageExpression
489 %type <messageParameter_> MessageParameter
490 %type <messageParameter_> MessageParameters
491 %type <messageParameter_> MessageParameterList
492 %type <messageParameter_> MessageParameterListOpt
493 %type <bool_> MessageScope
494 %type <argument_> SelectorCall
495 %type <argument_> SelectorCall_
496 %type <selector_> SelectorExpression
497 %type <selector_> SelectorExpression_
498 %type <selector_> SelectorExpressionOpt
499 %type <argument_> SelectorList
500 %type <expression_> TypeOpt
501 %type <argument_> VariadicCall
503 %type <word_> WordOpt
507 %type <propertyIdentifier_> PropertyIdentifier_
508 %type <selector_> PropertySelector
509 %type <selector_> PropertySelector_
510 %type <identifier_> QualifiedIdentifier
511 %type <identifier_> QualifiedIdentifier_
512 %type <identifier_> WildcardIdentifier
513 %type <identifier_> XMLComment
514 %type <identifier_> XMLCDATA
515 %type <identifier_> XMLElement
516 %type <identifier_> XMLElementContent
517 %type <identifier_> XMLMarkup
518 %type <identifier_> XMLPI
520 %type <attribute_> AttributeIdentifier
521 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
522 %type <expression_> PropertyIdentifier
523 %type <expression_> XMLListInitialiser
524 %type <expression_> XMLInitialiser
527 %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"
537 %left "<<" ">>" ">>>"
538 %left "<" ">" "<=" ">=" "instanceof" "in"
539 %left "==" "!=" "===" "!=="
546 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
552 /* Lexer State {{{ */
554 : { driver.SetCondition(CYDriver::RegExpCondition); }
559 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
569 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
574 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
594 : Identifier { $$ = $1; }
595 | "break" NewLineOpt { $$ = $1; }
596 | "case" { $$ = $1; }
597 | "catch" { $$ = $1; }
598 | "class" { $$ = $1; }
599 | "const" { $$ = $1; }
600 | "continue" NewLineOpt { $$ = $1; }
601 | "debugger" { $$ = $1; }
602 | "default" { $$ = $1; }
603 | "delete" { $$ = $1; }
605 | "else" { $$ = $1; }
606 | "enum" { $$ = $1; }
607 | "export" { $$ = $1; }
608 | "extends" { $$ = $1; }
609 | "false" { $$ = $1; }
610 | "finally" { $$ = $1; }
611 /* XXX: | "for" { $$ = $1; } */
612 | "function" { $$ = $1; }
614 | "import" { $$ = $1; }
615 /* XXX: | "in" { $$ = $1; } */
616 /* XXX: | "instanceof" { $$ = $1; } */
618 | "null" { $$ = $1; }
619 | "return" NewLineOpt { $$ = $1; }
620 | "super" { $$ = $1; }
621 | "switch" { $$ = $1; }
622 | "this" { $$ = $1; }
623 | "throw" NewLineOpt { $$ = $1; }
624 | "true" { $$ = $1; }
626 | "typeof" { $$ = $1; }
628 | "void" { $$ = $1; }
629 | "while" { $$ = $1; }
630 | "with" { $$ = $1; }
635 : Identifier_ { $$ = $1; }
637 | "implements" { $$ = $1; }
638 | "interface" { $$ = $1; }
639 | "package" { $$ = $1; }
640 | "private" { $$ = $1; }
641 | "protected" { $$ = $1; }
642 | "public" { $$ = $1; }
643 | "static" { $$ = $1; }
645 | "abstract" { $$ = $1; }
646 | "boolean" { $$ = $1; }
647 | "byte" { $$ = $1; }
648 | "char" { $$ = $1; }
649 | "double" { $$ = $1; }
650 | "final" { $$ = $1; }
651 | "float" { $$ = $1; }
652 | "goto" { $$ = $1; }
654 | "long" { $$ = $1; }
655 | "native" { $$ = $1; }
656 | "short" { $$ = $1; }
657 | "synchronized" { $$ = $1; }
658 | "throws" { $$ = $1; }
659 | "transient" { $$ = $1; }
660 | "volatile" { $$ = $1; }
663 | "yield" { $$ = $1; }
665 | "each" { $$ = $1; }
669 : Identifier { $$ = $1; }
674 : NullLiteral { $$ = $1; }
675 | BooleanLiteral { $$ = $1; }
676 | NumericLiteral { $$ = $1; }
677 | StringLiteral { $$ = $1; }
678 | "@" StringLiteral { $$ = $2; }
682 : RegularExpressionLiteral { $$ = $1; }
686 : LiteralNoRE { $$ = $1; }
687 | LiteralRE { $$ = $1; }
691 : "null" { $$ = $1; }
695 : "true" { $$ = $1; }
696 | "false" { $$ = $1; }
699 /* 11.1 Primary Expressions {{{ */
701 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
704 PrimaryExpressionNoBF
705 : PrimaryExpressionNo { $$ = $1; }
708 PrimaryExpressionNoRE
709 : PrimaryExpressionBF { $$ = $1; }
710 | PrimaryExpressionNo { $$ = $1; }
714 : "this" { $$ = $1; }
715 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
716 | Literal { $$ = $1; }
717 | ArrayLiteral { $$ = $1; }
718 | "(" Expression ")" { $$ = $2; }
722 : ObjectLiteral { $$ = $1; }
725 /* 11.1.4 Array Initialiser {{{ */
727 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
731 : AssignmentExpression { $$ = $1; }
735 : Element { $$ = $1; }
736 | LexSetRegExp { $$ = NULL; }
740 : ElementList { $$ = $1; }
741 | LexSetRegExp { $$ = NULL; }
745 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
746 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
749 /* 11.1.5 Object Initialiser {{{ */
751 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
754 PropertyNameAndValueList_
755 : "," PropertyNameAndValueList { $$ = $2; }
759 PropertyNameAndValueListOpt
760 : PropertyNameAndValueList { $$ = $1; }
764 PropertyNameAndValueList
765 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
769 : Identifier { $$ = $1; }
770 | StringLiteral { $$ = $1; }
771 | NumericLiteral { $$ = $1; }
775 : LexSetRegExp PropertyName_ { $$ = $2; }
779 /* 11.2 Left-Hand-Side Expressions {{{ */
781 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
785 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
786 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
790 : PrimaryExpression { $$ = $1; }
791 | LexSetRegExp FunctionExpression { $$ = $2; }
792 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
793 | LexSetRegExp MemberExpression_ { $$ = $2; }
797 : PrimaryExpressionNoBF { $$ = $1; }
798 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
799 | MemberExpression_ { $$ = $1; }
804 : PrimaryExpressionNoRE { $$ = $1; }
805 | FunctionExpression { $$ = $1; }
806 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
807 | MemberExpression_ { $$ = $1; }
812 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
816 : MemberExpression { $$ = $1; }
817 | LexSetRegExp NewExpression_ { $$ = $2; }
821 : MemberExpressionNoBF { $$ = $1; }
822 | NewExpression_ { $$ = $1; }
827 : MemberExpressionNoRE { $$ = $1; }
828 | NewExpression_ { $$ = $1; }
833 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
834 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
835 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
839 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
840 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
841 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
846 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
847 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
848 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
853 : "," ArgumentList { $$ = $2; }
858 : ArgumentList { $$ = $1; }
859 | LexSetRegExp { $$ = NULL; }
863 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
867 : "(" ArgumentListOpt ")" { $$ = $2; }
870 LeftHandSideExpression
871 : NewExpression { $$ = $1; }
872 | CallExpression { $$ = $1; }
875 LeftHandSideExpressionNoBF
876 : NewExpressionNoBF { $$ = $1; }
877 | CallExpressionNoBF { $$ = $1; }
881 LeftHandSideExpressionNoRE
882 : NewExpressionNoRE { $$ = $1; }
883 | CallExpressionNoRE { $$ = $1; }
887 /* 11.3 Postfix Expressions {{{ */
889 : AssigneeExpression { $$ = $1; }
890 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
891 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
894 PostfixExpressionNoBF
895 : AssigneeExpressionNoBF { $$ = $1; }
896 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
897 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
901 PostfixExpressionNoRE
902 : AssigneeExpressionNoRE { $$ = $1; }
903 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
904 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
908 /* 11.4 Unary Operators {{{ */
910 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
911 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
912 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
913 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
914 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
915 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
916 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
917 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
918 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
919 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
920 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
924 : PostfixExpression { $$ = $1; }
925 | LexSetRegExp UnaryExpression_ { $$ = $2; }
929 : PostfixExpressionNoBF { $$ = $1; }
930 | UnaryExpression_ { $$ = $1; }
935 : PostfixExpressionNoRE { $$ = $1; }
936 | UnaryExpression_ { $$ = $1; }
940 /* 11.5 Multiplicative Operators {{{ */
941 MultiplicativeExpression
942 : UnaryExpression { $$ = $1; }
943 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
944 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
945 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
948 MultiplicativeExpressionNoBF
949 : UnaryExpressionNoBF { $$ = $1; }
950 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
951 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
952 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
955 /* 11.6 Additive Operators {{{ */
957 : MultiplicativeExpression { $$ = $1; }
958 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
959 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
962 AdditiveExpressionNoBF
963 : MultiplicativeExpressionNoBF { $$ = $1; }
964 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
965 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
968 /* 11.7 Bitwise Shift Operators {{{ */
970 : AdditiveExpression { $$ = $1; }
971 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
972 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
973 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
977 : AdditiveExpressionNoBF { $$ = $1; }
978 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
979 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
980 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
983 /* 11.8 Relational Operators {{{ */
984 RelationalExpressionNoIn_
985 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
986 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
987 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
988 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
989 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
992 RelationalExpression_
993 : RelationalExpressionNoIn_ { $$ = $1; }
994 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
998 : ShiftExpression { $$ = $1; }
999 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1002 RelationalExpressionNoIn
1003 : ShiftExpression { $$ = $1; }
1004 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1007 RelationalExpressionNoBF
1008 : ShiftExpressionNoBF { $$ = $1; }
1009 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1012 /* 11.9 Equality Operators {{{ */
1014 : RelationalExpression { $$ = $1; }
1015 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1016 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1017 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1018 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1021 EqualityExpressionNoIn
1022 : RelationalExpressionNoIn { $$ = $1; }
1023 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1024 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1025 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1026 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1029 EqualityExpressionNoBF
1030 : RelationalExpressionNoBF { $$ = $1; }
1031 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1032 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1033 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1034 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1037 /* 11.10 Binary Bitwise Operators {{{ */
1038 BitwiseANDExpression
1039 : EqualityExpression { $$ = $1; }
1040 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1043 BitwiseANDExpressionNoIn
1044 : EqualityExpressionNoIn { $$ = $1; }
1045 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1048 BitwiseANDExpressionNoBF
1049 : EqualityExpressionNoBF { $$ = $1; }
1050 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1053 BitwiseXORExpression
1054 : BitwiseANDExpression { $$ = $1; }
1055 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1058 BitwiseXORExpressionNoIn
1059 : BitwiseANDExpressionNoIn { $$ = $1; }
1060 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1063 BitwiseXORExpressionNoBF
1064 : BitwiseANDExpressionNoBF { $$ = $1; }
1065 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1069 : BitwiseXORExpression { $$ = $1; }
1070 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1073 BitwiseORExpressionNoIn
1074 : BitwiseXORExpressionNoIn { $$ = $1; }
1075 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1078 BitwiseORExpressionNoBF
1079 : BitwiseXORExpressionNoBF { $$ = $1; }
1080 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1083 /* 11.11 Binary Logical Operators {{{ */
1084 LogicalANDExpression
1085 : BitwiseORExpression { $$ = $1; }
1086 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1089 LogicalANDExpressionNoIn
1090 : BitwiseORExpressionNoIn { $$ = $1; }
1091 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1094 LogicalANDExpressionNoBF
1095 : BitwiseORExpressionNoBF { $$ = $1; }
1096 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1100 : LogicalANDExpression { $$ = $1; }
1101 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1104 LogicalORExpressionNoIn
1105 : LogicalANDExpressionNoIn { $$ = $1; }
1106 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1109 LogicalORExpressionNoBF
1110 : LogicalANDExpressionNoBF { $$ = $1; }
1111 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1114 /* 11.12 Conditional Operator ( ? : ) {{{ */
1115 ConditionalExpression
1116 : LogicalORExpression { $$ = $1; }
1117 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1120 ConditionalExpressionNoIn
1121 : LogicalORExpressionNoIn { $$ = $1; }
1122 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1125 ConditionalExpressionNoBF
1126 : LogicalORExpressionNoBF { $$ = $1; }
1127 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1130 /* 11.13 Assignment Operators {{{ */
1131 AssignmentExpression_
1132 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1133 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1134 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1135 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1136 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1137 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1138 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1139 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1140 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1141 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1142 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1143 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1147 : LeftHandSideExpression { $$ = $1; }
1149 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1153 AssigneeExpressionNoBF
1154 : LeftHandSideExpressionNoBF { $$ = $1; }
1156 | UnaryAssigneeExpression { $$ = $1; }
1161 AssigneeExpressionNoRE
1162 : LeftHandSideExpressionNoRE { $$ = $1; }
1163 | UnaryAssigneeExpression { $$ = $1; }
1167 AssignmentExpression
1168 : ConditionalExpression { $$ = $1; }
1169 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1172 AssignmentExpressionNoIn
1173 : ConditionalExpressionNoIn { $$ = $1; }
1174 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1175 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1176 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1177 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1178 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1179 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1180 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1181 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1182 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1183 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1184 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1185 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1188 AssignmentExpressionNoBF
1189 : ConditionalExpressionNoBF { $$ = $1; }
1190 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1193 /* 11.14 Comma Operator {{{ */
1195 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1200 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1205 : Expression { $$ = $1; }
1206 | LexSetRegExp { $$ = NULL; }
1210 : ExpressionNoIn { $$ = $1; }
1211 | LexSetRegExp { $$ = NULL; }
1215 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1219 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1223 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1227 /* 12 Statements {{{ */
1229 : Block { $$ = $1; }
1230 | VariableStatement { $$ = $1; }
1231 | EmptyStatement { $$ = $1; }
1232 | ExpressionStatement { $$ = $1; }
1233 | IfStatement { $$ = $1; }
1234 | IterationStatement { $$ = $1; }
1235 | ContinueStatement { $$ = $1; }
1236 | BreakStatement { $$ = $1; }
1237 | ReturnStatement { $$ = $1; }
1238 | WithStatement { $$ = $1; }
1239 | LabelledStatement { $$ = $1; }
1240 | SwitchStatement { $$ = $1; }
1241 | ThrowStatement { $$ = $1; }
1242 | TryStatement { $$ = $1; }
1246 : LexSetRegExp Statement_ { $$ = $2; }
1249 /* 12.1 Block {{{ */
1251 : "{" StatementListOpt "}" { $$ = $2; }
1255 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1259 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1263 : StatementList { $$ = $1; }
1264 | LexSetRegExp { $$ = NULL; }
1267 /* 12.2 Variable Statement {{{ */
1269 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1272 VariableDeclarationList_
1273 : "," VariableDeclarationList { $$ = $2; }
1277 VariableDeclarationListNoIn_
1278 : "," VariableDeclarationListNoIn { $$ = $2; }
1282 VariableDeclarationList
1283 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1286 VariableDeclarationListNoIn
1287 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1291 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1294 VariableDeclarationNoIn
1295 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1299 : Initialiser { $$ = $1; }
1304 : InitialiserNoIn { $$ = $1; }
1309 : "=" AssignmentExpression { $$ = $2; }
1313 : "=" AssignmentExpressionNoIn { $$ = $2; }
1316 /* 12.3 Empty Statement {{{ */
1318 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1321 /* 12.4 Expression Statement {{{ */
1323 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1326 /* 12.5 The if Statement {{{ */
1328 : "else" Statement { $$ = $2; }
1329 | %prec "if" { $$ = NULL; }
1333 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1337 /* 12.6 Iteration Statements {{{ */
1339 : DoWhileStatement { $$ = $1; }
1340 | WhileStatement { $$ = $1; }
1341 | ForStatement { $$ = $1; }
1342 | ForInStatement { $$ = $1; }
1345 /* 12.6.1 The do-while Statement {{{ */
1347 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1350 /* 12.6.2 The while Statement {{{ */
1352 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1355 /* 12.6.3 The for Statement {{{ */
1357 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1360 ForStatementInitialiser
1361 : ExpressionNoInOpt { $$ = $1; }
1362 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1365 /* 12.6.4 The for-in Statement {{{ */
1367 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1370 ForInStatementInitialiser
1371 : LeftHandSideExpression { $$ = $1; }
1372 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1376 /* 12.7 The continue Statement {{{ */
1378 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1381 /* 12.8 The break Statement {{{ */
1383 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1386 /* 12.9 The return Statement {{{ */
1388 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1391 /* 12.10 The with Statement {{{ */
1393 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1397 /* 12.11 The switch Statement {{{ */
1399 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1403 : "{" CaseClausesOpt "}" { $$ = $2; }
1407 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1408 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1413 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1417 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1420 /* 12.12 Labelled Statements {{{ */
1422 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1425 /* 12.13 The throw Statement {{{ */
1427 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1430 /* 12.14 The try Statement {{{ */
1432 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1436 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1441 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1446 /* 13 Function Definition {{{ */
1448 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1452 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1455 FormalParameterList_
1456 : "," FormalParameterList { $$ = $2; }
1461 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1466 : SourceElements { $$ = $1; }
1469 /* 14 Program {{{ */
1471 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1475 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1476 | LexSetRegExp { $$ = NULL; }
1480 : Statement_ { $$ = $1; }
1481 | FunctionDeclaration { $$ = $1; }
1485 : LexSetRegExp SourceElement_ { $$ = $2; }
1490 /* Cycript (Objective-C): @class Declaration {{{ */
1492 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1493 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1498 : "{" "}" { $$ = NULL; }
1502 : "+" { $$ = false; }
1503 | "-" { $$ = true; }
1507 : "(" Expression ")" { $$ = $2; }
1512 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1515 MessageParameterListOpt
1516 : MessageParameterList { $$ = $1; }
1520 MessageParameterList
1521 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1525 : MessageParameterList { $$ = $1; }
1526 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1529 ClassMessageDeclaration
1530 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1533 ClassMessageDeclarationListOpt
1534 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1539 : Identifier { $$ = $1; }
1540 | "(" AssignmentExpression ")" { $$ = $2; }
1544 : ClassName { $$ = $1; }
1548 // XXX: this should be AssignmentExpressionNoRight
1550 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1554 : "," ClassProtocols { $$ = $2; }
1558 ClassProtocolListOpt
1559 : "<" ClassProtocols ">" { $$ = $2; }
1564 : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1568 : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1572 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1576 : ClassExpression { $$ = $1; }
1580 : ClassStatement { $$ = $1; }
1581 | CategoryStatement { $$ = $1; }
1584 /* Cycript (Objective-C): Send Message {{{ */
1586 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1591 : SelectorCall { $$ = $1; }
1592 | VariadicCall { $$ = $1; }
1596 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1600 : SelectorCall { $$ = $1; }
1601 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1605 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1606 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1609 SelectorExpressionOpt
1610 : SelectorExpression_ { $$ = $1; }
1615 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1619 : SelectorExpression_ { $$ = $1; }
1620 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1624 : MessageExpression { $$ = $1; }
1625 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1631 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1632 UnaryAssigneeExpression
1633 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1637 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1641 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1642 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1647 /* YUI: Documentation Comments {{{ */
1649 : Comment { $$ = $1; }
1654 /* Lexer State {{{ */
1656 : { driver.PushCondition(CYDriver::RegExpCondition); }
1660 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1664 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1668 : { driver.PopCondition(); }
1672 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1676 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1685 /* 8.1 Context Keywords {{{ */
1687 : "namespace" { $$ = $1; }
1688 | "xml" { $$ = $1; }
1691 /* 8.3 XML Initialiser Input Elements {{{ */
1693 : XMLComment { $$ = $1; }
1694 | XMLCDATA { $$ = $1; }
1695 | XMLPI { $$ = $1; }
1698 /* 11.1 Primary Expressions {{{ */
1700 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1701 | XMLInitialiser { $$ = $1; }
1702 | XMLListInitialiser { $$ = $1; }
1706 : AttributeIdentifier { $$ = $1; }
1707 | QualifiedIdentifier { $$ = $1; }
1708 | WildcardIdentifier { $$ = $1; }
1711 /* 11.1.1 Attribute Identifiers {{{ */
1713 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1717 : PropertySelector { $$ = $1; }
1718 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1722 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1723 | WildcardIdentifier { $$ = $1; }
1726 /* 11.1.2 Qualified Identifiers {{{ */
1727 QualifiedIdentifier_
1728 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1729 | QualifiedIdentifier { $$ = $1; }
1733 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1736 /* 11.1.3 Wildcard Identifiers {{{ */
1738 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1741 /* 11.1.4 XML Initialiser {{{ */
1743 : XMLMarkup { $$ = $1; }
1744 | XMLElement { $$ = $1; }
1748 : "<" XMLTagContent "/>" LexPop
1749 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1753 : LexPushXMLTag XMLTagName XMLAttributes
1757 : "{" LexPushRegExp Expression "}" LexPop
1766 : XMLAttributes_ XMLAttribute
1771 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1772 | XMLAttributes_ XMLWhitespaceOpt
1781 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1785 : XMLExpression XMLElementContentOpt
1786 | XMLMarkup XMLElementContentOpt
1787 | XMLText XMLElementContentOpt
1788 | XMLElement XMLElementContentOpt
1791 XMLElementContentOpt
1796 /* 11.1.5 XMLList Initialiser {{{ */
1798 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1801 /* 11.2 Left-Hand-Side Expressions {{{ */
1803 : Identifier { $$ = $1; }
1804 | PropertyIdentifier { $$ = $1; }
1808 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1809 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1810 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1813 /* 12.1 The default xml namespace Statement {{{ */
1814 /* XXX: DefaultXMLNamespaceStatement
1815 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1819 : DefaultXMLNamespaceStatement { $$ = $1; }
1824 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1825 PropertyNameAndValueList_
1826 : "," { $$ = NULL; }
1829 /* JavaScript 1.7: Array Comprehensions {{{ */
1831 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1835 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1836 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1839 ComprehensionListOpt
1840 : ComprehensionList { $$ = $1; }
1841 | IfComprehension { $$ = $1; }
1846 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1850 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1853 /* JavaScript 1.7: for each {{{ */
1855 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1858 /* JavaScript 1.7: let Statements {{{ *//*
1860 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1867 /* JavaScript FTW: Function Statements {{{ */
1869 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }