1 /* Cycript - Optimizing JavaScript Compiler/Runtime
 
   2  * Copyright (C) 2009-2015  Jay Freeman (saurik)
 
   5 /* GNU Affero General Public License, Version 3 {{{ */
 
   7  * This program is free software: you can redistribute it and/or modify
 
   8  * it under the terms of the GNU Affero General Public License as published by
 
   9  * the Free Software Foundation, either version 3 of the License, or
 
  10  * (at your option) any later version.
 
  12  * This program is distributed in the hope that it will be useful,
 
  13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  15  * GNU Affero General Public License for more details.
 
  17  * You should have received a copy of the GNU Affero General Public License
 
  18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
  23 #define cyscanner driver.scanner_
 
  24 #define YYSTACKEXPANDABLE 1
 
  31 #define CYNew new(driver.pool_)
 
  34 #include "ObjectiveC/Syntax.hpp"
 
  38 #include "E4X/Syntax.hpp"
 
  41 #include "Highlight.hpp"
 
  44 %union { bool bool_; }
 
  46 %union { CYArgument *argument_; }
 
  47 %union { CYAssignment *assignment_; }
 
  48 %union { CYBoolean *boolean_; }
 
  49 %union { CYClause *clause_; }
 
  50 %union { cy::Syntax::Catch *catch_; }
 
  51 %union { CYComprehension *comprehension_; }
 
  52 %union { CYDeclaration *declaration_; }
 
  53 %union { CYDeclarations *declarations_; }
 
  54 %union { CYElement *element_; }
 
  55 %union { CYExpression *expression_; }
 
  56 %union { CYFalse *false_; }
 
  57 %union { CYFinally *finally_; }
 
  58 %union { CYForInitializer *for_; }
 
  59 %union { CYForInInitializer *forin_; }
 
  60 %union { CYFunctionParameter *functionParameter_; }
 
  61 %union { CYIdentifier *identifier_; }
 
  62 %union { CYInfix *infix_; }
 
  63 %union { CYLiteral *literal_; }
 
  64 %union { CYMember *member_; }
 
  65 %union { CYModule *module_; }
 
  66 %union { CYNull *null_; }
 
  67 %union { CYNumber *number_; }
 
  68 %union { CYParenthetical *parenthetical_; }
 
  69 %union { CYProperty *property_; }
 
  70 %union { CYPropertyName *propertyName_; }
 
  71 %union { CYRubyProc *rubyProc_; }
 
  72 %union { CYSpan *span_; }
 
  73 %union { CYStatement *statement_; }
 
  74 %union { CYString *string_; }
 
  75 %union { CYThis *this_; }
 
  76 %union { CYTrue *true_; }
 
  77 %union { CYWord *word_; }
 
  80 %union { CYTypeModifier *modifier_; }
 
  81 %union { CYTypeSpecifier *specifier_; }
 
  82 %union { CYTypedIdentifier *typedIdentifier_; }
 
  83 %union { CYTypedParameter *typedParameter_; }
 
  87 %union { CYClassName *className_; }
 
  88 %union { CYClassField *classField_; }
 
  89 %union { CYMessage *message_; }
 
  90 %union { CYMessageParameter *messageParameter_; }
 
  91 %union { CYProtocol *protocol_; }
 
  92 %union { CYSelectorPart *selector_; }
 
  96 %union { CYAttribute *attribute_; }
 
  97 %union { CYPropertyIdentifier *propertyIdentifier_; }
 
  98 %union { CYSelector *selector_; }
 
 104     cy::parser::semantic_type semantic_;
 
 105     hi::Value highlight_;
 
 108 int cylex(YYSTYPE *, CYLocation *, void *);
 
 115 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, void *scanner) {
 
 117     int token(cylex(&data, location, scanner));
 
 118     *semantic = data.semantic_;
 
 129     @$.begin.filename = @$.end.filename = &driver.filename_;
 
 135 %define api.location.type { CYLocation }
 
 142 %parse-param { CYDriver &driver }
 
 143 %lex-param { void *cyscanner }
 
 145 /* Token Declarations {{{ */
 
 151 %token XMLAttributeValue
 
 153 %token XMLTagCharacters
 
 159 %token LeftRight "<>"
 
 160 %token LeftSlashRight "</>"
 
 162 %token SlashRight "/>"
 
 163 %token LeftSlash "</"
 
 165 %token ColonColon "::"
 
 166 %token PeriodPeriod ".."
 
 169 @begin E4X ObjectiveC
 
 175 %token AmpersandAmpersand "&&"
 
 176 %token AmpersandEqual "&="
 
 178 %token CarrotEqual "^="
 
 180 %token EqualEqual "=="
 
 181 %token EqualEqualEqual "==="
 
 182 %token EqualRight "=>"
 
 183 %token EqualRight_ "\n=>"
 
 184 %token Exclamation "!"
 
 185 %token ExclamationEqual "!="
 
 186 %token ExclamationEqualEqual "!=="
 
 188 %token HyphenEqual "-="
 
 189 %token HyphenHyphen "--"
 
 190 %token HyphenHyphen_ "\n--"
 
 191 %token HyphenRight "->"
 
 193 %token LeftEqual "<="
 
 195 %token LeftLeftEqual "<<="
 
 197 %token PercentEqual "%="
 
 199 %token PeriodPeriodPeriod "..."
 
 201 %token PipeEqual "|="
 
 204 %token PlusEqual "+="
 
 206 %token PlusPlus_ "\n++"
 
 208 %token RightEqual ">="
 
 209 %token RightRight ">>"
 
 210 %token RightRightEqual ">>="
 
 211 %token RightRightRight ">>>"
 
 212 %token RightRightRightEqual ">>>="
 
 214 %token SlashEqual "/="
 
 216 %token StarEqual "*="
 
 228 %token CloseParen ")"
 
 231 %token OpenBrace_ "\n{"
 
 232 %token OpenBrace__ ";{"
 
 233 %token CloseBrace "}"
 
 235 %token OpenBracket "["
 
 236 %token CloseBracket "]"
 
 238 %token At_error_ "@error"
 
 241 %token At_class_ "@class"
 
 245 %token _typedef_ "typedef"
 
 246 %token _unsigned_ "unsigned"
 
 247 %token _signed_ "signed"
 
 248 %token _extern_ "extern"
 
 252 %token At_encode_ "@encode"
 
 256 %token At_implementation_ "@implementation"
 
 257 %token At_import_ "@import"
 
 258 %token At_end_ "@end"
 
 259 %token At_selector_ "@selector"
 
 260 %token At_null_ "@null"
 
 261 %token At_YES_ "@YES"
 
 263 %token At_true_ "@true"
 
 264 %token At_false_ "@false"
 
 269 %token _false_ "false"
 
 273 %token _break_ "break"
 
 275 %token _catch_ "catch"
 
 276 %token _class_ "class"
 
 277 %token _class__ "!class"
 
 278 %token _const_ "const"
 
 279 %token _continue_ "continue"
 
 280 %token _debugger_ "debugger"
 
 281 %token _default_ "default"
 
 282 %token _delete_ "delete"
 
 286 %token _export_ "export"
 
 287 %token _extends_ "extends"
 
 288 %token _finally_ "finally"
 
 290 %token _function_ "function"
 
 291 %token _function__ ";function"
 
 293 %token _import_ "import"
 
 296 %token _instanceof_ "instanceof"
 
 298 %token _return_ "return"
 
 299 %token _super_ "super"
 
 300 %token _switch_ "switch"
 
 302 %token _throw_ "throw"
 
 304 %token _typeof_ "typeof"
 
 307 %token _while_ "while"
 
 310 %token _abstract_ "abstract"
 
 311 %token _await_ "await"
 
 312 %token _boolean_ "boolean"
 
 315 %token _double_ "double"
 
 316 %token _final_ "final"
 
 317 %token _float_ "float"
 
 319 %token _implements_ "implements"
 
 321 %token _interface_ "interface"
 
 324 %token _native_ "native"
 
 325 %token _package_ "package"
 
 326 %token _private_ "private"
 
 327 %token _protected_ "protected"
 
 328 %token _public_ "public"
 
 329 %token _short_ "short"
 
 330 %token _static_ "static"
 
 331 %token _synchronized_ "synchronized"
 
 332 %token _throws_ "throws"
 
 333 %token _transient_ "transient"
 
 334 %token _volatile_ "volatile"
 
 335 %token _yield_ "yield"
 
 337 %token _undefined_ "undefined"
 
 353 %token _namespace_ "namespace"
 
 359 %token <identifier_> Identifier_
 
 360 %token <number_> NumericLiteral
 
 361 %token <string_> StringLiteral
 
 362 %token <literal_> RegularExpressionLiteral
 
 364 %token <string_> NoSubstitutionTemplate
 
 365 %token <string_> TemplateHead
 
 366 %token <string_> TemplateMiddle
 
 367 %token <string_> TemplateTail
 
 369 %type <expression_> AdditiveExpression
 
 370 %type <argument_> ArgumentList_
 
 371 %type <argument_> ArgumentList
 
 372 %type <argument_> ArgumentListOpt
 
 373 %type <argument_> Arguments
 
 374 %type <expression_> ArrayComprehension
 
 375 %type <literal_> ArrayLiteral
 
 376 %type <expression_> ArrowFunction
 
 377 %type <functionParameter_> ArrowParameters
 
 378 %type <expression_> AssignmentExpression
 
 379 %type <expression_> AssignmentExpressionOpt
 
 380 %type <identifier_> Binding
 
 381 %type <identifier_> BindingIdentifier
 
 382 %type <expression_> BitwiseANDExpression
 
 383 %type <statement_> Block
 
 384 %type <statement_> BlockStatement
 
 385 %type <boolean_> BooleanLiteral
 
 386 %type <declaration_> BindingElement
 
 387 %type <expression_> BitwiseORExpression
 
 388 %type <expression_> BitwiseXORExpression
 
 389 %type <statement_> BreakStatement
 
 390 %type <statement_> BreakableStatement
 
 391 %type <expression_> CallExpression_
 
 392 %type <expression_> CallExpression
 
 393 %type <clause_> CaseBlock
 
 394 %type <clause_> CaseClause
 
 395 %type <clause_> CaseClausesOpt
 
 397 %type <identifier_> CatchParameter
 
 398 %type <expression_> Comprehension
 
 399 %type <comprehension_> ComprehensionFor
 
 400 %type <comprehension_> ComprehensionIf
 
 401 %type <comprehension_> ComprehensionTail
 
 402 %type <expression_> ConditionalExpression
 
 403 %type <statement_> ContinueStatement
 
 404 %type <statement_> ConciseBody
 
 405 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
 
 406 %type <statement_> DebuggerStatement
 
 407 %type <statement_> Declaration__
 
 408 %type <statement_> Declaration_
 
 409 %type <statement_> Declaration
 
 410 %type <clause_> DefaultClause
 
 411 %type <element_> ElementList
 
 412 %type <element_> ElementListOpt
 
 413 %type <statement_> ElseStatementOpt
 
 414 %type <statement_> EmptyStatement
 
 415 %type <expression_> EqualityExpression
 
 416 %type <expression_> Expression
 
 417 %type <expression_> ExpressionOpt
 
 418 %type <statement_> ExpressionStatement
 
 419 %type <finally_> Finally
 
 420 %type <for_> ForStatementInitializer
 
 421 %type <forin_> ForInStatementInitializer
 
 422 %type <declaration_> FormalParameter
 
 423 %type <functionParameter_> FormalParameterList_
 
 424 %type <functionParameter_> FormalParameterList
 
 425 %type <functionParameter_> FormalParameterListOpt
 
 426 %type <statement_> FunctionBody
 
 427 %type <statement_> FunctionDeclaration
 
 428 %type <expression_> FunctionExpression
 
 429 %type <statement_> HoistableDeclaration
 
 430 %type <identifier_> Identifier
 
 431 %type <identifier_> IdentifierOpt
 
 432 %type <identifier_> IdentifierType
 
 433 %type <word_> IdentifierName
 
 434 %type <expression_> IdentifierReference
 
 435 %type <statement_> IfStatement
 
 436 %type <expression_> Initializer
 
 437 %type <expression_> InitializerOpt
 
 438 %type <statement_> IterationStatement
 
 439 %type <identifier_> LabelIdentifier
 
 440 %type <statement_> LabelledItem
 
 441 %type <statement_> LabelledStatement
 
 442 %type <expression_> LeftHandSideExpression
 
 443 %type <statement_> LetStatement
 
 444 %type <statement_> LexicalDeclaration
 
 445 %type <literal_> Literal
 
 446 %type <expression_> LogicalANDExpression
 
 447 %type <expression_> LogicalORExpression
 
 448 %type <member_> MemberAccess
 
 449 %type <expression_> MemberExpression_
 
 450 %type <expression_> MemberExpression
 
 451 %type <module_> Module
 
 452 %type <expression_> MultiplicativeExpression
 
 453 %type <expression_> NewExpression
 
 454 %type <null_> NullLiteral
 
 455 %type <literal_> ObjectLiteral
 
 456 %type <expression_> PostfixExpression
 
 457 %type <expression_> PrimaryExpression
 
 458 %type <propertyName_> PropertyName_
 
 459 %type <propertyName_> PropertyName
 
 460 %type <property_> PropertyDefinition
 
 461 %type <property_> PropertyDefinitionList_
 
 462 %type <property_> PropertyDefinitionList
 
 463 %type <property_> PropertyDefinitionListOpt
 
 464 %type <expression_> RelationalExpression
 
 465 %type <statement_> ReturnStatement
 
 466 %type <rubyProc_> RubyProcExpression
 
 467 %type <functionParameter_> RubyProcParameterList_
 
 468 %type <functionParameter_> RubyProcParameterList
 
 469 %type <functionParameter_> RubyProcParameters
 
 470 %type <functionParameter_> RubyProcParametersOpt
 
 471 %type <statement_> Script
 
 472 %type <statement_> ScriptBody
 
 473 %type <statement_> ScriptBodyOpt
 
 474 %type <expression_> ShiftExpression
 
 475 %type <declaration_> SingleNameBinding
 
 476 %type <statement_> Statement__
 
 477 %type <statement_> Statement_
 
 478 %type <statement_> Statement
 
 479 %type <statement_> StatementList
 
 480 %type <statement_> StatementListOpt
 
 481 %type <statement_> StatementListItem
 
 482 %type <statement_> SwitchStatement
 
 483 %type <expression_> TemplateLiteral
 
 484 %type <span_> TemplateSpans
 
 485 %type <statement_> ThrowStatement
 
 486 %type <statement_> TryStatement
 
 487 %type <expression_> UnaryExpression_
 
 488 %type <expression_> UnaryExpression
 
 489 %type <declaration_> VariableDeclaration
 
 490 %type <declarations_> VariableDeclarationList_
 
 491 %type <declarations_> VariableDeclarationList
 
 492 %type <statement_> VariableStatement
 
 493 %type <statement_> WithStatement
 
 496 %type <word_> WordOpt
 
 500 %type <specifier_> IntegerType
 
 501 %type <specifier_> IntegerTypeOpt
 
 502 %type <typedIdentifier_> PrefixedType
 
 503 %type <specifier_> PrimitiveType
 
 504 %type <typedIdentifier_> SuffixedType
 
 505 %type <typedIdentifier_> TypeSignifier
 
 506 %type <modifier_> TypeQualifierLeft
 
 507 %type <typedIdentifier_> TypeQualifierRight
 
 508 %type <typedIdentifier_> TypedIdentifier
 
 509 %type <typedParameter_> TypedParameterList_
 
 510 %type <typedParameter_> TypedParameterList
 
 511 %type <typedParameter_> TypedParameterListOpt
 
 515 %type <expression_> BoxableExpression
 
 516 %type <statement_> CategoryStatement
 
 517 %type <classField_> ClassFieldListOpt
 
 518 %type <classField_> ClassFields
 
 519 %type <statement_> ClassStatement
 
 520 %type <expression_> ClassSuperOpt
 
 521 %type <message_> ClassMessageDeclaration
 
 522 %type <message_> ClassMessageDeclarationListOpt
 
 523 %type <className_> ClassName
 
 524 %type <protocol_> ClassProtocolListOpt
 
 525 %type <protocol_> ClassProtocols
 
 526 %type <protocol_> ClassProtocolsOpt
 
 527 %type <expression_> MessageExpression
 
 528 %type <messageParameter_> MessageParameter
 
 529 %type <messageParameter_> MessageParameters
 
 530 %type <messageParameter_> MessageParameterList
 
 531 %type <messageParameter_> MessageParameterListOpt
 
 532 %type <bool_> MessageScope
 
 533 %type <argument_> SelectorCall_
 
 534 %type <argument_> SelectorCall
 
 535 %type <selector_> SelectorExpression_
 
 536 %type <selector_> SelectorExpression
 
 537 %type <selector_> SelectorExpressionOpt
 
 538 %type <argument_> SelectorList
 
 539 %type <word_> SelectorWordOpt
 
 540 %type <typedIdentifier_> TypeOpt
 
 541 %type <argument_> VariadicCall
 
 545 %type <propertyIdentifier_> PropertyIdentifier_
 
 546 %type <selector_> PropertySelector_
 
 547 %type <selector_> PropertySelector
 
 548 %type <identifier_> QualifiedIdentifier_
 
 549 %type <identifier_> QualifiedIdentifier
 
 550 %type <identifier_> WildcardIdentifier
 
 551 %type <identifier_> XMLComment
 
 552 %type <identifier_> XMLCDATA
 
 553 %type <identifier_> XMLElement
 
 554 %type <identifier_> XMLElementContent
 
 555 %type <identifier_> XMLMarkup
 
 556 %type <identifier_> XMLPI
 
 558 %type <attribute_> AttributeIdentifier
 
 559 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
 
 560 %type <expression_> PropertyIdentifier
 
 561 %type <expression_> XMLListInitialiser
 
 562 %type <expression_> XMLInitialiser
 
 565 /* Token Priorities {{{ */
 
 577 /* Lexer State {{{ */
 
 579     : { driver.in_.push(true); }
 
 583     : { driver.in_.push(false); }
 
 587     : { driver.in_.pop(); }
 
 591     : { driver.SetCondition(CYDriver::RegExpCondition); }
 
 595     : { if (!yyla.empty() && yyla.type_get() != yyeof_) error(@$, "unexpected lookahead"); driver.no_.NewLine = true; }
 
 599     : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
 
 603     : { if (yyla.empty()) driver.no_.Class = true; else if (yyla.type == yytranslate_(token::_class_)) yyla.type = yytranslate_(token::_class__); }
 
 607     : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::_function_)) yyla.type = yytranslate_(token::_function__); }
 
 611     : LexNoBrace LexNoClass LexNoFunction
 
 614 /* Virtual Tokens {{{ */
 
 625 /* 11.6 Names and Keywords {{{ */
 
 628     | "for" { $$ = CYNew CYWord("for"); }
 
 629     | "in" { $$ = CYNew CYWord("in"); }
 
 630     | "instanceof" { $$ = CYNew CYWord("instanceof"); }
 
 634     : Identifier { $$ = $1; }
 
 635     | "auto" { $$ = CYNew CYWord("auto"); }
 
 636     | "break" { $$ = CYNew CYWord("break"); }
 
 637     | "case" { $$ = CYNew CYWord("case"); }
 
 638     | "catch" { $$ = CYNew CYWord("catch"); }
 
 639     | "class" { $$ = CYNew CYWord("class"); }
 
 640     | "!class" { $$ = CYNew CYWord("class"); }
 
 641     | "const" { $$ = CYNew CYWord("const"); }
 
 642     | "continue" { $$ = CYNew CYWord("continue"); }
 
 643     | "debugger" { $$ = CYNew CYWord("debugger"); }
 
 644     | "default" { $$ = CYNew CYWord("default"); }
 
 645     | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
 
 646     | "do" { $$ = CYNew CYWord("do"); }
 
 647     | "else" { $$ = CYNew CYWord("else"); }
 
 648     | "enum" { $$ = CYNew CYWord("enum"); }
 
 649     | "export" { $$ = CYNew CYWord("export"); }
 
 650     | "extends" { $$ = CYNew CYWord("extends"); }
 
 651     | "false" { $$ = CYNew CYWord("false"); }
 
 652     | "finally" { $$ = CYNew CYWord("finally"); }
 
 653     | "function" { $$ = CYNew CYWord("function"); }
 
 654     | "if" { $$ = CYNew CYWord("if"); }
 
 655     | "import" { $$ = CYNew CYWord("import"); }
 
 656     | "!in" { $$ = CYNew CYWord("in"); }
 
 657     | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
 
 658     | "null" { $$ = CYNew CYWord("null"); }
 
 659     | "return" { $$ = CYNew CYWord("return"); }
 
 660     | "super" { $$ = CYNew CYWord("super"); }
 
 661     | "switch" { $$ = CYNew CYWord("switch"); }
 
 662     | "this" { $$ = CYNew CYWord("this"); }
 
 663     | "throw" { $$ = CYNew CYWord("throw"); }
 
 664     | "true" { $$ = CYNew CYWord("true"); }
 
 665     | "try" { $$ = CYNew CYWord("try"); }
 
 666     | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
 
 667     | "var" { $$ = CYNew CYWord("var"); }
 
 668     | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
 
 669     | "while" { $$ = CYNew CYWord("while"); }
 
 670     | "with" { $$ = CYNew CYWord("with"); }
 
 672     // XXX: should be Identifier
 
 673     | "let" { $$ = CYNew CYIdentifier("let"); }
 
 683 /* 11.8.1 Null Literals {{{ */
 
 685     : "null" { $$ = CYNew CYNull(); }
 
 688 /* 11.8.2 Boolean Literals {{{ */
 
 690     : "true" { $$ = CYNew CYTrue(); }
 
 691     | "false" { $$ = CYNew CYFalse(); }
 
 695 /* 11.9 Automatic Semicolon Insertion {{{ */
 
 697     : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
 
 707     | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) { error(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
 
 712     | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
 
 716 /* 12.1 Identifiers {{{ */
 
 718     : Identifier { $$ = CYNew CYVariable($1); }
 
 723     : Identifier { $$ = $1; }
 
 728     : Identifier { $$ = $1; }
 
 733     : Identifier_ { $$ = $1; }
 
 734     | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
 
 735     | "await" { $$ = CYNew CYIdentifier("await"); }
 
 736     | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
 
 737     | "byte" { $$ = CYNew CYIdentifier("byte"); }
 
 738     | "double" { $$ = CYNew CYIdentifier("double"); }
 
 739     | "each" { $$ = CYNew CYIdentifier("each"); }
 
 740     | "final" { $$ = CYNew CYIdentifier("final"); }
 
 741     | "float" { $$ = CYNew CYIdentifier("float"); }
 
 742     | "goto" { $$ = CYNew CYIdentifier("goto"); }
 
 743     | "implements" { $$ = CYNew CYIdentifier("implements"); }
 
 744     | "interface" { $$ = CYNew CYIdentifier("interface"); }
 
 745     | "native" { $$ = CYNew CYIdentifier("native"); }
 
 746     | "of" { $$ = CYNew CYIdentifier("of"); }
 
 747     | "package" { $$ = CYNew CYIdentifier("package"); }
 
 748     | "private" { $$ = CYNew CYIdentifier("private"); }
 
 749     | "protected" { $$ = CYNew CYIdentifier("protected"); }
 
 750     | "public" { $$ = CYNew CYIdentifier("public"); }
 
 751     | "static" { $$ = CYNew CYIdentifier("static"); }
 
 752     | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
 
 753     | "throws" { $$ = CYNew CYIdentifier("throws"); }
 
 754     | "transient" { $$ = CYNew CYIdentifier("transient"); }
 
 755     | "yield" { $$ = CYNew CYIdentifier("yield"); }
 
 757     | "bool" { $$ = CYNew CYIdentifier("bool"); }
 
 758     | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
 
 759     | "id" { $$ = CYNew CYIdentifier("id"); }
 
 760     | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
 
 766     | "char" { $$ = CYNew CYIdentifier("char"); }
 
 767     | "int" { $$ = CYNew CYIdentifier("int"); }
 
 768     | "long" { $$ = CYNew CYIdentifier("long"); }
 
 769     | "short" { $$ = CYNew CYIdentifier("short"); }
 
 770     | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
 
 771     | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
 
 773     | "extern" { $$ = CYNew CYIdentifier("extern"); }
 
 774     | "signed" { $$ = CYNew CYIdentifier("signed"); }
 
 775     | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
 
 776     | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
 
 779     | "nil" { $$ = CYNew CYIdentifier("nil"); }
 
 780     | "NO" { $$ = CYNew CYIdentifier("NO"); }
 
 781     | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
 
 782     | "YES" { $$ = CYNew CYIdentifier("YES"); }
 
 787     : Identifier { $$ = $1; }
 
 791 /* 12.2 Primary Expression {{{ */
 
 793     : "this" { $$ = CYNew CYThis(); }
 
 794     | IdentifierReference { $$ = $1; }
 
 795     | Literal { $$ = $1; }
 
 796     | ArrayLiteral { $$ = $1; }
 
 797     | ObjectLiteral { $$ = $1; }
 
 798     | RegularExpressionLiteral { $$ = $1; }
 
 799     | TemplateLiteral { $$ = $1; }
 
 800     | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) error(@1, "invalid parenthetical"); $$ = $1; }
 
 801     | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
 
 804 CoverParenthesizedExpressionAndArrowParameterList
 
 805     : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
 
 806     | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
 
 809 /* 12.2.4 Literals {{{ */
 
 811     : NullLiteral { $$ = $1; }
 
 812     | BooleanLiteral { $$ = $1; }
 
 813     | NumericLiteral { $$ = $1; }
 
 814     | StringLiteral { $$ = $1; }
 
 817 /* 12.2.5 Array Initializer {{{ */
 
 819     : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
 
 823     : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
 
 824     | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
 
 825     | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
 
 829     : ElementList { $$ = $1; }
 
 830     | LexSetRegExp { $$ = NULL; }
 
 833 /* 12.2.6 Object Initializer {{{ */
 
 835     : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
 
 838 PropertyDefinitionList_
 
 839     : "," PropertyDefinitionList { $$ = $2; }
 
 840     | "," LexSetRegExp { $$ = NULL; }
 
 844 PropertyDefinitionList
 
 845     : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
 
 848 PropertyDefinitionListOpt
 
 849     : PropertyDefinitionList { $$ = $1; }
 
 850     | LexSetRegExp { $$ = NULL; }
 
 854     // XXX: this should be IdentifierName
 
 855     : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
 
 856     | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
 
 861     : IdentifierName { $$ = $1; }
 
 862     | StringLiteral { $$ = $1; }
 
 863     | NumericLiteral { $$ = $1; }
 
 867     : LexSetRegExp PropertyName_ { $$ = $2; }
 
 872     : "=" AssignmentExpression { $$ = $2; }
 
 876     : Initializer { $$ = $1; }
 
 880 /* 12.2.9 Template Literals {{{ */
 
 882     : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
 
 883     | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
 
 887     : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
 
 888     | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
 
 892 /* 12.3+ Left-Hand-Side Expressions {{{ */
 
 894     : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
 
 895     | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
 
 896     | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
 
 900     : MemberExpression { $$ = $1; }
 
 901     //| "super" { $$ = $1; }
 
 905     : LexSetRegExp PrimaryExpression { $$ = $2; }
 
 906     | LexSetRegExp FunctionExpression { $$ = $2; }
 
 907     | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 908     | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
 
 912     : MemberExpression { $$ = $1; }
 
 913     | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
 
 922     : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
 
 923     | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 927     : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
 
 931     : "," ArgumentList { $$ = $2; }
 
 936     : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
 
 937     | LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
 
 941     : ArgumentList { $$ = $1; }
 
 942     | LexSetRegExp { $$ = NULL; }
 
 945 LeftHandSideExpression
 
 946     : NewExpression { $$ = $1; }
 
 947     | CallExpression { $$ = $1; }
 
 950 /* 12.4 Postfix Expressions {{{ */
 
 952     : %prec "" LeftHandSideExpression { $$ = $1; }
 
 953     | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
 
 954     | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
 
 957 /* 12.5 Unary Operators {{{ */
 
 959     : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
 
 960     | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
 
 961     | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
 
 962     | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 963     | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 964     | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 965     | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 966     | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
 
 967     | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
 
 968     | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
 
 969     | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
 
 973     : PostfixExpression { $$ = $1; }
 
 974     | LexSetRegExp UnaryExpression_ { $$ = $2; }
 
 977 /* 12.6 Multiplicative Operators {{{ */
 
 978 MultiplicativeExpression
 
 979     : UnaryExpression { $$ = $1; }
 
 980     | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
 
 981     | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
 
 982     | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
 
 985 /* 12.7 Additive Operators {{{ */
 
 987     : MultiplicativeExpression { $$ = $1; }
 
 988     | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
 
 989     | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
 
 992 /* 12.8 Bitwise Shift Operators {{{ */
 
 994     : AdditiveExpression { $$ = $1; }
 
 995     | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
 
 996     | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
 
 997     | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
 
1000 /* 12.9 Relational Operators {{{ */
 
1001 RelationalExpression
 
1002     : ShiftExpression { $$ = $1; }
 
1003     | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
 
1004     | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
 
1005     | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
 
1006     | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
 
1007     | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
 
1008     | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
 
1011 /* 12.10 Equality Operators {{{ */
 
1013     : RelationalExpression { $$ = $1; }
 
1014     | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
 
1015     | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
 
1016     | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
 
1017     | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
 
1020 /* 12.11 Binary Bitwise Operators {{{ */
 
1021 BitwiseANDExpression
 
1022     : EqualityExpression { $$ = $1; }
 
1023     | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1026 BitwiseXORExpression
 
1027     : BitwiseANDExpression { $$ = $1; }
 
1028     | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1032     : BitwiseXORExpression { $$ = $1; }
 
1033     | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
 
1036 /* 12.12 Binary Logical Operators {{{ */
 
1037 LogicalANDExpression
 
1038     : BitwiseORExpression { $$ = $1; }
 
1039     | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
 
1043     : LogicalANDExpression { $$ = $1; }
 
1044     | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
 
1047 /* 12.13 Conditional Operator ( ? : ) {{{ */
 
1048 ConditionalExpression
 
1049     : LogicalORExpression { $$ = $1; }
 
1050     | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
 
1053 /* 12.14 Assignment Operators {{{ */
 
1054 AssignmentExpression
 
1055     : ConditionalExpression { $$ = $1; }
 
1056     // XXX: | YieldExpression { $$ = $1; }
 
1057     | ArrowFunction { $$ = $1; }
 
1058     | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
 
1059     | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
 
1060     | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
 
1061     | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
 
1062     | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
 
1063     | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
 
1064     | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
 
1065     | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
 
1066     | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
 
1067     | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
 
1068     | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
 
1069     | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
 
1072 AssignmentExpressionOpt
 
1073     : AssignmentExpression { $$ = $1; }
 
1074     | LexSetRegExp { $$ = NULL; }
 
1077 /* 12.15 Comma Operator ( , ) {{{ */
 
1079     : AssignmentExpression { $$ = $1; }
 
1080     /* XXX: I have this backwards... */
 
1081     | AssignmentExpression "," Expression { $$ = CYNew CYCompound($1, $3); }
 
1085     : Expression { $$ = $1; }
 
1086     | LexSetRegExp { $$ = NULL; }
 
1090 /* 13 Statements and Declarations {{{ */
 
1092     : BlockStatement { $$ = $1; }
 
1093     | VariableStatement { $$ = $1; }
 
1094     | EmptyStatement { $$ = $1; }
 
1095     | IfStatement { $$ = $1; }
 
1096     | BreakableStatement { $$ = $1; }
 
1097     | ContinueStatement { $$ = $1; }
 
1098     | BreakStatement { $$ = $1; }
 
1099     | ReturnStatement { $$ = $1; }
 
1100     | WithStatement { $$ = $1; }
 
1101     | LabelledStatement { $$ = $1; }
 
1102     | ThrowStatement { $$ = $1; }
 
1103     | TryStatement { $$ = $1; }
 
1104     | DebuggerStatement { $$ = $1; }
 
1108     : LexSetRegExp Statement__ { $$ = $2; }
 
1109     | ExpressionStatement { $$ = $1; }
 
1113     : LexSetStatement Statement_ { $$ = $2; }
 
1117     : HoistableDeclaration { $$ = $1; }
 
1118     // XXX: | ClassDeclaration { $$ = $1; }
 
1119     | LexicalDeclaration { $$ = $1; }
 
1123     : LexSetRegExp Declaration__ { $$ = $2; }
 
1127     : LexSetStatement Declaration_ { $$ = $2; }
 
1130 HoistableDeclaration
 
1131     : FunctionDeclaration
 
1132     // XXX: | GeneratorDeclaration
 
1136     : IterationStatement { $$ = $1; }
 
1137     | SwitchStatement { $$ = $1; }
 
1140 /* 13.2 Block {{{ */
 
1142     : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
 
1146     : BRACE StatementListOpt "}" { $$ = $2; }
 
1150     : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
 
1154     : StatementList { $$ = $1; }
 
1155     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1159     : Statement { $$ = $1; }
 
1160     | Declaration { $$ = $1; }
 
1163 /* 13.3+ Let and Const Declarations {{{ */
 
1165     : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1177 // XXX: lots of binding stuff
 
1179 /* 13.3.2+ Variable Statement {{{ */
 
1181     : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1184 VariableDeclarationList_
 
1185     : "," VariableDeclarationList { $$ = $2; }
 
1189 VariableDeclarationList
 
1190     : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
 
1194     : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1195     // XXX: | BindingPattern Initializer { $$ = CYNew CYDeclaration($1, $2); }
 
1198 /* 13.3.3+ Destructuring Binding Patterns {{{ */
 
1202     : SingleNameBinding { $$ = $1; }
 
1206     : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1209 /* 13.4 Empty Statement {{{ */
 
1211     : ";" { $$ = CYNew CYEmpty(); }
 
1214 /* 13.5 Expression Statement {{{ */
 
1216     : Expression Terminator { $$ = CYNew CYExpress($1); }
 
1219 /* 13.6 The if Statement {{{ */
 
1221     : "else" Statement { $$ = $2; }
 
1222     | %prec "if" { $$ = NULL; }
 
1226     : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
 
1229 /* 13.7+ Iteration Statements {{{ */
 
1231     : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
 
1232     | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
 
1233     | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
 
1234     | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
 
1235     | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
 
1238 ForStatementInitializer
 
1239     : ExpressionOpt { $$ = $1; }
 
1240     | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
 
1243 ForInStatementInitializer
 
1244     : LeftHandSideExpression { $$ = $1; }
 
1245     | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
 
1248 /* 13.8 The continue Statement {{{ */
 
1250     : "continue" LexNoNewLine
 
1254     : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
 
1255     | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
 
1258 /* 13.9 The break Statement {{{ */
 
1260     : "break" LexNoNewLine
 
1264     : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
 
1265     | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
 
1268 /* 13.10 The return Statement {{{ */
 
1270     : "return" LexNoNewLine
 
1274     : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
 
1275     | Return Expression Terminator { $$ = CYNew CYReturn($2); }
 
1278 /* 13.11 The with Statement {{{ */
 
1280     : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
 
1283 /* 13.12 The switch Statement {{{ */
 
1285     : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
 
1289     : BRACE CaseClausesOpt "}" { $$ = $2; }
 
1293     : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
 
1297     : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1298     | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1302 // XXX: the standard makes certain you can only have one of these
 
1304     : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
 
1307 /* 13.13 Labelled Statements {{{ */
 
1309     : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
 
1313     : Statement { $$ = $1; }
 
1314     | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
 
1317 /* 13.14 The throw Statement {{{ */
 
1319     : "throw" LexNoNewLine
 
1323     : Throw LexSetRegExp TerminatorSoft { error(@1, "throw without exception"); }
 
1324     | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
 
1327 /* 13.15 The try Statement {{{ */
 
1329     : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
 
1330     | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
 
1331     | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
 
1335     : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
 
1339     : "finally" Block { $$ = CYNew CYFinally($2); }
 
1343     : BindingIdentifier { $$ = $1; }
 
1344     // XXX: BindingPattern
 
1347 /* 13.16 The debugger Statement {{{ */
 
1349     : "debugger" Terminator { $$ = CYNew CYDebugger(); }
 
1353 /* 14.1+ Function Definitions {{{ */
 
1355     : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
 
1359     : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
 
1362 FormalParameterList_
 
1363     : "," FormalParameterList { $$ = $2; }
 
1368     // XXX: : FunctionRestParameter { $$ = $1; }
 
1369     : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
 
1372 FormalParameterListOpt
 
1373     : FormalParameterList
 
1377 /* XXX: FunctionRestParameter
 
1378     : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
 
1382     : BindingElement { $$ = $1; }
 
1386     : StatementListOpt { $$ = $1; }
 
1389 /* 14.2 Arrow Function Definitions {{{ */
 
1391     : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
 
1395     : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
 
1396     | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1->expression_->Parameter(); if ($$ == NULL) error(@1, "invalid parameter list"); }
 
1400     : AssignmentExpression { $$ = CYNew CYReturn($1); }
 
1401     | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
 
1404 /* 14.3+ Method Definitions {{{ */
 
1406 /* 14.4+ Generator Function Definitions {{{ */
 
1408 /* 14.5+ Class Definitions {{{ */
 
1411 /* 15.1 Scripts {{{ */
 
1413     : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
 
1417     : StatementList { $$ = $1; }
 
1421     : ScriptBody { $$ = $1; }
 
1422     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1425 /* 15.2+ Modules {{{ */
 
1427 /* 15.2.2+ Imports {{{ */
 
1429 /* 15.2.3+ Exports {{{ */
 
1433 /* Cycript (C): Type Encoding {{{ */
 
1435     : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
 
1436     | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
 
1440     : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
 
1441     | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
 
1442     | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
 
1443     | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
 
1444     | TypeSignifier { $$ = $1; }
 
1445     | { $$ = CYNew CYTypedIdentifier(@$); }
 
1449     : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
 
1454     | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
 
1455     | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
 
1459     : PrefixedType { $$ = $1; }
 
1460     | SuffixedType { $$ = $1; }
 
1461     | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
 
1462     | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
 
1466     : "int" { $$ = CYNew CYTypeVariable("int"); }
 
1467     | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
 
1468     | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
 
1469     | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
 
1470     | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
 
1474     : IntegerType { $$ = $1; }
 
1475     | { $$ = CYNew CYTypeVariable("int"); }
 
1479     : IdentifierType { $$ = CYNew CYTypeVariable($1); }
 
1480     | IntegerType { $$ = $1; }
 
1481     | "void" { $$ = CYNew CYTypeVoid(); }
 
1482     | "char" { $$ = CYNew CYTypeVariable("char"); }
 
1483     | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
 
1484     | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
 
1488     : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
 
1492     : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
 
1498 /* Cycript (Objective-C): @class Declaration {{{ */
 
1500     /* XXX: why the hell did I choose MemberExpression? */
 
1501     : ":" LexSetRegExp MemberExpression { $$ = $3; }
 
1506     : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
 
1507     | LexSetRegExp { $$ = NULL; }
 
1511     : BRACE ClassFieldListOpt "}" { $$ = $2; }
 
1515     : "+" { $$ = false; }
 
1516     | "-" { $$ = true; }
 
1520     : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) error($3->location_, "unexpected identifier"); $$ = $3; }
 
1521     | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
 
1525     : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
 
1528 MessageParameterList
 
1529     : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
 
1532 MessageParameterListOpt
 
1533     : MessageParameterList { $$ = $1; }
 
1538     : MessageParameterList { $$ = $1; }
 
1539     | Word { $$ = CYNew CYMessageParameter($1, NULL); }
 
1542 ClassMessageDeclaration
 
1543     : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
 
1546 ClassMessageDeclarationListOpt
 
1547     : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
 
1552     : Identifier { $$ = $1; }
 
1553     | "(" AssignmentExpression ")" { $$ = $2; }
 
1556 // XXX: this should be AssignmentExpressionNoRight
 
1558     : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
 
1562     : "," ClassProtocols { $$ = $2; }
 
1566 ClassProtocolListOpt
 
1567     : "<" ClassProtocols ">" { $$ = $2; }
 
1572     : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
 
1580     : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
 
1584     : ClassStatement { $$ = $1; }
 
1585     | CategoryStatement { $$ = $1; }
 
1588 /* Cycript (Objective-C): Send Message {{{ */
 
1590     : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
 
1595     : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
 
1596     | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
 
1600     : SelectorCall { $$ = $1; }
 
1601     | VariadicCall { $$ = $1; }
 
1605     : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
 
1609     : SelectorCall { $$ = $1; }
 
1610     | Word { $$ = CYNew CYArgument($1, NULL); }
 
1614     : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
 
1615     | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
 
1619     : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
 
1623     : SelectorExpression_ { $$ = $1; }
 
1624     | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
 
1627 SelectorExpressionOpt
 
1628     : SelectorExpression_ { $$ = $1; }
 
1633     : MessageExpression { $$ = $1; }
 
1634     | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
 
1639 /* Cycript: @import Directive {{{ */
 
1641     : Module "." Word { $$ = CYNew CYModule($3, $1); }
 
1642     | Word { $$ = CYNew CYModule($1); }
 
1646     : "@import" Module { $$ = CYNew CYImport($2); }
 
1651 /* Cycript (Objective-C): Boxed Expressions {{{ */
 
1653     : NullLiteral { $$ = $1; }
 
1654     | BooleanLiteral { $$ = $1; }
 
1655     | NumericLiteral { $$ = $1; }
 
1656     | StringLiteral { $$ = $1; }
 
1657     | ArrayLiteral { $$ = $1; }
 
1658     | ObjectLiteral { $$ = $1; }
 
1659     | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
 
1660     | "YES" { $$ = CYNew CYTrue(); }
 
1661     | "NO" { $$ = CYNew CYFalse(); }
 
1665     : "@" BoxableExpression { $$ = CYNew CYBox($2); }
 
1666     | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1667     | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1668     | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1669     | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1670     | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
 
1673 /* Cycript (Objective-C): Block Expressions {{{ */
 
1675     : "^" TypedIdentifier { if ($2->identifier_ != NULL) error($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else error($2->location_, "expected parameters"); }
 
1678 /* Cycript (Objective-C): Instance Literals {{{ */
 
1680     : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
 
1686 /* Cycript (C): Pointer Indirection/Addressing {{{ */
 
1687 LeftHandSideExpression
 
1688     : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
 
1692     : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
 
1696     : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
 
1697     | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
 
1698     | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
 
1701 /* Cycript (C): auto Compatibility {{{ */
 
1706 /* Cycript (C): Lambda Expressions {{{ */
 
1708     : "," TypedParameterList { $$ = $2; }
 
1713     : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
 
1716 TypedParameterListOpt
 
1717     : TypedParameterList { $$ = $1; }
 
1722     : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
 
1725 /* Cycript (C): Type Definitions {{{ */
 
1727     : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) error($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
 
1730 /* Cycript (C): extern "C" {{{ */
 
1732     : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) error(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) error($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
 
1739 /* Lexer State {{{ */
 
1741     : { driver.PushCondition(CYDriver::RegExpCondition); }
 
1745     : { driver.PushCondition(CYDriver::XMLContentCondition); }
 
1749     : { driver.PushCondition(CYDriver::XMLTagCondition); }
 
1753     : { driver.PopCondition(); }
 
1757     : { driver.SetCondition(CYDriver::XMLContentCondition); }
 
1761     : { driver.SetCondition(CYDriver::XMLTagCondition); }
 
1764 /* Virtual Tokens {{{ */
 
1771 /* 8.1 Context Keywords {{{ */
 
1773     : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
 
1774     | "xml" { $$ = CYNew CYIdentifier("xml"); }
 
1777 /* 8.3 XML Initializer Input Elements {{{ */
 
1779     : XMLComment { $$ = $1; }
 
1780     | XMLCDATA { $$ = $1; }
 
1781     | XMLPI { $$ = $1; }
 
1785 /* 11.1 Primary Expressions {{{ */
 
1787     : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
 
1788     | XMLInitialiser { $$ = $1; }
 
1789     | XMLListInitialiser { $$ = $1; }
 
1793     : AttributeIdentifier { $$ = $1; }
 
1794     | QualifiedIdentifier { $$ = $1; }
 
1795     | WildcardIdentifier { $$ = $1; }
 
1798 /* 11.1.1 Attribute Identifiers {{{ */
 
1800     : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
 
1804     : PropertySelector { $$ = $1; }
 
1805     | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
 
1809     : Identifier { $$ = CYNew CYSelector($1); }
 
1810     | WildcardIdentifier { $$ = $1; }
 
1813 /* 11.1.2 Qualified Identifiers {{{ */
 
1814 QualifiedIdentifier_
 
1815     : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
 
1816     | QualifiedIdentifier { $$ = $1; }
 
1820     : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
 
1823 /* 11.1.3 Wildcard Identifiers {{{ */
 
1825     : "*" { $$ = CYNew CYWildcard(); }
 
1828 /* 11.1.4 XML Initializer {{{ */
 
1830     : XMLMarkup { $$ = $1; }
 
1831     | XMLElement { $$ = $1; }
 
1835     : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
 
1836     | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
 
1840     : LexPushXMLTag XMLTagName XMLAttributes
 
1844     : BRACE LexPushRegExp Expression LexPop "}"
 
1853     : XMLAttributes_ XMLAttribute
 
1858     : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
 
1859     | XMLAttributes_ XMLWhitespaceOpt
 
1868     : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
 
1872     : XMLExpression XMLElementContentOpt
 
1873     | XMLMarkup XMLElementContentOpt
 
1874     | XMLText XMLElementContentOpt
 
1875     | XMLElement XMLElementContentOpt
 
1878 XMLElementContentOpt
 
1883 /* 11.1.5 XMLList Initializer {{{ */
 
1885     : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
 
1889 /* 11.2 Left-Hand-Side Expressions {{{ */
 
1891     : Identifier { $$ = $1; }
 
1892     | PropertyIdentifier { $$ = $1; }
 
1896     : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
 
1897     | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
 
1898     | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
 
1901 /* 12.1 The default xml namespace Statement {{{ */
 
1902 /* XXX: DefaultXMLNamespaceStatement
 
1903     : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
 
1907     : DefaultXMLNamespaceStatement { $$ = $1; }
 
1912 /* JavaScript FTL: Array Comprehensions {{{ */
 
1914     : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
 
1918     : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
 
1919     | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
 
1922 /* JavaScript FTL: for each {{{ */
 
1924     : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
 
1927 /* JavaScript FTL: let Statements {{{ */
 
1929     : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
 
1937 /* JavaScript FTW: Array Comprehensions {{{ */
 
1939     : ArrayComprehension
 
1943     : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
 
1947     : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
 
1952     | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
 
1953     | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
 
1957     : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
 
1961     : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
 
1964 /* JavaScript FTW: Coalesce Operator {{{ */
 
1965 ConditionalExpression
 
1966     : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
 
1969 /* JavaScript FTW: Ruby Blocks {{{ */
 
1970 RubyProcParameterList_
 
1971     : "," RubyProcParameterList { $$ = $2; }
 
1975 RubyProcParameterList
 
1976     : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
 
1981     : "|" RubyProcParameterList "|" { $$ = $2; }
 
1982     | "||" { $$ = NULL; }
 
1985 RubyProcParametersOpt
 
1986     : RubyProcParameters
 
1991     : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
 
1995     : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
 
1999     : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }