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 "]"
233 %token AtClass "@class"
234 %token AtSelector "@selector"
237 %token <false_> False "false"
238 %token <null_> Null "null"
239 %token <true_> True "true"
241 // ES3/ES5/WIE/JSC Reserved
242 %token <word_> Break "break"
243 %token <word_> Case "case"
244 %token <word_> Catch "catch"
245 %token <word_> Continue "continue"
246 %token <word_> Default "default"
247 %token <word_> Delete "delete"
248 %token <word_> Do "do"
249 %token <word_> Else "else"
250 %token <word_> Finally "finally"
251 %token <word_> For "for"
252 %token <word_> Function "function"
253 %token <word_> If "if"
254 %token <word_> In "in"
255 %token <word_> InstanceOf "instanceof"
256 %token <word_> New "new"
257 %token <word_> Return "return"
258 %token <word_> Switch "switch"
259 %token <this_> This "this"
260 %token <word_> Throw "throw"
261 %token <word_> Try "try"
262 %token <word_> TypeOf "typeof"
263 %token <word_> Var "var"
264 %token <word_> Void "void"
265 %token <word_> While "while"
266 %token <word_> With "with"
268 // ES3/IE6 Future, ES5/JSC Reserved
269 %token <word_> Debugger "debugger"
271 // ES3/ES5/IE6 Future, JSC Reserved
272 %token <word_> Const "const"
274 // ES3/ES5/IE6/JSC Future
275 %token <word_> Class "class"
276 %token <word_> Enum "enum"
277 %token <word_> Export "export"
278 %token <word_> Extends "extends"
279 %token <word_> Import "import"
280 %token <word_> Super "super"
282 // ES3 Future, ES5 Strict Future
283 %token <identifier_> Implements "implements"
284 %token <identifier_> Interface "interface"
285 %token <identifier_> Package "package"
286 %token <identifier_> Private "private"
287 %token <identifier_> Protected "protected"
288 %token <identifier_> Public "public"
289 %token <identifier_> Static "static"
292 %token <identifier_> Abstract "abstract"
293 %token <identifier_> Boolean "boolean"
294 %token <identifier_> Byte "byte"
295 %token <identifier_> Char "char"
296 %token <identifier_> Double "double"
297 %token <identifier_> Final "final"
298 %token <identifier_> Float "float"
299 %token <identifier_> Goto "goto"
300 %token <identifier_> Int "int"
301 %token <identifier_> Long "long"
302 %token <identifier_> Native "native"
303 %token <identifier_> Short "short"
304 %token <identifier_> Synchronized "synchronized"
305 %token <identifier_> Throws "throws"
306 %token <identifier_> Transient "transient"
307 %token <identifier_> Volatile "volatile"
310 %token <identifier_> Let "let"
311 %token <identifier_> Yield "yield"
314 %token <identifier_> Each "each"
318 %token <identifier_> Namespace "namespace"
319 %token <identifier_> XML "xml"
324 %token <identifier_> Identifier_
325 %token <number_> NumericLiteral
326 %token <string_> StringLiteral
327 %token <literal_> RegularExpressionLiteral
329 %type <expression_> AdditiveExpression
330 %type <expression_> AdditiveExpressionNoBF
331 %type <argument_> ArgumentList
332 %type <argument_> ArgumentList_
333 %type <argument_> ArgumentListOpt
334 %type <argument_> Arguments
335 %type <literal_> ArrayLiteral
336 %type <expression_> AssigneeExpression
337 %type <expression_> AssigneeExpressionNoBF
338 %type <expression_> AssignmentExpression
339 %type <assignment_> AssignmentExpression_
340 %type <expression_> AssignmentExpressionNoBF
341 %type <expression_> AssignmentExpressionNoIn
342 %type <expression_> BitwiseANDExpression
343 %type <expression_> BitwiseANDExpressionNoBF
344 %type <expression_> BitwiseANDExpressionNoIn
345 %type <statement_> Block
346 %type <statement_> Block_
347 %type <boolean_> BooleanLiteral
348 %type <expression_> BitwiseORExpression
349 %type <expression_> BitwiseORExpressionNoBF
350 %type <expression_> BitwiseORExpressionNoIn
351 %type <expression_> BitwiseXORExpression
352 %type <expression_> BitwiseXORExpressionNoBF
353 %type <expression_> BitwiseXORExpressionNoIn
354 %type <statement_> BreakStatement
355 %type <expression_> CallExpression
356 %type <expression_> CallExpressionNoBF
357 %type <clause_> CaseBlock
358 %type <clause_> CaseClause
359 %type <clause_> CaseClausesOpt
360 %type <catch_> CatchOpt
361 %type <comprehension_> ComprehensionList
362 %type <comprehension_> ComprehensionListOpt
363 %type <expression_> ConditionalExpression
364 %type <expression_> ConditionalExpressionNoBF
365 %type <expression_> ConditionalExpressionNoIn
366 %type <statement_> ContinueStatement
367 %type <clause_> DefaultClause
368 %type <statement_> DoWhileStatement
369 %type <expression_> Element
370 %type <expression_> ElementOpt
371 %type <element_> ElementList
372 %type <element_> ElementListOpt
373 %type <statement_> ElseStatementOpt
374 %type <statement_> EmptyStatement
375 %type <expression_> EqualityExpression
376 %type <expression_> EqualityExpressionNoBF
377 %type <expression_> EqualityExpressionNoIn
378 %type <expression_> Expression
379 %type <expression_> ExpressionOpt
380 %type <compound_> Expression_
381 %type <expression_> ExpressionNoBF
382 %type <expression_> ExpressionNoIn
383 %type <compound_> ExpressionNoIn_
384 %type <expression_> ExpressionNoInOpt
385 %type <statement_> ExpressionStatement
386 %type <finally_> FinallyOpt
387 %type <comprehension_> ForComprehension
388 %type <statement_> ForStatement
389 %type <for_> ForStatementInitialiser
390 %type <statement_> ForInStatement
391 %type <forin_> ForInStatementInitialiser
392 %type <functionParameter_> FormalParameterList
393 %type <functionParameter_> FormalParameterList_
394 %type <statement_> FunctionBody
395 %type <statement_> FunctionDeclaration
396 %type <expression_> FunctionExpression
397 %type <identifier_> Identifier
398 %type <identifier_> IdentifierOpt
399 %type <comprehension_> IfComprehension
400 %type <statement_> IfStatement
401 %type <expression_> Initialiser
402 %type <expression_> InitialiserOpt
403 %type <expression_> InitialiserNoIn
404 %type <expression_> InitialiserNoInOpt
405 %type <statement_> IterationStatement
406 %type <statement_> LabelledStatement
407 %type <expression_> LeftHandSideExpression
408 %type <expression_> LeftHandSideExpressionNoBF
409 //%type <statement_> LetStatement
410 %type <literal_> Literal
411 %type <literal_> LiteralNoRE
412 %type <literal_> LiteralRE
413 %type <expression_> LogicalANDExpression
414 %type <expression_> LogicalANDExpressionNoBF
415 %type <expression_> LogicalANDExpressionNoIn
416 %type <expression_> LogicalORExpression
417 %type <expression_> LogicalORExpressionNoBF
418 %type <expression_> LogicalORExpressionNoIn
419 %type <member_> MemberAccess
420 %type <expression_> MemberExpression
421 %type <expression_> MemberExpression_
422 %type <expression_> MemberExpressionNoBF
423 %type <expression_> MultiplicativeExpression
424 %type <expression_> MultiplicativeExpressionNoBF
425 %type <expression_> NewExpression
426 %type <expression_> NewExpression_
427 %type <expression_> NewExpressionNoBF
428 %type <null_> NullLiteral
429 %type <literal_> ObjectLiteral
430 %type <expression_> PostfixExpression
431 %type <expression_> PostfixExpressionNoBF
432 %type <expression_> PrimaryExpression
433 %type <expression_> PrimaryExpressionNo
434 %type <expression_> PrimaryExpressionNoBF
435 %type <expression_> PrimaryExpressionNoRE
436 %type <expression_> PrimaryExpressionBF
437 %type <statement_> Program
438 %type <propertyName_> PropertyName
439 %type <propertyName_> PropertyName_
440 %type <property_> PropertyNameAndValueList
441 %type <property_> PropertyNameAndValueList_
442 %type <property_> PropertyNameAndValueListOpt
443 %type <expression_> RelationalExpression
444 %type <infix_> RelationalExpression_
445 %type <expression_> RelationalExpressionNoBF
446 %type <expression_> RelationalExpressionNoIn
447 %type <infix_> RelationalExpressionNoIn_
448 %type <statement_> ReturnStatement
449 %type <rubyProc_> RubyProcExpression
450 %type <functionParameter_> RubyProcParameterList
451 %type <functionParameter_> RubyProcParameterList_
452 %type <functionParameter_> RubyProcParametersOpt
453 %type <expression_> ShiftExpression
454 %type <expression_> ShiftExpressionNoBF
455 %type <statement_> SourceElement
456 %type <statement_> SourceElement_
457 %type <statement_> SourceElements
458 %type <statement_> Statement
459 %type <statement_> Statement_
460 %type <statement_> StatementList
461 %type <statement_> StatementListOpt
462 %type <statement_> SwitchStatement
463 %type <statement_> ThrowStatement
464 %type <statement_> TryStatement
465 %type <expression_> UnaryExpression
466 %type <expression_> UnaryExpression_
467 %type <expression_> UnaryExpressionNoBF
468 %type <declaration_> VariableDeclaration
469 %type <declaration_> VariableDeclarationNoIn
470 %type <declarations_> VariableDeclarationList
471 %type <declarations_> VariableDeclarationList_
472 %type <declarations_> VariableDeclarationListNoIn
473 %type <declarations_> VariableDeclarationListNoIn_
474 %type <statement_> VariableStatement
475 %type <statement_> WhileStatement
476 %type <statement_> WithStatement
479 %type <expression_> AssigneeExpressionNoRE
480 %type <expression_> CallExpressionNoRE
481 %type <expression_> LeftHandSideExpressionNoRE
482 %type <expression_> MemberExpressionNoRE
483 %type <expression_> NewExpressionNoRE
484 %type <expression_> PostfixExpressionNoRE
485 %type <expression_> UnaryAssigneeExpression
486 %type <expression_> UnaryExpressionNoRE
490 %type <statement_> CategoryStatement
491 %type <expression_> ClassExpression
492 %type <statement_> ClassStatement
493 %type <expression_> ClassSuperOpt
494 %type <field_> ClassFieldList
495 %type <message_> ClassMessageDeclaration
496 %type <message_> ClassMessageDeclarationListOpt
497 %type <className_> ClassName
498 %type <className_> ClassNameOpt
499 %type <protocol_> ClassProtocolListOpt
500 %type <protocol_> ClassProtocols
501 %type <protocol_> ClassProtocolsOpt
502 %type <expression_> MessageExpression
503 %type <messageParameter_> MessageParameter
504 %type <messageParameter_> MessageParameters
505 %type <messageParameter_> MessageParameterList
506 %type <messageParameter_> MessageParameterListOpt
507 %type <bool_> MessageScope
508 %type <argument_> SelectorCall
509 %type <argument_> SelectorCall_
510 %type <selector_> SelectorExpression
511 %type <selector_> SelectorExpression_
512 %type <selector_> SelectorExpressionOpt
513 %type <argument_> SelectorList
514 %type <word_> SelectorWordOpt
515 %type <expression_> TypeOpt
516 %type <argument_> VariadicCall
518 %type <word_> WordOpt
522 %type <propertyIdentifier_> PropertyIdentifier_
523 %type <selector_> PropertySelector
524 %type <selector_> PropertySelector_
525 %type <identifier_> QualifiedIdentifier
526 %type <identifier_> QualifiedIdentifier_
527 %type <identifier_> WildcardIdentifier
528 %type <identifier_> XMLComment
529 %type <identifier_> XMLCDATA
530 %type <identifier_> XMLElement
531 %type <identifier_> XMLElementContent
532 %type <identifier_> XMLMarkup
533 %type <identifier_> XMLPI
535 %type <attribute_> AttributeIdentifier
536 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
537 %type <expression_> PropertyIdentifier
538 %type <expression_> XMLListInitialiser
539 %type <expression_> XMLInitialiser
542 %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield"
552 %left "<<" ">>" ">>>"
553 %left "<" ">" "<=" ">=" "instanceof" "in"
554 %left "==" "!=" "===" "!=="
561 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
567 /* Lexer State {{{ */
569 : { driver.SetCondition(CYDriver::RegExpCondition); }
579 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
589 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
594 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
614 : Identifier { $$ = $1; }
615 | "break" NewLineOpt { $$ = $1; }
616 | "case" { $$ = $1; }
617 | "catch" { $$ = $1; }
618 | "class" { $$ = $1; }
619 | "const" { $$ = $1; }
620 | "continue" NewLineOpt { $$ = $1; }
621 | "debugger" { $$ = $1; }
622 | "default" { $$ = $1; }
623 | "delete" { $$ = $1; }
625 | "else" { $$ = $1; }
626 | "enum" { $$ = $1; }
627 | "export" { $$ = $1; }
628 | "extends" { $$ = $1; }
629 | "false" { $$ = $1; }
630 | "finally" { $$ = $1; }
631 /* XXX: | "for" { $$ = $1; } */
632 | "function" { $$ = $1; }
634 | "import" { $$ = $1; }
635 /* XXX: | "in" { $$ = $1; } */
636 /* XXX: | "instanceof" { $$ = $1; } */
638 | "null" { $$ = $1; }
639 | "return" NewLineOpt { $$ = $1; }
640 | "super" { $$ = $1; }
641 | "switch" { $$ = $1; }
642 | "this" { $$ = $1; }
643 | "throw" NewLineOpt { $$ = $1; }
644 | "true" { $$ = $1; }
646 | "typeof" { $$ = $1; }
648 | "void" { $$ = $1; }
649 | "while" { $$ = $1; }
650 | "with" { $$ = $1; }
655 : Identifier_ { $$ = $1; }
657 | "implements" { $$ = $1; }
658 | "interface" { $$ = $1; }
659 | "package" { $$ = $1; }
660 | "private" { $$ = $1; }
661 | "protected" { $$ = $1; }
662 | "public" { $$ = $1; }
663 | "static" { $$ = $1; }
665 | "abstract" { $$ = $1; }
666 | "boolean" { $$ = $1; }
667 | "byte" { $$ = $1; }
668 | "char" { $$ = $1; }
669 | "double" { $$ = $1; }
670 | "final" { $$ = $1; }
671 | "float" { $$ = $1; }
672 | "goto" { $$ = $1; }
674 | "long" { $$ = $1; }
675 | "native" { $$ = $1; }
676 | "short" { $$ = $1; }
677 | "synchronized" { $$ = $1; }
678 | "throws" { $$ = $1; }
679 | "transient" { $$ = $1; }
680 | "volatile" { $$ = $1; }
683 | "yield" { $$ = $1; }
685 | "each" { $$ = $1; }
689 : Identifier { $$ = $1; }
694 : NullLiteral { $$ = $1; }
695 | BooleanLiteral { $$ = $1; }
696 | NumericLiteral { $$ = $1; }
697 | StringLiteral { $$ = $1; }
698 | "@" StringLiteral { $$ = $2; }
702 : RegularExpressionLiteral { $$ = $1; }
706 : LiteralNoRE { $$ = $1; }
707 | LiteralRE { $$ = $1; }
711 : "null" { $$ = $1; }
715 : "true" { $$ = $1; }
716 | "false" { $$ = $1; }
719 /* 11.1 Primary Expressions {{{ */
721 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
724 PrimaryExpressionNoBF
725 : PrimaryExpressionNo { $$ = $1; }
728 PrimaryExpressionNoRE
729 : PrimaryExpressionBF { $$ = $1; }
730 | PrimaryExpressionNo { $$ = $1; }
734 : "this" { $$ = $1; }
735 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
736 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
737 | Literal { $$ = $1; }
738 | ArrayLiteral { $$ = $1; }
739 | "(" Expression ")" { $$ = $2; }
743 : ObjectLiteral { $$ = $1; }
746 /* 11.1.4 Array Initialiser {{{ */
748 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
752 : AssignmentExpression { $$ = $1; }
756 : Element { $$ = $1; }
757 | LexSetRegExp { $$ = NULL; }
761 : ElementList { $$ = $1; }
762 | LexSetRegExp { $$ = NULL; }
766 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
767 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
770 /* 11.1.5 Object Initialiser {{{ */
772 : OpenBrace PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
775 PropertyNameAndValueList_
776 : "," PropertyNameAndValueList { $$ = $2; }
780 PropertyNameAndValueListOpt
781 : PropertyNameAndValueList { $$ = $1; }
785 PropertyNameAndValueList
786 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
790 : Identifier { $$ = $1; }
791 | StringLiteral { $$ = $1; }
792 | NumericLiteral { $$ = $1; }
796 : LexSetRegExp PropertyName_ { $$ = $2; }
800 /* 11.2 Left-Hand-Side Expressions {{{ */
802 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
806 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
807 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
808 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
812 : PrimaryExpression { $$ = $1; }
813 | LexSetRegExp FunctionExpression { $$ = $2; }
814 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
815 | LexSetRegExp MemberExpression_ { $$ = $2; }
819 : PrimaryExpressionNoBF { $$ = $1; }
820 | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
821 | MemberExpression_ { $$ = $1; }
826 : PrimaryExpressionNoRE { $$ = $1; }
827 | FunctionExpression { $$ = $1; }
828 | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
829 | MemberExpression_ { $$ = $1; }
834 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
838 : MemberExpression { $$ = $1; }
839 | LexSetRegExp NewExpression_ { $$ = $2; }
843 : MemberExpressionNoBF { $$ = $1; }
844 | NewExpression_ { $$ = $1; }
849 : MemberExpressionNoRE { $$ = $1; }
850 | NewExpression_ { $$ = $1; }
855 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
856 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
857 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
861 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
862 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
863 | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
868 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
869 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
870 | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
875 : "," ArgumentList { $$ = $2; }
880 : ArgumentList { $$ = $1; }
881 | LexSetRegExp { $$ = NULL; }
885 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
889 : "(" ArgumentListOpt ")" { $$ = $2; }
892 LeftHandSideExpression
893 : NewExpression { $$ = $1; }
894 | CallExpression { $$ = $1; }
897 LeftHandSideExpressionNoBF
898 : NewExpressionNoBF { $$ = $1; }
899 | CallExpressionNoBF { $$ = $1; }
903 LeftHandSideExpressionNoRE
904 : NewExpressionNoRE { $$ = $1; }
905 | CallExpressionNoRE { $$ = $1; }
909 /* 11.3 Postfix Expressions {{{ */
911 : AssigneeExpression { $$ = $1; }
912 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
913 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
916 PostfixExpressionNoBF
917 : AssigneeExpressionNoBF { $$ = $1; }
918 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
919 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
923 PostfixExpressionNoRE
924 : AssigneeExpressionNoRE { $$ = $1; }
925 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
926 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
930 /* 11.4 Unary Operators {{{ */
932 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
933 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
934 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
935 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
936 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
937 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
938 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
939 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
940 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
941 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
942 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
946 : PostfixExpression { $$ = $1; }
947 | LexSetRegExp UnaryExpression_ { $$ = $2; }
951 : PostfixExpressionNoBF { $$ = $1; }
952 | UnaryExpression_ { $$ = $1; }
957 : PostfixExpressionNoRE { $$ = $1; }
958 | UnaryExpression_ { $$ = $1; }
962 /* 11.5 Multiplicative Operators {{{ */
963 MultiplicativeExpression
964 : UnaryExpression { $$ = $1; }
965 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
966 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
967 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
970 MultiplicativeExpressionNoBF
971 : UnaryExpressionNoBF { $$ = $1; }
972 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
973 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
974 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
977 /* 11.6 Additive Operators {{{ */
979 : MultiplicativeExpression { $$ = $1; }
980 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
981 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
984 AdditiveExpressionNoBF
985 : MultiplicativeExpressionNoBF { $$ = $1; }
986 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
987 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
990 /* 11.7 Bitwise Shift Operators {{{ */
992 : AdditiveExpression { $$ = $1; }
993 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
994 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
995 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
999 : AdditiveExpressionNoBF { $$ = $1; }
1000 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
1001 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
1002 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1005 /* 11.8 Relational Operators {{{ */
1006 RelationalExpressionNoIn_
1007 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
1008 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
1009 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
1010 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
1011 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
1014 RelationalExpression_
1015 : RelationalExpressionNoIn_ { $$ = $1; }
1016 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1019 RelationalExpression
1020 : ShiftExpression { $$ = $1; }
1021 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1024 RelationalExpressionNoIn
1025 : ShiftExpression { $$ = $1; }
1026 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1029 RelationalExpressionNoBF
1030 : ShiftExpressionNoBF { $$ = $1; }
1031 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1034 /* 11.9 Equality Operators {{{ */
1036 : RelationalExpression { $$ = $1; }
1037 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1038 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1039 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1040 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1043 EqualityExpressionNoIn
1044 : RelationalExpressionNoIn { $$ = $1; }
1045 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1046 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1047 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1048 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1051 EqualityExpressionNoBF
1052 : RelationalExpressionNoBF { $$ = $1; }
1053 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1054 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1055 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1056 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1059 /* 11.10 Binary Bitwise Operators {{{ */
1060 BitwiseANDExpression
1061 : EqualityExpression { $$ = $1; }
1062 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1065 BitwiseANDExpressionNoIn
1066 : EqualityExpressionNoIn { $$ = $1; }
1067 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1070 BitwiseANDExpressionNoBF
1071 : EqualityExpressionNoBF { $$ = $1; }
1072 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1075 BitwiseXORExpression
1076 : BitwiseANDExpression { $$ = $1; }
1077 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1080 BitwiseXORExpressionNoIn
1081 : BitwiseANDExpressionNoIn { $$ = $1; }
1082 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1085 BitwiseXORExpressionNoBF
1086 : BitwiseANDExpressionNoBF { $$ = $1; }
1087 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1091 : BitwiseXORExpression { $$ = $1; }
1092 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1095 BitwiseORExpressionNoIn
1096 : BitwiseXORExpressionNoIn { $$ = $1; }
1097 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1100 BitwiseORExpressionNoBF
1101 : BitwiseXORExpressionNoBF { $$ = $1; }
1102 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1105 /* 11.11 Binary Logical Operators {{{ */
1106 LogicalANDExpression
1107 : BitwiseORExpression { $$ = $1; }
1108 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1111 LogicalANDExpressionNoIn
1112 : BitwiseORExpressionNoIn { $$ = $1; }
1113 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1116 LogicalANDExpressionNoBF
1117 : BitwiseORExpressionNoBF { $$ = $1; }
1118 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1122 : LogicalANDExpression { $$ = $1; }
1123 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1126 LogicalORExpressionNoIn
1127 : LogicalANDExpressionNoIn { $$ = $1; }
1128 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1131 LogicalORExpressionNoBF
1132 : LogicalANDExpressionNoBF { $$ = $1; }
1133 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1136 /* 11.12 Conditional Operator ( ? : ) {{{ */
1137 ConditionalExpression
1138 : LogicalORExpression { $$ = $1; }
1139 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1142 ConditionalExpressionNoIn
1143 : LogicalORExpressionNoIn { $$ = $1; }
1144 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1147 ConditionalExpressionNoBF
1148 : LogicalORExpressionNoBF { $$ = $1; }
1149 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1152 /* 11.13 Assignment Operators {{{ */
1153 AssignmentExpression_
1154 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1155 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1156 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1157 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1158 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1159 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1160 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1161 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1162 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1163 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1164 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1165 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1169 : LeftHandSideExpression { $$ = $1; }
1171 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1175 AssigneeExpressionNoBF
1176 : LeftHandSideExpressionNoBF { $$ = $1; }
1178 | UnaryAssigneeExpression { $$ = $1; }
1183 AssigneeExpressionNoRE
1184 : LeftHandSideExpressionNoRE { $$ = $1; }
1185 | UnaryAssigneeExpression { $$ = $1; }
1189 AssignmentExpression
1190 : ConditionalExpression { $$ = $1; }
1191 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1194 AssignmentExpressionNoIn
1195 : ConditionalExpressionNoIn { $$ = $1; }
1196 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1197 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1198 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1199 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1200 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1201 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1202 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1203 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1204 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1205 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1206 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1207 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1210 AssignmentExpressionNoBF
1211 : ConditionalExpressionNoBF { $$ = $1; }
1212 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1215 /* 11.14 Comma Operator {{{ */
1217 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1222 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1227 : Expression { $$ = $1; }
1228 | LexSetRegExp { $$ = NULL; }
1232 : ExpressionNoIn { $$ = $1; }
1233 | LexSetRegExp { $$ = NULL; }
1237 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1241 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1245 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1249 /* 12 Statements {{{ */
1251 : Block { $$ = $1; }
1252 | VariableStatement { $$ = $1; }
1253 | EmptyStatement { $$ = $1; }
1254 | ExpressionStatement { $$ = $1; }
1255 | IfStatement { $$ = $1; }
1256 | IterationStatement { $$ = $1; }
1257 | ContinueStatement { $$ = $1; }
1258 | BreakStatement { $$ = $1; }
1259 | ReturnStatement { $$ = $1; }
1260 | WithStatement { $$ = $1; }
1261 | LabelledStatement { $$ = $1; }
1262 | SwitchStatement { $$ = $1; }
1263 | ThrowStatement { $$ = $1; }
1264 | TryStatement { $$ = $1; }
1268 : LexSetRegExp Statement_ { $$ = $2; }
1271 /* 12.1 Block {{{ */
1273 : Brace StatementListOpt "}" { $$ = $2; }
1277 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1281 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1285 : StatementList { $$ = $1; }
1286 | LexSetRegExp { $$ = NULL; }
1289 /* 12.2 Variable Statement {{{ */
1291 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1294 VariableDeclarationList_
1295 : "," VariableDeclarationList { $$ = $2; }
1299 VariableDeclarationListNoIn_
1300 : "," VariableDeclarationListNoIn { $$ = $2; }
1304 VariableDeclarationList
1305 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1308 VariableDeclarationListNoIn
1309 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1313 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1316 VariableDeclarationNoIn
1317 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1321 : Initialiser { $$ = $1; }
1326 : InitialiserNoIn { $$ = $1; }
1331 : "=" AssignmentExpression { $$ = $2; }
1335 : "=" AssignmentExpressionNoIn { $$ = $2; }
1338 /* 12.3 Empty Statement {{{ */
1340 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1343 /* 12.4 Expression Statement {{{ */
1345 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1348 /* 12.5 The if Statement {{{ */
1350 : "else" Statement { $$ = $2; }
1351 | %prec "if" { $$ = NULL; }
1355 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1359 /* 12.6 Iteration Statements {{{ */
1361 : DoWhileStatement { $$ = $1; }
1362 | WhileStatement { $$ = $1; }
1363 | ForStatement { $$ = $1; }
1364 | ForInStatement { $$ = $1; }
1367 /* 12.6.1 The do-while Statement {{{ */
1369 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1372 /* 12.6.2 The while Statement {{{ */
1374 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1377 /* 12.6.3 The for Statement {{{ */
1379 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1382 ForStatementInitialiser
1383 : ExpressionNoInOpt { $$ = $1; }
1384 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1387 /* 12.6.4 The for-in Statement {{{ */
1389 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1392 ForInStatementInitialiser
1393 : LeftHandSideExpression { $$ = $1; }
1394 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1398 /* 12.7 The continue Statement {{{ */
1400 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1403 /* 12.8 The break Statement {{{ */
1405 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1408 /* 12.9 The return Statement {{{ */
1410 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1413 /* 12.10 The with Statement {{{ */
1415 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1419 /* 12.11 The switch Statement {{{ */
1421 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1425 : Brace CaseClausesOpt "}" { $$ = $2; }
1429 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1430 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1435 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1439 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1442 /* 12.12 Labelled Statements {{{ */
1444 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1447 /* 12.13 The throw Statement {{{ */
1449 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1452 /* 12.14 The try Statement {{{ */
1454 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1458 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1463 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1468 /* 13 Function Definition {{{ */
1470 : "function" Identifier "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1474 : "function" IdentifierOpt "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1477 FormalParameterList_
1478 : "," FormalParameterList { $$ = $2; }
1483 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1488 : SourceElements { $$ = $1; }
1491 /* 14 Program {{{ */
1493 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1497 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1498 | LexSetRegExp { $$ = NULL; }
1502 : Statement_ { $$ = $1; }
1503 | FunctionDeclaration { $$ = $1; }
1507 : LexSetRegExp SourceElement_ { $$ = $2; }
1512 /* Cycript (Objective-C): @class Declaration {{{ */
1514 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1515 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1520 : Brace "}" { $$ = NULL; }
1524 : "+" { $$ = false; }
1525 | "-" { $$ = true; }
1529 : "(" Expression ")" { $$ = $2; }
1534 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1537 MessageParameterListOpt
1538 : MessageParameterList { $$ = $1; }
1542 MessageParameterList
1543 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1547 : MessageParameterList { $$ = $1; }
1548 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1551 ClassMessageDeclaration
1552 : MessageScope TypeOpt MessageParameters Brace FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1555 ClassMessageDeclarationListOpt
1556 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1561 : Identifier { $$ = $1; }
1562 | "(" AssignmentExpression ")" { $$ = $2; }
1566 : ClassName { $$ = $1; }
1570 // XXX: this should be AssignmentExpressionNoRight
1572 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1576 : "," ClassProtocols { $$ = $2; }
1580 ClassProtocolListOpt
1581 : "<" ClassProtocols ">" { $$ = $2; }
1586 : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1590 : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1594 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1598 : ClassExpression { $$ = $1; }
1602 : ClassStatement { $$ = $1; }
1603 | CategoryStatement { $$ = $1; }
1606 /* Cycript (Objective-C): Send Message {{{ */
1608 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1613 : SelectorCall { $$ = $1; }
1614 | VariadicCall { $$ = $1; }
1618 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1619 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1623 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1627 : SelectorCall { $$ = $1; }
1628 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1632 : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = new(driver.pool_) CYSendDirect($2, $4); }
1633 | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($5); }
1636 SelectorExpressionOpt
1637 : SelectorExpression_ { $$ = $1; }
1642 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1646 : SelectorExpression_ { $$ = $1; }
1647 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1651 : MessageExpression { $$ = $1; }
1652 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1658 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1659 UnaryAssigneeExpression
1660 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1664 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1668 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1669 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1670 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1675 /* YUI: Documentation Comments {{{ */
1677 : Comment { $$ = $1; }
1682 /* Lexer State {{{ */
1684 : { driver.PushCondition(CYDriver::RegExpCondition); }
1688 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1692 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1696 : { driver.PopCondition(); }
1700 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1704 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1713 /* 8.1 Context Keywords {{{ */
1715 : "namespace" { $$ = $1; }
1716 | "xml" { $$ = $1; }
1719 /* 8.3 XML Initialiser Input Elements {{{ */
1721 : XMLComment { $$ = $1; }
1722 | XMLCDATA { $$ = $1; }
1723 | XMLPI { $$ = $1; }
1726 /* 11.1 Primary Expressions {{{ */
1728 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1729 | XMLInitialiser { $$ = $1; }
1730 | XMLListInitialiser { $$ = $1; }
1734 : AttributeIdentifier { $$ = $1; }
1735 | QualifiedIdentifier { $$ = $1; }
1736 | WildcardIdentifier { $$ = $1; }
1739 /* 11.1.1 Attribute Identifiers {{{ */
1741 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1745 : PropertySelector { $$ = $1; }
1746 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1750 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1751 | WildcardIdentifier { $$ = $1; }
1754 /* 11.1.2 Qualified Identifiers {{{ */
1755 QualifiedIdentifier_
1756 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1757 | QualifiedIdentifier { $$ = $1; }
1761 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1764 /* 11.1.3 Wildcard Identifiers {{{ */
1766 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1769 /* 11.1.4 XML Initialiser {{{ */
1771 : XMLMarkup { $$ = $1; }
1772 | XMLElement { $$ = $1; }
1776 : "<" XMLTagContent "/>" LexPop
1777 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1781 : LexPushXMLTag XMLTagName XMLAttributes
1785 : Brace LexPushRegExp Expression "}" LexPop
1794 : XMLAttributes_ XMLAttribute
1799 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1800 | XMLAttributes_ XMLWhitespaceOpt
1809 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1813 : XMLExpression XMLElementContentOpt
1814 | XMLMarkup XMLElementContentOpt
1815 | XMLText XMLElementContentOpt
1816 | XMLElement XMLElementContentOpt
1819 XMLElementContentOpt
1824 /* 11.1.5 XMLList Initialiser {{{ */
1826 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1829 /* 11.2 Left-Hand-Side Expressions {{{ */
1831 : Identifier { $$ = $1; }
1832 | PropertyIdentifier { $$ = $1; }
1836 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1837 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1838 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1841 /* 12.1 The default xml namespace Statement {{{ */
1842 /* XXX: DefaultXMLNamespaceStatement
1843 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1847 : DefaultXMLNamespaceStatement { $$ = $1; }
1852 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1853 PropertyNameAndValueList_
1854 : "," { $$ = NULL; }
1858 /* JavaScript 1.7: Array Comprehensions {{{ */
1860 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1864 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1865 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1868 ComprehensionListOpt
1869 : ComprehensionList { $$ = $1; }
1870 | IfComprehension { $$ = $1; }
1875 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1879 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1882 /* JavaScript 1.7: for each {{{ */
1884 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1887 /* JavaScript 1.7: let Statements {{{ *//*
1889 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1897 /* JavaScript FTW: Function Statements {{{ */
1899 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }
1902 /* JavaScript FTW: Optional Arguments {{{ */
1904 : Identifier "=" AssignmentExpression FormalParameterList_ { $$ = new(driver.pool_) CYOptionalFunctionParameter($1, $3, $4); }
1907 /* JavaScript FTW: Ruby Blocks {{{ */
1908 RubyProcParameterList_
1909 : "," RubyProcParameterList { $$ = $2; }
1913 RubyProcParameterList
1914 : Identifier RubyProcParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1918 RubyProcParametersOpt
1919 : "|" RubyProcParameterList "|" { $$ = $2; }
1924 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = new(driver.pool_) CYRubyProc($2, $3); }
1927 LeftHandSideExpression
1928 : LeftHandSideExpression RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }
1931 LeftHandSideExpressionNoBF
1932 : LeftHandSideExpressionNoBF RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }
1936 LeftHandSideExpressionNoRE
1937 : LeftHandSideExpressionNoRE RubyProcExpression { $$ = new(driver.pool_) CYRubyBlock($1, $2); }