2 #include "Cycript.tab.hh"
 
   3 int cylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
 
   4 #define scanner driver.scanner_
 
  14         CYArgument *argument_;
 
  18         CYDeclaration *declaration_;
 
  19         CYDeclarations *declarations_;
 
  21         CYExpression *expression_;
 
  23         CYForInitialiser *for_;
 
  24         CYForInInitialiser *forin_;
 
  25         CYIdentifier *identifier_;
 
  30         CYParameter *parameter_;
 
  31         CYProperty *property_;
 
  33         CYStatement *statement_;
 
  50     @$.begin.filename = @$.end.filename = &driver.filename_;
 
  58 %parse-param { CYDriver &driver }
 
  59 %lex-param { void *scanner }
 
  62 %token AmpersandAmpersand "&&"
 
  63 %token AmpersandEqual "&="
 
  65 %token CarrotEqual "^="
 
  67 %token EqualEqual "=="
 
  68 %token EqualEqualEqual "==="
 
  69 %token Exclamation "!"
 
  70 %token ExclamationEqual "!="
 
  71 %token ExclamationEqualEqual "!=="
 
  73 %token HyphenEqual "-="
 
  74 %token HyphenHyphen "--"
 
  75 %token HyphenHyphen_ "\n--"
 
  76 %token HyphenRight "->"
 
  80 %token LeftLeftEqual "<<="
 
  82 %token PercentEqual "%="
 
  90 %token PlusPlus_ "\n++"
 
  92 %token RightEqual ">="
 
  93 %token RightRight ">>"
 
  94 %token RightRightEqual ">>="
 
  95 %token RightRightRight ">>>"
 
  96 %token RightRightRightEqual ">>>="
 
  98 %token SlashEqual "/="
 
 100 %token StarEqual "*="
 
 110 %token CloseParen ")"
 
 113 %token CloseBrace "}"
 
 115 %token OpenBracket "["
 
 116 %token CloseBracket "]"
 
 118 %token <word_> Break "break"
 
 119 %token <word_> Case "case"
 
 120 %token <word_> Catch "catch"
 
 121 %token <word_> Continue "continue"
 
 122 %token <word_> Default "default"
 
 123 %token <word_> Delete "delete"
 
 124 %token <word_> Do "do"
 
 125 %token <word_> Else "else"
 
 126 %token <false_> False "false"
 
 127 %token <word_> Finally "finally"
 
 128 %token <word_> For "for"
 
 129 %token <word_> Function "function"
 
 130 %token <word_> If "if"
 
 131 %token <word_> In "in"
 
 132 %token <word_> InstanceOf "instanceof"
 
 133 %token <word_> New "new"
 
 134 %token <null_> Null "null"
 
 135 %token <word_> Return "return"
 
 136 %token <word_> Switch "switch"
 
 137 %token <this_> This "this"
 
 138 %token <word_> Throw "throw"
 
 139 %token <true_> True "true"
 
 140 %token <word_> Try "try"
 
 141 %token <word_> TypeOf "typeof"
 
 142 %token <word_> Var "var"
 
 143 %token <word_> Void "void"
 
 144 %token <word_> While "while"
 
 145 %token <word_> With "with"
 
 147 %token <identifier_> Identifier
 
 148 %token <number_> NumericLiteral
 
 149 %token <string_> StringLiteral
 
 151 %type <expression_> AdditiveExpression
 
 152 %type <argument_> ArgumentList
 
 153 %type <argument_> ArgumentList_
 
 154 %type <argument_> ArgumentListOpt
 
 155 %type <argument_> Arguments
 
 156 %type <literal_> ArrayLiteral
 
 157 %type <expression_> AssignmentExpression
 
 158 %type <expression_> BitwiseANDExpression
 
 159 %type <statement_> Block
 
 160 %type <boolean_> BooleanLiteral
 
 161 %type <expression_> BitwiseORExpression
 
 162 %type <expression_> BitwiseXORExpression
 
 163 %type <statement_> BreakStatement
 
 164 %type <expression_> CallExpression
 
 165 %type <clause_> CaseBlock
 
 166 %type <clause_> CaseClause
 
 167 %type <clause_> CaseClausesOpt
 
 168 %type <catch_> CatchOpt
 
 169 %type <expression_> ConditionalExpression
 
 170 %type <statement_> ContinueStatement
 
 171 %type <clause_> DefaultClause
 
 172 %type <statement_> DoWhileStatement
 
 173 %type <expression_> Element
 
 174 %type <element_> ElementList
 
 175 %type <element_> ElementList_
 
 176 %type <statement_> ElseStatementOpt
 
 177 %type <statement_> EmptyStatement
 
 178 %type <expression_> EqualityExpression
 
 179 %type <expression_> Expression
 
 180 %type <expression_> Expression_
 
 181 %type <expression_> ExpressionOpt
 
 182 %type <statement_> ExpressionStatement
 
 183 %type <statement_> FinallyOpt
 
 184 %type <statement_> ForStatement
 
 185 %type <for_> ForStatementInitialiser
 
 186 %type <statement_> ForInStatement
 
 187 %type <forin_> ForInStatementInitialiser
 
 188 %type <parameter_> FormalParameterList
 
 189 %type <parameter_> FormalParameterList_
 
 190 %type <source_> FunctionBody
 
 191 %type <source_> FunctionDeclaration
 
 192 %type <expression_> FunctionExpression
 
 193 %type <identifier_> IdentifierOpt
 
 194 %type <statement_> IfStatement
 
 195 %type <expression_> Initialiser
 
 196 %type <expression_> InitialiserOpt
 
 197 %type <statement_> IterationStatement
 
 198 %type <statement_> LabelledStatement
 
 199 %type <expression_> LeftHandSideExpression
 
 200 %type <literal_> Literal
 
 201 %type <expression_> LogicalANDExpression
 
 202 %type <expression_> LogicalORExpression
 
 203 %type <expression_> MemberExpression
 
 204 %type <expression_> MultiplicativeExpression
 
 205 %type <expression_> NewExpression
 
 206 %type <null_> NullLiteral
 
 207 %type <literal_> ObjectLiteral
 
 208 %type <expression_> MessageExpression
 
 209 %type <expression_> PostfixExpression
 
 210 %type <expression_> PrimaryExpression
 
 211 %type <source_> Program
 
 212 %type <name_> PropertyName
 
 213 %type <property_> PropertyNameAndValueList
 
 214 %type <property_> PropertyNameAndValueList_
 
 215 %type <property_> PropertyNameAndValueListOpt
 
 216 %type <expression_> QExpressionOpt
 
 217 %type <identifier_> QIdentifierOpt
 
 218 %type <expression_> RelationalExpression
 
 219 %type <statement_> ReturnStatement
 
 220 %type <argument_> SelectorCall
 
 221 %type <argument_> SelectorCall_
 
 222 %type <argument_> SelectorList
 
 223 %type <expression_> ShiftExpression
 
 224 %type <source_> SourceElement
 
 225 %type <source_> SourceElements
 
 226 %type <statement_> Statement
 
 227 %type <statement_> StatementListOpt
 
 228 %type <statement_> SwitchStatement
 
 229 %type <statement_> ThrowStatement
 
 230 %type <statement_> TryStatement
 
 231 %type <expression_> UnaryExpression
 
 232 %type <declaration_> VariableDeclaration
 
 233 %type <declarations_> VariableDeclarationList
 
 234 %type <declarations_> VariableDeclarationList_
 
 235 %type <statement_> VariableStatement
 
 236 %type <argument_> VariadicCall
 
 237 %type <statement_> WhileStatement
 
 238 %type <statement_> WithStatement
 
 240 %type <word_> WordOpt
 
 291     : Identifier { $$ = $1; }
 
 292     | "break" NewLineOpt { $$ = $1; }
 
 293     | "case" { $$ = $1; }
 
 294     | "catch" { $$ = $1; }
 
 295     | "continue" NewLineOpt { $$ = $1; }
 
 296     | "default" { $$ = $1; }
 
 297     | "delete" { $$ = $1; }
 
 299     | "else" { $$ = $1; }
 
 300     | "false" { $$ = $1; }
 
 301     | "finally" { $$ = $1; }
 
 303     | "function" { $$ = $1; }
 
 306     | "instanceof" { $$ = $1; }
 
 308     | "null" { $$ = $1; }
 
 309     | "return" NewLineOpt { $$ = $1; }
 
 310     | "switch" { $$ = $1; }
 
 311     | "this" { $$ = $1; }
 
 312     | "throw" NewLineOpt { $$ = $1; }
 
 313     | "true" { $$ = $1; }
 
 315     | "typeof" { $$ = $1; }
 
 317     | "void" { $$ = $1; }
 
 318     | "while" { $$ = $1; }
 
 319     | "with" { $$ = $1; }
 
 323     : Identifier { $$ = $1; }
 
 328     : Q Identifier { $$ = $2; }
 
 333     : NullLiteral { $$ = $1; }
 
 334     | BooleanLiteral { $$ = $1; }
 
 335     | NumericLiteral { $$ = $1; }
 
 336     | StringLiteral { $$ = $1; }
 
 340     : "null" { $$ = $1; }
 
 344     : "true" { $$ = $1; }
 
 345     | "false" { $$ = $1; }
 
 348 /* Objective-C Extensions {{{ */
 
 350     : "," Q AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $3, $4); }
 
 355     : SelectorCall { $$ = $1; }
 
 356     | VariadicCall { $$ = $1; }
 
 360     : WordOpt ":" Q AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $4, $5); }
 
 364     : SelectorCall { $$ = $1; }
 
 365     | Word Q { $$ = new(driver.pool_) CYArgument($1, NULL); }
 
 368 MessageExpression /*Q*/
 
 369     : "[" Q AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($3, $4); }
 
 373 /* 11.1 Primary Expressions {{{ */
 
 374 PrimaryExpression /*Q*/
 
 375     : "this" { $$ = $1; }
 
 376     | Identifier { $$ = new(driver.pool_) CYVariable($1); }
 
 377     | Literal { $$ = $1; }
 
 378     | ArrayLiteral { $$ = $1; }
 
 379     | ObjectLiteral { $$ = $1; }
 
 380     | "(" Q Expression ")" { $$ = $3; }
 
 381     | MessageExpression { $$ = $1; }
 
 384 /* 11.1.4 Array Initialiser {{{ */
 
 386     : "[" Q ElementList "]" { $$ = $3; }
 
 390     : AssignmentExpression { $$ = $1; }
 
 395     : "," Q ElementList { $$ = $3; }
 
 400     : Element ElementList_ { $$ = new(driver.pool_) CYElement($1, $2); }
 
 403 /* 11.1.5 Object Initialiser {{{ */
 
 405     : "{" PropertyNameAndValueListOpt "}" { $$ = $2; }
 
 408 PropertyNameAndValueList_ /*Qq*/
 
 409     : "," PropertyNameAndValueList { $$ = $2; }
 
 413 PropertyNameAndValueListOpt /*q*/
 
 414     : PropertyNameAndValueList { $$ = $1; }
 
 418 PropertyNameAndValueList /*q*/
 
 419     : PropertyName Q ":" Q AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $5, $6); }
 
 423     : Q Identifier { $$ = $2; }
 
 424     | Q StringLiteral { $$ = $2; }
 
 425     | Q NumericLiteral { $$ = $2; }
 
 429 MemberExpression /*Q*/
 
 430     : PrimaryExpression { $$ = $1; }
 
 431     | FunctionExpression { $$ = $1; }
 
 432     | MemberExpression Q "[" Q Expression "]" { $$ = new(driver.pool_) CYMember($1, $5); }
 
 433     | MemberExpression Q "." Q Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($5)); }
 
 434     | "new" Q MemberExpression Arguments { $$ = new(driver.pool_) CYNew($3, $4); }
 
 438     : MemberExpression { $$ = $1; }
 
 439     | "new" Q NewExpression { $$ = new(driver.pool_) CYNew($3, NULL); }
 
 443     : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
 
 444     | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
 
 445     | CallExpression Q "[" Q Expression "]" { $$ = new(driver.pool_) CYMember($1, $5); }
 
 446     | CallExpression Q "." Q Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($5)); }
 
 450     : "," ArgumentList { $$ = $2; }
 
 454 ArgumentListOpt /*q*/
 
 455     : ArgumentList { $$ = $1; }
 
 460     : Q AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
 
 464     : Q "(" ArgumentListOpt ")" { $$ = $3; }
 
 467 LeftHandSideExpression /*Q*/
 
 468     : NewExpression { $$ = $1; }
 
 469     | CallExpression { $$ = $1; }
 
 470     | "*" Q LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($3); }
 
 473 PostfixExpression /*Q*/
 
 474     : LeftHandSideExpression { $$ = $1; }
 
 475     | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
 
 476     | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
 
 479 UnaryExpression /*Qq*/
 
 480     : PostfixExpression Q { $$ = $1; }
 
 481     | "delete" Q UnaryExpression { $$ = new(driver.pool_) CYDelete($3); }
 
 482     | "void" Q UnaryExpression { $$ = new(driver.pool_) CYVoid($3); }
 
 483     | "typeof" Q UnaryExpression { $$ = new(driver.pool_) CYTypeOf($3); }
 
 484     | "++" Q UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($3); }
 
 485     | "\n++" Q UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($3); }
 
 486     | "--" Q UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($3); }
 
 487     | "\n--" Q UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($3); }
 
 488     | "+" Q UnaryExpression { $$ = $3; }
 
 489     | "-" Q UnaryExpression { $$ = new(driver.pool_) CYNegate($3); }
 
 490     | "~" Q UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($3); }
 
 491     | "!" Q UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($3); }
 
 492     | "&" Q UnaryExpression { $$ = new(driver.pool_) CYAddressOf($3); }
 
 495 MultiplicativeExpression /*Qq*/
 
 496     : UnaryExpression { $$ = $1; }
 
 497     | MultiplicativeExpression "*" Q UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $4); }
 
 498     | MultiplicativeExpression "/" Q UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $4); }
 
 499     | MultiplicativeExpression "%" Q UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $4); }
 
 502 AdditiveExpression /*Qq*/
 
 503     : MultiplicativeExpression { $$ = $1; }
 
 504     | AdditiveExpression "+" Q MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $4); }
 
 505     | AdditiveExpression "-" Q MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $4); }
 
 508 ShiftExpression /*Qq*/
 
 509     : AdditiveExpression { $$ = $1; }
 
 510     | ShiftExpression "<<" Q AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $4); }
 
 511     | ShiftExpression ">>" Q AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $4); }
 
 512     | ShiftExpression ">>>" Q AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $4); }
 
 515 RelationalExpression /*Qq*/
 
 516     : ShiftExpression { $$ = $1; }
 
 517     | RelationalExpression "<" Q ShiftExpression { $$ = new(driver.pool_) CYLess($1, $4); }
 
 518     | RelationalExpression ">" Q ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $4); }
 
 519     | RelationalExpression "<=" Q ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $4); }
 
 520     | RelationalExpression ">=" Q ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $4); }
 
 521     | RelationalExpression "instanceof" Q ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $4); }
 
 522     | RelationalExpression "in" Q ShiftExpression { $$ = new(driver.pool_) CYIn($1, $4); }
 
 525 EqualityExpression /*Qq*/
 
 526     : RelationalExpression { $$ = $1; }
 
 527     | EqualityExpression "==" Q RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $4); }
 
 528     | EqualityExpression "!=" Q RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $4); }
 
 529     | EqualityExpression "===" Q RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $4); }
 
 530     | EqualityExpression "!==" Q RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $4); }
 
 533 BitwiseANDExpression /*Qq*/
 
 534     : EqualityExpression { $$ = $1; }
 
 535     | BitwiseANDExpression "&" Q EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $4); }
 
 538 BitwiseXORExpression /*Qq*/
 
 539     : BitwiseANDExpression { $$ = $1; }
 
 540     | BitwiseXORExpression "^" Q BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $4); }
 
 543 BitwiseORExpression /*Qq*/
 
 544     : BitwiseXORExpression { $$ = $1; }
 
 545     | BitwiseORExpression "|" Q BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $4); }
 
 548 LogicalANDExpression /*Qq*/
 
 549     : BitwiseORExpression { $$ = $1; }
 
 550     | LogicalANDExpression "&&" Q BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $4); }
 
 553 LogicalORExpression /*Qq*/
 
 554     : LogicalANDExpression { $$ = $1; }
 
 555     | LogicalORExpression "||" Q LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $4); }
 
 558 ConditionalExpression /*Qq*/
 
 559     : LogicalORExpression { $$ = $1; }
 
 560     | LogicalORExpression "?" Q AssignmentExpression ":" Q AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $4, $7); }
 
 563 AssignmentExpression /*Qq*/
 
 564     : ConditionalExpression { $$ = $1; }
 
 565     | LeftHandSideExpression Q "=" Q AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $5); }
 
 566     | LeftHandSideExpression Q "*=" Q AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $5); }
 
 567     | LeftHandSideExpression Q "/=" Q AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $5); }
 
 568     | LeftHandSideExpression Q "%=" Q AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $5); }
 
 569     | LeftHandSideExpression Q "+=" Q AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $5); }
 
 570     | LeftHandSideExpression Q "-=" Q AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $5); }
 
 571     | LeftHandSideExpression Q "<<=" Q AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $5); }
 
 572     | LeftHandSideExpression Q ">>=" Q AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $5); }
 
 573     | LeftHandSideExpression Q ">>>=" Q AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $5); }
 
 574     | LeftHandSideExpression Q "&=" Q AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $5); }
 
 575     | LeftHandSideExpression Q "^=" Q AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $5); }
 
 576     | LeftHandSideExpression Q "|=" Q AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $5); }
 
 580     : "," Q Expression { $$ = $3; }
 
 585     : Expression { $$ = $1; }
 
 590     : Q Expression { $$ = $2; }
 
 595     : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
 
 599     : Block Q { $$ = $1; }
 
 600     | VariableStatement Q { $$ = $1; }
 
 601     | EmptyStatement Q { $$ = $1; }
 
 602     | ExpressionStatement Q { $$ = $1; }
 
 603     | IfStatement { $$ = $1; }
 
 604     | IterationStatement { $$ = $1; }
 
 605     | ContinueStatement Q { $$ = $1; }
 
 606     | BreakStatement Q { $$ = $1; }
 
 607     | ReturnStatement Q { $$ = $1; }
 
 608     | WithStatement { $$ = $1; }
 
 609     | LabelledStatement { $$ = $1; }
 
 610     | SwitchStatement Q { $$ = $1; }
 
 611     | ThrowStatement Q { $$ = $1; }
 
 612     | TryStatement Q { $$ = $1; }
 
 616     : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
 
 619 StatementListOpt /*Qq*/
 
 620     : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
 
 624 VariableStatement /*Q*/
 
 625     : "var" VariableDeclarationList Terminator { $$ = $2; }
 
 628 VariableDeclarationList_ /*Qq*/
 
 629     : "," VariableDeclarationList { $$ = $2; }
 
 633 VariableDeclarationList /*q*/
 
 634     : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
 
 637 VariableDeclaration /*q*/
 
 638     : Q Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($2, $3); }
 
 642     : Initialiser { $$ = $1; }
 
 647     : Q "=" Q AssignmentExpression { $$ = $4; }
 
 651     : ";" { $$ = new(driver.pool_) CYEmpty(); }
 
 654 ExpressionStatement /*Q*/
 
 655     : Expression Terminator { $$ = new(driver.pool_) CYExpress($1); }
 
 658 ElseStatementOpt /*Qq*/
 
 659     : "else" Q Statement { $$ = $3; }
 
 660     | %prec "if" { $$ = NULL; }
 
 664     : "if" Q "(" Q Expression ")" Q Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($5, $8, $9); }
 
 667 IterationStatement /*Qq*/
 
 668     : DoWhileStatement Q { $$ = $1; }
 
 669     | WhileStatement { $$ = $1; }
 
 670     | ForStatement { $$ = $1; }
 
 671     | ForInStatement { $$ = $1; }
 
 674 DoWhileStatement /*Q*/
 
 675     : "do" Q Statement "while" Q "(" Q Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($8, $3); }
 
 678 WhileStatement /*Qq*/
 
 679     : "while" Q "(" Q Expression ")" Q Statement { $$ = new(driver.pool_) CYWhile($5, $8); }
 
 683     : "for" Q "(" Q ForStatementInitialiser ";" QExpressionOpt ";" QExpressionOpt ")" Q Statement { $$ = new(driver.pool_) CYFor($5, $7, $9, $12); }
 
 686 ForStatementInitialiser /*Qq*/
 
 687     : ExpressionOpt { $$ = $1; }
 
 688     | "var" VariableDeclarationList { $$ = $2; }
 
 691 ForInStatement /*Qq*/
 
 692     : "for" Q "(" Q ForInStatementInitialiser "in" Q Expression ")" Q Statement { $$ = new(driver.pool_) CYForIn($5, $8, $11); }
 
 695 ForInStatementInitialiser /*Qq*/
 
 696     : LeftHandSideExpression Q { $$ = $1; }
 
 697     | "var" VariableDeclaration { $$ = $2; }
 
 700 ContinueStatement /*Q*/
 
 701     : "continue" IdentifierOpt QTerminator { $$ = new(driver.pool_) CYContinue($2); }
 
 705     : "break" IdentifierOpt QTerminator { $$ = new(driver.pool_) CYBreak($2); }
 
 708 ReturnStatement /*Q*/
 
 709     : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
 
 713     : "with" Q "(" Q Expression ")" Q Statement { $$ = new(driver.pool_) CYWith($5, $8); }
 
 716 SwitchStatement /*Qq*/
 
 717     : "switch" Q "(" Q Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($5, $7); }
 
 721     : Q "{" Q CaseClausesOpt "}" { $$ = $4; }
 
 724 CaseClausesOpt /*Qq*/
 
 725     : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
 726     | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
 
 731     : "case" Q Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($3, $5); }
 
 735     : "default" Q ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $4); }
 
 738 LabelledStatement /*Qq*/
 
 739     : Identifier Q ":" Q Statement { $5->AddLabel($1); $$ = $5; }
 
 743     : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
 
 747     : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
 
 751     : Q "catch" Q "(" Q Identifier Q ")" Block { $$ = new(driver.pool_) CYCatch($6, $9); }
 
 756     : Q "finally" Block { $$ = $3; }
 
 760 FunctionDeclaration /*Q*/
 
 761     : "function" Q Identifier Q "(" FormalParameterList Q ")" Q "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($3, $6, $11); }
 
 764 FunctionExpression /*Q*/
 
 765     : "function" QIdentifierOpt Q "(" FormalParameterList Q ")" Q "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $5, $10); }
 
 769     : Q "," FormalParameterList { $$ = $3; }
 
 774     : Q Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($2, $3); }
 
 779     : Q SourceElements { $$ = $2; }
 
 783     : Q SourceElements { driver.source_.push_back($2); $$ = $2; }
 
 786 SourceElements /*Qq*/
 
 787     : SourceElement Q SourceElements { $1->SetNext($3); $$ = $1; }
 
 792     : Q SourceElement { driver.source_.push_back($2); if (driver.filename_.empty() && false) YYACCEPT; $2->Show(std::cout); }
 
 796     : Statement { $$ = $1; }
 
 797     | FunctionDeclaration Q { $$ = $1; }