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 {
 
  50 #define CYNew new($pool)
 
  53 #include "ObjectiveC/Syntax.hpp"
 
  57 #include "E4X/Syntax.hpp"
 
  66         CYDriver::Condition condition_;
 
  68         CYArgument *argument_;
 
  69         CYAssignment *assignment_;
 
  72         cy::Syntax::Catch *catch_;
 
  74         CYComprehension *comprehension_;
 
  75         CYCompound *compound_;
 
  76         CYDeclaration *declaration_;
 
  77         CYDeclarations *declarations_;
 
  79         CYExpression *expression_;
 
  82         CYForInitialiser *for_;
 
  83         CYForInInitialiser *forin_;
 
  84         CYFunctionParameter *functionParameter_;
 
  85         CYIdentifier *identifier_;
 
  92         CYProperty *property_;
 
  93         CYPropertyName *propertyName_;
 
  94         CYRubyProc *rubyProc_;
 
  95         CYStatement *statement_;
 
 102         CYClassName *className_;
 
 105         CYMessageParameter *messageParameter_;
 
 106         CYProtocol *protocol_;
 
 107         CYSelectorPart *selector_;
 
 111         CYAttribute *attribute_;
 
 112         CYPropertyIdentifier *propertyIdentifier_;
 
 113         CYSelector *selector_;
 
 118 #define YYSTYPE YYSTYPE
 
 121 @if Bison24 %code provides {
 
 122 int cylex(YYSTYPE *, cy::location *, void *);
 
 129 @if Bison23 %skeleton "lalr1.cc"
 
 130 @if Bison24 %language "C++"
 
 133     @$.begin.filename = @$.end.filename = &driver.filename_;
 
 144 %parse-param { CYDriver &driver }
 
 145 %lex-param { void *cyscanner }
 
 152 %token XMLAttributeValue
 
 154 %token XMLTagCharacters
 
 160 %token LeftRight "<>"
 
 161 %token LeftSlashRight "</>"
 
 163 %token SlashRight "/>"
 
 164 %token LeftSlash "</"
 
 166 %token ColonColon "::"
 
 167 %token PeriodPeriod ".."
 
 170 @begin E4X ObjectiveC
 
 175 %token AmpersandAmpersand "&&"
 
 176 %token AmpersandEqual "&="
 
 178 %token CarrotEqual "^="
 
 180 %token EqualEqual "=="
 
 181 %token EqualEqualEqual "==="
 
 182 %token Exclamation "!"
 
 183 %token ExclamationEqual "!="
 
 184 %token ExclamationEqualEqual "!=="
 
 186 %token HyphenEqual "-="
 
 187 %token HyphenHyphen "--"
 
 188 %token HyphenHyphen_ "\n--"
 
 189 %token HyphenRight "->"
 
 191 %token LeftEqual "<="
 
 193 %token LeftLeftEqual "<<="
 
 195 %token PercentEqual "%="
 
 198 %token PipeEqual "|="
 
 201 %token PlusEqual "+="
 
 203 %token PlusPlus_ "\n++"
 
 205 %token RightEqual ">="
 
 206 %token RightRight ">>"
 
 207 %token RightRightEqual ">>="
 
 208 %token RightRightRight ">>>"
 
 209 %token RightRightRightEqual ">>>="
 
 211 %token SlashEqual "/="
 
 213 %token StarEqual "*="
 
 222 %token <comment_> Comment
 
 225 %token CloseParen ")"
 
 228 %token OpenBrace_ "\n{"
 
 229 %token CloseBrace "}"
 
 231 %token OpenBracket "["
 
 232 %token CloseBracket "]"
 
 235 %token AtClass "@class"
 
 239 %token AtImplementation "@implementation"
 
 240 %token AtImport "@import"
 
 242 %token AtSelector "@selector"
 
 245 %token <false_> False "false"
 
 246 %token <null_> Null "null"
 
 247 %token <true_> True "true"
 
 249 // ES3/ES5/WIE/JSC Reserved
 
 250 %token <word_> Break "break"
 
 251 %token <word_> Case "case"
 
 252 %token <word_> Catch "catch"
 
 253 %token <word_> Continue "continue"
 
 254 %token <word_> Default "default"
 
 255 %token <word_> Delete "delete"
 
 256 %token <word_> Do "do"
 
 257 %token <word_> Else "else"
 
 258 %token <word_> Finally "finally"
 
 259 %token <word_> For "for"
 
 260 %token <word_> Function "function"
 
 261 %token <word_> If "if"
 
 262 %token <word_> In "in"
 
 263 %token <word_> InstanceOf "instanceof"
 
 264 %token <word_> New "new"
 
 265 %token <word_> Return "return"
 
 266 %token <word_> Switch "switch"
 
 267 %token <this_> This "this"
 
 268 %token <word_> Throw "throw"
 
 269 %token <word_> Try "try"
 
 270 %token <word_> TypeOf "typeof"
 
 271 %token <word_> Var "var"
 
 272 %token <word_> Void "void"
 
 273 %token <word_> While "while"
 
 274 %token <word_> With "with"
 
 276 // ES3/IE6 Future, ES5/JSC Reserved
 
 277 %token <word_> Debugger "debugger"
 
 279 // ES3/ES5/IE6 Future, JSC Reserved
 
 280 %token <word_> Const "const"
 
 282 // ES3/ES5/IE6/JSC Future
 
 283 %token <word_> Class "class"
 
 284 %token <word_> Enum "enum"
 
 285 %token <word_> Export "export"
 
 286 %token <word_> Extends "extends"
 
 287 %token <word_> Import "import"
 
 288 %token <word_> Super "super"
 
 290 // ES3 Future, ES5 Strict Future
 
 291 %token <identifier_> Implements "implements"
 
 292 %token <identifier_> Interface "interface"
 
 293 %token <identifier_> Package "package"
 
 294 %token <identifier_> Private "private"
 
 295 %token <identifier_> Protected "protected"
 
 296 %token <identifier_> Public "public"
 
 297 %token <identifier_> Static "static"
 
 300 %token <identifier_> Abstract "abstract"
 
 301 %token <identifier_> Boolean "boolean"
 
 302 %token <identifier_> Byte "byte"
 
 303 %token <identifier_> Char "char"
 
 304 %token <identifier_> Double "double"
 
 305 %token <identifier_> Final "final"
 
 306 %token <identifier_> Float "float"
 
 307 %token <identifier_> Goto "goto"
 
 308 %token <identifier_> Int "int"
 
 309 %token <identifier_> Long "long"
 
 310 %token <identifier_> Native "native"
 
 311 %token <identifier_> Short "short"
 
 312 %token <identifier_> Synchronized "synchronized"
 
 313 %token <identifier_> Throws "throws"
 
 314 %token <identifier_> Transient "transient"
 
 315 %token <identifier_> Volatile "volatile"
 
 318 %token <identifier_> Let "let"
 
 319 %token <identifier_> Yield "yield"
 
 322 %token <identifier_> Each "each"
 
 326 %token <identifier_> Namespace "namespace"
 
 327 %token <identifier_> XML "xml"
 
 332 %token <identifier_> Identifier_
 
 333 %token <number_> NumericLiteral
 
 334 %token <string_> StringLiteral
 
 335 %token <literal_> RegularExpressionLiteral
 
 337 %type <expression_> AdditiveExpression
 
 338 %type <expression_> AdditiveExpressionNoBF
 
 339 %type <argument_> ArgumentList
 
 340 %type <argument_> ArgumentList_
 
 341 %type <argument_> ArgumentListOpt
 
 342 %type <argument_> Arguments
 
 343 %type <literal_> ArrayLiteral
 
 344 %type <expression_> AssigneeExpression
 
 345 %type <expression_> AssigneeExpressionNoBF
 
 346 %type <expression_> AssignmentExpression
 
 347 %type <assignment_> AssignmentExpression_
 
 348 %type <expression_> AssignmentExpressionNoBF
 
 349 %type <expression_> AssignmentExpressionNoIn
 
 350 %type <expression_> BitwiseANDExpression
 
 351 %type <expression_> BitwiseANDExpressionNoBF
 
 352 %type <expression_> BitwiseANDExpressionNoIn
 
 353 %type <statement_> Block
 
 354 %type <statement_> Block_
 
 355 %type <boolean_> BooleanLiteral
 
 356 %type <expression_> BitwiseORExpression
 
 357 %type <expression_> BitwiseORExpressionNoBF
 
 358 %type <expression_> BitwiseORExpressionNoIn
 
 359 %type <expression_> BitwiseXORExpression
 
 360 %type <expression_> BitwiseXORExpressionNoBF
 
 361 %type <expression_> BitwiseXORExpressionNoIn
 
 362 %type <statement_> BreakStatement
 
 363 %type <expression_> CallExpression
 
 364 %type <expression_> CallExpressionNoBF
 
 365 %type <clause_> CaseBlock
 
 366 %type <clause_> CaseClause
 
 367 %type <clause_> CaseClausesOpt
 
 368 %type <catch_> CatchOpt
 
 369 %type <comprehension_> ComprehensionList
 
 370 %type <comprehension_> ComprehensionListOpt
 
 371 %type <expression_> ConditionalExpression
 
 372 %type <expression_> ConditionalExpressionNoBF
 
 373 %type <expression_> ConditionalExpressionNoIn
 
 374 %type <statement_> ContinueStatement
 
 375 %type <clause_> DefaultClause
 
 376 %type <statement_> DoWhileStatement
 
 377 %type <expression_> Element
 
 378 %type <expression_> ElementOpt
 
 379 %type <element_> ElementList
 
 380 %type <element_> ElementListOpt
 
 381 %type <statement_> ElseStatementOpt
 
 382 %type <statement_> EmptyStatement
 
 383 %type <expression_> EqualityExpression
 
 384 %type <expression_> EqualityExpressionNoBF
 
 385 %type <expression_> EqualityExpressionNoIn
 
 386 %type <expression_> Expression
 
 387 %type <expression_> ExpressionOpt
 
 388 %type <compound_> Expression_
 
 389 %type <expression_> ExpressionNoBF
 
 390 %type <expression_> ExpressionNoIn
 
 391 %type <compound_> ExpressionNoIn_
 
 392 %type <expression_> ExpressionNoInOpt
 
 393 %type <statement_> ExpressionStatement
 
 394 %type <finally_> FinallyOpt
 
 395 %type <comprehension_> ForComprehension
 
 396 %type <statement_> ForStatement
 
 397 %type <for_> ForStatementInitialiser
 
 398 %type <statement_> ForInStatement
 
 399 %type <forin_> ForInStatementInitialiser
 
 400 %type <functionParameter_> FormalParameterList
 
 401 %type <functionParameter_> FormalParameterList_
 
 402 %type <statement_> FunctionBody
 
 403 %type <statement_> FunctionDeclaration
 
 404 %type <expression_> FunctionExpression
 
 405 %type <identifier_> Identifier
 
 406 %type <identifier_> IdentifierOpt
 
 407 %type <comprehension_> IfComprehension
 
 408 %type <statement_> IfStatement
 
 409 %type <expression_> Initialiser
 
 410 %type <expression_> InitialiserOpt
 
 411 %type <expression_> InitialiserNoIn
 
 412 %type <expression_> InitialiserNoInOpt
 
 413 %type <statement_> IterationStatement
 
 414 %type <statement_> LabelledStatement
 
 415 %type <expression_> LeftHandSideExpression
 
 416 %type <expression_> LeftHandSideExpressionNoBF
 
 417 //%type <statement_> LetStatement
 
 418 %type <literal_> Literal
 
 419 %type <literal_> LiteralNoRE
 
 420 %type <literal_> LiteralRE
 
 421 %type <expression_> LogicalANDExpression
 
 422 %type <expression_> LogicalANDExpressionNoBF
 
 423 %type <expression_> LogicalANDExpressionNoIn
 
 424 %type <expression_> LogicalORExpression
 
 425 %type <expression_> LogicalORExpressionNoBF
 
 426 %type <expression_> LogicalORExpressionNoIn
 
 427 %type <member_> MemberAccess
 
 428 %type <expression_> MemberExpression
 
 429 %type <expression_> MemberExpression_
 
 430 %type <expression_> MemberExpressionNoBF
 
 431 %type <expression_> MultiplicativeExpression
 
 432 %type <expression_> MultiplicativeExpressionNoBF
 
 433 %type <expression_> NewExpression
 
 434 %type <expression_> NewExpression_
 
 435 %type <expression_> NewExpressionNoBF
 
 436 %type <null_> NullLiteral
 
 437 %type <literal_> ObjectLiteral
 
 438 %type <expression_> PostfixExpression
 
 439 %type <expression_> PostfixExpressionNoBF
 
 440 %type <expression_> PrimaryExpression
 
 441 %type <expression_> PrimaryExpressionNo
 
 442 %type <expression_> PrimaryExpressionNoBF
 
 443 %type <expression_> PrimaryExpressionNoRE
 
 444 %type <expression_> PrimaryExpressionBF
 
 445 %type <statement_> Program
 
 446 %type <propertyName_> PropertyName
 
 447 %type <propertyName_> PropertyName_
 
 448 %type <property_> PropertyNameAndValueList
 
 449 %type <property_> PropertyNameAndValueList_
 
 450 %type <property_> PropertyNameAndValueListOpt
 
 451 %type <expression_> RelationalExpression
 
 452 %type <infix_> RelationalExpression_
 
 453 %type <expression_> RelationalExpressionNoBF
 
 454 %type <expression_> RelationalExpressionNoIn
 
 455 %type <infix_> RelationalExpressionNoIn_
 
 456 %type <statement_> ReturnStatement
 
 457 %type <rubyProc_> RubyProcExpression
 
 458 %type <functionParameter_> RubyProcParameterList
 
 459 %type <functionParameter_> RubyProcParameterList_
 
 460 %type <functionParameter_> RubyProcParametersOpt
 
 461 %type <expression_> ShiftExpression
 
 462 %type <expression_> ShiftExpressionNoBF
 
 463 %type <statement_> SourceElement
 
 464 %type <statement_> SourceElement_
 
 465 %type <statement_> SourceElements
 
 466 %type <statement_> Statement
 
 467 %type <statement_> Statement_
 
 468 %type <statement_> StatementList
 
 469 %type <statement_> StatementListOpt
 
 470 %type <statement_> SwitchStatement
 
 471 %type <statement_> ThrowStatement
 
 472 %type <statement_> TryStatement
 
 473 %type <expression_> UnaryExpression
 
 474 %type <expression_> UnaryExpression_
 
 475 %type <expression_> UnaryExpressionNoBF
 
 476 %type <declaration_> VariableDeclaration
 
 477 %type <declaration_> VariableDeclarationNoIn
 
 478 %type <declarations_> VariableDeclarationList
 
 479 %type <declarations_> VariableDeclarationList_
 
 480 %type <declarations_> VariableDeclarationListNoIn
 
 481 %type <declarations_> VariableDeclarationListNoIn_
 
 482 %type <statement_> VariableStatement
 
 483 %type <statement_> WhileStatement
 
 484 %type <statement_> WithStatement
 
 487 %type <expression_> AssigneeExpressionNoRE
 
 488 %type <expression_> CallExpressionNoRE
 
 489 %type <expression_> LeftHandSideExpressionNoRE
 
 490 %type <expression_> MemberExpressionNoRE
 
 491 %type <expression_> NewExpressionNoRE
 
 492 %type <expression_> PostfixExpressionNoRE
 
 493 %type <expression_> UnaryAssigneeExpression
 
 494 %type <expression_> UnaryExpressionNoRE
 
 498 %type <statement_> CategoryStatement
 
 499 %type <expression_> ClassExpression
 
 500 %type <statement_> ClassStatement
 
 501 %type <expression_> ClassSuperOpt
 
 502 %type <field_> ClassFieldList
 
 503 %type <message_> ClassMessageDeclaration
 
 504 %type <message_> ClassMessageDeclarationListOpt
 
 505 %type <className_> ClassName
 
 506 %type <className_> ClassNameOpt
 
 507 %type <protocol_> ClassProtocolListOpt
 
 508 %type <protocol_> ClassProtocols
 
 509 %type <protocol_> ClassProtocolsOpt
 
 510 %type <expression_> MessageExpression
 
 511 %type <messageParameter_> MessageParameter
 
 512 %type <messageParameter_> MessageParameters
 
 513 %type <messageParameter_> MessageParameterList
 
 514 %type <messageParameter_> MessageParameterListOpt
 
 515 %type <bool_> MessageScope
 
 516 %type <argument_> SelectorCall
 
 517 %type <argument_> SelectorCall_
 
 518 %type <selector_> SelectorExpression
 
 519 %type <selector_> SelectorExpression_
 
 520 %type <selector_> SelectorExpressionOpt
 
 521 %type <argument_> SelectorList
 
 522 %type <word_> SelectorWordOpt
 
 523 %type <expression_> TypeOpt
 
 524 %type <argument_> VariadicCall
 
 526 %type <word_> WordOpt
 
 530 %type <propertyIdentifier_> PropertyIdentifier_
 
 531 %type <selector_> PropertySelector
 
 532 %type <selector_> PropertySelector_
 
 533 %type <identifier_> QualifiedIdentifier
 
 534 %type <identifier_> QualifiedIdentifier_
 
 535 %type <identifier_> WildcardIdentifier
 
 536 %type <identifier_> XMLComment
 
 537 %type <identifier_> XMLCDATA
 
 538 %type <identifier_> XMLElement
 
 539 %type <identifier_> XMLElementContent
 
 540 %type <identifier_> XMLMarkup
 
 541 %type <identifier_> XMLPI
 
 543 %type <attribute_> AttributeIdentifier
 
 544 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
 
 545 %type <expression_> PropertyIdentifier
 
 546 %type <expression_> XMLListInitialiser
 
 547 %type <expression_> XMLInitialiser
 
 550 %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"
 
 560 %left "<<" ">>" ">>>"
 
 561 %left "<" ">" "<=" ">=" "instanceof" "in"
 
 562 %left "==" "!=" "===" "!=="
 
 569 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
 
 575 /* Lexer State {{{ */
 
 577     : { driver.SetCondition(CYDriver::RegExpCondition); }
 
 587     : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
 
 597     | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
 
 602     | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
 
 622     : Identifier { $$ = $1; }
 
 623     | "break" NewLineOpt { $$ = $1; }
 
 624     | "case" { $$ = $1; }
 
 625     | "catch" { $$ = $1; }
 
 626     | "class" { $$ = $1; }
 
 627     | "const" { $$ = $1; }
 
 628     | "continue" NewLineOpt { $$ = $1; }
 
 629     | "debugger" { $$ = $1; }
 
 630     | "default" { $$ = $1; }
 
 631     | "delete" { $$ = $1; }
 
 633     | "else" { $$ = $1; }
 
 634     | "enum" { $$ = $1; }
 
 635     | "export" { $$ = $1; }
 
 636     | "extends" { $$ = $1; }
 
 637     | "false" { $$ = $1; }
 
 638     | "finally" { $$ = $1; }
 
 639     /* XXX: | "for" { $$ = $1; } */
 
 640     | "function" { $$ = $1; }
 
 642     | "import" { $$ = $1; }
 
 643     /* XXX: | "in" { $$ = $1; } */
 
 644     /* XXX: | "instanceof" { $$ = $1; } */
 
 646     | "null" { $$ = $1; }
 
 647     | "return" NewLineOpt { $$ = $1; }
 
 648     | "super" { $$ = $1; }
 
 649     | "switch" { $$ = $1; }
 
 650     | "this" { $$ = $1; }
 
 651     | "throw" NewLineOpt { $$ = $1; }
 
 652     | "true" { $$ = $1; }
 
 654     | "typeof" { $$ = $1; }
 
 656     | "void" { $$ = $1; }
 
 657     | "while" { $$ = $1; }
 
 658     | "with" { $$ = $1; }
 
 663     : Identifier_ { $$ = $1; }
 
 665     | "implements" { $$ = $1; }
 
 666     | "interface" { $$ = $1; }
 
 667     | "package" { $$ = $1; }
 
 668     | "private" { $$ = $1; }
 
 669     | "protected" { $$ = $1; }
 
 670     | "public" { $$ = $1; }
 
 671     | "static" { $$ = $1; }
 
 673     | "abstract" { $$ = $1; }
 
 674     | "boolean" { $$ = $1; }
 
 675     | "byte" { $$ = $1; }
 
 676     | "char" { $$ = $1; }
 
 677     | "double" { $$ = $1; }
 
 678     | "final" { $$ = $1; }
 
 679     | "float" { $$ = $1; }
 
 680     | "goto" { $$ = $1; }
 
 682     | "long" { $$ = $1; }
 
 683     | "native" { $$ = $1; }
 
 684     | "short" { $$ = $1; }
 
 685     | "synchronized" { $$ = $1; }
 
 686     | "throws" { $$ = $1; }
 
 687     | "transient" { $$ = $1; }
 
 688     | "volatile" { $$ = $1; }
 
 691     | "yield" { $$ = $1; }
 
 693     | "each" { $$ = $1; }
 
 697     : Identifier { $$ = $1; }
 
 702     : NullLiteral { $$ = $1; }
 
 703     | BooleanLiteral { $$ = $1; }
 
 704     | NumericLiteral { $$ = $1; }
 
 705     | StringLiteral { $$ = $1; }
 
 706     | "@" StringLiteral { $$ = $2; }
 
 710     : RegularExpressionLiteral { $$ = $1; }
 
 714     : LiteralNoRE { $$ = $1; }
 
 715     | LiteralRE { $$ = $1; }
 
 719     : "null" { $$ = $1; }
 
 723     : "true" { $$ = $1; }
 
 724     | "false" { $$ = $1; }
 
 727 /* 11.1 Primary Expressions {{{ */
 
 729     : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
 
 732 PrimaryExpressionNoBF
 
 733     : PrimaryExpressionNo { $$ = $1; }
 
 736 PrimaryExpressionNoRE
 
 737     : PrimaryExpressionBF { $$ = $1; }
 
 738     | PrimaryExpressionNo { $$ = $1; }
 
 742     : "this" { $$ = $1; }
 
 743     | Identifier { $$ = CYNew CYVariable($1); }
 
 744     | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
 
 745     | Literal { $$ = $1; }
 
 746     | ArrayLiteral { $$ = $1; }
 
 747     | "(" Expression ")" { $$ = $2; }
 
 751     : ObjectLiteral { $$ = $1; }
 
 754 /* 11.1.4 Array Initialiser {{{ */
 
 756     : "[" ElementListOpt "]" { $$ = CYNew CYArray($2); }
 
 760     : AssignmentExpression { $$ = $1; }
 
 764     : Element { $$ = $1; }
 
 765     | LexSetRegExp { $$ = NULL; }
 
 769     : ElementList { $$ = $1; }
 
 770     | LexSetRegExp { $$ = NULL; }
 
 774     : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
 
 775     | Element { $$ = CYNew CYElement($1, NULL); }
 
 778 /* 11.1.5 Object Initialiser {{{ */
 
 780     : OpenBrace PropertyNameAndValueListOpt "}" { $$ = CYNew CYObject($2); }
 
 783 PropertyNameAndValueList_
 
 784     : "," PropertyNameAndValueList { $$ = $2; }
 
 788 PropertyNameAndValueListOpt
 
 789     : PropertyNameAndValueList { $$ = $1; }
 
 793 PropertyNameAndValueList
 
 794     : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = CYNew CYProperty($1, $3, $4); }
 
 798     : Identifier { $$ = $1; }
 
 799     | StringLiteral { $$ = $1; }
 
 800     | NumericLiteral { $$ = $1; }
 
 804     : LexSetRegExp PropertyName_ { $$ = $2; }
 
 808 /* 11.2 Left-Hand-Side Expressions {{{ */
 
 810     : "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($2, $3); }
 
 814     : "[" Expression "]" { $$ = CYNew CYDirectMember(NULL, $2); }
 
 815     | "." Identifier { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
 
 816     | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
 
 820     : PrimaryExpression { $$ = $1; }
 
 821     | LexSetRegExp FunctionExpression { $$ = $2; }
 
 822     | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 823     | LexSetRegExp MemberExpression_ { $$ = $2; }
 
 827     : PrimaryExpressionNoBF { $$ = $1; }
 
 828     | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 829     | MemberExpression_ { $$ = $1; }
 
 834     : PrimaryExpressionNoRE { $$ = $1; }
 
 835     | FunctionExpression { $$ = $1; }
 
 836     | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 837     | MemberExpression_ { $$ = $1; }
 
 842     : "new" NewExpression { $$ = CYNew cy::Syntax::New($2, NULL); }
 
 846     : MemberExpression { $$ = $1; }
 
 847     | LexSetRegExp NewExpression_ { $$ = $2; }
 
 851     : MemberExpressionNoBF { $$ = $1; }
 
 852     | NewExpression_ { $$ = $1; }
 
 857     : MemberExpressionNoRE { $$ = $1; }
 
 858     | NewExpression_ { $$ = $1; }
 
 863     : MemberExpression Arguments { $$ = CYNew CYCall($1, $2); }
 
 864     | CallExpression Arguments { $$ = CYNew CYCall($1, $2); }
 
 865     | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 869     : MemberExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
 
 870     | CallExpressionNoBF Arguments { $$ = CYNew CYCall($1, $2); }
 
 871     | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 876     : MemberExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
 
 877     | CallExpressionNoRE Arguments { $$ = CYNew CYCall($1, $2); }
 
 878     | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 883     : "," ArgumentList { $$ = $2; }
 
 888     : ArgumentList { $$ = $1; }
 
 889     | LexSetRegExp { $$ = NULL; }
 
 893     : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
 
 897     : "(" ArgumentListOpt ")" { $$ = $2; }
 
 900 LeftHandSideExpression
 
 901     : NewExpression { $$ = $1; }
 
 902     | CallExpression { $$ = $1; }
 
 905 LeftHandSideExpressionNoBF
 
 906     : NewExpressionNoBF { $$ = $1; }
 
 907     | CallExpressionNoBF { $$ = $1; }
 
 911 LeftHandSideExpressionNoRE
 
 912     : NewExpressionNoRE { $$ = $1; }
 
 913     | CallExpressionNoRE { $$ = $1; }
 
 917 /* 11.3 Postfix Expressions {{{ */
 
 919     : AssigneeExpression { $$ = $1; }
 
 920     | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
 
 921     | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
 
 924 PostfixExpressionNoBF
 
 925     : AssigneeExpressionNoBF { $$ = $1; }
 
 926     | LeftHandSideExpressionNoBF "++" { $$ = CYNew CYPostIncrement($1); }
 
 927     | LeftHandSideExpressionNoBF "--" { $$ = CYNew CYPostDecrement($1); }
 
 931 PostfixExpressionNoRE
 
 932     : AssigneeExpressionNoRE { $$ = $1; }
 
 933     | LeftHandSideExpressionNoRE "++" { $$ = CYNew CYPostIncrement($1); }
 
 934     | LeftHandSideExpressionNoRE "--" { $$ = CYNew CYPostDecrement($1); }
 
 938 /* 11.4 Unary Operators {{{ */
 
 940     : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
 
 941     | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
 
 942     | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
 
 943     | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 944     | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 945     | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 946     | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 947     | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
 
 948     | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
 
 949     | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
 
 950     | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
 
 954     : PostfixExpression { $$ = $1; }
 
 955     | LexSetRegExp UnaryExpression_ { $$ = $2; }
 
 959     : PostfixExpressionNoBF { $$ = $1; }
 
 960     | UnaryExpression_ { $$ = $1; }
 
 965     : PostfixExpressionNoRE { $$ = $1; }
 
 966     | UnaryExpression_ { $$ = $1; }
 
 970 /* 11.5 Multiplicative Operators {{{ */
 
 971 MultiplicativeExpression
 
 972     : UnaryExpression { $$ = $1; }
 
 973     | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
 
 974     | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
 
 975     | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
 
 978 MultiplicativeExpressionNoBF
 
 979     : UnaryExpressionNoBF { $$ = $1; }
 
 980     | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
 
 981     | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
 
 982     | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
 
 985 /* 11.6 Additive Operators {{{ */
 
 987     : MultiplicativeExpression { $$ = $1; }
 
 988     | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
 
 989     | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
 
 992 AdditiveExpressionNoBF
 
 993     : MultiplicativeExpressionNoBF { $$ = $1; }
 
 994     | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
 
 995     | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
 
 998 /* 11.7 Bitwise Shift Operators {{{ */
 
1000     : AdditiveExpression { $$ = $1; }
 
1001     | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
 
1002     | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
 
1003     | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
 
1007     : AdditiveExpressionNoBF { $$ = $1; }
 
1008     | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
 
1009     | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
 
1010     | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
 
1013 /* 11.8 Relational Operators {{{ */
 
1014 RelationalExpressionNoIn_
 
1015     : "<" ShiftExpression { $$ = CYNew CYLess(NULL, $2); }
 
1016     | ">" ShiftExpression { $$ = CYNew CYGreater(NULL, $2); }
 
1017     | "<=" ShiftExpression { $$ = CYNew CYLessOrEqual(NULL, $2); }
 
1018     | ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual(NULL, $2); }
 
1019     | "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf(NULL, $2); }
 
1022 RelationalExpression_
 
1023     : RelationalExpressionNoIn_ { $$ = $1; }
 
1024     | "in" ShiftExpression { $$ = CYNew CYIn(NULL, $2); }
 
1027 RelationalExpression
 
1028     : ShiftExpression { $$ = $1; }
 
1029     | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
 
1032 RelationalExpressionNoIn
 
1033     : ShiftExpression { $$ = $1; }
 
1034     | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
 
1037 RelationalExpressionNoBF
 
1038     : ShiftExpressionNoBF { $$ = $1; }
 
1039     | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
 
1042 /* 11.9 Equality Operators {{{ */
 
1044     : RelationalExpression { $$ = $1; }
 
1045     | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
 
1046     | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
 
1047     | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
 
1048     | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
 
1051 EqualityExpressionNoIn
 
1052     : RelationalExpressionNoIn { $$ = $1; }
 
1053     | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = CYNew CYEqual($1, $3); }
 
1054     | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = CYNew CYNotEqual($1, $3); }
 
1055     | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = CYNew CYIdentical($1, $3); }
 
1056     | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = CYNew CYNotIdentical($1, $3); }
 
1059 EqualityExpressionNoBF
 
1060     : RelationalExpressionNoBF { $$ = $1; }
 
1061     | EqualityExpressionNoBF "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
 
1062     | EqualityExpressionNoBF "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
 
1063     | EqualityExpressionNoBF "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
 
1064     | EqualityExpressionNoBF "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
 
1067 /* 11.10 Binary Bitwise Operators {{{ */
 
1068 BitwiseANDExpression
 
1069     : EqualityExpression { $$ = $1; }
 
1070     | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1073 BitwiseANDExpressionNoIn
 
1074     : EqualityExpressionNoIn { $$ = $1; }
 
1075     | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1078 BitwiseANDExpressionNoBF
 
1079     : EqualityExpressionNoBF { $$ = $1; }
 
1080     | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1083 BitwiseXORExpression
 
1084     : BitwiseANDExpression { $$ = $1; }
 
1085     | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1088 BitwiseXORExpressionNoIn
 
1089     : BitwiseANDExpressionNoIn { $$ = $1; }
 
1090     | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1093 BitwiseXORExpressionNoBF
 
1094     : BitwiseANDExpressionNoBF { $$ = $1; }
 
1095     | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1099     : BitwiseXORExpression { $$ = $1; }
 
1100     | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
 
1103 BitwiseORExpressionNoIn
 
1104     : BitwiseXORExpressionNoIn { $$ = $1; }
 
1105     | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = CYNew CYBitwiseOr($1, $3); }
 
1108 BitwiseORExpressionNoBF
 
1109     : BitwiseXORExpressionNoBF { $$ = $1; }
 
1110     | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
 
1113 /* 11.11 Binary Logical Operators {{{ */
 
1114 LogicalANDExpression
 
1115     : BitwiseORExpression { $$ = $1; }
 
1116     | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
 
1119 LogicalANDExpressionNoIn
 
1120     : BitwiseORExpressionNoIn { $$ = $1; }
 
1121     | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = CYNew CYLogicalAnd($1, $3); }
 
1124 LogicalANDExpressionNoBF
 
1125     : BitwiseORExpressionNoBF { $$ = $1; }
 
1126     | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
 
1130     : LogicalANDExpression { $$ = $1; }
 
1131     | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
 
1134 LogicalORExpressionNoIn
 
1135     : LogicalANDExpressionNoIn { $$ = $1; }
 
1136     | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = CYNew CYLogicalOr($1, $3); }
 
1139 LogicalORExpressionNoBF
 
1140     : LogicalANDExpressionNoBF { $$ = $1; }
 
1141     | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
 
1144 /* 11.12 Conditional Operator ( ? : ) {{{ */
 
1145 ConditionalExpression
 
1146     : LogicalORExpression { $$ = $1; }
 
1147     | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
 
1150 ConditionalExpressionNoIn
 
1151     : LogicalORExpressionNoIn { $$ = $1; }
 
1152     | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = CYNew CYCondition($1, $3, $5); }
 
1155 ConditionalExpressionNoBF
 
1156     : LogicalORExpressionNoBF { $$ = $1; }
 
1157     | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = CYNew CYCondition($1, $3, $5); }
 
1160 /* 11.13 Assignment Operators {{{ */
 
1161 AssignmentExpression_
 
1162     : "=" AssignmentExpression { $$ = CYNew CYAssign(NULL, $2); }
 
1163     | "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign(NULL, $2); }
 
1164     | "/=" AssignmentExpression { $$ = CYNew CYDivideAssign(NULL, $2); }
 
1165     | "%=" AssignmentExpression { $$ = CYNew CYModulusAssign(NULL, $2); }
 
1166     | "+=" AssignmentExpression { $$ = CYNew CYAddAssign(NULL, $2); }
 
1167     | "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign(NULL, $2); }
 
1168     | "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign(NULL, $2); }
 
1169     | ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign(NULL, $2); }
 
1170     | ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign(NULL, $2); }
 
1171     | "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign(NULL, $2); }
 
1172     | "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign(NULL, $2); }
 
1173     | "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign(NULL, $2); }
 
1177     : LeftHandSideExpression { $$ = $1; }
 
1179     | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
 
1183 AssigneeExpressionNoBF
 
1184     : LeftHandSideExpressionNoBF { $$ = $1; }
 
1186     | UnaryAssigneeExpression { $$ = $1; }
 
1191 AssigneeExpressionNoRE
 
1192     : LeftHandSideExpressionNoRE { $$ = $1; }
 
1193     | UnaryAssigneeExpression { $$ = $1; }
 
1197 AssignmentExpression
 
1198     : ConditionalExpression { $$ = $1; }
 
1199     | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
 
1202 AssignmentExpressionNoIn
 
1203     : ConditionalExpressionNoIn { $$ = $1; }
 
1204     | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = CYNew CYAssign($1, $3); }
 
1205     | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = CYNew CYMultiplyAssign($1, $3); }
 
1206     | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = CYNew CYDivideAssign($1, $3); }
 
1207     | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = CYNew CYModulusAssign($1, $3); }
 
1208     | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = CYNew CYAddAssign($1, $3); }
 
1209     | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = CYNew CYSubtractAssign($1, $3); }
 
1210     | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = CYNew CYShiftLeftAssign($1, $3); }
 
1211     | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
 
1212     | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
 
1213     | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseAndAssign($1, $3); }
 
1214     | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
 
1215     | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = CYNew CYBitwiseOrAssign($1, $3); }
 
1218 AssignmentExpressionNoBF
 
1219     : ConditionalExpressionNoBF { $$ = $1; }
 
1220     | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
 
1223 /* 11.14 Comma Operator {{{ */
 
1225     : "," Expression { $$ = CYNew CYCompound($2); }
 
1230     : "," ExpressionNoIn { $$ = CYNew CYCompound($2); }
 
1235     : Expression { $$ = $1; }
 
1236     | LexSetRegExp { $$ = NULL; }
 
1240     : ExpressionNoIn { $$ = $1; }
 
1241     | LexSetRegExp { $$ = NULL; }
 
1245     : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
 
1249     : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
 
1253     : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
 
1257 /* 12 Statements {{{ */
 
1259     : Block { $$ = $1; }
 
1260     | VariableStatement { $$ = $1; }
 
1261     | EmptyStatement { $$ = $1; }
 
1262     | ExpressionStatement { $$ = $1; }
 
1263     | IfStatement { $$ = $1; }
 
1264     | IterationStatement { $$ = $1; }
 
1265     | ContinueStatement { $$ = $1; }
 
1266     | BreakStatement { $$ = $1; }
 
1267     | ReturnStatement { $$ = $1; }
 
1268     | WithStatement { $$ = $1; }
 
1269     | LabelledStatement { $$ = $1; }
 
1270     | SwitchStatement { $$ = $1; }
 
1271     | ThrowStatement { $$ = $1; }
 
1272     | TryStatement { $$ = $1; }
 
1276     : LexSetRegExp Statement_ { $$ = $2; }
 
1279 /* 12.1 Block {{{ */
 
1281     : Brace StatementListOpt "}" { $$ = $2; }
 
1285     : Block_ { if ($1) $$ = CYNew CYBlock($1); else $$ = CYNew CYEmpty(); }
 
1289     : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
 
1293     : StatementList { $$ = $1; }
 
1294     | LexSetRegExp { $$ = NULL; }
 
1297 /* 12.2 Variable Statement {{{ */
 
1299     : "var" VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1302 VariableDeclarationList_
 
1303     : "," VariableDeclarationList { $$ = $2; }
 
1307 VariableDeclarationListNoIn_
 
1308     : "," VariableDeclarationListNoIn { $$ = $2; }
 
1312 VariableDeclarationList
 
1313     : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
 
1316 VariableDeclarationListNoIn
 
1317     : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = CYNew CYDeclarations($1, $2); }
 
1321     : Identifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1324 VariableDeclarationNoIn
 
1325     : Identifier InitialiserNoInOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1329     : Initialiser { $$ = $1; }
 
1334     : InitialiserNoIn { $$ = $1; }
 
1339     : "=" AssignmentExpression { $$ = $2; }
 
1343     : "=" AssignmentExpressionNoIn { $$ = $2; }
 
1346 /* 12.3 Empty Statement {{{ */
 
1348     : ";" { $$ = CYNew CYEmpty(); }
 
1351 /* 12.4 Expression Statement {{{ */
 
1353     : ExpressionNoBF Terminator { $$ = CYNew CYExpress($1); }
 
1356 /* 12.5 The if Statement {{{ */
 
1358     : "else" Statement { $$ = $2; }
 
1359     | %prec "if" { $$ = NULL; }
 
1363     : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
 
1367 /* 12.6 Iteration Statements {{{ */
 
1369     : DoWhileStatement { $$ = $1; }
 
1370     | WhileStatement { $$ = $1; }
 
1371     | ForStatement { $$ = $1; }
 
1372     | ForInStatement { $$ = $1; }
 
1375 /* 12.6.1 The do-while Statement {{{ */
 
1377     : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
 
1380 /* 12.6.2 The while Statement {{{ */
 
1382     : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
 
1385 /* 12.6.3 The for Statement {{{ */
 
1387     : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($3, $5, $7, $9); }
 
1390 ForStatementInitialiser
 
1391     : ExpressionNoInOpt { $$ = $1; }
 
1392     | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
 
1395 /* 12.6.4 The for-in Statement {{{ */
 
1397     : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForIn($3, $5, $7); }
 
1400 ForInStatementInitialiser
 
1401     : LeftHandSideExpression { $$ = $1; }
 
1402     | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
 
1406 /* 12.7 The continue Statement {{{ */
 
1408     : "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
 
1411 /* 12.8 The break Statement {{{ */
 
1413     : "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
 
1416 /* 12.9 The return Statement {{{ */
 
1418     : "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
 
1421 /* 12.10 The with Statement {{{ */
 
1423     : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
 
1427 /* 12.11 The switch Statement {{{ */
 
1429     : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
 
1433     : Brace CaseClausesOpt "}" { $$ = $2; }
 
1437     : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1438     | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1443     : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
 
1447     : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
 
1450 /* 12.12 Labelled Statements {{{ */
 
1452     : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
 
1455 /* 12.13 The throw Statement {{{ */
 
1457     : "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
 
1460 /* 12.14 The try Statement {{{ */
 
1462     : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
 
1466     : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
 
1471     : "finally" Block_ { $$ = CYNew CYFinally($2); }
 
1476 /* 13 Function Definition {{{ */
 
1478     : "function" Identifier "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
 
1482     : "function" IdentifierOpt "(" FormalParameterList ")" Brace FunctionBody "}" { $$ = CYNew CYFunctionExpression($2, $4, $7); }
 
1485 FormalParameterList_
 
1486     : "," FormalParameterList { $$ = $2; }
 
1491     : Identifier FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
 
1496     : SourceElements { $$ = $1; }
 
1499 /* 14 Program {{{ */
 
1501     : SourceElements { driver.program_ = CYNew CYProgram($1); }
 
1505     : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
 
1506     | LexSetRegExp { $$ = NULL; }
 
1510     : Statement_ { $$ = $1; }
 
1511     | FunctionDeclaration { $$ = $1; }
 
1515     : LexSetRegExp SourceElement_ { $$ = $2; }
 
1520 /* Cycript (Objective-C): @class Declaration {{{ */
 
1522     /* XXX: why the hell did I choose MemberExpressionNoBF? */
 
1523     : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
 
1528     : Expression Identifier ";"
 
1532     : ClassFieldListOpt ClassField
 
1537     : Brace ClassFieldListOpt "}" { $$ = NULL; }
 
1541     : "+" { $$ = false; }
 
1542     | "-" { $$ = true; }
 
1546     : "(" Expression ")" { $$ = $2; }
 
1547     | "(" LexSetRegExp "void" ")" { $$ = NULL; }
 
1552     : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
 
1555 MessageParameterListOpt
 
1556     : MessageParameterList { $$ = $1; }
 
1560 MessageParameterList
 
1561     : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
 
1565     : MessageParameterList { $$ = $1; }
 
1566     | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
 
1569 ClassMessageDeclaration
 
1570     : MessageScope TypeOpt MessageParameters Brace FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
 
1573 ClassMessageDeclarationListOpt
 
1574     : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
 
1575     | ClassMessageDeclarationListOpt Comment { $$ = $1; }
 
1580     : Identifier { $$ = $1; }
 
1581     | "(" AssignmentExpression ")" { $$ = $2; }
 
1585     : ClassName { $$ = $1; }
 
1589 // XXX: this should be AssignmentExpressionNoRight
 
1591     : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
 
1595     : "," ClassProtocols { $$ = $2; }
 
1599 ClassProtocolListOpt
 
1600     : "<" ClassProtocols ">" { $$ = $2; }
 
1605     : "@implementation" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassExpression($2, $3, $4, $5, $6); }
 
1609     : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
 
1617     : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
 
1621     : ClassExpression { $$ = $1; }
 
1625     : ClassStatement { $$ = $1; }
 
1626     | CategoryStatement { $$ = $1; }
 
1629 /* Cycript (Objective-C): Send Message {{{ */
 
1631     : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
 
1636     : SelectorCall { $$ = $1; }
 
1637     | VariadicCall { $$ = $1; }
 
1641     : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
 
1642     | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
 
1646     : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
 
1650     : SelectorCall { $$ = $1; }
 
1651     | Word { $$ = CYNew CYArgument($1, NULL); }
 
1655     : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($2, $4); }
 
1656     | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = CYNew CYSendSuper($5); }
 
1659 SelectorExpressionOpt
 
1660     : SelectorExpression_ { $$ = $1; }
 
1665     : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
 
1669     : SelectorExpression_ { $$ = $1; }
 
1670     | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
 
1674     : MessageExpression { $$ = $1; }
 
1675     | "@selector" "(" SelectorExpression ")" { $$ = CYNew CYSelector($3); }
 
1678 /* Cycript (Objective-C): @import Directive {{{ */
 
1692     : "@import" ImportPath { $$ = CYNew CYImport(); }
 
1698 /* Cycript (C): Pointer Indirection/Addressing {{{ */
 
1699 UnaryAssigneeExpression
 
1700     : "*" UnaryExpressionNoRE { $$ = CYNew CYIndirect($2); }
 
1704     : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
 
1708     : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
 
1709     | "->" Identifier { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
 
1710     | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
 
1715 /* YUI: Documentation Comments {{{ */
 
1717     : Comment { $$ = $1; }
 
1722 /* Lexer State {{{ */
 
1724     : { driver.PushCondition(CYDriver::RegExpCondition); }
 
1728     : { driver.PushCondition(CYDriver::XMLContentCondition); }
 
1732     : { driver.PushCondition(CYDriver::XMLTagCondition); }
 
1736     : { driver.PopCondition(); }
 
1740     : { driver.SetCondition(CYDriver::XMLContentCondition); }
 
1744     : { driver.SetCondition(CYDriver::XMLTagCondition); }
 
1753 /* 8.1 Context Keywords {{{ */
 
1755     : "namespace" { $$ = $1; }
 
1756     | "xml" { $$ = $1; }
 
1759 /* 8.3 XML Initialiser Input Elements {{{ */
 
1761     : XMLComment { $$ = $1; }
 
1762     | XMLCDATA { $$ = $1; }
 
1763     | XMLPI { $$ = $1; }
 
1766 /* 11.1 Primary Expressions {{{ */
 
1768     : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
 
1769     | XMLInitialiser { $$ = $1; }
 
1770     | XMLListInitialiser { $$ = $1; }
 
1774     : AttributeIdentifier { $$ = $1; }
 
1775     | QualifiedIdentifier { $$ = $1; }
 
1776     | WildcardIdentifier { $$ = $1; }
 
1779 /* 11.1.1 Attribute Identifiers {{{ */
 
1781     : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
 
1785     : PropertySelector { $$ = $1; }
 
1786     | "[" Expression "]" { $$ = CYNew CYSelector($2); }
 
1790     : Identifier { $$ = CYNew CYSelector($1); }
 
1791     | WildcardIdentifier { $$ = $1; }
 
1794 /* 11.1.2 Qualified Identifiers {{{ */
 
1795 QualifiedIdentifier_
 
1796     : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
 
1797     | QualifiedIdentifier { $$ = $1; }
 
1801     : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
 
1804 /* 11.1.3 Wildcard Identifiers {{{ */
 
1806     : "*" { $$ = CYNew CYWildcard(); }
 
1809 /* 11.1.4 XML Initialiser {{{ */
 
1811     : XMLMarkup { $$ = $1; }
 
1812     | XMLElement { $$ = $1; }
 
1816     : "<" XMLTagContent "/>" LexPop
 
1817     | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
 
1821     : LexPushXMLTag XMLTagName XMLAttributes
 
1825     : Brace LexPushRegExp Expression "}" LexPop
 
1834     : XMLAttributes_ XMLAttribute
 
1839     : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
 
1840     | XMLAttributes_ XMLWhitespaceOpt
 
1849     : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
 
1853     : XMLExpression XMLElementContentOpt
 
1854     | XMLMarkup XMLElementContentOpt
 
1855     | XMLText XMLElementContentOpt
 
1856     | XMLElement XMLElementContentOpt
 
1859 XMLElementContentOpt
 
1864 /* 11.1.5 XMLList Initialiser {{{ */
 
1866     : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = CYNew CYXMLList($3); }
 
1869 /* 11.2 Left-Hand-Side Expressions {{{ */
 
1871     : Identifier { $$ = $1; }
 
1872     | PropertyIdentifier { $$ = $1; }
 
1876     : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
 
1877     | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
 
1878     | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
 
1881 /* 12.1 The default xml namespace Statement {{{ */
 
1882 /* XXX: DefaultXMLNamespaceStatement
 
1883     : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
 
1887     : DefaultXMLNamespaceStatement { $$ = $1; }
 
1892 /* ECMAScript5: Object Literal Trailing Comma {{{ */
 
1893 PropertyNameAndValueList_
 
1894     : "," { $$ = NULL; }
 
1898 /* JavaScript 1.7: Array Comprehensions {{{ */
 
1900     : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
 
1904     : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
 
1905     | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForEachInComprehension($4, $6); }
 
1908 ComprehensionListOpt
 
1909     : ComprehensionList { $$ = $1; }
 
1910     | IfComprehension { $$ = $1; }
 
1915     : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
 
1919     : "[" AssignmentExpression ComprehensionList "]" { $$ = CYNew CYArrayComprehension($2, $3); }
 
1922 /* JavaScript 1.7: for each {{{ */
 
1924     : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = CYNew CYForEachIn($4, $6, $8); }
 
1927 /* JavaScript 1.7: let Statements {{{ *//*
 
1929     : "let" "(" VariableDeclarationList ")" Block_ { $$ = CYNew CYLet($3, $5); }
 
1937 /* JavaScript FTW: Function Statements {{{ */
 
1939     : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }
 
1942 /* JavaScript FTW: Optional Arguments {{{ */
 
1944     : Identifier "=" AssignmentExpression FormalParameterList_ { $$ = CYNew CYOptionalFunctionParameter($1, $3, $4); }
 
1947 /* JavaScript FTW: Ruby Blocks {{{ */
 
1948 RubyProcParameterList_
 
1949     : "," RubyProcParameterList { $$ = $2; }
 
1953 RubyProcParameterList
 
1954     : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
 
1958 RubyProcParametersOpt
 
1959     : "|" RubyProcParameterList "|" { $$ = $2; }
 
1964     : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
 
1967 LeftHandSideExpression
 
1968     : LeftHandSideExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
 
1971 LeftHandSideExpressionNoBF
 
1972     : LeftHandSideExpressionNoBF RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
 
1976 LeftHandSideExpressionNoRE
 
1977     : LeftHandSideExpressionNoRE RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }