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.
42 @if Bison24 %code top {
43 #define cyscanner driver.scanner_
44 #define YYSTACKEXPANDABLE 1
45 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
48 @if Bison24 %code requires {
52 #include "ObjectiveC/Syntax.hpp"
56 #include "E4X/Syntax.hpp"
65 CYDriver::Condition condition_;
67 CYArgument *argument_;
68 CYAssignment *assignment_;
71 cy::Syntax::Catch *catch_;
73 CYComprehension *comprehension_;
74 CYCompound *compound_;
75 CYDeclaration *declaration_;
76 CYDeclarations *declarations_;
78 CYExpression *expression_;
81 CYForInitialiser *for_;
82 CYForInInitialiser *forin_;
83 CYFunctionParameter *functionParameter_;
84 CYIdentifier *identifier_;
91 CYProperty *property_;
92 CYPropertyName *propertyName_;
93 CYRubyProc *rubyProc_;
94 CYStatement *statement_;
101 CYClassName *className_;
104 CYMessageParameter *messageParameter_;
105 CYProtocol *protocol_;
106 CYSelectorPart *selector_;
110 CYAttribute *attribute_;
111 CYPropertyIdentifier *propertyIdentifier_;
112 CYSelector *selector_;
117 #define YYSTYPE YYSTYPE
120 @if Bison24 %code provides {
121 int cylex(YYSTYPE *, cy::location *, void *);
128 @if Bison23 %skeleton "lalr1.cc"
129 @if Bison24 %language "C++"
132 @$.begin.filename = @$.end.filename = &driver.filename_;
143 %parse-param { CYDriver &driver }
144 %lex-param { void *cyscanner }
151 %token XMLAttributeValue
153 %token XMLTagCharacters
159 %token LeftRight "<>"
160 %token LeftSlashRight "</>"
162 %token SlashRight "/>"
163 %token LeftSlash "</"
165 %token ColonColon "::"
166 %token PeriodPeriod ".."
169 @begin E4X ObjectiveC
174 %token AmpersandAmpersand "&&"
175 %token AmpersandEqual "&="
177 %token CarrotEqual "^="
179 %token EqualEqual "=="
180 %token EqualEqualEqual "==="
181 %token Exclamation "!"
182 %token ExclamationEqual "!="
183 %token ExclamationEqualEqual "!=="
185 %token HyphenEqual "-="
186 %token HyphenHyphen "--"
187 %token HyphenHyphen_ "\n--"
188 %token HyphenRight "->"
190 %token LeftEqual "<="
192 %token LeftLeftEqual "<<="
194 %token PercentEqual "%="
197 %token PipeEqual "|="
200 %token PlusEqual "+="
202 %token PlusPlus_ "\n++"
204 %token RightEqual ">="
205 %token RightRight ">>"
206 %token RightRightEqual ">>="
207 %token RightRightRight ">>>"
208 %token RightRightRightEqual ">>>="
210 %token SlashEqual "/="
212 %token StarEqual "*="
221 %token <comment_> Comment
224 %token CloseParen ")"
227 %token OpenBrace_ "\n{"
228 %token CloseBrace "}"
230 %token OpenBracket "["
231 %token CloseBracket "]"
234 %token AtClass "@class"
238 %token AtImplementation "@implementation"
239 %token AtImport "@import"
241 %token AtSelector "@selector"
244 %token <false_> False "false"
245 %token <null_> Null "null"
246 %token <true_> True "true"
248 // ES3/ES5/WIE/JSC Reserved
249 %token <word_> Break "break"
250 %token <word_> Case "case"
251 %token <word_> Catch "catch"
252 %token <word_> Continue "continue"
253 %token <word_> Default "default"
254 %token <word_> Delete "delete"
255 %token <word_> Do "do"
256 %token <word_> Else "else"
257 %token <word_> Finally "finally"
258 %token <word_> For "for"
259 %token <word_> Function "function"
260 %token <word_> If "if"
261 %token <word_> In "in"
262 %token <word_> InstanceOf "instanceof"
263 %token <word_> New "new"
264 %token <word_> Return "return"
265 %token <word_> Switch "switch"
266 %token <this_> This "this"
267 %token <word_> Throw "throw"
268 %token <word_> Try "try"
269 %token <word_> TypeOf "typeof"
270 %token <word_> Var "var"
271 %token <word_> Void "void"
272 %token <word_> While "while"
273 %token <word_> With "with"
275 // ES3/IE6 Future, ES5/JSC Reserved
276 %token <word_> Debugger "debugger"
278 // ES3/ES5/IE6 Future, JSC Reserved
279 %token <word_> Const "const"
281 // ES3/ES5/IE6/JSC Future
282 %token <word_> Class "class"
283 %token <word_> Enum "enum"
284 %token <word_> Export "export"
285 %token <word_> Extends "extends"
286 %token <word_> Import "import"
287 %token <word_> Super "super"
289 // ES3 Future, ES5 Strict Future
290 %token <identifier_> Implements "implements"
291 %token <identifier_> Interface "interface"
292 %token <identifier_> Package "package"
293 %token <identifier_> Private "private"
294 %token <identifier_> Protected "protected"
295 %token <identifier_> Public "public"
296 %token <identifier_> Static "static"
299 %token <identifier_> Abstract "abstract"
300 %token <identifier_> Boolean "boolean"
301 %token <identifier_> Byte "byte"
302 %token <identifier_> Char "char"
303 %token <identifier_> Double "double"
304 %token <identifier_> Final "final"
305 %token <identifier_> Float "float"
306 %token <identifier_> Goto "goto"
307 %token <identifier_> Int "int"
308 %token <identifier_> Long "long"
309 %token <identifier_> Native "native"
310 %token <identifier_> Short "short"
311 %token <identifier_> Synchronized "synchronized"
312 %token <identifier_> Throws "throws"
313 %token <identifier_> Transient "transient"
314 %token <identifier_> Volatile "volatile"
317 %token <identifier_> Let "let"
318 %token <identifier_> Yield "yield"
321 %token <identifier_> Each "each"
325 %token <identifier_> Namespace "namespace"
326 %token <identifier_> XML "xml"
331 %token <identifier_> Identifier_
332 %token <number_> NumericLiteral
333 %token <string_> StringLiteral
334 %token <literal_> RegularExpressionLiteral
336 %type <expression_> AdditiveExpression
337 %type <expression_> AdditiveExpressionNoBF
338 %type <argument_> ArgumentList
339 %type <argument_> ArgumentList_
340 %type <argument_> ArgumentListOpt
341 %type <argument_> Arguments
342 %type <literal_> ArrayLiteral
343 %type <expression_> AssigneeExpression
344 %type <expression_> AssigneeExpressionNoBF
345 %type <expression_> AssignmentExpression
346 %type <assignment_> AssignmentExpression_
347 %type <expression_> AssignmentExpressionNoBF
348 %type <expression_> AssignmentExpressionNoIn
349 %type <expression_> BitwiseANDExpression
350 %type <expression_> BitwiseANDExpressionNoBF
351 %type <expression_> BitwiseANDExpressionNoIn
352 %type <statement_> Block
353 %type <statement_> Block_
354 %type <boolean_> BooleanLiteral
355 %type <expression_> BitwiseORExpression
356 %type <expression_> BitwiseORExpressionNoBF
357 %type <expression_> BitwiseORExpressionNoIn
358 %type <expression_> BitwiseXORExpression
359 %type <expression_> BitwiseXORExpressionNoBF
360 %type <expression_> BitwiseXORExpressionNoIn
361 %type <statement_> BreakStatement
362 %type <expression_> CallExpression
363 %type <expression_> CallExpressionNoBF
364 %type <clause_> CaseBlock
365 %type <clause_> CaseClause
366 %type <clause_> CaseClausesOpt
367 %type <catch_> CatchOpt
368 %type <comprehension_> ComprehensionList
369 %type <comprehension_> ComprehensionListOpt
370 %type <expression_> ConditionalExpression
371 %type <expression_> ConditionalExpressionNoBF
372 %type <expression_> ConditionalExpressionNoIn
373 %type <statement_> ContinueStatement
374 %type <clause_> DefaultClause
375 %type <statement_> DoWhileStatement
376 %type <expression_> Element
377 %type <expression_> ElementOpt
378 %type <element_> ElementList
379 %type <element_> ElementListOpt
380 %type <statement_> ElseStatementOpt
381 %type <statement_> EmptyStatement
382 %type <expression_> EqualityExpression
383 %type <expression_> EqualityExpressionNoBF
384 %type <expression_> EqualityExpressionNoIn
385 %type <expression_> Expression
386 %type <expression_> ExpressionOpt
387 %type <compound_> Expression_
388 %type <expression_> ExpressionNoBF
389 %type <expression_> ExpressionNoIn
390 %type <compound_> ExpressionNoIn_
391 %type <expression_> ExpressionNoInOpt
392 %type <statement_> ExpressionStatement
393 %type <finally_> FinallyOpt
394 %type <comprehension_> ForComprehension
395 %type <statement_> ForStatement
396 %type <for_> ForStatementInitialiser
397 %type <statement_> ForInStatement
398 %type <forin_> ForInStatementInitialiser
399 %type <functionParameter_> FormalParameterList
400 %type <functionParameter_> FormalParameterList_
401 %type <statement_> FunctionBody
402 %type <statement_> FunctionDeclaration
403 %type <expression_> FunctionExpression
404 %type <identifier_> Identifier
405 %type <identifier_> IdentifierOpt
406 %type <comprehension_> IfComprehension
407 %type <statement_> IfStatement
408 %type <expression_> Initialiser
409 %type <expression_> InitialiserOpt
410 %type <expression_> InitialiserNoIn
411 %type <expression_> InitialiserNoInOpt
412 %type <statement_> IterationStatement
413 %type <statement_> LabelledStatement
414 %type <expression_> LeftHandSideExpression
415 %type <expression_> LeftHandSideExpressionNoBF
416 //%type <statement_> LetStatement
417 %type <literal_> Literal
418 %type <literal_> LiteralNoRE
419 %type <literal_> LiteralRE
420 %type <expression_> LogicalANDExpression
421 %type <expression_> LogicalANDExpressionNoBF
422 %type <expression_> LogicalANDExpressionNoIn
423 %type <expression_> LogicalORExpression
424 %type <expression_> LogicalORExpressionNoBF
425 %type <expression_> LogicalORExpressionNoIn
426 %type <member_> MemberAccess
427 %type <expression_> MemberExpression
428 %type <expression_> MemberExpression_
429 %type <expression_> MemberExpressionNoBF
430 %type <expression_> MultiplicativeExpression
431 %type <expression_> MultiplicativeExpressionNoBF
432 %type <expression_> NewExpression
433 %type <expression_> NewExpression_
434 %type <expression_> NewExpressionNoBF
435 %type <null_> NullLiteral
436 %type <literal_> ObjectLiteral
437 %type <expression_> PostfixExpression
438 %type <expression_> PostfixExpressionNoBF
439 %type <expression_> PrimaryExpression
440 %type <expression_> PrimaryExpressionNo
441 %type <expression_> PrimaryExpressionNoBF
442 %type <expression_> PrimaryExpressionNoRE
443 %type <expression_> PrimaryExpressionBF
444 %type <statement_> Program
445 %type <propertyName_> PropertyName
446 %type <propertyName_> PropertyName_
447 %type <property_> PropertyNameAndValueList
448 %type <property_> PropertyNameAndValueList_
449 %type <property_> PropertyNameAndValueListOpt
450 %type <expression_> RelationalExpression
451 %type <infix_> RelationalExpression_
452 %type <expression_> RelationalExpressionNoBF
453 %type <expression_> RelationalExpressionNoIn
454 %type <infix_> RelationalExpressionNoIn_
455 %type <statement_> ReturnStatement
456 %type <rubyProc_> RubyProcExpression
457 %type <functionParameter_> RubyProcParameterList
458 %type <functionParameter_> RubyProcParameterList_
459 %type <functionParameter_> RubyProcParametersOpt
460 %type <expression_> ShiftExpression
461 %type <expression_> ShiftExpressionNoBF
462 %type <statement_> SourceElement
463 %type <statement_> SourceElement_
464 %type <statement_> SourceElements
465 %type <statement_> Statement
466 %type <statement_> Statement_
467 %type <statement_> StatementList
468 %type <statement_> StatementListOpt
469 %type <statement_> SwitchStatement
470 %type <statement_> ThrowStatement
471 %type <statement_> TryStatement
472 %type <expression_> UnaryExpression
473 %type <expression_> UnaryExpression_
474 %type <expression_> UnaryExpressionNoBF
475 %type <declaration_> VariableDeclaration
476 %type <declaration_> VariableDeclarationNoIn
477 %type <declarations_> VariableDeclarationList
478 %type <declarations_> VariableDeclarationList_
479 %type <declarations_> VariableDeclarationListNoIn
480 %type <declarations_> VariableDeclarationListNoIn_
481 %type <statement_> VariableStatement
482 %type <statement_> WhileStatement
483 %type <statement_> WithStatement
486 %type <expression_> AssigneeExpressionNoRE
487 %type <expression_> CallExpressionNoRE
488 %type <expression_> LeftHandSideExpressionNoRE
489 %type <expression_> MemberExpressionNoRE
490 %type <expression_> NewExpressionNoRE
491 %type <expression_> PostfixExpressionNoRE
492 %type <expression_> UnaryAssigneeExpression
493 %type <expression_> UnaryExpressionNoRE
497 %type <statement_> CategoryStatement
498 %type <expression_> ClassExpression
499 %type <statement_> ClassStatement
500 %type <expression_> ClassSuperOpt
501 %type <field_> ClassFieldList
502 %type <message_> ClassMessageDeclaration
503 %type <message_> ClassMessageDeclarationListOpt
504 %type <className_> ClassName
505 %type <className_> ClassNameOpt
506 %type <protocol_> ClassProtocolListOpt
507 %type <protocol_> ClassProtocols
508 %type <protocol_> ClassProtocolsOpt
509 %type <expression_> MessageExpression
510 %type <messageParameter_> MessageParameter
511 %type <messageParameter_> MessageParameters
512 %type <messageParameter_> MessageParameterList
513 %type <messageParameter_> MessageParameterListOpt
514 %type <bool_> MessageScope
515 %type <argument_> SelectorCall
516 %type <argument_> SelectorCall_
517 %type <selector_> SelectorExpression
518 %type <selector_> SelectorExpression_
519 %type <selector_> SelectorExpressionOpt
520 %type <argument_> SelectorList
521 %type <word_> SelectorWordOpt
522 %type <expression_> TypeOpt
523 %type <argument_> VariadicCall
525 %type <word_> WordOpt
529 %type <propertyIdentifier_> PropertyIdentifier_
530 %type <selector_> PropertySelector
531 %type <selector_> PropertySelector_
532 %type <identifier_> QualifiedIdentifier
533 %type <identifier_> QualifiedIdentifier_
534 %type <identifier_> WildcardIdentifier
535 %type <identifier_> XMLComment
536 %type <identifier_> XMLCDATA
537 %type <identifier_> XMLElement
538 %type <identifier_> XMLElementContent
539 %type <identifier_> XMLMarkup
540 %type <identifier_> XMLPI
542 %type <attribute_> AttributeIdentifier
543 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
544 %type <expression_> PropertyIdentifier
545 %type <expression_> XMLListInitialiser
546 %type <expression_> XMLInitialiser
549 %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"
559 %left "<<" ">>" ">>>"
560 %left "<" ">" "<=" ">=" "instanceof" "in"
561 %left "==" "!=" "===" "!=="
568 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
574 /* Lexer State {{{ */
576 : { driver.SetCondition(CYDriver::RegExpCondition); }
586 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
596 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
601 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
621 : Identifier { $$ = $1; }
622 | "break" NewLineOpt { $$ = $1; }
623 | "case" { $$ = $1; }
624 | "catch" { $$ = $1; }
625 | "class" { $$ = $1; }
626 | "const" { $$ = $1; }
627 | "continue" NewLineOpt { $$ = $1; }
628 | "debugger" { $$ = $1; }
629 | "default" { $$ = $1; }
630 | "delete" { $$ = $1; }
632 | "else" { $$ = $1; }
633 | "enum" { $$ = $1; }
634 | "export" { $$ = $1; }
635 | "extends" { $$ = $1; }
636 | "false" { $$ = $1; }
637 | "finally" { $$ = $1; }
638 /* XXX: | "for" { $$ = $1; } */
639 | "function" { $$ = $1; }
641 | "import" { $$ = $1; }
642 /* XXX: | "in" { $$ = $1; } */
643 /* XXX: | "instanceof" { $$ = $1; } */
645 | "null" { $$ = $1; }
646 | "return" NewLineOpt { $$ = $1; }
647 | "super" { $$ = $1; }
648 | "switch" { $$ = $1; }
649 | "this" { $$ = $1; }
650 | "throw" NewLineOpt { $$ = $1; }
651 | "true" { $$ = $1; }
653 | "typeof" { $$ = $1; }
655 | "void" { $$ = $1; }
656 | "while" { $$ = $1; }
657 | "with" { $$ = $1; }
662 : Identifier_ { $$ = $1; }
664 | "implements" { $$ = $1; }
665 | "interface" { $$ = $1; }
666 | "package" { $$ = $1; }
667 | "private" { $$ = $1; }
668 | "protected" { $$ = $1; }
669 | "public" { $$ = $1; }
670 | "static" { $$ = $1; }
672 | "abstract" { $$ = $1; }
673 | "boolean" { $$ = $1; }
674 | "byte" { $$ = $1; }
675 | "char" { $$ = $1; }
676 | "double" { $$ = $1; }
677 | "final" { $$ = $1; }
678 | "float" { $$ = $1; }
679 | "goto" { $$ = $1; }
681 | "long" { $$ = $1; }
682 | "native" { $$ = $1; }
683 | "short" { $$ = $1; }
684 | "synchronized" { $$ = $1; }
685 | "throws" { $$ = $1; }
686 | "transient" { $$ = $1; }
687 | "volatile" { $$ = $1; }
690 | "yield" { $$ = $1; }
692 | "each" { $$ = $1; }
696 : Identifier { $$ = $1; }
701 : NullLiteral { $$ = $1; }
702 | BooleanLiteral { $$ = $1; }
703 | NumericLiteral { $$ = $1; }
704 | StringLiteral { $$ = $1; }
705 | "@" StringLiteral { $$ = $2; }
709 : RegularExpressionLiteral { $$ = $1; }
713 : LiteralNoRE { $$ = $1; }
714 | LiteralRE { $$ = $1; }
718 : "null" { $$ = $1; }
722 : "true" { $$ = $1; }
723 | "false" { $$ = $1; }
726 /* 11.1 Primary Expressions {{{ */
728 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
731 PrimaryExpressionNoBF
732 : PrimaryExpressionNo { $$ = $1; }
735 PrimaryExpressionNoRE
736 : PrimaryExpressionBF { $$ = $1; }
737 | PrimaryExpressionNo { $$ = $1; }
741 : "this" { $$ = $1; }
742 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
743 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
744 | Literal { $$ = $1; }
745 | ArrayLiteral { $$ = $1; }
746 | "(" Expression ")" { $$ = $2; }
750 : ObjectLiteral { $$ = $1; }
753 /* 11.1.4 Array Initialiser {{{ */
755 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
759 : AssignmentExpression { $$ = $1; }
763 : Element { $$ = $1; }
764 | LexSetRegExp { $$ = NULL; }
768 : ElementList { $$ = $1; }
769 | LexSetRegExp { $$ = NULL; }
773 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
774 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
777 /* 11.1.5 Object Initialiser {{{ */
779 : OpenBrace PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
782 PropertyNameAndValueList_
783 : "," PropertyNameAndValueList { $$ = $2; }
787 PropertyNameAndValueListOpt
788 : PropertyNameAndValueList { $$ = $1; }
792 PropertyNameAndValueList
793 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
797 : Identifier { $$ = $1; }
798 | StringLiteral { $$ = $1; }
799 | NumericLiteral { $$ = $1; }
803 : LexSetRegExp PropertyName_ { $$ = $2; }
807 /* 11.2 Left-Hand-Side Expressions {{{ */
809 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
813 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
814 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
815 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
819 : PrimaryExpression { $$ = $1; }
820 | LexSetRegExp FunctionExpression { $$ = $2; }
821 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
822 | LexSetRegExp MemberExpression_ { $$ = $2; }
826 : PrimaryExpressionNoBF { $$ = $1; }
827 | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
828 | MemberExpression_ { $$ = $1; }
833 : PrimaryExpressionNoRE { $$ = $1; }
834 | FunctionExpression { $$ = $1; }
835 | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
836 | MemberExpression_ { $$ = $1; }
841 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
845 : MemberExpression { $$ = $1; }
846 | LexSetRegExp NewExpression_ { $$ = $2; }
850 : MemberExpressionNoBF { $$ = $1; }
851 | NewExpression_ { $$ = $1; }
856 : MemberExpressionNoRE { $$ = $1; }
857 | NewExpression_ { $$ = $1; }
862 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
863 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
864 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
868 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
869 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
870 | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
875 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
876 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
877 | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
882 : "," ArgumentList { $$ = $2; }
887 : ArgumentList { $$ = $1; }
888 | LexSetRegExp { $$ = NULL; }
892 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
896 : "(" ArgumentListOpt ")" { $$ = $2; }
899 LeftHandSideExpression
900 : NewExpression { $$ = $1; }
901 | CallExpression { $$ = $1; }
904 LeftHandSideExpressionNoBF
905 : NewExpressionNoBF { $$ = $1; }
906 | CallExpressionNoBF { $$ = $1; }
910 LeftHandSideExpressionNoRE
911 : NewExpressionNoRE { $$ = $1; }
912 | CallExpressionNoRE { $$ = $1; }
916 /* 11.3 Postfix Expressions {{{ */
918 : AssigneeExpression { $$ = $1; }
919 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
920 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
923 PostfixExpressionNoBF
924 : AssigneeExpressionNoBF { $$ = $1; }
925 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
926 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
930 PostfixExpressionNoRE
931 : AssigneeExpressionNoRE { $$ = $1; }
932 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
933 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
937 /* 11.4 Unary Operators {{{ */
939 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
940 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
941 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
942 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
943 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
944 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
945 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
946 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
947 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
948 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
949 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
953 : PostfixExpression { $$ = $1; }
954 | LexSetRegExp UnaryExpression_ { $$ = $2; }
958 : PostfixExpressionNoBF { $$ = $1; }
959 | UnaryExpression_ { $$ = $1; }
964 : PostfixExpressionNoRE { $$ = $1; }
965 | UnaryExpression_ { $$ = $1; }
969 /* 11.5 Multiplicative Operators {{{ */
970 MultiplicativeExpression
971 : UnaryExpression { $$ = $1; }
972 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
973 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
974 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
977 MultiplicativeExpressionNoBF
978 : UnaryExpressionNoBF { $$ = $1; }
979 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
980 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
981 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
984 /* 11.6 Additive Operators {{{ */
986 : MultiplicativeExpression { $$ = $1; }
987 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
988 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
991 AdditiveExpressionNoBF
992 : MultiplicativeExpressionNoBF { $$ = $1; }
993 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
994 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
997 /* 11.7 Bitwise Shift Operators {{{ */
999 : AdditiveExpression { $$ = $1; }
1000 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1001 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1002 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1006 : AdditiveExpressionNoBF { $$ = $1; }
1007 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1008 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1009 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1012 /* 11.8 Relational Operators {{{ */
1013 RelationalExpressionNoIn_
1014 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
1015 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
1016 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
1017 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
1018 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
1021 RelationalExpression_
1022 : RelationalExpressionNoIn_ { $$ = $1; }
1023 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1026 RelationalExpression
1027 : ShiftExpression { $$ = $1; }
1028 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1031 RelationalExpressionNoIn
1032 : ShiftExpression { $$ = $1; }
1033 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1036 RelationalExpressionNoBF
1037 : ShiftExpressionNoBF { $$ = $1; }
1038 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1041 /* 11.9 Equality Operators {{{ */
1043 : RelationalExpression { $$ = $1; }
1044 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1045 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1046 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1047 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1050 EqualityExpressionNoIn
1051 : RelationalExpressionNoIn { $$ = $1; }
1052 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1053 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1054 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1055 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1058 EqualityExpressionNoBF
1059 : RelationalExpressionNoBF { $$ = $1; }
1060 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1061 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1062 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1063 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1066 /* 11.10 Binary Bitwise Operators {{{ */
1067 BitwiseANDExpression
1068 : EqualityExpression { $$ = $1; }
1069 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1072 BitwiseANDExpressionNoIn
1073 : EqualityExpressionNoIn { $$ = $1; }
1074 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1077 BitwiseANDExpressionNoBF
1078 : EqualityExpressionNoBF { $$ = $1; }
1079 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1082 BitwiseXORExpression
1083 : BitwiseANDExpression { $$ = $1; }
1084 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1087 BitwiseXORExpressionNoIn
1088 : BitwiseANDExpressionNoIn { $$ = $1; }
1089 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1092 BitwiseXORExpressionNoBF
1093 : BitwiseANDExpressionNoBF { $$ = $1; }
1094 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1098 : BitwiseXORExpression { $$ = $1; }
1099 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1102 BitwiseORExpressionNoIn
1103 : BitwiseXORExpressionNoIn { $$ = $1; }
1104 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1107 BitwiseORExpressionNoBF
1108 : BitwiseXORExpressionNoBF { $$ = $1; }
1109 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1112 /* 11.11 Binary Logical Operators {{{ */
1113 LogicalANDExpression
1114 : BitwiseORExpression { $$ = $1; }
1115 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1118 LogicalANDExpressionNoIn
1119 : BitwiseORExpressionNoIn { $$ = $1; }
1120 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1123 LogicalANDExpressionNoBF
1124 : BitwiseORExpressionNoBF { $$ = $1; }
1125 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1129 : LogicalANDExpression { $$ = $1; }
1130 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1133 LogicalORExpressionNoIn
1134 : LogicalANDExpressionNoIn { $$ = $1; }
1135 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1138 LogicalORExpressionNoBF
1139 : LogicalANDExpressionNoBF { $$ = $1; }
1140 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1143 /* 11.12 Conditional Operator ( ? : ) {{{ */
1144 ConditionalExpression
1145 : LogicalORExpression { $$ = $1; }
1146 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1149 ConditionalExpressionNoIn
1150 : LogicalORExpressionNoIn { $$ = $1; }
1151 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1154 ConditionalExpressionNoBF
1155 : LogicalORExpressionNoBF { $$ = $1; }
1156 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1159 /* 11.13 Assignment Operators {{{ */
1160 AssignmentExpression_
1161 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1162 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1163 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1164 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1165 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1166 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1167 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1168 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1169 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1170 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1171 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1172 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1176 : LeftHandSideExpression { $$ = $1; }
1178 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1182 AssigneeExpressionNoBF
1183 : LeftHandSideExpressionNoBF { $$ = $1; }
1185 | UnaryAssigneeExpression { $$ = $1; }
1190 AssigneeExpressionNoRE
1191 : LeftHandSideExpressionNoRE { $$ = $1; }
1192 | UnaryAssigneeExpression { $$ = $1; }
1196 AssignmentExpression
1197 : ConditionalExpression { $$ = $1; }
1198 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1201 AssignmentExpressionNoIn
1202 : ConditionalExpressionNoIn { $$ = $1; }
1203 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1204 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1205 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1206 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1207 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1208 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1209 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1210 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1211 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1212 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1213 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1214 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1217 AssignmentExpressionNoBF
1218 : ConditionalExpressionNoBF { $$ = $1; }
1219 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1222 /* 11.14 Comma Operator {{{ */
1224 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1229 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1234 : Expression { $$ = $1; }
1235 | LexSetRegExp { $$ = NULL; }
1239 : ExpressionNoIn { $$ = $1; }
1240 | LexSetRegExp { $$ = NULL; }
1244 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1248 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1252 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1256 /* 12 Statements {{{ */
1258 : Block { $$ = $1; }
1259 | VariableStatement { $$ = $1; }
1260 | EmptyStatement { $$ = $1; }
1261 | ExpressionStatement { $$ = $1; }
1262 | IfStatement { $$ = $1; }
1263 | IterationStatement { $$ = $1; }
1264 | ContinueStatement { $$ = $1; }
1265 | BreakStatement { $$ = $1; }
1266 | ReturnStatement { $$ = $1; }
1267 | WithStatement { $$ = $1; }
1268 | LabelledStatement { $$ = $1; }
1269 | SwitchStatement { $$ = $1; }
1270 | ThrowStatement { $$ = $1; }
1271 | TryStatement { $$ = $1; }
1275 : LexSetRegExp Statement_ { $$ = $2; }
1278 /* 12.1 Block {{{ */
1280 : Brace StatementListOpt "}" { $$ = $2; }
1284 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1288 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1292 : StatementList { $$ = $1; }
1293 | LexSetRegExp { $$ = NULL; }
1296 /* 12.2 Variable Statement {{{ */
1298 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1301 VariableDeclarationList_
1302 : "," VariableDeclarationList { $$ = $2; }
1306 VariableDeclarationListNoIn_
1307 : "," VariableDeclarationListNoIn { $$ = $2; }
1311 VariableDeclarationList
1312 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1315 VariableDeclarationListNoIn
1316 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1320 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1323 VariableDeclarationNoIn
1324 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1328 : Initialiser { $$ = $1; }
1333 : InitialiserNoIn { $$ = $1; }
1338 : "=" AssignmentExpression { $$ = $2; }
1342 : "=" AssignmentExpressionNoIn { $$ = $2; }
1345 /* 12.3 Empty Statement {{{ */
1347 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1350 /* 12.4 Expression Statement {{{ */
1352 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1355 /* 12.5 The if Statement {{{ */
1357 : "else" Statement { $$ = $2; }
1358 | %prec "if" { $$ = NULL; }
1362 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1366 /* 12.6 Iteration Statements {{{ */
1368 : DoWhileStatement { $$ = $1; }
1369 | WhileStatement { $$ = $1; }
1370 | ForStatement { $$ = $1; }
1371 | ForInStatement { $$ = $1; }
1374 /* 12.6.1 The do-while Statement {{{ */
1376 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1379 /* 12.6.2 The while Statement {{{ */
1381 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1384 /* 12.6.3 The for Statement {{{ */
1386 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1389 ForStatementInitialiser
1390 : ExpressionNoInOpt { $$ = $1; }
1391 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1394 /* 12.6.4 The for-in Statement {{{ */
1396 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1399 ForInStatementInitialiser
1400 : LeftHandSideExpression { $$ = $1; }
1401 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1405 /* 12.7 The continue Statement {{{ */
1407 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1410 /* 12.8 The break Statement {{{ */
1412 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1415 /* 12.9 The return Statement {{{ */
1417 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1420 /* 12.10 The with Statement {{{ */
1422 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1426 /* 12.11 The switch Statement {{{ */
1428 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1432 : Brace CaseClausesOpt "}" { $$ = $2; }
1436 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1437 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1442 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1446 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1449 /* 12.12 Labelled Statements {{{ */
1451 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1454 /* 12.13 The throw Statement {{{ */
1456 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1459 /* 12.14 The try Statement {{{ */
1461 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1465 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1470 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1475 /* 13 Function Definition {{{ */
1477 : "function" Identifier "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1481 : "function" IdentifierOpt "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1484 FormalParameterList_
1485 : "," FormalParameterList { $$ = $2; }
1490 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1495 : SourceElements { $$ = $1; }
1498 /* 14 Program {{{ */
1500 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1504 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1505 | LexSetRegExp { $$ = NULL; }
1509 : Statement_ { $$ = $1; }
1510 | FunctionDeclaration { $$ = $1; }
1514 : LexSetRegExp SourceElement_ { $$ = $2; }
1519 /* Cycript (Objective-C): @class Declaration {{{ */
1521 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1522 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1527 : Expression Identifier ";"
1531 : ClassFieldListOpt ClassField
1536 : Brace ClassFieldListOpt "}" { $$ = NULL; }
1540 : "+" { $$ = false; }
1541 | "-" { $$ = true; }
1545 : "(" Expression ")" { $$ = $2; }
1546 | "(" LexSetRegExp "void" ")" { $$ = NULL; }
1551 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1554 MessageParameterListOpt
1555 : MessageParameterList { $$ = $1; }
1559 MessageParameterList
1560 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1564 : MessageParameterList { $$ = $1; }
1565 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1568 ClassMessageDeclaration
1569 : MessageScope TypeOpt MessageParameters Brace FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1572 ClassMessageDeclarationListOpt
1573 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1574 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1579 : Identifier { $$ = $1; }
1580 | "(" AssignmentExpression ")" { $$ = $2; }
1584 : ClassName { $$ = $1; }
1588 // XXX: this should be AssignmentExpressionNoRight
1590 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1594 : "," ClassProtocols { $$ = $2; }
1598 ClassProtocolListOpt
1599 : "<" ClassProtocols ">" { $$ = $2; }
1604 : "@implementation" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1608 : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1616 : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $4); }
1620 : ClassExpression { $$ = $1; }
1624 : ClassStatement { $$ = $1; }
1625 | CategoryStatement { $$ = $1; }
1628 /* Cycript (Objective-C): Send Message {{{ */
1630 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1635 : SelectorCall { $$ = $1; }
1636 | VariadicCall { $$ = $1; }
1640 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1641 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1645 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1649 : SelectorCall { $$ = $1; }
1650 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1654 : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = new(driver.pool_) CYSendDirect($2, $4); }
1655 | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($5); }
1658 SelectorExpressionOpt
1659 : SelectorExpression_ { $$ = $1; }
1664 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1668 : SelectorExpression_ { $$ = $1; }
1669 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1673 : MessageExpression { $$ = $1; }
1674 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1677 /* Cycript (Objective-C): @import Directive {{{ */
1691 : "@import" ImportPath { $$ = new(driver.pool_) CYImport(); }
1697 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1698 UnaryAssigneeExpression
1699 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1703 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1707 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1708 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1709 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1714 /* YUI: Documentation Comments {{{ */
1716 : Comment { $$ = $1; }
1721 /* Lexer State {{{ */
1723 : { driver.PushCondition(CYDriver::RegExpCondition); }
1727 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1731 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1735 : { driver.PopCondition(); }
1739 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1743 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1752 /* 8.1 Context Keywords {{{ */
1754 : "namespace" { $$ = $1; }
1755 | "xml" { $$ = $1; }
1758 /* 8.3 XML Initialiser Input Elements {{{ */
1760 : XMLComment { $$ = $1; }
1761 | XMLCDATA { $$ = $1; }
1762 | XMLPI { $$ = $1; }
1765 /* 11.1 Primary Expressions {{{ */
1767 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1768 | XMLInitialiser { $$ = $1; }
1769 | XMLListInitialiser { $$ = $1; }
1773 : AttributeIdentifier { $$ = $1; }
1774 | QualifiedIdentifier { $$ = $1; }
1775 | WildcardIdentifier { $$ = $1; }
1778 /* 11.1.1 Attribute Identifiers {{{ */
1780 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1784 : PropertySelector { $$ = $1; }
1785 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1789 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1790 | WildcardIdentifier { $$ = $1; }
1793 /* 11.1.2 Qualified Identifiers {{{ */
1794 QualifiedIdentifier_
1795 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1796 | QualifiedIdentifier { $$ = $1; }
1800 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1803 /* 11.1.3 Wildcard Identifiers {{{ */
1805 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1808 /* 11.1.4 XML Initialiser {{{ */
1810 : XMLMarkup { $$ = $1; }
1811 | XMLElement { $$ = $1; }
1815 : "<" XMLTagContent "/>" LexPop
1816 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1820 : LexPushXMLTag XMLTagName XMLAttributes
1824 : Brace LexPushRegExp Expression "}" LexPop
1833 : XMLAttributes_ XMLAttribute
1838 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1839 | XMLAttributes_ XMLWhitespaceOpt
1848 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1852 : XMLExpression XMLElementContentOpt
1853 | XMLMarkup XMLElementContentOpt
1854 | XMLText XMLElementContentOpt
1855 | XMLElement XMLElementContentOpt
1858 XMLElementContentOpt
1863 /* 11.1.5 XMLList Initialiser {{{ */
1865 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1868 /* 11.2 Left-Hand-Side Expressions {{{ */
1870 : Identifier { $$ = $1; }
1871 | PropertyIdentifier { $$ = $1; }
1875 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1876 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1877 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1880 /* 12.1 The default xml namespace Statement {{{ */
1881 /* XXX: DefaultXMLNamespaceStatement
1882 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1886 : DefaultXMLNamespaceStatement { $$ = $1; }
1891 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1892 PropertyNameAndValueList_
1893 : "," { $$ = NULL; }
1897 /* JavaScript 1.7: Array Comprehensions {{{ */
1899 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1903 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1904 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1907 ComprehensionListOpt
1908 : ComprehensionList { $$ = $1; }
1909 | IfComprehension { $$ = $1; }
1914 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1918 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1921 /* JavaScript 1.7: for each {{{ */
1923 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1926 /* JavaScript 1.7: let Statements {{{ *//*
1928 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1936 /* JavaScript FTW: Function Statements {{{ */
1938 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }
1941 /* JavaScript FTW: Optional Arguments {{{ */
1943 : Identifier "=" AssignmentExpression FormalParameterList_ { $$ = new(driver.pool_) CYOptionalFunctionParameter($1, $3, $4); }
1946 /* JavaScript FTW: Ruby Blocks {{{ */
1947 RubyProcParameterList_
1948 : "," RubyProcParameterList { $$ = $2; }
1952 RubyProcParameterList
1953 : Identifier RubyProcParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1957 RubyProcParametersOpt
1958 : "|" RubyProcParameterList "|" { $$ = $2; }
1963 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = new(driver.pool_) CYRubyProc($2, $3); }
1966 LeftHandSideExpression
1967 : LeftHandSideExpression RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }
1970 LeftHandSideExpressionNoBF
1971 : LeftHandSideExpressionNoBF RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }
1975 LeftHandSideExpressionNoRE
1976 : LeftHandSideExpressionNoRE RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }