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_;
 
 122 #define CYMAP(to, from) do { \
 
 124         yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, cyscanner)); \
 
 125     if (yyla.type == yytranslate_(token::from)) \
 
 126         yyla.type = yytranslate_(token::to); \
 
 129 #define CYERR(location, message) do { \
 
 130     error(location, message); \
 
 141     @$.begin.filename = @$.end.filename = &driver.filename_;
 
 147 %define api.location.type { CYLocation }
 
 154 %parse-param { CYDriver &driver }
 
 155 %lex-param { void *cyscanner }
 
 157 /* Token Declarations {{{ */
 
 163 %token XMLAttributeValue
 
 165 %token XMLTagCharacters
 
 171 %token LeftRight "<>"
 
 172 %token LeftSlashRight "</>"
 
 174 %token SlashRight "/>"
 
 175 %token LeftSlash "</"
 
 177 %token ColonColon "::"
 
 178 %token PeriodPeriod ".."
 
 181 @begin E4X ObjectiveC
 
 187 %token AmpersandAmpersand "&&"
 
 188 %token AmpersandEqual "&="
 
 190 %token CarrotEqual "^="
 
 192 %token EqualEqual "=="
 
 193 %token EqualEqualEqual "==="
 
 194 %token EqualRight "=>"
 
 195 %token EqualRight_ "\n=>"
 
 196 %token Exclamation "!"
 
 197 %token ExclamationEqual "!="
 
 198 %token ExclamationEqualEqual "!=="
 
 200 %token HyphenEqual "-="
 
 201 %token HyphenHyphen "--"
 
 202 %token HyphenHyphen_ "\n--"
 
 203 %token HyphenRight "->"
 
 205 %token LeftEqual "<="
 
 207 %token LeftLeftEqual "<<="
 
 209 %token PercentEqual "%="
 
 211 %token PeriodPeriodPeriod "..."
 
 213 %token PipeEqual "|="
 
 216 %token PlusEqual "+="
 
 218 %token PlusPlus_ "\n++"
 
 220 %token RightEqual ">="
 
 221 %token RightRight ">>"
 
 222 %token RightRightEqual ">>="
 
 223 %token RightRightRight ">>>"
 
 224 %token RightRightRightEqual ">>>="
 
 226 %token SlashEqual "/="
 
 228 %token StarEqual "*="
 
 240 %token CloseParen ")"
 
 243 %token OpenBrace_ "\n{"
 
 244 %token OpenBrace__ ";{"
 
 245 %token CloseBrace "}"
 
 247 %token OpenBracket "["
 
 248 %token CloseBracket "]"
 
 250 %token At_error_ "@error"
 
 253 %token At_class_ "@class"
 
 257 %token _typedef_ "typedef"
 
 258 %token _unsigned_ "unsigned"
 
 259 %token _signed_ "signed"
 
 260 %token _extern_ "extern"
 
 264 %token At_encode_ "@encode"
 
 268 %token At_implementation_ "@implementation"
 
 269 %token At_import_ "@import"
 
 270 %token At_end_ "@end"
 
 271 %token At_selector_ "@selector"
 
 272 %token At_null_ "@null"
 
 273 %token At_YES_ "@YES"
 
 275 %token At_true_ "@true"
 
 276 %token At_false_ "@false"
 
 281 %token _false_ "false"
 
 285 %token _break_ "break"
 
 287 %token _catch_ "catch"
 
 288 %token _class_ "class"
 
 289 %token _class__ "!class"
 
 290 %token _const_ "const"
 
 291 %token _continue_ "continue"
 
 292 %token _debugger_ "debugger"
 
 293 %token _default_ "default"
 
 294 %token _delete_ "delete"
 
 298 %token _export_ "export"
 
 299 %token _extends_ "extends"
 
 300 %token _finally_ "finally"
 
 302 %token _function_ "function"
 
 303 %token _function__ ";function"
 
 305 %token _import_ "import"
 
 308 %token _instanceof_ "instanceof"
 
 310 %token _return_ "return"
 
 311 %token _super_ "super"
 
 312 %token _switch_ "switch"
 
 314 %token _throw_ "throw"
 
 316 %token _typeof_ "typeof"
 
 319 %token _while_ "while"
 
 322 %token _abstract_ "abstract"
 
 323 %token _await_ "await"
 
 324 %token _boolean_ "boolean"
 
 327 %token _double_ "double"
 
 328 %token _final_ "final"
 
 329 %token _float_ "float"
 
 331 %token _implements_ "implements"
 
 333 %token _interface_ "interface"
 
 336 %token _native_ "native"
 
 337 %token _package_ "package"
 
 338 %token _private_ "private"
 
 339 %token _protected_ "protected"
 
 340 %token _public_ "public"
 
 341 %token _short_ "short"
 
 342 %token _static_ "static"
 
 343 %token _synchronized_ "synchronized"
 
 344 %token _throws_ "throws"
 
 345 %token _transient_ "transient"
 
 346 %token _volatile_ "volatile"
 
 347 %token _yield_ "yield"
 
 349 %token _undefined_ "undefined"
 
 365 %token _namespace_ "namespace"
 
 371 %token <identifier_> Identifier_
 
 372 %token <number_> NumericLiteral
 
 373 %token <string_> StringLiteral
 
 374 %token <literal_> RegularExpressionLiteral
 
 376 %token <string_> NoSubstitutionTemplate
 
 377 %token <string_> TemplateHead
 
 378 %token <string_> TemplateMiddle
 
 379 %token <string_> TemplateTail
 
 381 %type <expression_> AdditiveExpression
 
 382 %type <argument_> ArgumentList_
 
 383 %type <argument_> ArgumentList
 
 384 %type <argument_> ArgumentListOpt
 
 385 %type <argument_> Arguments
 
 386 %type <expression_> ArrayComprehension
 
 387 %type <literal_> ArrayLiteral
 
 388 %type <expression_> ArrowFunction
 
 389 %type <functionParameter_> ArrowParameters
 
 390 %type <expression_> AssignmentExpression
 
 391 %type <expression_> AssignmentExpressionOpt
 
 392 %type <identifier_> Binding
 
 393 %type <identifier_> BindingIdentifier
 
 394 %type <expression_> BitwiseANDExpression
 
 395 %type <statement_> Block
 
 396 %type <statement_> BlockStatement
 
 397 %type <boolean_> BooleanLiteral
 
 398 %type <declaration_> BindingElement
 
 399 %type <expression_> BitwiseORExpression
 
 400 %type <expression_> BitwiseXORExpression
 
 401 %type <statement_> BreakStatement
 
 402 %type <statement_> BreakableStatement
 
 403 %type <expression_> CallExpression_
 
 404 %type <expression_> CallExpression
 
 405 %type <clause_> CaseBlock
 
 406 %type <clause_> CaseClause
 
 407 %type <clause_> CaseClausesOpt
 
 409 %type <identifier_> CatchParameter
 
 410 %type <expression_> Comprehension
 
 411 %type <comprehension_> ComprehensionFor
 
 412 %type <comprehension_> ComprehensionIf
 
 413 %type <comprehension_> ComprehensionTail
 
 414 %type <expression_> ConditionalExpression
 
 415 %type <statement_> ContinueStatement
 
 416 %type <statement_> ConciseBody
 
 417 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
 
 418 %type <statement_> DebuggerStatement
 
 419 %type <statement_> Declaration__
 
 420 %type <statement_> Declaration_
 
 421 %type <statement_> Declaration
 
 422 %type <clause_> DefaultClause
 
 423 %type <element_> ElementList
 
 424 %type <element_> ElementListOpt
 
 425 %type <statement_> ElseStatementOpt
 
 426 %type <statement_> EmptyStatement
 
 427 %type <expression_> EqualityExpression
 
 428 %type <expression_> Expression
 
 429 %type <expression_> ExpressionOpt
 
 430 %type <statement_> ExpressionStatement
 
 431 %type <finally_> Finally
 
 432 %type <for_> ForStatementInitializer
 
 433 %type <forin_> ForInStatementInitializer
 
 434 %type <declaration_> FormalParameter
 
 435 %type <functionParameter_> FormalParameterList_
 
 436 %type <functionParameter_> FormalParameterList
 
 437 %type <functionParameter_> FormalParameterListOpt
 
 438 %type <statement_> FunctionBody
 
 439 %type <statement_> FunctionDeclaration
 
 440 %type <expression_> FunctionExpression
 
 441 %type <statement_> HoistableDeclaration
 
 442 %type <identifier_> Identifier
 
 443 %type <identifier_> IdentifierOpt
 
 444 %type <identifier_> IdentifierType
 
 445 %type <word_> IdentifierName
 
 446 %type <expression_> IdentifierReference
 
 447 %type <statement_> IfStatement
 
 448 %type <expression_> Initializer
 
 449 %type <expression_> InitializerOpt
 
 450 %type <statement_> IterationStatement
 
 451 %type <identifier_> LabelIdentifier
 
 452 %type <statement_> LabelledItem
 
 453 %type <statement_> LabelledStatement
 
 454 %type <expression_> LeftHandSideExpression
 
 455 %type <statement_> LetStatement
 
 456 %type <statement_> LexicalDeclaration
 
 457 %type <literal_> Literal
 
 458 %type <expression_> LogicalANDExpression
 
 459 %type <expression_> LogicalORExpression
 
 460 %type <member_> MemberAccess
 
 461 %type <expression_> MemberExpression_
 
 462 %type <expression_> MemberExpression
 
 463 %type <module_> Module
 
 464 %type <expression_> MultiplicativeExpression
 
 465 %type <expression_> NewExpression
 
 466 %type <null_> NullLiteral
 
 467 %type <literal_> ObjectLiteral
 
 468 %type <expression_> PostfixExpression
 
 469 %type <expression_> PrimaryExpression
 
 470 %type <propertyName_> PropertyName_
 
 471 %type <propertyName_> PropertyName
 
 472 %type <property_> PropertyDefinition
 
 473 %type <property_> PropertyDefinitionList_
 
 474 %type <property_> PropertyDefinitionList
 
 475 %type <property_> PropertyDefinitionListOpt
 
 476 %type <expression_> RelationalExpression
 
 477 %type <statement_> ReturnStatement
 
 478 %type <rubyProc_> RubyProcExpression
 
 479 %type <functionParameter_> RubyProcParameterList_
 
 480 %type <functionParameter_> RubyProcParameterList
 
 481 %type <functionParameter_> RubyProcParameters
 
 482 %type <functionParameter_> RubyProcParametersOpt
 
 483 %type <statement_> Script
 
 484 %type <statement_> ScriptBody
 
 485 %type <statement_> ScriptBodyOpt
 
 486 %type <expression_> ShiftExpression
 
 487 %type <declaration_> SingleNameBinding
 
 488 %type <statement_> Statement__
 
 489 %type <statement_> Statement_
 
 490 %type <statement_> Statement
 
 491 %type <statement_> StatementList
 
 492 %type <statement_> StatementListOpt
 
 493 %type <statement_> StatementListItem
 
 494 %type <statement_> SwitchStatement
 
 495 %type <expression_> TemplateLiteral
 
 496 %type <span_> TemplateSpans
 
 497 %type <statement_> ThrowStatement
 
 498 %type <statement_> TryStatement
 
 499 %type <expression_> UnaryExpression_
 
 500 %type <expression_> UnaryExpression
 
 501 %type <declaration_> VariableDeclaration
 
 502 %type <declarations_> VariableDeclarationList_
 
 503 %type <declarations_> VariableDeclarationList
 
 504 %type <statement_> VariableStatement
 
 505 %type <statement_> WithStatement
 
 508 %type <word_> WordOpt
 
 512 %type <specifier_> IntegerType
 
 513 %type <specifier_> IntegerTypeOpt
 
 514 %type <typedIdentifier_> PrefixedType
 
 515 %type <specifier_> PrimitiveType
 
 516 %type <typedIdentifier_> SuffixedType
 
 517 %type <typedIdentifier_> TypeSignifier
 
 518 %type <modifier_> TypeQualifierLeft
 
 519 %type <typedIdentifier_> TypeQualifierRight
 
 520 %type <typedIdentifier_> TypedIdentifier
 
 521 %type <typedParameter_> TypedParameterList_
 
 522 %type <typedParameter_> TypedParameterList
 
 523 %type <typedParameter_> TypedParameterListOpt
 
 527 %type <expression_> BoxableExpression
 
 528 %type <statement_> CategoryStatement
 
 529 %type <classField_> ClassFieldListOpt
 
 530 %type <classField_> ClassFields
 
 531 %type <statement_> ClassStatement
 
 532 %type <expression_> ClassSuperOpt
 
 533 %type <message_> ClassMessageDeclaration
 
 534 %type <message_> ClassMessageDeclarationListOpt
 
 535 %type <className_> ClassName
 
 536 %type <protocol_> ClassProtocolListOpt
 
 537 %type <protocol_> ClassProtocols
 
 538 %type <protocol_> ClassProtocolsOpt
 
 539 %type <expression_> MessageExpression
 
 540 %type <messageParameter_> MessageParameter
 
 541 %type <messageParameter_> MessageParameters
 
 542 %type <messageParameter_> MessageParameterList
 
 543 %type <messageParameter_> MessageParameterListOpt
 
 544 %type <bool_> MessageScope
 
 545 %type <argument_> SelectorCall_
 
 546 %type <argument_> SelectorCall
 
 547 %type <selector_> SelectorExpression_
 
 548 %type <selector_> SelectorExpression
 
 549 %type <selector_> SelectorExpressionOpt
 
 550 %type <argument_> SelectorList
 
 551 %type <word_> SelectorWordOpt
 
 552 %type <typedIdentifier_> TypeOpt
 
 553 %type <argument_> VariadicCall
 
 557 %type <propertyIdentifier_> PropertyIdentifier_
 
 558 %type <selector_> PropertySelector_
 
 559 %type <selector_> PropertySelector
 
 560 %type <identifier_> QualifiedIdentifier_
 
 561 %type <identifier_> QualifiedIdentifier
 
 562 %type <identifier_> WildcardIdentifier
 
 563 %type <identifier_> XMLComment
 
 564 %type <identifier_> XMLCDATA
 
 565 %type <identifier_> XMLElement
 
 566 %type <identifier_> XMLElementContent
 
 567 %type <identifier_> XMLMarkup
 
 568 %type <identifier_> XMLPI
 
 570 %type <attribute_> AttributeIdentifier
 
 571 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
 
 572 %type <expression_> PropertyIdentifier
 
 573 %type <expression_> XMLListInitialiser
 
 574 %type <expression_> XMLInitialiser
 
 577 /* Token Priorities {{{ */
 
 589 /* Lexer State {{{ */
 
 591     : { driver.in_.push(true); }
 
 595     : { driver.in_.push(false); }
 
 599     : { driver.in_.pop(); }
 
 603     : { driver.SetCondition(CYDriver::RegExpCondition); }
 
 607     : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
 
 611     : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
 
 615     : { CYMAP(_class__, _class_); }
 
 619     : { CYMAP(_function__, _function_); }
 
 623     : LexNoBrace LexNoClass LexNoFunction
 
 626 /* Virtual Tokens {{{ */
 
 637 /* 11.6 Names and Keywords {{{ */
 
 640     | "for" { $$ = CYNew CYWord("for"); }
 
 641     | "in" { $$ = CYNew CYWord("in"); }
 
 642     | "instanceof" { $$ = CYNew CYWord("instanceof"); }
 
 646     : Identifier { $$ = $1; }
 
 647     | "auto" { $$ = CYNew CYWord("auto"); }
 
 648     | "break" { $$ = CYNew CYWord("break"); }
 
 649     | "case" { $$ = CYNew CYWord("case"); }
 
 650     | "catch" { $$ = CYNew CYWord("catch"); }
 
 651     | "class" { $$ = CYNew CYWord("class"); }
 
 652     | "!class" { $$ = CYNew CYWord("class"); }
 
 653     | "const" { $$ = CYNew CYWord("const"); }
 
 654     | "continue" { $$ = CYNew CYWord("continue"); }
 
 655     | "debugger" { $$ = CYNew CYWord("debugger"); }
 
 656     | "default" { $$ = CYNew CYWord("default"); }
 
 657     | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
 
 658     | "do" { $$ = CYNew CYWord("do"); }
 
 659     | "else" { $$ = CYNew CYWord("else"); }
 
 660     | "enum" { $$ = CYNew CYWord("enum"); }
 
 661     | "export" { $$ = CYNew CYWord("export"); }
 
 662     | "extends" { $$ = CYNew CYWord("extends"); }
 
 663     | "false" { $$ = CYNew CYWord("false"); }
 
 664     | "finally" { $$ = CYNew CYWord("finally"); }
 
 665     | "function" { $$ = CYNew CYWord("function"); }
 
 666     | "if" { $$ = CYNew CYWord("if"); }
 
 667     | "import" { $$ = CYNew CYWord("import"); }
 
 668     | "!in" { $$ = CYNew CYWord("in"); }
 
 669     | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
 
 670     | "null" { $$ = CYNew CYWord("null"); }
 
 671     | "return" { $$ = CYNew CYWord("return"); }
 
 672     | "super" { $$ = CYNew CYWord("super"); }
 
 673     | "switch" { $$ = CYNew CYWord("switch"); }
 
 674     | "this" { $$ = CYNew CYWord("this"); }
 
 675     | "throw" { $$ = CYNew CYWord("throw"); }
 
 676     | "true" { $$ = CYNew CYWord("true"); }
 
 677     | "try" { $$ = CYNew CYWord("try"); }
 
 678     | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
 
 679     | "var" { $$ = CYNew CYWord("var"); }
 
 680     | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
 
 681     | "while" { $$ = CYNew CYWord("while"); }
 
 682     | "with" { $$ = CYNew CYWord("with"); }
 
 684     // XXX: should be Identifier
 
 685     | "let" { $$ = CYNew CYIdentifier("let"); }
 
 695 /* 11.8.1 Null Literals {{{ */
 
 697     : "null" { $$ = CYNew CYNull(); }
 
 700 /* 11.8.2 Boolean Literals {{{ */
 
 702     : "true" { $$ = CYNew CYTrue(); }
 
 703     | "false" { $$ = CYNew CYFalse(); }
 
 707 /* 11.9 Automatic Semicolon Insertion {{{ */
 
 709     : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
 
 719     | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) { CYERR(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
 
 724     | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
 
 728 /* 12.1 Identifiers {{{ */
 
 730     : Identifier { $$ = CYNew CYVariable($1); }
 
 735     : Identifier { $$ = $1; }
 
 740     : Identifier { $$ = $1; }
 
 745     : Identifier_ { $$ = $1; }
 
 746     | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
 
 747     | "await" { $$ = CYNew CYIdentifier("await"); }
 
 748     | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
 
 749     | "byte" { $$ = CYNew CYIdentifier("byte"); }
 
 750     | "double" { $$ = CYNew CYIdentifier("double"); }
 
 751     | "each" { $$ = CYNew CYIdentifier("each"); }
 
 752     | "final" { $$ = CYNew CYIdentifier("final"); }
 
 753     | "float" { $$ = CYNew CYIdentifier("float"); }
 
 754     | "goto" { $$ = CYNew CYIdentifier("goto"); }
 
 755     | "implements" { $$ = CYNew CYIdentifier("implements"); }
 
 756     | "interface" { $$ = CYNew CYIdentifier("interface"); }
 
 757     | "native" { $$ = CYNew CYIdentifier("native"); }
 
 758     | "of" { $$ = CYNew CYIdentifier("of"); }
 
 759     | "package" { $$ = CYNew CYIdentifier("package"); }
 
 760     | "private" { $$ = CYNew CYIdentifier("private"); }
 
 761     | "protected" { $$ = CYNew CYIdentifier("protected"); }
 
 762     | "public" { $$ = CYNew CYIdentifier("public"); }
 
 763     | "static" { $$ = CYNew CYIdentifier("static"); }
 
 764     | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
 
 765     | "throws" { $$ = CYNew CYIdentifier("throws"); }
 
 766     | "transient" { $$ = CYNew CYIdentifier("transient"); }
 
 767     | "yield" { $$ = CYNew CYIdentifier("yield"); }
 
 769     | "bool" { $$ = CYNew CYIdentifier("bool"); }
 
 770     | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
 
 771     | "id" { $$ = CYNew CYIdentifier("id"); }
 
 772     | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
 
 778     | "char" { $$ = CYNew CYIdentifier("char"); }
 
 779     | "int" { $$ = CYNew CYIdentifier("int"); }
 
 780     | "long" { $$ = CYNew CYIdentifier("long"); }
 
 781     | "short" { $$ = CYNew CYIdentifier("short"); }
 
 782     | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
 
 783     | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
 
 785     | "extern" { $$ = CYNew CYIdentifier("extern"); }
 
 786     | "signed" { $$ = CYNew CYIdentifier("signed"); }
 
 787     | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
 
 788     | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
 
 791     | "nil" { $$ = CYNew CYIdentifier("nil"); }
 
 792     | "NO" { $$ = CYNew CYIdentifier("NO"); }
 
 793     | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
 
 794     | "YES" { $$ = CYNew CYIdentifier("YES"); }
 
 799     : Identifier { $$ = $1; }
 
 803 /* 12.2 Primary Expression {{{ */
 
 805     : "this" { $$ = CYNew CYThis(); }
 
 806     | IdentifierReference { $$ = $1; }
 
 807     | Literal { $$ = $1; }
 
 808     | ArrayLiteral { $$ = $1; }
 
 809     | ObjectLiteral { $$ = $1; }
 
 810     | RegularExpressionLiteral { $$ = $1; }
 
 811     | TemplateLiteral { $$ = $1; }
 
 812     | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
 
 813     | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
 
 816 CoverParenthesizedExpressionAndArrowParameterList
 
 817     : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
 
 818     | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
 
 821 /* 12.2.4 Literals {{{ */
 
 823     : NullLiteral { $$ = $1; }
 
 824     | BooleanLiteral { $$ = $1; }
 
 825     | NumericLiteral { $$ = $1; }
 
 826     | StringLiteral { $$ = $1; }
 
 829 /* 12.2.5 Array Initializer {{{ */
 
 831     : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
 
 835     : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
 
 836     | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
 
 837     | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
 
 841     : ElementList { $$ = $1; }
 
 842     | LexSetRegExp { $$ = NULL; }
 
 845 /* 12.2.6 Object Initializer {{{ */
 
 847     : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
 
 850 PropertyDefinitionList_
 
 851     : "," PropertyDefinitionList { $$ = $2; }
 
 852     | "," LexSetRegExp { $$ = NULL; }
 
 856 PropertyDefinitionList
 
 857     : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
 
 860 PropertyDefinitionListOpt
 
 861     : PropertyDefinitionList { $$ = $1; }
 
 862     | LexSetRegExp { $$ = NULL; }
 
 866     // XXX: this should be IdentifierName
 
 867     : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
 
 868     | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
 
 873     : IdentifierName { $$ = $1; }
 
 874     | StringLiteral { $$ = $1; }
 
 875     | NumericLiteral { $$ = $1; }
 
 879     : LexSetRegExp PropertyName_ { $$ = $2; }
 
 884     : "=" AssignmentExpression { $$ = $2; }
 
 888     : Initializer { $$ = $1; }
 
 892 /* 12.2.9 Template Literals {{{ */
 
 894     : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
 
 895     | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
 
 899     : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
 
 900     | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
 
 904 /* 12.3+ Left-Hand-Side Expressions {{{ */
 
 906     : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
 
 907     | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
 
 908     | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
 
 912     : MemberExpression { $$ = $1; }
 
 913     //| "super" { $$ = $1; }
 
 917     : LexSetRegExp PrimaryExpression { $$ = $2; }
 
 918     | LexSetRegExp FunctionExpression { $$ = $2; }
 
 919     | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 920     | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
 
 924     : MemberExpression { $$ = $1; }
 
 925     | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
 
 934     : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
 
 935     | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 939     : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
 
 943     : "," ArgumentList { $$ = $2; }
 
 948     : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
 
 949     | LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
 
 953     : ArgumentList { $$ = $1; }
 
 954     | LexSetRegExp { $$ = NULL; }
 
 957 LeftHandSideExpression
 
 958     : NewExpression { $$ = $1; }
 
 959     | CallExpression { $$ = $1; }
 
 962 /* 12.4 Postfix Expressions {{{ */
 
 964     : %prec "" LeftHandSideExpression { $$ = $1; }
 
 965     | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
 
 966     | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
 
 969 /* 12.5 Unary Operators {{{ */
 
 971     : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
 
 972     | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
 
 973     | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
 
 974     | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 975     | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 976     | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 977     | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 978     | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
 
 979     | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
 
 980     | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
 
 981     | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
 
 985     : PostfixExpression { $$ = $1; }
 
 986     | LexSetRegExp UnaryExpression_ { $$ = $2; }
 
 989 /* 12.6 Multiplicative Operators {{{ */
 
 990 MultiplicativeExpression
 
 991     : UnaryExpression { $$ = $1; }
 
 992     | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
 
 993     | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
 
 994     | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
 
 997 /* 12.7 Additive Operators {{{ */
 
 999     : MultiplicativeExpression { $$ = $1; }
 
1000     | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
 
1001     | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
 
1004 /* 12.8 Bitwise Shift Operators {{{ */
 
1006     : AdditiveExpression { $$ = $1; }
 
1007     | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
 
1008     | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
 
1009     | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
 
1012 /* 12.9 Relational Operators {{{ */
 
1013 RelationalExpression
 
1014     : ShiftExpression { $$ = $1; }
 
1015     | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
 
1016     | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
 
1017     | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
 
1018     | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
 
1019     | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
 
1020     | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
 
1023 /* 12.10 Equality Operators {{{ */
 
1025     : RelationalExpression { $$ = $1; }
 
1026     | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
 
1027     | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
 
1028     | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
 
1029     | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
 
1032 /* 12.11 Binary Bitwise Operators {{{ */
 
1033 BitwiseANDExpression
 
1034     : EqualityExpression { $$ = $1; }
 
1035     | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1038 BitwiseXORExpression
 
1039     : BitwiseANDExpression { $$ = $1; }
 
1040     | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1044     : BitwiseXORExpression { $$ = $1; }
 
1045     | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
 
1048 /* 12.12 Binary Logical Operators {{{ */
 
1049 LogicalANDExpression
 
1050     : BitwiseORExpression { $$ = $1; }
 
1051     | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
 
1055     : LogicalANDExpression { $$ = $1; }
 
1056     | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
 
1059 /* 12.13 Conditional Operator ( ? : ) {{{ */
 
1060 ConditionalExpression
 
1061     : LogicalORExpression { $$ = $1; }
 
1062     | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
 
1065 /* 12.14 Assignment Operators {{{ */
 
1066 AssignmentExpression
 
1067     : ConditionalExpression { $$ = $1; }
 
1068     // XXX: | YieldExpression { $$ = $1; }
 
1069     | ArrowFunction { $$ = $1; }
 
1070     | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
 
1071     | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
 
1072     | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
 
1073     | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
 
1074     | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
 
1075     | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
 
1076     | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
 
1077     | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
 
1078     | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
 
1079     | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
 
1080     | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
 
1081     | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
 
1084 AssignmentExpressionOpt
 
1085     : AssignmentExpression { $$ = $1; }
 
1086     | LexSetRegExp { $$ = NULL; }
 
1089 /* 12.15 Comma Operator ( , ) {{{ */
 
1091     : AssignmentExpression { $$ = $1; }
 
1092     /* XXX: I have this backwards... */
 
1093     | AssignmentExpression "," Expression { $$ = CYNew CYCompound($1, $3); }
 
1097     : Expression { $$ = $1; }
 
1098     | LexSetRegExp { $$ = NULL; }
 
1102 /* 13 Statements and Declarations {{{ */
 
1104     : BlockStatement { $$ = $1; }
 
1105     | VariableStatement { $$ = $1; }
 
1106     | EmptyStatement { $$ = $1; }
 
1107     | IfStatement { $$ = $1; }
 
1108     | BreakableStatement { $$ = $1; }
 
1109     | ContinueStatement { $$ = $1; }
 
1110     | BreakStatement { $$ = $1; }
 
1111     | ReturnStatement { $$ = $1; }
 
1112     | WithStatement { $$ = $1; }
 
1113     | LabelledStatement { $$ = $1; }
 
1114     | ThrowStatement { $$ = $1; }
 
1115     | TryStatement { $$ = $1; }
 
1116     | DebuggerStatement { $$ = $1; }
 
1120     : LexSetRegExp Statement__ { $$ = $2; }
 
1121     | ExpressionStatement { $$ = $1; }
 
1125     : LexSetStatement Statement_ { $$ = $2; }
 
1129     : HoistableDeclaration { $$ = $1; }
 
1130     // XXX: | ClassDeclaration { $$ = $1; }
 
1131     | LexicalDeclaration { $$ = $1; }
 
1135     : LexSetRegExp Declaration__ { $$ = $2; }
 
1139     : LexSetStatement Declaration_ { $$ = $2; }
 
1142 HoistableDeclaration
 
1143     : FunctionDeclaration
 
1144     // XXX: | GeneratorDeclaration
 
1148     : IterationStatement { $$ = $1; }
 
1149     | SwitchStatement { $$ = $1; }
 
1152 /* 13.2 Block {{{ */
 
1154     : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
 
1158     : BRACE StatementListOpt "}" { $$ = $2; }
 
1162     : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
 
1166     : StatementList { $$ = $1; }
 
1167     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1171     : Statement { $$ = $1; }
 
1172     | Declaration { $$ = $1; }
 
1175 /* 13.3+ Let and Const Declarations {{{ */
 
1177     : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1189 // XXX: lots of binding stuff
 
1191 /* 13.3.2+ Variable Statement {{{ */
 
1193     : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1196 VariableDeclarationList_
 
1197     : "," VariableDeclarationList { $$ = $2; }
 
1201 VariableDeclarationList
 
1202     : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
 
1206     : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1207     // XXX: | BindingPattern Initializer { $$ = CYNew CYDeclaration($1, $2); }
 
1210 /* 13.3.3+ Destructuring Binding Patterns {{{ */
 
1214     : SingleNameBinding { $$ = $1; }
 
1218     : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1221 /* 13.4 Empty Statement {{{ */
 
1223     : ";" { $$ = CYNew CYEmpty(); }
 
1226 /* 13.5 Expression Statement {{{ */
 
1228     : Expression Terminator { $$ = CYNew CYExpress($1); }
 
1231 /* 13.6 The if Statement {{{ */
 
1233     : "else" Statement { $$ = $2; }
 
1234     | %prec "if" { $$ = NULL; }
 
1238     : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
 
1241 /* 13.7+ Iteration Statements {{{ */
 
1243     : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
 
1244     | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
 
1245     | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
 
1246     | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
 
1247     | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
 
1250 ForStatementInitializer
 
1251     : ExpressionOpt { $$ = $1; }
 
1252     | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
 
1255 ForInStatementInitializer
 
1256     : LeftHandSideExpression { $$ = $1; }
 
1257     | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
 
1260 /* 13.8 The continue Statement {{{ */
 
1262     : "continue" LexNewLine
 
1266     : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
 
1267     | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
 
1270 /* 13.9 The break Statement {{{ */
 
1272     : "break" LexNewLine
 
1276     : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
 
1277     | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
 
1280 /* 13.10 The return Statement {{{ */
 
1282     : "return" LexNewLine
 
1286     : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
 
1287     | Return Expression Terminator { $$ = CYNew CYReturn($2); }
 
1290 /* 13.11 The with Statement {{{ */
 
1292     : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
 
1295 /* 13.12 The switch Statement {{{ */
 
1297     : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
 
1301     : BRACE CaseClausesOpt "}" { $$ = $2; }
 
1305     : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
 
1309     : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1310     | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1314 // XXX: the standard makes certain you can only have one of these
 
1316     : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
 
1319 /* 13.13 Labelled Statements {{{ */
 
1321     : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
 
1325     : Statement { $$ = $1; }
 
1326     | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
 
1329 /* 13.14 The throw Statement {{{ */
 
1331     : "throw" LexNewLine
 
1335     : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
 
1336     | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
 
1339 /* 13.15 The try Statement {{{ */
 
1341     : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
 
1342     | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
 
1343     | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
 
1347     : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
 
1351     : "finally" Block { $$ = CYNew CYFinally($2); }
 
1355     : BindingIdentifier { $$ = $1; }
 
1356     // XXX: BindingPattern
 
1359 /* 13.16 The debugger Statement {{{ */
 
1361     : "debugger" Terminator { $$ = CYNew CYDebugger(); }
 
1365 /* 14.1+ Function Definitions {{{ */
 
1367     : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
 
1371     : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
 
1374 FormalParameterList_
 
1375     : "," FormalParameterList { $$ = $2; }
 
1380     // XXX: : FunctionRestParameter { $$ = $1; }
 
1381     : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
 
1384 FormalParameterListOpt
 
1385     : FormalParameterList
 
1389 /* XXX: FunctionRestParameter
 
1390     : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
 
1394     : BindingElement { $$ = $1; }
 
1398     : StatementListOpt { $$ = $1; }
 
1401 /* 14.2 Arrow Function Definitions {{{ */
 
1403     : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
 
1407     : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
 
1408     | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); }
 
1412     : AssignmentExpression { $$ = CYNew CYReturn($1); }
 
1413     | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
 
1416 /* 14.3+ Method Definitions {{{ */
 
1418 /* 14.4+ Generator Function Definitions {{{ */
 
1420 /* 14.5+ Class Definitions {{{ */
 
1423 /* 15.1 Scripts {{{ */
 
1425     : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
 
1429     : StatementList { $$ = $1; }
 
1433     : ScriptBody { $$ = $1; }
 
1434     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1437 /* 15.2+ Modules {{{ */
 
1439 /* 15.2.2+ Imports {{{ */
 
1441 /* 15.2.3+ Exports {{{ */
 
1445 /* Cycript (C): Type Encoding {{{ */
 
1447     : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
 
1448     | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
 
1452     : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
 
1453     | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
 
1454     | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
 
1455     | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
 
1456     | TypeSignifier { $$ = $1; }
 
1457     | { $$ = CYNew CYTypedIdentifier(@$); }
 
1461     : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
 
1466     | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
 
1467     | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
 
1471     : PrefixedType { $$ = $1; }
 
1472     | SuffixedType { $$ = $1; }
 
1473     | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
 
1474     | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
 
1478     : "int" { $$ = CYNew CYTypeVariable("int"); }
 
1479     | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
 
1480     | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
 
1481     | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
 
1482     | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
 
1486     : IntegerType { $$ = $1; }
 
1487     | { $$ = CYNew CYTypeVariable("int"); }
 
1491     : IdentifierType { $$ = CYNew CYTypeVariable($1); }
 
1492     | IntegerType { $$ = $1; }
 
1493     | "void" { $$ = CYNew CYTypeVoid(); }
 
1494     | "char" { $$ = CYNew CYTypeVariable("char"); }
 
1495     | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
 
1496     | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
 
1500     : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
 
1504     : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
 
1510 /* Cycript (Objective-C): @class Declaration {{{ */
 
1512     /* XXX: why the hell did I choose MemberExpression? */
 
1513     : ":" LexSetRegExp MemberExpression { $$ = $3; }
 
1518     : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
 
1519     | LexSetRegExp { $$ = NULL; }
 
1523     : BRACE ClassFieldListOpt "}" { $$ = $2; }
 
1527     : "+" { $$ = false; }
 
1528     | "-" { $$ = true; }
 
1532     : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
 
1533     | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
 
1537     : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
 
1540 MessageParameterList
 
1541     : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
 
1544 MessageParameterListOpt
 
1545     : MessageParameterList { $$ = $1; }
 
1550     : MessageParameterList { $$ = $1; }
 
1551     | Word { $$ = CYNew CYMessageParameter($1, NULL); }
 
1554 ClassMessageDeclaration
 
1555     : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
 
1558 ClassMessageDeclarationListOpt
 
1559     : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
 
1564     : Identifier { $$ = $1; }
 
1565     | "(" AssignmentExpression ")" { $$ = $2; }
 
1568 // XXX: this should be AssignmentExpressionNoRight
 
1570     : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
 
1574     : "," ClassProtocols { $$ = $2; }
 
1578 ClassProtocolListOpt
 
1579     : "<" ClassProtocols ">" { $$ = $2; }
 
1584     : "@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
 
1592     : "@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
 
1596     : ClassStatement { $$ = $1; }
 
1597     | CategoryStatement { $$ = $1; }
 
1600 /* Cycript (Objective-C): Send Message {{{ */
 
1602     : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
 
1607     : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
 
1608     | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
 
1612     : SelectorCall { $$ = $1; }
 
1613     | VariadicCall { $$ = $1; }
 
1617     : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
 
1621     : SelectorCall { $$ = $1; }
 
1622     | Word { $$ = CYNew CYArgument($1, NULL); }
 
1626     : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
 
1627     | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
 
1631     : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
 
1635     : SelectorExpression_ { $$ = $1; }
 
1636     | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
 
1639 SelectorExpressionOpt
 
1640     : SelectorExpression_ { $$ = $1; }
 
1645     : MessageExpression { $$ = $1; }
 
1646     | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
 
1651 /* Cycript: @import Directive {{{ */
 
1653     : Module "." Word { $$ = CYNew CYModule($3, $1); }
 
1654     | Word { $$ = CYNew CYModule($1); }
 
1658     : "@import" Module { $$ = CYNew CYImport($2); }
 
1663 /* Cycript (Objective-C): Boxed Expressions {{{ */
 
1665     : NullLiteral { $$ = $1; }
 
1666     | BooleanLiteral { $$ = $1; }
 
1667     | NumericLiteral { $$ = $1; }
 
1668     | StringLiteral { $$ = $1; }
 
1669     | ArrayLiteral { $$ = $1; }
 
1670     | ObjectLiteral { $$ = $1; }
 
1671     | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
 
1672     | "YES" { $$ = CYNew CYTrue(); }
 
1673     | "NO" { $$ = CYNew CYFalse(); }
 
1677     : "@" BoxableExpression { $$ = CYNew CYBox($2); }
 
1678     | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1679     | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1680     | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1681     | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1682     | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
 
1685 /* Cycript (Objective-C): Block Expressions {{{ */
 
1687     : "^" TypedIdentifier { if ($2->identifier_ != NULL) CYERR($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else CYERR($2->location_, "expected parameters"); }
 
1690 /* Cycript (Objective-C): Instance Literals {{{ */
 
1692     : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
 
1698 /* Cycript (C): Pointer Indirection/Addressing {{{ */
 
1699 LeftHandSideExpression
 
1700     : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
 
1704     : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
 
1708     : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
 
1709     | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
 
1710     | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
 
1713 /* Cycript (C): auto Compatibility {{{ */
 
1718 /* Cycript (C): Lambda Expressions {{{ */
 
1720     : "," TypedParameterList { $$ = $2; }
 
1725     : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
 
1728 TypedParameterListOpt
 
1729     : TypedParameterList { $$ = $1; }
 
1734     : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
 
1737 /* Cycript (C): Type Definitions {{{ */
 
1739     : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
 
1742 /* Cycript (C): extern "C" {{{ */
 
1744     : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) CYERR(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) CYERR($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
 
1751 /* Lexer State {{{ */
 
1753     : { driver.PushCondition(CYDriver::RegExpCondition); }
 
1757     : { driver.PushCondition(CYDriver::XMLContentCondition); }
 
1761     : { driver.PushCondition(CYDriver::XMLTagCondition); }
 
1765     : { driver.PopCondition(); }
 
1769     : { driver.SetCondition(CYDriver::XMLContentCondition); }
 
1773     : { driver.SetCondition(CYDriver::XMLTagCondition); }
 
1776 /* Virtual Tokens {{{ */
 
1783 /* 8.1 Context Keywords {{{ */
 
1785     : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
 
1786     | "xml" { $$ = CYNew CYIdentifier("xml"); }
 
1789 /* 8.3 XML Initializer Input Elements {{{ */
 
1791     : XMLComment { $$ = $1; }
 
1792     | XMLCDATA { $$ = $1; }
 
1793     | XMLPI { $$ = $1; }
 
1797 /* 11.1 Primary Expressions {{{ */
 
1799     : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
 
1800     | XMLInitialiser { $$ = $1; }
 
1801     | XMLListInitialiser { $$ = $1; }
 
1805     : AttributeIdentifier { $$ = $1; }
 
1806     | QualifiedIdentifier { $$ = $1; }
 
1807     | WildcardIdentifier { $$ = $1; }
 
1810 /* 11.1.1 Attribute Identifiers {{{ */
 
1812     : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
 
1816     : PropertySelector { $$ = $1; }
 
1817     | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
 
1821     : Identifier { $$ = CYNew CYSelector($1); }
 
1822     | WildcardIdentifier { $$ = $1; }
 
1825 /* 11.1.2 Qualified Identifiers {{{ */
 
1826 QualifiedIdentifier_
 
1827     : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
 
1828     | QualifiedIdentifier { $$ = $1; }
 
1832     : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
 
1835 /* 11.1.3 Wildcard Identifiers {{{ */
 
1837     : "*" { $$ = CYNew CYWildcard(); }
 
1840 /* 11.1.4 XML Initializer {{{ */
 
1842     : XMLMarkup { $$ = $1; }
 
1843     | XMLElement { $$ = $1; }
 
1847     : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
 
1848     | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
 
1852     : LexPushXMLTag XMLTagName XMLAttributes
 
1856     : BRACE LexPushRegExp Expression LexPop "}"
 
1865     : XMLAttributes_ XMLAttribute
 
1870     : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
 
1871     | XMLAttributes_ XMLWhitespaceOpt
 
1880     : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
 
1884     : XMLExpression XMLElementContentOpt
 
1885     | XMLMarkup XMLElementContentOpt
 
1886     | XMLText XMLElementContentOpt
 
1887     | XMLElement XMLElementContentOpt
 
1890 XMLElementContentOpt
 
1895 /* 11.1.5 XMLList Initializer {{{ */
 
1897     : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
 
1901 /* 11.2 Left-Hand-Side Expressions {{{ */
 
1903     : Identifier { $$ = $1; }
 
1904     | PropertyIdentifier { $$ = $1; }
 
1908     : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
 
1909     | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
 
1910     | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
 
1913 /* 12.1 The default xml namespace Statement {{{ */
 
1914 /* XXX: DefaultXMLNamespaceStatement
 
1915     : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
 
1919     : DefaultXMLNamespaceStatement { $$ = $1; }
 
1924 /* JavaScript FTL: Array Comprehensions {{{ */
 
1926     : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
 
1930     : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
 
1931     | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
 
1934 /* JavaScript FTL: for each {{{ */
 
1936     : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
 
1939 /* JavaScript FTL: let Statements {{{ */
 
1941     : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
 
1949 /* JavaScript FTW: Array Comprehensions {{{ */
 
1951     : ArrayComprehension
 
1955     : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
 
1959     : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
 
1964     | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
 
1965     | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
 
1969     : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
 
1973     : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
 
1976 /* JavaScript FTW: Coalesce Operator {{{ */
 
1977 ConditionalExpression
 
1978     : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
 
1981 /* JavaScript FTW: Ruby Blocks {{{ */
 
1982 RubyProcParameterList_
 
1983     : "," RubyProcParameterList { $$ = $2; }
 
1987 RubyProcParameterList
 
1988     : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
 
1993     : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
 
1994     | LexSetRegExp "||" { $$ = NULL; }
 
1997 RubyProcParametersOpt
 
1998     : RubyProcParameters { $$ = $1; }
 
2003     : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
 
2007     : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
 
2011     : LeftHandSideExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }