1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2010 Jay Freeman (saurik)
5 /* GNU Lesser General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
24 @if Bison24 %code top {
25 #define cyscanner driver.scanner_
26 #define YYSTACKEXPANDABLE 1
27 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
30 @if Bison24 %code requires {
32 #define CYNew new($pool)
35 #include "ObjectiveC/Syntax.hpp"
39 #include "E4X/Syntax.hpp"
48 CYDriver::Condition condition_;
50 CYArgument *argument_;
51 CYAssignment *assignment_;
54 cy::Syntax::Catch *catch_;
56 CYComprehension *comprehension_;
57 CYCompound *compound_;
58 CYDeclaration *declaration_;
59 CYDeclarations *declarations_;
61 CYExpression *expression_;
64 CYForInitialiser *for_;
65 CYForInInitialiser *forin_;
66 CYFunctionParameter *functionParameter_;
67 CYIdentifier *identifier_;
74 CYProperty *property_;
75 CYPropertyName *propertyName_;
76 CYRubyProc *rubyProc_;
77 CYStatement *statement_;
84 CYClassName *className_;
87 CYMessageParameter *messageParameter_;
88 CYProtocol *protocol_;
89 CYSelectorPart *selector_;
93 CYAttribute *attribute_;
94 CYPropertyIdentifier *propertyIdentifier_;
95 CYSelector *selector_;
100 #define YYSTYPE YYSTYPE
103 @if Bison24 %code provides {
104 int cylex(YYSTYPE *, cy::location *, void *);
111 @if Bison23 %skeleton "lalr1.cc"
112 @if Bison24 %language "C++"
115 @$.begin.filename = @$.end.filename = &driver.filename_;
126 %parse-param { CYDriver &driver }
127 %lex-param { void *cyscanner }
134 %token XMLAttributeValue
136 %token XMLTagCharacters
142 %token LeftRight "<>"
143 %token LeftSlashRight "</>"
145 %token SlashRight "/>"
146 %token LeftSlash "</"
148 %token ColonColon "::"
149 %token PeriodPeriod ".."
152 @begin E4X ObjectiveC
157 %token AmpersandAmpersand "&&"
158 %token AmpersandEqual "&="
160 %token CarrotEqual "^="
162 %token EqualEqual "=="
163 %token EqualEqualEqual "==="
164 %token Exclamation "!"
165 %token ExclamationEqual "!="
166 %token ExclamationEqualEqual "!=="
168 %token HyphenEqual "-="
169 %token HyphenHyphen "--"
170 %token HyphenHyphen_ "\n--"
171 %token HyphenRight "->"
173 %token LeftEqual "<="
175 %token LeftLeftEqual "<<="
177 %token PercentEqual "%="
179 %token PeriodPeriodPeriod "..."
181 %token PipeEqual "|="
184 %token PlusEqual "+="
186 %token PlusPlus_ "\n++"
188 %token RightEqual ">="
189 %token RightRight ">>"
190 %token RightRightEqual ">>="
191 %token RightRightRight ">>>"
192 %token RightRightRightEqual ">>>="
194 %token SlashEqual "/="
196 %token StarEqual "*="
205 %token <comment_> Comment
208 %token CloseParen ")"
211 %token OpenBrace_ "\n{"
212 %token CloseBrace "}"
214 %token OpenBracket "["
215 %token CloseBracket "]"
218 %token AtClass "@class"
222 %token AtImplementation "@implementation"
223 %token AtImport "@import"
225 %token AtSelector "@selector"
228 %token <false_> False "false"
229 %token <null_> Null "null"
230 %token <true_> True "true"
232 // ES3/ES5/WIE/JSC Reserved
233 %token <word_> Break "break"
234 %token <word_> Case "case"
235 %token <word_> Catch "catch"
236 %token <word_> Continue "continue"
237 %token <word_> Default "default"
238 %token <word_> Delete "delete"
239 %token <word_> Do "do"
240 %token <word_> Else "else"
241 %token <word_> Finally "finally"
242 %token <word_> For "for"
243 %token <word_> Function "function"
244 %token <word_> If "if"
245 %token <word_> In "in"
246 %token <word_> InstanceOf "instanceof"
247 %token <word_> New "new"
248 %token <word_> Return "return"
249 %token <word_> Switch "switch"
250 %token <this_> This "this"
251 %token <word_> Throw "throw"
252 %token <word_> Try "try"
253 %token <word_> TypeOf "typeof"
254 %token <word_> Var "var"
255 %token <word_> Void "void"
256 %token <word_> While "while"
257 %token <word_> With "with"
259 // ES3/IE6 Future, ES5/JSC Reserved
260 %token <word_> Debugger "debugger"
262 // ES3/ES5/IE6 Future, JSC Reserved
263 %token <word_> Const "const"
265 // ES3/ES5/IE6/JSC Future
266 %token <word_> Class "class"
267 %token <word_> Enum "enum"
268 %token <word_> Export "export"
269 %token <word_> Extends "extends"
270 %token <word_> Import "import"
271 %token <word_> Super "super"
273 // ES3 Future, ES5 Strict Future
274 %token <identifier_> Implements "implements"
275 %token <identifier_> Interface "interface"
276 %token <identifier_> Package "package"
277 %token <identifier_> Private "private"
278 %token <identifier_> Protected "protected"
279 %token <identifier_> Public "public"
280 %token <identifier_> Static "static"
283 %token <identifier_> Abstract "abstract"
284 %token <identifier_> Boolean "boolean"
285 %token <identifier_> Byte "byte"
286 %token <identifier_> Char "char"
287 %token <identifier_> Double "double"
288 %token <identifier_> Final "final"
289 %token <identifier_> Float "float"
290 %token <identifier_> Goto "goto"
291 %token <identifier_> Int "int"
292 %token <identifier_> Long "long"
293 %token <identifier_> Native "native"
294 %token <identifier_> Short "short"
295 %token <identifier_> Synchronized "synchronized"
296 %token <identifier_> Throws "throws"
297 %token <identifier_> Transient "transient"
298 %token <identifier_> Volatile "volatile"
301 %token <identifier_> Let "let"
302 %token <identifier_> Yield "yield"
305 %token <identifier_> Each "each"
309 %token <identifier_> Namespace "namespace"
310 %token <identifier_> XML "xml"
315 %token <identifier_> Identifier_
316 %token <number_> NumericLiteral
317 %token <string_> StringLiteral
318 %token <literal_> RegularExpressionLiteral
320 %type <expression_> AdditiveExpression
321 %type <expression_> AdditiveExpressionNoBF
322 %type <argument_> ArgumentList
323 %type <argument_> ArgumentList_
324 %type <argument_> ArgumentListOpt
325 %type <argument_> Arguments
326 %type <literal_> ArrayLiteral
327 %type <expression_> AssigneeExpression
328 %type <expression_> AssigneeExpressionNoBF
329 %type <expression_> AssignmentExpression
330 %type <assignment_> AssignmentExpression_
331 %type <expression_> AssignmentExpressionNoBF
332 %type <expression_> AssignmentExpressionNoIn
333 %type <identifier_> BindingIdentifier
334 %type <expression_> BitwiseANDExpression
335 %type <expression_> BitwiseANDExpressionNoBF
336 %type <expression_> BitwiseANDExpressionNoIn
337 %type <statement_> Block
338 %type <statement_> Block_
339 %type <boolean_> BooleanLiteral
340 %type <declaration_> BindingElement
341 %type <expression_> BitwiseORExpression
342 %type <expression_> BitwiseORExpressionNoBF
343 %type <expression_> BitwiseORExpressionNoIn
344 %type <expression_> BitwiseXORExpression
345 %type <expression_> BitwiseXORExpressionNoBF
346 %type <expression_> BitwiseXORExpressionNoIn
347 %type <statement_> BreakStatement
348 %type <statement_> BreakableStatement
349 %type <expression_> CallExpression
350 %type <expression_> CallExpressionNoBF
351 %type <clause_> CaseBlock
352 %type <clause_> CaseClause
353 %type <clause_> CaseClausesOpt
354 %type <catch_> CatchOpt
355 %type <comprehension_> ComprehensionList
356 %type <comprehension_> ComprehensionListOpt
357 %type <expression_> ConditionalExpression
358 %type <expression_> ConditionalExpressionNoBF
359 %type <expression_> ConditionalExpressionNoIn
360 %type <statement_> ContinueStatement
361 %type <statement_> DebuggerStatement
362 %type <statement_> Declaration
363 %type <clause_> DefaultClause
364 %type <statement_> DoWhileStatement
365 %type <expression_> Element
366 %type <expression_> ElementOpt
367 %type <element_> ElementList
368 %type <element_> ElementListOpt
369 %type <statement_> ElseStatementOpt
370 %type <statement_> EmptyStatement
371 %type <expression_> EqualityExpression
372 %type <expression_> EqualityExpressionNoBF
373 %type <expression_> EqualityExpressionNoIn
374 %type <expression_> Expression
375 %type <expression_> ExpressionOpt
376 %type <compound_> Expression_
377 %type <expression_> ExpressionNoBF
378 %type <expression_> ExpressionNoIn
379 %type <compound_> ExpressionNoIn_
380 %type <expression_> ExpressionNoInOpt
381 %type <statement_> ExpressionStatement
382 %type <finally_> FinallyOpt
383 %type <comprehension_> ForComprehension
384 %type <statement_> ForStatement
385 %type <for_> ForStatementInitialiser
386 %type <statement_> ForInStatement
387 %type <forin_> ForInStatementInitialiser
388 %type <declaration_> FormalParameter
389 %type <functionParameter_> FormalParameterList
390 %type <functionParameter_> FormalParameterList_
391 %type <functionParameter_> FormalParameterListOpt
392 %type <statement_> FunctionBody
393 %type <statement_> FunctionDeclaration
394 %type <expression_> FunctionExpression
395 %type <identifier_> Identifier
396 %type <identifier_> IdentifierOpt
397 %type <comprehension_> IfComprehension
398 %type <statement_> IfStatement
399 %type <expression_> Initialiser
400 %type <expression_> InitialiserOpt
401 %type <expression_> InitialiserNoIn
402 %type <expression_> InitialiserNoInOpt
403 %type <statement_> IterationStatement
404 %type <statement_> LabelledStatement
405 %type <expression_> LeftHandSideExpression
406 %type <expression_> LeftHandSideExpressionNoBF
407 //%type <expression_> LetExpression
408 %type <statement_> LetStatement
409 %type <statement_> LexicalDeclaration
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 <statement_> ProgramBody
439 %type <statement_> ProgramBodyOpt
440 %type <propertyName_> PropertyName
441 %type <propertyName_> PropertyName_
442 %type <property_> PropertyNameAndValueList
443 %type <property_> PropertyNameAndValueList_
444 %type <property_> PropertyNameAndValueListOpt
445 %type <expression_> RelationalExpression
446 %type <infix_> RelationalExpression_
447 %type <expression_> RelationalExpressionNoBF
448 %type <expression_> RelationalExpressionNoIn
449 %type <infix_> RelationalExpressionNoIn_
450 %type <statement_> ReturnStatement
451 %type <rubyProc_> RubyProcExpression
452 %type <rubyProc_> RubyProcExpressionNoOA
453 %type <functionParameter_> RubyProcParameterList
454 %type <functionParameter_> RubyProcParameterList_
455 %type <functionParameter_> RubyProcParameters
456 %type <functionParameter_> RubyProcParametersOpt
457 %type <expression_> ShiftExpression
458 %type <expression_> ShiftExpressionNoBF
459 %type <declaration_> SingleNameBinding
460 %type <statement_> Statement
461 %type <statement_> Statement_
462 %type <statement_> StatementList
463 %type <statement_> StatementListOpt
464 %type <statement_> StatementListItem
465 %type <statement_> SwitchStatement
466 %type <statement_> ThrowStatement
467 %type <statement_> TryStatement
468 %type <expression_> UnaryExpression
469 %type <expression_> UnaryExpression_
470 %type <expression_> UnaryExpressionNoBF
471 %type <declaration_> VariableDeclaration
472 %type <declaration_> VariableDeclarationNoIn
473 %type <declarations_> VariableDeclarationList
474 %type <declarations_> VariableDeclarationList_
475 %type <declarations_> VariableDeclarationListNoIn
476 %type <declarations_> VariableDeclarationListNoIn_
477 %type <statement_> VariableStatement
478 %type <statement_> WhileStatement
479 %type <statement_> WithStatement
482 %type <expression_> AssigneeExpressionNoRE
483 %type <expression_> CallExpressionNoRE
484 %type <expression_> LeftHandSideExpressionNoRE
485 %type <expression_> MemberExpressionNoRE
486 %type <expression_> NewExpressionNoRE
487 %type <expression_> PostfixExpressionNoRE
488 %type <expression_> UnaryAssigneeExpression
489 %type <expression_> UnaryExpressionNoRE
493 %type <statement_> CategoryStatement
494 %type <expression_> ClassExpression
495 %type <statement_> ClassStatement
496 %type <expression_> ClassSuperOpt
497 %type <field_> ClassFieldList
498 %type <message_> ClassMessageDeclaration
499 %type <message_> ClassMessageDeclarationListOpt
500 %type <className_> ClassName
501 %type <className_> ClassNameOpt
502 %type <protocol_> ClassProtocolListOpt
503 %type <protocol_> ClassProtocols
504 %type <protocol_> ClassProtocolsOpt
505 %type <expression_> MessageExpression
506 %type <messageParameter_> MessageParameter
507 %type <messageParameter_> MessageParameters
508 %type <messageParameter_> MessageParameterList
509 %type <messageParameter_> MessageParameterListOpt
510 %type <bool_> MessageScope
511 %type <argument_> SelectorCall
512 %type <argument_> SelectorCall_
513 %type <selector_> SelectorExpression
514 %type <selector_> SelectorExpression_
515 %type <selector_> SelectorExpressionOpt
516 %type <argument_> SelectorList
517 %type <word_> SelectorWordOpt
518 %type <expression_> TypeOpt
519 %type <argument_> VariadicCall
521 %type <word_> WordOpt
525 %type <propertyIdentifier_> PropertyIdentifier_
526 %type <selector_> PropertySelector
527 %type <selector_> PropertySelector_
528 %type <identifier_> QualifiedIdentifier
529 %type <identifier_> QualifiedIdentifier_
530 %type <identifier_> WildcardIdentifier
531 %type <identifier_> XMLComment
532 %type <identifier_> XMLCDATA
533 %type <identifier_> XMLElement
534 %type <identifier_> XMLElementContent
535 %type <identifier_> XMLMarkup
536 %type <identifier_> XMLPI
538 %type <attribute_> AttributeIdentifier
539 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
540 %type <expression_> PropertyIdentifier
541 %type <expression_> XMLListInitialiser
542 %type <expression_> XMLInitialiser
545 %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"
555 %left "<<" ">>" ">>>"
556 %left "<" ">" "<=" ">=" "instanceof" "in"
557 %left "==" "!=" "===" "!=="
564 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
570 /* Lexer State {{{ */
572 : { driver.SetCondition(CYDriver::RegExpCondition); }
582 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
592 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
597 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
617 : Identifier { $$ = $1; }
618 | "break" NewLineOpt { $$ = $1; }
619 | "case" { $$ = $1; }
620 | "catch" { $$ = $1; }
621 | "class" { $$ = $1; }
622 | "const" { $$ = $1; }
623 | "continue" NewLineOpt { $$ = $1; }
624 | "debugger" { $$ = $1; }
625 | "default" { $$ = $1; }
626 | "delete" { $$ = $1; }
628 | "else" { $$ = $1; }
629 | "enum" { $$ = $1; }
630 | "export" { $$ = $1; }
631 | "extends" { $$ = $1; }
632 | "false" { $$ = $1; }
633 | "finally" { $$ = $1; }
634 /* XXX: | "for" { $$ = $1; } */
635 | "function" { $$ = $1; }
637 | "import" { $$ = $1; }
638 /* XXX: | "in" { $$ = $1; } */
639 /* XXX: | "instanceof" { $$ = $1; } */
641 | "null" { $$ = $1; }
642 | "return" NewLineOpt { $$ = $1; }
643 | "super" { $$ = $1; }
644 | "switch" { $$ = $1; }
645 | "this" { $$ = $1; }
646 | "throw" NewLineOpt { $$ = $1; }
647 | "true" { $$ = $1; }
649 | "typeof" { $$ = $1; }
651 | "void" { $$ = $1; }
652 | "while" { $$ = $1; }
653 | "with" { $$ = $1; }
657 : "@" LiteralNoRE { $$ = CYNew CYBox($2); }
658 | "@" ArrayLiteral { $$ = CYNew CYBox($2); }
659 | "@" ObjectLiteral { $$ = CYNew CYBox($2); }
660 | "@" "(" Expression ")" { $$ = CYNew CYBox($3); }
665 : Identifier_ { $$ = $1; }
667 | "implements" { $$ = $1; }
668 | "interface" { $$ = $1; }
669 | "package" { $$ = $1; }
670 | "private" { $$ = $1; }
671 | "protected" { $$ = $1; }
672 | "public" { $$ = $1; }
673 | "static" { $$ = $1; }
675 | "abstract" { $$ = $1; }
676 | "boolean" { $$ = $1; }
677 | "byte" { $$ = $1; }
678 | "char" { $$ = $1; }
679 | "double" { $$ = $1; }
680 | "final" { $$ = $1; }
681 | "float" { $$ = $1; }
682 | "goto" { $$ = $1; }
684 | "long" { $$ = $1; }
685 | "native" { $$ = $1; }
686 | "short" { $$ = $1; }
687 | "synchronized" { $$ = $1; }
688 | "throws" { $$ = $1; }
689 | "transient" { $$ = $1; }
690 | "volatile" { $$ = $1; }
692 // XXX: is this allowed?! | "let" { $$ = $1; }
693 | "yield" { $$ = $1; }
695 | "each" { $$ = $1; }
699 : Identifier { $$ = $1; }
704 : NullLiteral { $$ = $1; }
705 | BooleanLiteral { $$ = $1; }
706 | NumericLiteral { $$ = $1; }
707 | StringLiteral { $$ = $1; }
711 : RegularExpressionLiteral { $$ = $1; }
715 : LiteralNoRE { $$ = $1; }
716 | LiteralRE { $$ = $1; }
720 : "null" { $$ = $1; }
724 : "true" { $$ = $1; }
725 | "false" { $$ = $1; }
728 /* 11.1 Primary Expressions {{{ */
730 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
733 PrimaryExpressionNoBF
734 : PrimaryExpressionNo { $$ = $1; }
737 PrimaryExpressionNoRE
738 : PrimaryExpressionBF { $$ = $1; }
739 | PrimaryExpressionNo { $$ = $1; }
743 : "this" { $$ = $1; }
744 | Identifier { $$ = CYNew CYVariable($1); }
745 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
746 | Literal { $$ = $1; }
747 | ArrayLiteral { $$ = $1; }
748 | "(" Expression ")" { $$ = $2; }
752 : ObjectLiteral { $$ = $1; }
755 /* 11.1.4 Array Initialiser {{{ */
757 : "[" ElementListOpt "]" { $$ = CYNew CYArray($2); }
761 : AssignmentExpression { $$ = $1; }
765 : Element { $$ = $1; }
766 | LexSetRegExp { $$ = NULL; }
770 : ElementList { $$ = $1; }
771 | LexSetRegExp { $$ = NULL; }
775 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
776 | Element { $$ = CYNew CYElement($1, NULL); }
779 /* 11.1.5 Object Initialiser {{{ */
781 : Brace PropertyNameAndValueListOpt "}" { $$ = CYNew CYObject($2); }
784 PropertyNameAndValueList_
785 : "," PropertyNameAndValueList { $$ = $2; }
789 PropertyNameAndValueListOpt
790 : PropertyNameAndValueList { $$ = $1; }
794 PropertyNameAndValueList
795 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = CYNew CYProperty($1, $3, $4); }
799 : Identifier { $$ = $1; }
800 | StringLiteral { $$ = $1; }
801 | NumericLiteral { $$ = $1; }
805 : LexSetRegExp PropertyName_ { $$ = $2; }
809 /* 11.2 Left-Hand-Side Expressions {{{ */
811 : "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($2, $3); }
815 : "[" Expression "]" { $$ = CYNew CYDirectMember(NULL, $2); }
816 | "." Identifier { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
817 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
821 : PrimaryExpression { $$ = $1; }
822 | LexSetRegExp FunctionExpression { $$ = $2; }
823 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
824 | LexSetRegExp MemberExpression_ { $$ = $2; }
828 : PrimaryExpressionNoBF { $$ = $1; }
829 | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
830 | MemberExpression_ { $$ = $1; }
835 : PrimaryExpressionNoRE { $$ = $1; }
836 | FunctionExpression { $$ = $1; }
837 | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
838 | MemberExpression_ { $$ = $1; }
843 : "new" NewExpression { $$ = CYNew cy::Syntax::New($2, NULL); }
847 : MemberExpression { $$ = $1; }
848 | LexSetRegExp NewExpression_ { $$ = $2; }
852 : MemberExpressionNoBF { $$ = $1; }
853 | NewExpression_ { $$ = $1; }
858 : MemberExpressionNoRE { $$ = $1; }
859 | NewExpression_ { $$ = $1; }
864 : MemberExpression Arguments { $$ = CYNew CYCall($1, $2); }
865 | CallExpression Arguments { $$ = CYNew CYCall($1, $2); }
866 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
870 : MemberExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
871 | CallExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
872 | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
877 : MemberExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
878 | CallExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
879 | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
884 : "," ArgumentList { $$ = $2; }
889 : ArgumentList { $$ = $1; }
890 | LexSetRegExp { $$ = NULL; }
894 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
898 : "(" ArgumentListOpt ")" { $$ = $2; }
901 LeftHandSideExpression
902 : NewExpression { $$ = $1; }
903 | CallExpression { $$ = $1; }
906 LeftHandSideExpressionNoBF
907 : NewExpressionNoBF { $$ = $1; }
908 | CallExpressionNoBF { $$ = $1; }
912 LeftHandSideExpressionNoRE
913 : NewExpressionNoRE { $$ = $1; }
914 | CallExpressionNoRE { $$ = $1; }
918 /* 11.3 Postfix Expressions {{{ */
920 : AssigneeExpression { $$ = $1; }
921 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
922 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
925 PostfixExpressionNoBF
926 : AssigneeExpressionNoBF { $$ = $1; }
927 | LeftHandSideExpressionNoBF "++" { $$ = CYNew CYPostIncrement($1); }
928 | LeftHandSideExpressionNoBF "--" { $$ = CYNew CYPostDecrement($1); }
932 PostfixExpressionNoRE
933 : AssigneeExpressionNoRE { $$ = $1; }
934 | LeftHandSideExpressionNoRE "++" { $$ = CYNew CYPostIncrement($1); }
935 | LeftHandSideExpressionNoRE "--" { $$ = CYNew CYPostDecrement($1); }
939 /* 11.4 Unary Operators {{{ */
941 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
942 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
943 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
944 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
945 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
946 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
947 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
948 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
949 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
950 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
951 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
955 : PostfixExpression { $$ = $1; }
956 | LexSetRegExp UnaryExpression_ { $$ = $2; }
960 : PostfixExpressionNoBF { $$ = $1; }
961 | UnaryExpression_ { $$ = $1; }
966 : PostfixExpressionNoRE { $$ = $1; }
967 | UnaryExpression_ { $$ = $1; }
971 /* 11.5 Multiplicative Operators {{{ */
972 MultiplicativeExpression
973 : UnaryExpression { $$ = $1; }
974 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
975 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
976 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
979 MultiplicativeExpressionNoBF
980 : UnaryExpressionNoBF { $$ = $1; }
981 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
982 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
983 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
986 /* 11.6 Additive Operators {{{ */
988 : MultiplicativeExpression { $$ = $1; }
989 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
990 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
993 AdditiveExpressionNoBF
994 : MultiplicativeExpressionNoBF { $$ = $1; }
995 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
996 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
999 /* 11.7 Bitwise Shift Operators {{{ */
1001 : AdditiveExpression { $$ = $1; }
1002 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1003 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1004 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1008 : AdditiveExpressionNoBF { $$ = $1; }
1009 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1010 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1011 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1014 /* 11.8 Relational Operators {{{ */
1015 RelationalExpressionNoIn_
1016 : "<" ShiftExpression { $$ = CYNew CYLess(NULL, $2); }
1017 | ">" ShiftExpression { $$ = CYNew CYGreater(NULL, $2); }
1018 | "<=" ShiftExpression { $$ = CYNew CYLessOrEqual(NULL, $2); }
1019 | ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual(NULL, $2); }
1020 | "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf(NULL, $2); }
1023 RelationalExpression_
1024 : RelationalExpressionNoIn_ { $$ = $1; }
1025 | "in" ShiftExpression { $$ = CYNew CYIn(NULL, $2); }
1028 RelationalExpression
1029 : ShiftExpression { $$ = $1; }
1030 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1033 RelationalExpressionNoIn
1034 : ShiftExpression { $$ = $1; }
1035 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1038 RelationalExpressionNoBF
1039 : ShiftExpressionNoBF { $$ = $1; }
1040 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1043 /* 11.9 Equality Operators {{{ */
1045 : RelationalExpression { $$ = $1; }
1046 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1047 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1048 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1049 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1052 EqualityExpressionNoIn
1053 : RelationalExpressionNoIn { $$ = $1; }
1054 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = CYNew CYEqual($1, $3); }
1055 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = CYNew CYNotEqual($1, $3); }
1056 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = CYNew CYIdentical($1, $3); }
1057 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = CYNew CYNotIdentical($1, $3); }
1060 EqualityExpressionNoBF
1061 : RelationalExpressionNoBF { $$ = $1; }
1062 | EqualityExpressionNoBF "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1063 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1064 | EqualityExpressionNoBF "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1065 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1068 /* 11.10 Binary Bitwise Operators {{{ */
1069 BitwiseANDExpression
1070 : EqualityExpression { $$ = $1; }
1071 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1074 BitwiseANDExpressionNoIn
1075 : EqualityExpressionNoIn { $$ = $1; }
1076 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = CYNew CYBitwiseAnd($1, $3); }
1079 BitwiseANDExpressionNoBF
1080 : EqualityExpressionNoBF { $$ = $1; }
1081 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1084 BitwiseXORExpression
1085 : BitwiseANDExpression { $$ = $1; }
1086 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1089 BitwiseXORExpressionNoIn
1090 : BitwiseANDExpressionNoIn { $$ = $1; }
1091 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = CYNew CYBitwiseXOr($1, $3); }
1094 BitwiseXORExpressionNoBF
1095 : BitwiseANDExpressionNoBF { $$ = $1; }
1096 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1100 : BitwiseXORExpression { $$ = $1; }
1101 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1104 BitwiseORExpressionNoIn
1105 : BitwiseXORExpressionNoIn { $$ = $1; }
1106 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = CYNew CYBitwiseOr($1, $3); }
1109 BitwiseORExpressionNoBF
1110 : BitwiseXORExpressionNoBF { $$ = $1; }
1111 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1114 /* 11.11 Binary Logical Operators {{{ */
1115 LogicalANDExpression
1116 : BitwiseORExpression { $$ = $1; }
1117 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1120 LogicalANDExpressionNoIn
1121 : BitwiseORExpressionNoIn { $$ = $1; }
1122 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = CYNew CYLogicalAnd($1, $3); }
1125 LogicalANDExpressionNoBF
1126 : BitwiseORExpressionNoBF { $$ = $1; }
1127 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1131 : LogicalANDExpression { $$ = $1; }
1132 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1135 LogicalORExpressionNoIn
1136 : LogicalANDExpressionNoIn { $$ = $1; }
1137 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = CYNew CYLogicalOr($1, $3); }
1140 LogicalORExpressionNoBF
1141 : LogicalANDExpressionNoBF { $$ = $1; }
1142 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1145 /* 11.12 Conditional Operator ( ? : ) {{{ */
1146 ConditionalExpression
1147 : LogicalORExpression { $$ = $1; }
1148 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
1151 ConditionalExpressionNoIn
1152 : LogicalORExpressionNoIn { $$ = $1; }
1153 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = CYNew CYCondition($1, $3, $5); }
1156 ConditionalExpressionNoBF
1157 : LogicalORExpressionNoBF { $$ = $1; }
1158 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
1161 /* 11.13 Assignment Operators {{{ */
1162 AssignmentExpression_
1163 : "=" AssignmentExpression { $$ = CYNew CYAssign(NULL, $2); }
1164 | "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign(NULL, $2); }
1165 | "/=" AssignmentExpression { $$ = CYNew CYDivideAssign(NULL, $2); }
1166 | "%=" AssignmentExpression { $$ = CYNew CYModulusAssign(NULL, $2); }
1167 | "+=" AssignmentExpression { $$ = CYNew CYAddAssign(NULL, $2); }
1168 | "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign(NULL, $2); }
1169 | "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign(NULL, $2); }
1170 | ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign(NULL, $2); }
1171 | ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign(NULL, $2); }
1172 | "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign(NULL, $2); }
1173 | "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign(NULL, $2); }
1174 | "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign(NULL, $2); }
1178 : LeftHandSideExpression { $$ = $1; }
1180 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1184 AssigneeExpressionNoBF
1185 : LeftHandSideExpressionNoBF { $$ = $1; }
1187 | UnaryAssigneeExpression { $$ = $1; }
1192 AssigneeExpressionNoRE
1193 : LeftHandSideExpressionNoRE { $$ = $1; }
1194 | UnaryAssigneeExpression { $$ = $1; }
1198 AssignmentExpression
1199 : ConditionalExpression { $$ = $1; }
1200 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1203 AssignmentExpressionNoIn
1204 : ConditionalExpressionNoIn { $$ = $1; }
1205 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = CYNew CYAssign($1, $3); }
1206 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = CYNew CYMultiplyAssign($1, $3); }
1207 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = CYNew CYDivideAssign($1, $3); }
1208 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = CYNew CYModulusAssign($1, $3); }
1209 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = CYNew CYAddAssign($1, $3); }
1210 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = CYNew CYSubtractAssign($1, $3); }
1211 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = CYNew CYShiftLeftAssign($1, $3); }
1212 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1213 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1214 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1215 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1216 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1219 AssignmentExpressionNoBF
1220 : ConditionalExpressionNoBF { $$ = $1; }
1221 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1224 /* 11.14 Comma Operator {{{ */
1226 : "," Expression { $$ = CYNew CYCompound($2); }
1231 : "," ExpressionNoIn { $$ = CYNew CYCompound($2); }
1236 : Expression { $$ = $1; }
1237 | LexSetRegExp { $$ = NULL; }
1241 : ExpressionNoIn { $$ = $1; }
1242 | LexSetRegExp { $$ = NULL; }
1246 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1250 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1254 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1258 /* 12 Statements {{{ */
1260 : Block { $$ = $1; }
1261 | VariableStatement { $$ = $1; }
1262 | EmptyStatement { $$ = $1; }
1263 | ExpressionStatement { $$ = $1; }
1264 | IfStatement { $$ = $1; }
1265 | BreakableStatement { $$ = $1; }
1266 | ContinueStatement { $$ = $1; }
1267 | BreakStatement { $$ = $1; }
1268 | ReturnStatement { $$ = $1; }
1269 | WithStatement { $$ = $1; }
1270 | LabelledStatement { $$ = $1; }
1271 | ThrowStatement { $$ = $1; }
1272 | TryStatement { $$ = $1; }
1273 | DebuggerStatement { $$ = $1; }
1277 : LexSetRegExp Statement_ { $$ = $2; }
1281 : FunctionDeclaration { $$ = $1; }
1282 | LexicalDeclaration { $$ = $1; }
1286 : IterationStatement { $$ = $1; }
1287 | SwitchStatement { $$ = $1; }
1290 /* 12.1 Block {{{ */
1292 : Brace StatementListOpt "}" { $$ = $2; }
1296 : Block_ { $$ = CYNew CYBlock($1); }
1300 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1304 : StatementList { $$ = $1; }
1305 | LexSetRegExp { $$ = NULL; }
1309 : Statement { $$ = $1; }
1310 | LexSetRegExp Declaration { $$ = $2; }
1313 /* 12.2 Declarations {{{ */
1315 : Identifier { $$ = $1; }
1318 // XXX: BindingPattern
1320 /* 12.2.1 Let and Const Declarations {{{ */
1322 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1330 /* 12.2.2 Variable Statement {{{ */
1332 : "var" VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1335 VariableDeclarationList_
1336 : "," VariableDeclarationList { $$ = $2; }
1340 VariableDeclarationListNoIn_
1341 : "," VariableDeclarationListNoIn { $$ = $2; }
1345 VariableDeclarationList
1346 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1349 VariableDeclarationListNoIn
1350 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = CYNew CYDeclarations($1, $2); }
1354 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1355 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1358 VariableDeclarationNoIn
1359 : BindingIdentifier InitialiserNoInOpt { $$ = CYNew CYDeclaration($1, $2); }
1360 // XXX: | BindingPattern InitialiserNoIn { $$ = CYNew CYDeclaration($1, $2); }
1364 : Initialiser { $$ = $1; }
1369 : InitialiserNoIn { $$ = $1; }
1374 : "=" AssignmentExpression { $$ = $2; }
1378 : "=" AssignmentExpressionNoIn { $$ = $2; }
1381 /* 12.2.4 Destructuring Binding Patterns {{{ */
1385 : SingleNameBinding { $$ = $1; }
1389 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1392 /* 12.3 Empty Statement {{{ */
1394 : ";" { $$ = CYNew CYEmpty(); }
1397 /* 12.4 Expression Statement {{{ */
1399 : ExpressionNoBF Terminator { $$ = CYNew CYExpress($1); }
1402 /* 12.5 The if Statement {{{ */
1404 : "else" Statement { $$ = $2; }
1405 | %prec "if" { $$ = NULL; }
1409 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1413 /* 12.6 Iteration Statements {{{ */
1415 : DoWhileStatement { $$ = $1; }
1416 | WhileStatement { $$ = $1; }
1417 | ForStatement { $$ = $1; }
1418 | ForInStatement { $$ = $1; }
1421 /* 12.6.1 The do-while Statement {{{ */
1423 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1426 /* 12.6.2 The while Statement {{{ */
1428 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1431 /* 12.6.3 The for Statement {{{ */
1433 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($3, $5, $7, $9); }
1436 ForStatementInitialiser
1437 : ExpressionNoInOpt { $$ = $1; }
1438 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = CYNew CYForDeclarations($3); }
1441 /* 12.6.4 The for-in Statement {{{ */
1443 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForIn($3, $5, $7); }
1446 ForInStatementInitialiser
1447 : LeftHandSideExpression { $$ = $1; }
1448 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1452 /* 12.7 The continue Statement {{{ */
1454 : "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1457 /* 12.8 The break Statement {{{ */
1459 : "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1462 /* 12.9 The return Statement {{{ */
1464 : "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1467 /* 12.10 The with Statement {{{ */
1469 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1473 /* 12.11 The switch Statement {{{ */
1475 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1479 : Brace CaseClausesOpt "}" { $$ = $2; }
1483 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1484 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1489 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1493 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1496 /* 12.12 Labelled Statements {{{ */
1498 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1501 /* 12.13 The throw Statement {{{ */
1503 : "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1506 /* 12.14 The try Statement {{{ */
1508 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1512 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1517 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1521 /* 12.14 The debugger Statement {{{ */
1523 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1527 /* 13 Function Definition {{{ */
1529 : "function" Identifier "(" FormalParameterListOpt ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1533 : "function" IdentifierOpt "(" FormalParameterListOpt ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionExpression($2, $4, $7); }
1536 FormalParameterList_
1537 : "," FormalParameterList { $$ = $2; }
1541 FormalParameterListOpt
1542 : FormalParameterList
1547 // XXX: : FunctionRestParameter { $$ = $1; }
1548 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1551 /* XXX: FunctionRestParameter
1552 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1556 : BindingElement { $$ = $1; }
1560 : StatementListOpt { $$ = $1; }
1563 /* 14 Program {{{ */
1565 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1569 : ProgramBody { $$ = $1; }
1574 : StatementList { $$ = $1; }
1579 /* Cycript (Objective-C): @class Declaration {{{ */
1581 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1582 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1587 : Expression Identifier ";"
1591 : ClassFieldListOpt ClassField
1596 : Brace ClassFieldListOpt "}" { $$ = NULL; }
1600 : "+" { $$ = false; }
1601 | "-" { $$ = true; }
1605 : "(" Expression ")" { $$ = $2; }
1606 | "(" LexSetRegExp "void" ")" { $$ = NULL; }
1611 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1614 MessageParameterListOpt
1615 : MessageParameterList { $$ = $1; }
1619 MessageParameterList
1620 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1624 : MessageParameterList { $$ = $1; }
1625 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1628 ClassMessageDeclaration
1629 : MessageScope TypeOpt MessageParameters Brace FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1632 ClassMessageDeclarationListOpt
1633 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1634 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1639 : Identifier { $$ = $1; }
1640 | "(" AssignmentExpression ")" { $$ = $2; }
1644 : ClassName { $$ = $1; }
1648 // XXX: this should be AssignmentExpressionNoRight
1650 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1654 : "," ClassProtocols { $$ = $2; }
1658 ClassProtocolListOpt
1659 : "<" ClassProtocols ">" { $$ = $2; }
1664 : "@implementation" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassExpression($2, $3, $4, $5, $6); }
1668 : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1676 : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1680 : ClassExpression { $$ = $1; }
1684 : ClassStatement { $$ = $1; }
1685 | CategoryStatement { $$ = $1; }
1688 /* Cycript (Objective-C): Send Message {{{ */
1690 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1695 : SelectorCall { $$ = $1; }
1696 | VariadicCall { $$ = $1; }
1700 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1701 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1705 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1709 : SelectorCall { $$ = $1; }
1710 | Word { $$ = CYNew CYArgument($1, NULL); }
1714 : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($2, $4); }
1715 | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = CYNew CYSendSuper($5); }
1718 SelectorExpressionOpt
1719 : SelectorExpression_ { $$ = $1; }
1724 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1728 : SelectorExpression_ { $$ = $1; }
1729 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1733 : MessageExpression { $$ = $1; }
1734 | "@selector" "(" SelectorExpression ")" { $$ = CYNew CYSelector($3); }
1737 /* Cycript (Objective-C): @import Directive {{{ */
1751 : "@import" ImportPath { $$ = CYNew CYImport(); }
1757 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1758 UnaryAssigneeExpression
1759 : "*" UnaryExpressionNoRE { $$ = CYNew CYIndirect($2); }
1763 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1767 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1768 | "->" Identifier { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1769 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1774 /* YUI: Documentation Comments {{{ */
1776 : Comment { $$ = $1; }
1781 /* Lexer State {{{ */
1783 : { driver.PushCondition(CYDriver::RegExpCondition); }
1787 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1791 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1795 : { driver.PopCondition(); }
1799 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1803 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1812 /* 8.1 Context Keywords {{{ */
1814 : "namespace" { $$ = $1; }
1815 | "xml" { $$ = $1; }
1818 /* 8.3 XML Initialiser Input Elements {{{ */
1820 : XMLComment { $$ = $1; }
1821 | XMLCDATA { $$ = $1; }
1822 | XMLPI { $$ = $1; }
1825 /* 11.1 Primary Expressions {{{ */
1827 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1828 | XMLInitialiser { $$ = $1; }
1829 | XMLListInitialiser { $$ = $1; }
1833 : AttributeIdentifier { $$ = $1; }
1834 | QualifiedIdentifier { $$ = $1; }
1835 | WildcardIdentifier { $$ = $1; }
1838 /* 11.1.1 Attribute Identifiers {{{ */
1840 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1844 : PropertySelector { $$ = $1; }
1845 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
1849 : Identifier { $$ = CYNew CYSelector($1); }
1850 | WildcardIdentifier { $$ = $1; }
1853 /* 11.1.2 Qualified Identifiers {{{ */
1854 QualifiedIdentifier_
1855 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1856 | QualifiedIdentifier { $$ = $1; }
1860 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1863 /* 11.1.3 Wildcard Identifiers {{{ */
1865 : "*" { $$ = CYNew CYWildcard(); }
1868 /* 11.1.4 XML Initialiser {{{ */
1870 : XMLMarkup { $$ = $1; }
1871 | XMLElement { $$ = $1; }
1875 : "<" XMLTagContent "/>" LexPop
1876 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1880 : LexPushXMLTag XMLTagName XMLAttributes
1884 : Brace LexPushRegExp Expression "}" LexPop
1893 : XMLAttributes_ XMLAttribute
1898 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1899 | XMLAttributes_ XMLWhitespaceOpt
1908 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1912 : XMLExpression XMLElementContentOpt
1913 | XMLMarkup XMLElementContentOpt
1914 | XMLText XMLElementContentOpt
1915 | XMLElement XMLElementContentOpt
1918 XMLElementContentOpt
1923 /* 11.1.5 XMLList Initialiser {{{ */
1925 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = CYNew CYXMLList($3); }
1928 /* 11.2 Left-Hand-Side Expressions {{{ */
1930 : Identifier { $$ = $1; }
1931 | PropertyIdentifier { $$ = $1; }
1935 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1936 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1937 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1940 /* 12.1 The default xml namespace Statement {{{ */
1941 /* XXX: DefaultXMLNamespaceStatement
1942 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1946 : DefaultXMLNamespaceStatement { $$ = $1; }
1951 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1952 PropertyNameAndValueList_
1953 : "," { $$ = NULL; }
1957 /* JavaScript 1.7: Array Comprehensions {{{ */
1959 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1963 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1964 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForEachInComprehension($4, $6); }
1967 ComprehensionListOpt
1968 : ComprehensionList { $$ = $1; }
1969 | IfComprehension { $$ = $1; }
1974 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1978 : "[" AssignmentExpression ComprehensionList "]" { $$ = CYNew CYArrayComprehension($2, $3); }
1981 /* JavaScript 1.7: for each {{{ */
1983 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $6, $8); }
1986 /* JavaScript 1.7: let Expressions {{{ */
1988 : "let" "(" VariableDeclarationList ")" Expression { $$ = CYNew CYLetExpression($3, $5); }
1992 : LexSetRegExp LetExpression { $$ = $2; }
1995 /* JavaScript 1.7: let Statements {{{ */
1997 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
2005 /* JavaScript FTW: Ruby Blocks {{{ */
2006 RubyProcParameterList_
2007 : "," RubyProcParameterList { $$ = $2; }
2011 RubyProcParameterList
2012 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2017 : "|" RubyProcParameterList "|" { $$ = $2; }
2018 | "||" { $$ = NULL; }
2021 RubyProcParametersOpt
2022 : RubyProcParameters
2027 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2030 RubyProcExpressionNoOA
2031 : "{" RubyProcParameters StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2035 : RubyProcExpressionNoOA { $$ = $1; }
2038 LeftHandSideExpression
2039 : LeftHandSideExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2042 LeftHandSideExpressionNoBF
2043 : LeftHandSideExpressionNoBF RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2047 LeftHandSideExpressionNoRE
2048 : LeftHandSideExpressionNoRE RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }