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
 
  30 #define CYNew new($pool)
 
  33 #include "ObjectiveC/Syntax.hpp"
 
  37 #include "E4X/Syntax.hpp"
 
  40 #include "Highlight.hpp"
 
  49         CYDriver::Condition condition_;
 
  51         CYArgument *argument_;
 
  52         CYAssignment *assignment_;
 
  55         cy::Syntax::Catch *catch_;
 
  57         CYComprehension *comprehension_;
 
  58         CYDeclaration *declaration_;
 
  59         CYDeclarations *declarations_;
 
  61         CYExpression *expression_;
 
  64         CYForInitialiser *for_;
 
  65         CYForInInitialiser *forin_;
 
  66         CYFunctionParameter *functionParameter_;
 
  67         CYIdentifier *identifier_;
 
  74         CYParenthetical *parenthetical_;
 
  76         CYProperty *property_;
 
  77         CYPropertyName *propertyName_;
 
  78         CYRubyProc *rubyProc_;
 
  79         CYStatement *statement_;
 
  86         CYTypeModifier *modifier_;
 
  87         CYTypeSpecifier *specifier_;
 
  88         CYTypedIdentifier *typedIdentifier_;
 
  89         CYTypedParameter *typedParameter_;
 
  93         CYClassName *className_;
 
  94         CYClassField *classField_;
 
  96         CYMessageParameter *messageParameter_;
 
  97         CYProtocol *protocol_;
 
  98         CYSelectorPart *selector_;
 
 102         CYAttribute *attribute_;
 
 103         CYPropertyIdentifier *propertyIdentifier_;
 
 104         CYSelector *selector_;
 
 109 #define YYSTYPE YYSTYPE
 
 113 int cylex(YYSTYPE *, CYLocation *, void *);
 
 121     @$.begin.filename = @$.end.filename = &driver.filename_;
 
 127 %define api.location.type { CYLocation }
 
 134 %parse-param { CYDriver &driver }
 
 135 %lex-param { void *cyscanner }
 
 137 /* Token Declarations {{{ */
 
 143 %token XMLAttributeValue
 
 145 %token XMLTagCharacters
 
 151 %token LeftRight "<>"
 
 152 %token LeftSlashRight "</>"
 
 154 %token SlashRight "/>"
 
 155 %token LeftSlash "</"
 
 157 %token ColonColon "::"
 
 158 %token PeriodPeriod ".."
 
 161 @begin E4X ObjectiveC
 
 167 %token AmpersandAmpersand "&&"
 
 168 %token AmpersandEqual "&="
 
 170 %token CarrotEqual "^="
 
 172 %token EqualEqual "=="
 
 173 %token EqualEqualEqual "==="
 
 174 %token EqualRight "=>"
 
 175 %token Exclamation "!"
 
 176 %token ExclamationEqual "!="
 
 177 %token ExclamationEqualEqual "!=="
 
 179 %token HyphenEqual "-="
 
 180 %token HyphenHyphen "--"
 
 181 %token HyphenHyphen_ "\n--"
 
 182 %token HyphenRight "->"
 
 184 %token LeftEqual "<="
 
 186 %token LeftLeftEqual "<<="
 
 188 %token PercentEqual "%="
 
 190 %token PeriodPeriodPeriod "..."
 
 192 %token PipeEqual "|="
 
 195 %token PlusEqual "+="
 
 197 %token PlusPlus_ "\n++"
 
 199 %token RightEqual ">="
 
 200 %token RightRight ">>"
 
 201 %token RightRightEqual ">>="
 
 202 %token RightRightRight ">>>"
 
 203 %token RightRightRightEqual ">>>="
 
 205 %token SlashEqual "/="
 
 207 %token StarEqual "*="
 
 216 %token <comment_> Comment
 
 219 %token CloseParen ")"
 
 222 %token OpenBrace_ "\n{"
 
 223 %token OpenBrace__ ";{"
 
 224 %token CloseBrace "}"
 
 226 %token OpenBracket "["
 
 227 %token CloseBracket "]"
 
 229 %token AtError "@error"
 
 232 %token AtClass "@class"
 
 236 %token <identifier_> Typedef "typedef"
 
 237 %token <identifier_> Unsigned "unsigned"
 
 238 %token <identifier_> Signed "signed"
 
 239 %token <identifier_> Extern "extern"
 
 243 %token AtEncode "@encode"
 
 247 %token AtImplementation "@implementation"
 
 248 %token AtImplementation_ ";@implementation"
 
 249 %token AtImport "@import"
 
 251 %token AtSelector "@selector"
 
 252 %token AtNull "@null"
 
 255 %token AtTrue "@true"
 
 256 %token AtFalse "@false"
 
 257 %token <identifier_> Yes "YES"
 
 258 %token <identifier_> No "NO"
 
 261 %token <false_> False "false"
 
 262 %token <null_> Null "null"
 
 263 %token <true_> True "true"
 
 265 // ES3/ES5/WIE/JSC Reserved
 
 266 %token <word_> Auto "auto"
 
 267 %token <word_> Break "break"
 
 268 %token <word_> Case "case"
 
 269 %token <word_> Catch "catch"
 
 270 %token <word_> Continue "continue"
 
 271 %token <word_> Default "default"
 
 272 %token <word_> Delete "delete"
 
 273 %token <word_> Do "do"
 
 274 %token <word_> Else "else"
 
 275 %token <word_> Finally "finally"
 
 276 %token <word_> For "for"
 
 277 %token <word_> Function "function"
 
 278 %token <word_> Function_ ";function"
 
 279 %token <word_> If "if"
 
 280 %token <word_> In "in"
 
 281 %token <word_> In_ "!in"
 
 282 %token <word_> InstanceOf "instanceof"
 
 283 %token <word_> New "new"
 
 284 %token <word_> Return "return"
 
 285 %token <word_> Switch "switch"
 
 286 %token <this_> This "this"
 
 287 %token <word_> Throw "throw"
 
 288 %token <word_> Try "try"
 
 289 %token <word_> TypeOf "typeof"
 
 290 %token <word_> Var "var"
 
 291 %token <word_> Void "void"
 
 292 %token <word_> While "while"
 
 293 %token <word_> With "with"
 
 295 // ES3/IE6 Future, ES5/JSC Reserved
 
 296 %token <word_> Debugger "debugger"
 
 298 // ES3/ES5/IE6 Future, JSC Reserved
 
 299 %token <word_> Const "const"
 
 301 // ES3/ES5/IE6/JSC Future
 
 302 %token <word_> Class "class"
 
 303 %token <word_> Enum "enum"
 
 304 %token <word_> Export "export"
 
 305 %token <word_> Extends "extends"
 
 306 %token <word_> Import "import"
 
 307 %token <word_> Super "super"
 
 309 // ES3 Future, ES5 Strict Future
 
 310 %token <identifier_> Implements "implements"
 
 311 %token <identifier_> Interface "interface"
 
 312 %token <identifier_> Package "package"
 
 313 %token <identifier_> Private "private"
 
 314 %token <identifier_> Protected "protected"
 
 315 %token <identifier_> Public "public"
 
 316 %token <identifier_> Static "static"
 
 319 %token <identifier_> Abstract "abstract"
 
 320 %token <identifier_> Boolean "boolean"
 
 321 %token <identifier_> Byte "byte"
 
 322 %token <identifier_> Char "char"
 
 323 %token <identifier_> Double "double"
 
 324 %token <identifier_> Final "final"
 
 325 %token <identifier_> Float "float"
 
 326 %token <identifier_> Goto "goto"
 
 327 %token <identifier_> Int "int"
 
 328 %token <identifier_> Long "long"
 
 329 %token <identifier_> Native "native"
 
 330 %token <identifier_> Short "short"
 
 331 %token <identifier_> Synchronized "synchronized"
 
 332 %token <identifier_> Throws "throws"
 
 333 %token <identifier_> Transient "transient"
 
 334 %token <identifier_> Volatile "volatile"
 
 337 %token <identifier_> Let "let"
 
 338 %token <identifier_> Yield "yield"
 
 341 %token <identifier_> Each "each"
 
 342 %token <identifier_> Of "of"
 
 346 %token <identifier_> Namespace "namespace"
 
 347 %token <identifier_> XML "xml"
 
 352 %token <identifier_> Identifier_
 
 353 %token <number_> NumericLiteral
 
 354 %token <string_> StringLiteral
 
 355 %token <literal_> RegularExpressionLiteral
 
 357 %type <expression_> AdditiveExpression
 
 358 %type <argument_> ArgumentList_
 
 359 %type <argument_> ArgumentList
 
 360 %type <argument_> ArgumentListOpt
 
 361 %type <argument_> Arguments
 
 362 %type <expression_> ArrayComprehension
 
 363 %type <expression_> ArrayInitialiser
 
 364 %type <literal_> ArrayLiteral
 
 365 %type <expression_> ArrowFunction
 
 366 %type <functionParameter_> ArrowParameters
 
 367 %type <expression_> AssignmentExpression
 
 368 %type <identifier_> Binding
 
 369 %type <identifier_> BindingIdentifier
 
 370 %type <expression_> BitwiseANDExpression
 
 371 %type <statement_> Block_
 
 372 %type <statement_> Block
 
 373 %type <boolean_> BooleanLiteral
 
 374 %type <declaration_> BindingElement
 
 375 %type <expression_> BitwiseORExpression
 
 376 %type <expression_> BitwiseXORExpression
 
 377 %type <statement_> BreakStatement
 
 378 %type <statement_> BreakableStatement
 
 379 %type <expression_> CallExpression_
 
 380 %type <expression_> CallExpression
 
 381 %type <clause_> CaseBlock
 
 382 %type <clause_> CaseClause
 
 383 %type <clause_> CaseClausesOpt
 
 384 %type <catch_> CatchOpt
 
 385 %type <expression_> Comprehension
 
 386 %type <comprehension_> ComprehensionFor
 
 387 %type <comprehension_> ComprehensionIf
 
 388 %type <comprehension_> ComprehensionTail
 
 389 %type <expression_> ConditionalExpression
 
 390 %type <statement_> ContinueStatement
 
 391 %type <statement_> ConciseBody
 
 392 %type <statement_> DebuggerStatement
 
 393 %type <statement_> Declaration__
 
 394 %type <statement_> Declaration_
 
 395 %type <statement_> Declaration
 
 396 %type <clause_> DefaultClause
 
 397 %type <expression_> Element
 
 398 %type <expression_> ElementOpt
 
 399 %type <element_> ElementList
 
 400 %type <element_> ElementListOpt
 
 401 %type <statement_> ElseStatementOpt
 
 402 %type <statement_> EmptyStatement
 
 403 %type <expression_> EqualityExpression
 
 404 %type <expression_> Expression
 
 405 %type <expression_> ExpressionOpt
 
 406 %type <statement_> ExpressionStatement
 
 407 %type <finally_> FinallyOpt
 
 408 %type <for_> ForStatementInitialiser
 
 409 %type <forin_> ForInStatementInitialiser
 
 410 %type <declaration_> FormalParameter
 
 411 %type <functionParameter_> FormalParameterList_
 
 412 %type <functionParameter_> FormalParameterList
 
 413 %type <functionParameter_> FormalParameterListOpt
 
 414 %type <statement_> FunctionBody
 
 415 %type <statement_> FunctionDeclaration
 
 416 %type <expression_> FunctionExpression
 
 417 %type <identifier_> Identifier
 
 418 %type <identifier_> IdentifierOpt
 
 419 %type <identifier_> IdentifierType
 
 420 %type <word_> IdentifierName
 
 421 %type <statement_> IfStatement
 
 422 %type <expression_> Initialiser
 
 423 %type <expression_> InitialiserOpt
 
 424 %type <statement_> IterationStatement
 
 425 %type <statement_> LabelledStatement
 
 426 %type <expression_> LeftHandSideExpression
 
 427 %type <statement_> LetStatement
 
 428 %type <statement_> LexicalDeclaration
 
 429 %type <literal_> Literal
 
 430 %type <literal_> ValueLiteral
 
 431 %type <expression_> LogicalANDExpression
 
 432 %type <expression_> LogicalORExpression
 
 433 %type <member_> MemberAccess
 
 434 %type <expression_> MemberExpression_
 
 435 %type <expression_> MemberExpression
 
 436 %type <module_> Module
 
 437 %type <expression_> MultiplicativeExpression
 
 438 %type <expression_> NewExpression
 
 439 %type <null_> NullLiteral
 
 440 %type <literal_> ObjectLiteral
 
 441 %type <parenthetical_> Parenthetical
 
 442 %type <expression_> PostfixExpression
 
 443 %type <expression_> PrimaryExpression
 
 444 %type <statement_> Program
 
 445 %type <statement_> ProgramBody
 
 446 %type <statement_> ProgramBodyOpt
 
 447 %type <propertyName_> PropertyName_
 
 448 %type <propertyName_> PropertyName
 
 449 %type <property_> PropertyDefinition
 
 450 %type <property_> PropertyDefinitionList_
 
 451 %type <property_> PropertyDefinitionList
 
 452 %type <property_> PropertyDefinitionListOpt
 
 453 %type <expression_> RelationalExpression
 
 454 %type <statement_> ReturnStatement
 
 455 %type <rubyProc_> RubyProcExpression
 
 456 %type <functionParameter_> RubyProcParameterList_
 
 457 %type <functionParameter_> RubyProcParameterList
 
 458 %type <functionParameter_> RubyProcParameters
 
 459 %type <functionParameter_> RubyProcParametersOpt
 
 460 %type <expression_> ShiftExpression
 
 461 %type <declaration_> SingleNameBinding
 
 462 %type <statement_> Statement__
 
 463 %type <statement_> Statement_
 
 464 %type <statement_> Statement
 
 465 %type <statement_> StatementList
 
 466 %type <statement_> StatementListOpt
 
 467 %type <statement_> StatementListItem
 
 468 %type <statement_> SwitchStatement
 
 469 %type <statement_> ThrowStatement
 
 470 %type <statement_> TryStatement
 
 471 %type <expression_> UnaryExpression_
 
 472 %type <expression_> UnaryExpression
 
 473 %type <declaration_> VariableDeclaration
 
 474 %type <declarations_> VariableDeclarationList_
 
 475 %type <declarations_> VariableDeclarationList
 
 476 %type <statement_> VariableStatement
 
 477 %type <statement_> WithStatement
 
 480 %type <word_> WordOpt
 
 482 %type <expression_> Variable
 
 485 %type <specifier_> IntegerType
 
 486 %type <specifier_> IntegerTypeOpt
 
 487 %type <typedIdentifier_> PrefixedType
 
 488 %type <specifier_> PrimitiveType
 
 489 %type <typedIdentifier_> SuffixedType
 
 490 %type <typedIdentifier_> TypeSignifier
 
 491 %type <modifier_> TypeQualifierLeft
 
 492 %type <typedIdentifier_> TypeQualifierRight
 
 493 %type <typedIdentifier_> TypedIdentifier
 
 494 %type <typedParameter_> TypedParameterList_
 
 495 %type <typedParameter_> TypedParameterList
 
 496 %type <typedParameter_> TypedParameterListOpt
 
 500 %type <expression_> BoxableExpression
 
 501 %type <statement_> CategoryStatement
 
 502 %type <expression_> ClassExpression
 
 503 %type <classField_> ClassFieldListOpt
 
 504 %type <classField_> ClassFields
 
 505 %type <statement_> ClassStatement
 
 506 %type <expression_> ClassSuperOpt
 
 507 %type <message_> ClassMessageDeclaration
 
 508 %type <message_> ClassMessageDeclarationListOpt
 
 509 %type <className_> ClassName
 
 510 %type <className_> ClassNameOpt
 
 511 %type <protocol_> ClassProtocolListOpt
 
 512 %type <protocol_> ClassProtocols
 
 513 %type <protocol_> ClassProtocolsOpt
 
 514 %type <expression_> MessageExpression
 
 515 %type <messageParameter_> MessageParameter
 
 516 %type <messageParameter_> MessageParameters
 
 517 %type <messageParameter_> MessageParameterList
 
 518 %type <messageParameter_> MessageParameterListOpt
 
 519 %type <bool_> MessageScope
 
 520 %type <argument_> SelectorCall_
 
 521 %type <argument_> SelectorCall
 
 522 %type <selector_> SelectorExpression_
 
 523 %type <selector_> SelectorExpression
 
 524 %type <selector_> SelectorExpressionOpt
 
 525 %type <argument_> SelectorList
 
 526 %type <word_> SelectorWordOpt
 
 527 %type <typedIdentifier_> TypeOpt
 
 528 %type <argument_> VariadicCall
 
 532 %type <propertyIdentifier_> PropertyIdentifier_
 
 533 %type <selector_> PropertySelector_
 
 534 %type <selector_> PropertySelector
 
 535 %type <identifier_> QualifiedIdentifier_
 
 536 %type <identifier_> QualifiedIdentifier
 
 537 %type <identifier_> WildcardIdentifier
 
 538 %type <identifier_> XMLComment
 
 539 %type <identifier_> XMLCDATA
 
 540 %type <identifier_> XMLElement
 
 541 %type <identifier_> XMLElementContent
 
 542 %type <identifier_> XMLMarkup
 
 543 %type <identifier_> XMLPI
 
 545 %type <attribute_> AttributeIdentifier
 
 546 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
 
 547 %type <expression_> PropertyIdentifier
 
 548 %type <expression_> XMLListInitialiser
 
 549 %type <expression_> XMLInitialiser
 
 552 /* Token Priorities {{{ */
 
 564 /* Lexer State {{{ */
 
 566     : { driver.in_.push(true); }
 
 570     : { driver.in_.push(false); }
 
 574     : { driver.in_.pop(); }
 
 578     : { driver.SetCondition(CYDriver::RegExpCondition); }
 
 582     : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
 
 586     : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); }
 
 589 LexNoAtImplementation :
 
 591     { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); }
 
 596     : LexNoBrace LexNoFunction LexNoAtImplementation
 
 599 /* Virtual Tokens {{{ */
 
 610 /* 7.6 Identifier Names and Identifiers {{{ */
 
 621     : Identifier { $$ = $1; }
 
 622     | "auto" { $$ = $1; }
 
 623     | "break" NewLineOpt { $$ = $1; }
 
 624     | "case" { $$ = $1; }
 
 625     | "catch" { $$ = $1; }
 
 626     | "class" { $$ = $1; }
 
 627     | "const" { $$ = $1; }
 
 628     | "continue" NewLineOpt { $$ = $1; }
 
 629     | "debugger" { $$ = $1; }
 
 630     | "default" { $$ = $1; }
 
 631     | "delete" LexSetRegExp { $$ = $1; }
 
 633     | "else" { $$ = $1; }
 
 634     | "enum" { $$ = $1; }
 
 635     | "export" { $$ = $1; }
 
 636     | "extends" { $$ = $1; }
 
 637     | "false" { $$ = $1; }
 
 638     | "finally" { $$ = $1; }
 
 639     /* XXX: | "for" { $$ = $1; } */
 
 640     | "function" { $$ = $1; }
 
 642     | "import" { $$ = $1; }
 
 643     /* XXX: | "in" { $$ = $1; } */
 
 645     /* XXX: | "instanceof" { $$ = $1; } */
 
 647     // XXX: as it currently is not an Identifier
 
 650     | "new" LexSetRegExp { $$ = $1; }
 
 651     | "null" { $$ = $1; }
 
 652     | "return" NewLineOpt { $$ = $1; }
 
 653     | "super" { $$ = $1; }
 
 654     | "switch" { $$ = $1; }
 
 655     | "this" { $$ = $1; }
 
 656     | "throw" NewLineOpt { $$ = $1; }
 
 657     | "true" { $$ = $1; }
 
 659     | "typeof" LexSetRegExp { $$ = $1; }
 
 661     | "void" LexSetRegExp { $$ = $1; }
 
 662     | "while" { $$ = $1; }
 
 663     | "with" { $$ = $1; }
 
 674     : Identifier_ { $$ = $1; }
 
 676     | "implements" { $$ = $1; }
 
 677     | "interface" { $$ = $1; }
 
 678     | "package" { $$ = $1; }
 
 679     | "private" { $$ = $1; }
 
 680     | "protected" { $$ = $1; }
 
 681     | "public" { $$ = $1; }
 
 682     | "static" { $$ = $1; }
 
 684     | "abstract" { $$ = $1; }
 
 685     | "boolean" { $$ = $1; }
 
 686     | "byte" { $$ = $1; }
 
 687     | "double" { $$ = $1; }
 
 688     | "final" { $$ = $1; }
 
 689     | "float" { $$ = $1; }
 
 690     | "goto" { $$ = $1; }
 
 691     | "native" { $$ = $1; }
 
 692     | "synchronized" { $$ = $1; }
 
 693     | "throws" { $$ = $1; }
 
 694     | "transient" { $$ = $1; }
 
 696     // XXX: currently I only have this as Word
 
 697     // | "let" { $$ = $1; }
 
 699     | "yield" { $$ = $1; }
 
 701     | "each" { $$ = $1; }
 
 707     | "char" { $$ = $1; }
 
 709     | "long" { $$ = $1; }
 
 710     | "short" { $$ = $1; }
 
 711     | "volatile" { $$ = $1; }
 
 713     | "typedef" { $$ = $1; }
 
 714     | "unsigned" { $$ = $1; }
 
 715     | "signed" { $$ = $1; }
 
 716     | "extern" { $$ = $1; }
 
 725     : Identifier { $$ = $1; }
 
 730 /* 7.8 Literals {{{ */
 
 732     : NullLiteral { $$ = $1; }
 
 733     | ValueLiteral { $$ = $1; }
 
 737     : BooleanLiteral { $$ = $1; }
 
 738     | NumericLiteral { $$ = $1; }
 
 739     | StringLiteral { $$ = $1; }
 
 740     | RegularExpressionLiteral { $$ = $1; }
 
 743 /* 7.8.1 Null Literals {{{ */
 
 745     : "null" { $$ = $1; }
 
 748 /* 7.8.2 Boolean Literals {{{ */
 
 750     : "true" { $$ = $1; }
 
 751     | "false" { $$ = $1; }
 
 755 /* 7.9 Automatic Semicolon Insertion {{{ */
 
 757     : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
 
 762     | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !yyla.value.newline_) { error(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
 
 767     | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
 
 771 /* 11.1 Primary Expressions {{{ */
 
 773     : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
 
 777     : Identifier { $$ = CYNew CYVariable($1); }
 
 781     : "this" { $$ = $1; }
 
 782     | Variable { $$ = $1; }
 
 783     | Literal { $$ = $1; }
 
 784     | ArrayInitialiser { $$ = $1; }
 
 785     | ObjectLiteral { $$ = $1; }
 
 786     | Parenthetical { $$ = $1; }
 
 787     | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
 
 790 /* 11.1.4 Array Initializer {{{ */
 
 792     : ArrayLiteral { $$ = $1; }
 
 793     | ArrayComprehension { $$ = $1; }
 
 796 /* 11.1.4.1 Array Literal {{{ */
 
 798     : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
 
 802     : AssignmentExpression { $$ = $1; }
 
 806     : Element { $$ = $1; }
 
 807     | LexSetRegExp { $$ = NULL; }
 
 811     : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
 
 812     | Element { $$ = CYNew CYElement($1, NULL); }
 
 816     : ElementList { $$ = $1; }
 
 817     | LexSetRegExp { $$ = NULL; }
 
 820 /* 11.1.4.2 Array Comprehension {{{ */
 
 822     : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
 
 826     : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
 
 831     | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
 
 832     | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
 
 836     : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
 
 840     : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
 
 843 /* 11.1.5 Object Initialiser {{{ */
 
 845     : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
 
 848 PropertyDefinitionList_
 
 849     : "," PropertyDefinitionList { $$ = $2; }
 
 850     | "," LexSetRegExp { $$ = NULL; }
 
 854 PropertyDefinitionList
 
 855     : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
 
 858 PropertyDefinitionListOpt
 
 859     : PropertyDefinitionList { $$ = $1; }
 
 860     | LexSetRegExp { $$ = NULL; }
 
 864     // XXX: this should be IdentifierName
 
 865     : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
 
 866     | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
 
 871     : IdentifierName { $$ = $1; }
 
 872     | StringLiteral { $$ = $1; }
 
 873     | NumericLiteral { $$ = $1; }
 
 877     : LexSetRegExp PropertyName_ { $$ = $2; }
 
 881 /* 11.2 Left-Hand-Side Expressions {{{ */
 
 883     : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
 
 884     | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
 
 885     | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
 
 889     : MemberExpression { $$ = $1; }
 
 890     //| "super" { $$ = $1; }
 
 894     : LexSetRegExp PrimaryExpression { $$ = $2; }
 
 895     | LexSetRegExp FunctionExpression { $$ = $2; }
 
 896     | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 897     | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
 
 901     : MemberExpression { $$ = $1; }
 
 902     | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
 
 911     : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
 
 912     | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
 
 916     : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
 
 920     : "," ArgumentList { $$ = $2; }
 
 925     : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
 
 926     | LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
 
 930     : ArgumentList { $$ = $1; }
 
 931     | LexSetRegExp { $$ = NULL; }
 
 934 LeftHandSideExpression
 
 935     : NewExpression { $$ = $1; }
 
 936     | CallExpression { $$ = $1; }
 
 939 /* 11.3 Postfix Expressions {{{ */
 
 941     : %prec "" LeftHandSideExpression { $$ = $1; }
 
 942     | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
 
 943     | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
 
 946 /* 11.4 Unary Operators {{{ */
 
 948     : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
 
 949     | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
 
 950     | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
 
 951     | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 952     | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
 
 953     | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 954     | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
 
 955     | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
 
 956     | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
 
 957     | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
 
 958     | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
 
 962     : PostfixExpression { $$ = $1; }
 
 963     | LexSetRegExp UnaryExpression_ { $$ = $2; }
 
 966 /* 11.5 Multiplicative Operators {{{ */
 
 967 MultiplicativeExpression
 
 968     : UnaryExpression { $$ = $1; }
 
 969     | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
 
 970     | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
 
 971     | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
 
 974 /* 11.6 Additive Operators {{{ */
 
 976     : MultiplicativeExpression { $$ = $1; }
 
 977     | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
 
 978     | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
 
 981 /* 11.7 Bitwise Shift Operators {{{ */
 
 983     : AdditiveExpression { $$ = $1; }
 
 984     | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
 
 985     | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
 
 986     | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
 
 989 /* 11.8 Relational Operators {{{ */
 
 991     : ShiftExpression { $$ = $1; }
 
 992     | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
 
 993     | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
 
 994     | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
 
 995     | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
 
 996     | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
 
 997     | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
 
1000 /* 11.9 Equality Operators {{{ */
 
1002     : RelationalExpression { $$ = $1; }
 
1003     | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
 
1004     | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
 
1005     | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
 
1006     | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
 
1009 /* 11.10 Binary Bitwise Operators {{{ */
 
1010 BitwiseANDExpression
 
1011     : EqualityExpression { $$ = $1; }
 
1012     | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
 
1015 BitwiseXORExpression
 
1016     : BitwiseANDExpression { $$ = $1; }
 
1017     | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
 
1021     : BitwiseXORExpression { $$ = $1; }
 
1022     | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
 
1025 /* 11.11 Binary Logical Operators {{{ */
 
1026 LogicalANDExpression
 
1027     : BitwiseORExpression { $$ = $1; }
 
1028     | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
 
1032     : LogicalANDExpression { $$ = $1; }
 
1033     | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
 
1036 /* 11.12 Conditional Operator ( ? : ) {{{ */
 
1037 ConditionalExpression
 
1038     : LogicalORExpression { $$ = $1; }
 
1039     | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
 
1040     | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
 
1043 /* 11.13 Assignment Operators {{{ */
 
1044 AssignmentExpression
 
1045     : ConditionalExpression { $$ = $1; }
 
1046     | ArrowFunction { $$ = $1; }
 
1047     | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
 
1048     | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
 
1049     | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
 
1050     | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
 
1051     | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
 
1052     | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
 
1053     | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
 
1054     | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
 
1055     | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
 
1056     | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
 
1057     | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
 
1058     | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
 
1061 /* 11.14 Comma Operator {{{ */
 
1063     : AssignmentExpression { $$ = $1; }
 
1064     | AssignmentExpression "," Expression { $$ = CYNew CYCompound($1, $3); }
 
1068     : Expression { $$ = $1; }
 
1069     | LexSetRegExp { $$ = NULL; }
 
1073 /* 12 Statements {{{ */
 
1075     : Block { $$ = $1; }
 
1076     | VariableStatement { $$ = $1; }
 
1077     | EmptyStatement { $$ = $1; }
 
1078     | IfStatement { $$ = $1; }
 
1079     | BreakableStatement { $$ = $1; }
 
1080     | ContinueStatement { $$ = $1; }
 
1081     | BreakStatement { $$ = $1; }
 
1082     | ReturnStatement { $$ = $1; }
 
1083     | WithStatement { $$ = $1; }
 
1084     | LabelledStatement { $$ = $1; }
 
1085     | ThrowStatement { $$ = $1; }
 
1086     | TryStatement { $$ = $1; }
 
1087     | DebuggerStatement { $$ = $1; }
 
1091     : LexSetRegExp Statement__ { $$ = $2; }
 
1092     | ExpressionStatement { $$ = $1; }
 
1096     : LexSetStatement Statement_ { $$ = $2; }
 
1100     : FunctionDeclaration { $$ = $1; }
 
1101     | LexicalDeclaration { $$ = $1; }
 
1105     : LexSetRegExp Declaration__ { $$ = $2; }
 
1109     : LexSetStatement Declaration_ { $$ = $2; }
 
1113     : IterationStatement { $$ = $1; }
 
1114     | SwitchStatement { $$ = $1; }
 
1117 /* 12.1 Block {{{ */
 
1119     : BRACE StatementListOpt "}" { $$ = $2; }
 
1123     : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
 
1127     : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
 
1131     : StatementList { $$ = $1; }
 
1132     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1136     : Statement { $$ = $1; }
 
1137     | Declaration { $$ = $1; }
 
1141 /* 12.2 Declarations {{{ */
 
1143     : Identifier { $$ = $1; }
 
1150 // XXX: BindingPattern
 
1152 /* 12.2.1 Let and Const Declarations {{{ */
 
1154     : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1162 /* 12.2.2 Variable Statement {{{ */
 
1164     : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
 
1167 VariableDeclarationList_
 
1168     : "," VariableDeclarationList { $$ = $2; }
 
1172 VariableDeclarationList
 
1173     : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
 
1177     : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1178     // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
 
1182     : "=" AssignmentExpression { $$ = $2; }
 
1186     : Initialiser { $$ = $1; }
 
1190 /* 12.2.4 Destructuring Binding Patterns {{{ */
 
1194     : SingleNameBinding { $$ = $1; }
 
1198     : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
 
1202 /* 12.3 Empty Statement {{{ */
 
1204     : ";" { $$ = CYNew CYEmpty(); }
 
1207 /* 12.4 Expression Statement {{{ */
 
1209     : Expression Terminator { $$ = CYNew CYExpress($1); }
 
1212 /* 12.5 The if Statement {{{ */
 
1214     : "else" Statement { $$ = $2; }
 
1215     | %prec "if" { $$ = NULL; }
 
1219     : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
 
1223 /* 12.6.1 The do-while Statement {{{ */
 
1225     : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
 
1228 /* 12.6.2 The while Statement {{{ */
 
1230     : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
 
1233 /* 12.6.3 The for Statement {{{ */
 
1235     : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
 
1238 ForStatementInitialiser
 
1239     : ExpressionOpt { $$ = $1; }
 
1240     | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
 
1243 /* 12.6.4 The for-in and for-of Statements {{{ */
 
1245     : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
 
1246     | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
 
1249 ForInStatementInitialiser
 
1250     : LeftHandSideExpression { $$ = $1; }
 
1251     | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
 
1255 /* 12.7 The continue Statement {{{ */
 
1257     : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
 
1258     | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
 
1261 /* 12.8 The break Statement {{{ */
 
1263     : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
 
1264     | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
 
1267 /* 12.9 The return Statement {{{ */
 
1269     : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
 
1270     | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
 
1273 /* 12.10 The with Statement {{{ */
 
1275     : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
 
1279 /* 12.11 The switch Statement {{{ */
 
1281     : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
 
1285     : BRACE CaseClausesOpt "}" { $$ = $2; }
 
1289     : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
 
1293     : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1294     | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
1299     : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
 
1302 /* 12.12 Labelled Statements {{{ */
 
1304     : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
 
1307 /* 12.13 The throw Statement {{{ */
 
1309     : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
 
1310     | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
 
1313 /* 12.14 The try Statement {{{ */
 
1315     : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
 
1319     : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
 
1324     : "finally" Block_ { $$ = CYNew CYFinally($2); }
 
1328 /* 12.14 The debugger Statement {{{ */
 
1330     : "debugger" Terminator { $$ = CYNew CYDebugger(); }
 
1334 /* 13.1 Function Definitions {{{ */
 
1336     : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
 
1340     : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
 
1343 FormalParameterList_
 
1344     : "," FormalParameterList { $$ = $2; }
 
1349     // XXX: : FunctionRestParameter { $$ = $1; }
 
1350     : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
 
1353 FormalParameterListOpt
 
1354     : FormalParameterList
 
1358 /* XXX: FunctionRestParameter
 
1359     : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
 
1363     : BindingElement { $$ = $1; }
 
1367     : StatementListOpt { $$ = $1; }
 
1370 /* 13.2 Arrow Function Definitions {{{ */
 
1372     : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
 
1376     : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
 
1377     | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
 
1378     | Parenthetical { $$ = $1->expression_->Parameter(); if ($$ == NULL) error(@1, "invalid parameter list"); }
 
1382     : AssignmentExpression { $$ = CYNew CYReturn($1); }
 
1383     | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
 
1386 /* 14 Program {{{ */
 
1388     : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
 
1392     : StatementList { $$ = $1; }
 
1396     : ProgramBody { $$ = $1; }
 
1397     | LexSetStatement LexSetRegExp { $$ = NULL; }
 
1402 /* Cycript (C): Type Encoding {{{ */
 
1404     : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
 
1405     | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
 
1409     : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
 
1410     | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
 
1411     | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
 
1412     | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
 
1413     | TypeSignifier { $$ = $1; }
 
1414     | { $$ = CYNew CYTypedIdentifier(@$); }
 
1418     : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
 
1423     | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
 
1424     | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
 
1428     : PrefixedType { $$ = $1; }
 
1429     | SuffixedType { $$ = $1; }
 
1430     | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
 
1431     | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
 
1435     : "int" { $$ = CYNew CYTypeVariable("int"); }
 
1436     | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
 
1437     | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
 
1438     | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
 
1439     | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
 
1443     : IntegerType { $$ = $1; }
 
1444     | { $$ = CYNew CYTypeVariable("int"); }
 
1448     : IdentifierType { $$ = CYNew CYTypeVariable($1); }
 
1449     | IntegerType { $$ = $1; }
 
1450     | "void" { $$ = CYNew CYTypeVoid(); }
 
1451     | "char" { $$ = CYNew CYTypeVariable("char"); }
 
1452     | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
 
1453     | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
 
1457     : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
 
1461     : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
 
1467 /* Cycript (Objective-C): @class Declaration {{{ */
 
1469     /* XXX: why the hell did I choose MemberExpression? */
 
1470     : ":" LexSetRegExp MemberExpression { $$ = $3; }
 
1475     : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
 
1476     | LexSetRegExp { $$ = NULL; }
 
1480     : BRACE ClassFieldListOpt "}" { $$ = $2; }
 
1484     : "+" { $$ = false; }
 
1485     | "-" { $$ = true; }
 
1489     : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) error($3->location_, "unexpected identifier"); $$ = $3; }
 
1490     | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
 
1494     : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
 
1497 MessageParameterList
 
1498     : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
 
1501 MessageParameterListOpt
 
1502     : MessageParameterList { $$ = $1; }
 
1507     : MessageParameterList { $$ = $1; }
 
1508     | Word { $$ = CYNew CYMessageParameter($1, NULL); }
 
1511 ClassMessageDeclaration
 
1512     : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
 
1515 ClassMessageDeclarationListOpt
 
1516     : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
 
1517     | ClassMessageDeclarationListOpt Comment { $$ = $1; }
 
1522     : Identifier { $$ = $1; }
 
1523     | "(" AssignmentExpression ")" { $$ = $2; }
 
1527     : ClassName { $$ = $1; }
 
1531 // XXX: this should be AssignmentExpressionNoRight
 
1533     : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
 
1537     : "," ClassProtocols { $$ = $2; }
 
1541 ClassProtocolListOpt
 
1542     : "<" ClassProtocols ">" { $$ = $2; }
 
1547     : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
 
1551     : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
 
1559     : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
 
1563     : ClassExpression { $$ = $1; }
 
1567     : ClassStatement { $$ = $1; }
 
1568     | CategoryStatement { $$ = $1; }
 
1571 /* Cycript (Objective-C): Send Message {{{ */
 
1573     : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
 
1578     : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
 
1579     | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
 
1583     : SelectorCall { $$ = $1; }
 
1584     | VariadicCall { $$ = $1; }
 
1588     : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
 
1592     : SelectorCall { $$ = $1; }
 
1593     | Word { $$ = CYNew CYArgument($1, NULL); }
 
1597     : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
 
1598     | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
 
1602     : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
 
1606     : SelectorExpression_ { $$ = $1; }
 
1607     | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
 
1610 SelectorExpressionOpt
 
1611     : SelectorExpression_ { $$ = $1; }
 
1616     : MessageExpression { $$ = $1; }
 
1617     | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
 
1622 /* Cycript: @import Directive {{{ */
 
1624     : Module "." Word { $$ = CYNew CYModule($3, $1); }
 
1625     | Word { $$ = CYNew CYModule($1); }
 
1629     : "@import" Module { $$ = CYNew CYImport($2); }
 
1634 /* Cycript (Objective-C): Boxed Expressions {{{ */
 
1636     : NullLiteral { $$ = $1; }
 
1637     | BooleanLiteral { $$ = $1; }
 
1638     | NumericLiteral { $$ = $1; }
 
1639     | StringLiteral { $$ = $1; }
 
1640     | ArrayLiteral { $$ = $1; }
 
1641     | ObjectLiteral { $$ = $1; }
 
1642     | Parenthetical { $$ = $1; }
 
1643     | "YES" { $$ = CYNew CYTrue(); }
 
1644     | "NO" { $$ = CYNew CYFalse(); }
 
1648     : "@" BoxableExpression { $$ = CYNew CYBox($2); }
 
1649     | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1650     | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1651     | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
 
1652     | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
 
1653     | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
 
1656 /* Cycript (Objective-C): Block Expressions {{{ */
 
1658     : "^" 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"); }
 
1661 /* Cycript (Objective-C): Instance Literals {{{ */
 
1663     : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
 
1669 /* Cycript (C): Pointer Indirection/Addressing {{{ */
 
1670 LeftHandSideExpression
 
1671     : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
 
1675     : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
 
1679     : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
 
1680     | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
 
1681     | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
 
1684 /* Cycript (C): auto Compatibility {{{ */
 
1689 /* Cycript (C): Lambda Expressions {{{ */
 
1691     : "," TypedParameterList { $$ = $2; }
 
1696     : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
 
1699 TypedParameterListOpt
 
1700     : TypedParameterList { $$ = $1; }
 
1705     : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
 
1708 /* Cycript (C): Type Definitions {{{ */
 
1710     : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) error($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
 
1713 /* Cycript (C): extern "C" {{{ */
 
1715     : "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); }
 
1721 /* YUI: Documentation Comments {{{ */
 
1723     : Comment { $$ = $1; }
 
1728 /* Lexer State {{{ */
 
1730     : { driver.PushCondition(CYDriver::RegExpCondition); }
 
1734     : { driver.PushCondition(CYDriver::XMLContentCondition); }
 
1738     : { driver.PushCondition(CYDriver::XMLTagCondition); }
 
1742     : { driver.PopCondition(); }
 
1746     : { driver.SetCondition(CYDriver::XMLContentCondition); }
 
1750     : { driver.SetCondition(CYDriver::XMLTagCondition); }
 
1753 /* Virtual Tokens {{{ */
 
1760 /* 8.1 Context Keywords {{{ */
 
1762     : "namespace" { $$ = $1; }
 
1763     | "xml" { $$ = $1; }
 
1766 /* 8.3 XML Initialiser Input Elements {{{ */
 
1768     : XMLComment { $$ = $1; }
 
1769     | XMLCDATA { $$ = $1; }
 
1770     | XMLPI { $$ = $1; }
 
1774 /* 11.1 Primary Expressions {{{ */
 
1776     : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
 
1777     | XMLInitialiser { $$ = $1; }
 
1778     | XMLListInitialiser { $$ = $1; }
 
1782     : AttributeIdentifier { $$ = $1; }
 
1783     | QualifiedIdentifier { $$ = $1; }
 
1784     | WildcardIdentifier { $$ = $1; }
 
1787 /* 11.1.1 Attribute Identifiers {{{ */
 
1789     : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
 
1793     : PropertySelector { $$ = $1; }
 
1794     | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
 
1798     : Identifier { $$ = CYNew CYSelector($1); }
 
1799     | WildcardIdentifier { $$ = $1; }
 
1802 /* 11.1.2 Qualified Identifiers {{{ */
 
1803 QualifiedIdentifier_
 
1804     : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
 
1805     | QualifiedIdentifier { $$ = $1; }
 
1809     : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
 
1812 /* 11.1.3 Wildcard Identifiers {{{ */
 
1814     : "*" { $$ = CYNew CYWildcard(); }
 
1817 /* 11.1.4 XML Initialiser {{{ */
 
1819     : XMLMarkup { $$ = $1; }
 
1820     | XMLElement { $$ = $1; }
 
1824     : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
 
1825     | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
 
1829     : LexPushXMLTag XMLTagName XMLAttributes
 
1833     : BRACE LexPushRegExp Expression LexPop "}"
 
1842     : XMLAttributes_ XMLAttribute
 
1847     : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
 
1848     | XMLAttributes_ XMLWhitespaceOpt
 
1857     : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
 
1861     : XMLExpression XMLElementContentOpt
 
1862     | XMLMarkup XMLElementContentOpt
 
1863     | XMLText XMLElementContentOpt
 
1864     | XMLElement XMLElementContentOpt
 
1867 XMLElementContentOpt
 
1872 /* 11.1.5 XMLList Initialiser {{{ */
 
1874     : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
 
1878 /* 11.2 Left-Hand-Side Expressions {{{ */
 
1880     : Identifier { $$ = $1; }
 
1881     | PropertyIdentifier { $$ = $1; }
 
1885     : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
 
1886     | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
 
1887     | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
 
1890 /* 12.1 The default xml namespace Statement {{{ */
 
1891 /* XXX: DefaultXMLNamespaceStatement
 
1892     : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
 
1896     : DefaultXMLNamespaceStatement { $$ = $1; }
 
1901 /* JavaScript 1.7: Array Comprehensions {{{ */
 
1903     : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
 
1907     : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
 
1908     | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
 
1911 /* JavaScript 1.7: for each {{{ */
 
1913     : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
 
1916 /* JavaScript 1.7: let Statements {{{ */
 
1918     : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
 
1926 /* JavaScript FTW: Ruby Blocks {{{ */
 
1927 RubyProcParameterList_
 
1928     : "," RubyProcParameterList { $$ = $2; }
 
1932 RubyProcParameterList
 
1933     : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
 
1938     : "|" RubyProcParameterList "|" { $$ = $2; }
 
1939     | "||" { $$ = NULL; }
 
1942 RubyProcParametersOpt
 
1943     : RubyProcParameters
 
1948     : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
 
1952     : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
 
1956     : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }