1 /* Cycript - Inlining/Optimizing JavaScript Compiler
2 * Copyright (C) 2009 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 @if Bison24 %code top {
43 #define cyscanner driver.scanner_
44 #define YYSTACKEXPANDABLE 1
45 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
48 @if Bison24 %code requires {
52 #include "ObjectiveC/Syntax.hpp"
56 #include "E4X/Syntax.hpp"
65 CYDriver::Condition condition_;
67 CYArgument *argument_;
68 CYAssignment *assignment_;
71 cy::Syntax::Catch *catch_;
73 CYComprehension *comprehension_;
74 CYCompound *compound_;
75 CYDeclaration *declaration_;
76 CYDeclarations *declarations_;
78 CYExpression *expression_;
81 CYForInitialiser *for_;
82 CYForInInitialiser *forin_;
83 CYFunctionParameter *functionParameter_;
84 CYIdentifier *identifier_;
91 CYProperty *property_;
92 CYPropertyName *propertyName_;
93 CYStatement *statement_;
100 CYClassName *className_;
103 CYMessageParameter *messageParameter_;
104 CYProtocol *protocol_;
105 CYSelectorPart *selector_;
109 CYAttribute *attribute_;
110 CYPropertyIdentifier *propertyIdentifier_;
111 CYSelector *selector_;
116 #define YYSTYPE YYSTYPE
119 @if Bison24 %code provides {
120 int cylex(YYSTYPE *, cy::location *, void *);
127 @if Bison23 %skeleton "lalr1.cc"
128 @if Bison24 %language "C++"
131 @$.begin.filename = @$.end.filename = &driver.filename_;
142 %parse-param { CYDriver &driver }
143 %lex-param { void *cyscanner }
150 %token XMLAttributeValue
152 %token XMLTagCharacters
158 %token LeftRight "<>"
159 %token LeftSlashRight "</>"
161 %token SlashRight "/>"
162 %token LeftSlash "</"
164 %token ColonColon "::"
165 %token PeriodPeriod ".."
168 @begin E4X ObjectiveC
173 %token AmpersandAmpersand "&&"
174 %token AmpersandEqual "&="
176 %token CarrotEqual "^="
178 %token EqualEqual "=="
179 %token EqualEqualEqual "==="
180 %token Exclamation "!"
181 %token ExclamationEqual "!="
182 %token ExclamationEqualEqual "!=="
184 %token HyphenEqual "-="
185 %token HyphenHyphen "--"
186 %token HyphenHyphen_ "\n--"
187 %token HyphenRight "->"
189 %token LeftEqual "<="
191 %token LeftLeftEqual "<<="
193 %token PercentEqual "%="
196 %token PipeEqual "|="
199 %token PlusEqual "+="
201 %token PlusPlus_ "\n++"
203 %token RightEqual ">="
204 %token RightRight ">>"
205 %token RightRightEqual ">>="
206 %token RightRightRight ">>>"
207 %token RightRightRightEqual ">>>="
209 %token SlashEqual "/="
211 %token StarEqual "*="
220 %token <comment_> Comment
223 %token CloseParen ")"
226 %token CloseBrace "}"
228 %token OpenBracket "["
229 %token CloseBracket "]"
231 %token AtClass "@class"
232 %token AtSelector "@selector"
235 %token <false_> False "false"
236 %token <null_> Null "null"
237 %token <true_> True "true"
239 // ES3/ES5/WIE/JSC Reserved
240 %token <word_> Break "break"
241 %token <word_> Case "case"
242 %token <word_> Catch "catch"
243 %token <word_> Continue "continue"
244 %token <word_> Default "default"
245 %token <word_> Delete "delete"
246 %token <word_> Do "do"
247 %token <word_> Else "else"
248 %token <word_> Finally "finally"
249 %token <word_> For "for"
250 %token <word_> Function "function"
251 %token <word_> If "if"
252 %token <word_> In "in"
253 %token <word_> InstanceOf "instanceof"
254 %token <word_> New "new"
255 %token <word_> Return "return"
256 %token <word_> Switch "switch"
257 %token <this_> This "this"
258 %token <word_> Throw "throw"
259 %token <word_> Try "try"
260 %token <word_> TypeOf "typeof"
261 %token <word_> Var "var"
262 %token <word_> Void "void"
263 %token <word_> While "while"
264 %token <word_> With "with"
266 // ES3/IE6 Future, ES5/JSC Reserved
267 %token <word_> Debugger "debugger"
269 // ES3/ES5/IE6 Future, JSC Reserved
270 %token <word_> Const "const"
272 // ES3/ES5/IE6/JSC Future
273 %token <word_> Class "class"
274 %token <word_> Enum "enum"
275 %token <word_> Export "export"
276 %token <word_> Extends "extends"
277 %token <word_> Import "import"
278 %token <word_> Super "super"
280 // ES3 Future, ES5 Strict Future
281 %token <identifier_> Implements "implements"
282 %token <identifier_> Interface "interface"
283 %token <identifier_> Package "package"
284 %token <identifier_> Private "private"
285 %token <identifier_> Protected "protected"
286 %token <identifier_> Public "public"
287 %token <identifier_> Static "static"
290 %token <identifier_> Abstract "abstract"
291 %token <identifier_> Boolean "boolean"
292 %token <identifier_> Byte "byte"
293 %token <identifier_> Char "char"
294 %token <identifier_> Double "double"
295 %token <identifier_> Final "final"
296 %token <identifier_> Float "float"
297 %token <identifier_> Goto "goto"
298 %token <identifier_> Int "int"
299 %token <identifier_> Long "long"
300 %token <identifier_> Native "native"
301 %token <identifier_> Short "short"
302 %token <identifier_> Synchronized "synchronized"
303 %token <identifier_> Throws "throws"
304 %token <identifier_> Transient "transient"
305 %token <identifier_> Volatile "volatile"
308 %token <identifier_> Let "let"
309 %token <identifier_> Yield "yield"
312 %token <identifier_> Each "each"
316 %token <identifier_> Namespace "namespace"
317 %token <identifier_> XML "xml"
322 %token <identifier_> Identifier_
323 %token <number_> NumericLiteral
324 %token <string_> StringLiteral
325 %token <literal_> RegularExpressionLiteral
327 %type <expression_> AdditiveExpression
328 %type <expression_> AdditiveExpressionNoBF
329 %type <argument_> ArgumentList
330 %type <argument_> ArgumentList_
331 %type <argument_> ArgumentListOpt
332 %type <argument_> Arguments
333 %type <literal_> ArrayLiteral
334 %type <expression_> AssigneeExpression
335 %type <expression_> AssigneeExpressionNoBF
336 %type <expression_> AssignmentExpression
337 %type <assignment_> AssignmentExpression_
338 %type <expression_> AssignmentExpressionNoBF
339 %type <expression_> AssignmentExpressionNoIn
340 %type <expression_> BitwiseANDExpression
341 %type <expression_> BitwiseANDExpressionNoBF
342 %type <expression_> BitwiseANDExpressionNoIn
343 %type <statement_> Block
344 %type <statement_> Block_
345 %type <boolean_> BooleanLiteral
346 %type <expression_> BitwiseORExpression
347 %type <expression_> BitwiseORExpressionNoBF
348 %type <expression_> BitwiseORExpressionNoIn
349 %type <expression_> BitwiseXORExpression
350 %type <expression_> BitwiseXORExpressionNoBF
351 %type <expression_> BitwiseXORExpressionNoIn
352 %type <statement_> BreakStatement
353 %type <expression_> CallExpression
354 %type <expression_> CallExpressionNoBF
355 %type <clause_> CaseBlock
356 %type <clause_> CaseClause
357 %type <clause_> CaseClausesOpt
358 %type <catch_> CatchOpt
359 %type <comprehension_> ComprehensionList
360 %type <comprehension_> ComprehensionListOpt
361 %type <expression_> ConditionalExpression
362 %type <expression_> ConditionalExpressionNoBF
363 %type <expression_> ConditionalExpressionNoIn
364 %type <statement_> ContinueStatement
365 %type <clause_> DefaultClause
366 %type <statement_> DoWhileStatement
367 %type <expression_> Element
368 %type <expression_> ElementOpt
369 %type <element_> ElementList
370 %type <element_> ElementListOpt
371 %type <statement_> ElseStatementOpt
372 %type <statement_> EmptyStatement
373 %type <expression_> EqualityExpression
374 %type <expression_> EqualityExpressionNoBF
375 %type <expression_> EqualityExpressionNoIn
376 %type <expression_> Expression
377 %type <expression_> ExpressionOpt
378 %type <compound_> Expression_
379 %type <expression_> ExpressionNoBF
380 %type <expression_> ExpressionNoIn
381 %type <compound_> ExpressionNoIn_
382 %type <expression_> ExpressionNoInOpt
383 %type <statement_> ExpressionStatement
384 %type <finally_> FinallyOpt
385 %type <comprehension_> ForComprehension
386 %type <statement_> ForStatement
387 %type <for_> ForStatementInitialiser
388 %type <statement_> ForInStatement
389 %type <forin_> ForInStatementInitialiser
390 %type <functionParameter_> FormalParameterList
391 %type <functionParameter_> FormalParameterList_
392 %type <statement_> FunctionBody
393 %type <statement_> FunctionDeclaration
394 %type <expression_> FunctionExpression
395 %type <identifier_> Identifier
396 %type <identifier_> IdentifierOpt
397 %type <comprehension_> IfComprehension
398 %type <statement_> IfStatement
399 %type <expression_> Initialiser
400 %type <expression_> InitialiserOpt
401 %type <expression_> InitialiserNoIn
402 %type <expression_> InitialiserNoInOpt
403 %type <statement_> IterationStatement
404 %type <statement_> LabelledStatement
405 %type <expression_> LeftHandSideExpression
406 %type <expression_> LeftHandSideExpressionNoBF
407 //%type <statement_> LetStatement
408 %type <literal_> Literal
409 %type <literal_> LiteralNoRE
410 %type <literal_> LiteralRE
411 %type <expression_> LogicalANDExpression
412 %type <expression_> LogicalANDExpressionNoBF
413 %type <expression_> LogicalANDExpressionNoIn
414 %type <expression_> LogicalORExpression
415 %type <expression_> LogicalORExpressionNoBF
416 %type <expression_> LogicalORExpressionNoIn
417 %type <member_> MemberAccess
418 %type <expression_> MemberExpression
419 %type <expression_> MemberExpression_
420 %type <expression_> MemberExpressionNoBF
421 %type <expression_> MultiplicativeExpression
422 %type <expression_> MultiplicativeExpressionNoBF
423 %type <expression_> NewExpression
424 %type <expression_> NewExpression_
425 %type <expression_> NewExpressionNoBF
426 %type <null_> NullLiteral
427 %type <literal_> ObjectLiteral
428 %type <expression_> PostfixExpression
429 %type <expression_> PostfixExpressionNoBF
430 %type <expression_> PrimaryExpression
431 %type <expression_> PrimaryExpressionNo
432 %type <expression_> PrimaryExpressionNoBF
433 %type <expression_> PrimaryExpressionNoRE
434 %type <expression_> PrimaryExpressionBF
435 %type <statement_> Program
436 %type <propertyName_> PropertyName
437 %type <propertyName_> PropertyName_
438 %type <property_> PropertyNameAndValueList
439 %type <property_> PropertyNameAndValueList_
440 %type <property_> PropertyNameAndValueListOpt
441 %type <expression_> RelationalExpression
442 %type <infix_> RelationalExpression_
443 %type <expression_> RelationalExpressionNoBF
444 %type <expression_> RelationalExpressionNoIn
445 %type <infix_> RelationalExpressionNoIn_
446 %type <statement_> ReturnStatement
447 %type <expression_> ShiftExpression
448 %type <expression_> ShiftExpressionNoBF
449 %type <statement_> SourceElement
450 %type <statement_> SourceElement_
451 %type <statement_> SourceElements
452 %type <statement_> Statement
453 %type <statement_> Statement_
454 %type <statement_> StatementList
455 %type <statement_> StatementListOpt
456 %type <statement_> SwitchStatement
457 %type <statement_> ThrowStatement
458 %type <statement_> TryStatement
459 %type <expression_> UnaryExpression
460 %type <expression_> UnaryExpression_
461 %type <expression_> UnaryExpressionNoBF
462 %type <declaration_> VariableDeclaration
463 %type <declaration_> VariableDeclarationNoIn
464 %type <declarations_> VariableDeclarationList
465 %type <declarations_> VariableDeclarationList_
466 %type <declarations_> VariableDeclarationListNoIn
467 %type <declarations_> VariableDeclarationListNoIn_
468 %type <statement_> VariableStatement
469 %type <statement_> WhileStatement
470 %type <statement_> WithStatement
473 %type <expression_> AssigneeExpressionNoRE
474 %type <expression_> CallExpressionNoRE
475 %type <expression_> LeftHandSideExpressionNoRE
476 %type <expression_> MemberExpressionNoRE
477 %type <expression_> NewExpressionNoRE
478 %type <expression_> PostfixExpressionNoRE
479 %type <expression_> UnaryAssigneeExpression
480 %type <expression_> UnaryExpressionNoRE
484 %type <statement_> CategoryStatement
485 %type <expression_> ClassExpression
486 %type <statement_> ClassStatement
487 %type <expression_> ClassSuperOpt
488 %type <field_> ClassFieldList
489 %type <message_> ClassMessageDeclaration
490 %type <message_> ClassMessageDeclarationListOpt
491 %type <className_> ClassName
492 %type <className_> ClassNameOpt
493 %type <protocol_> ClassProtocolListOpt
494 %type <protocol_> ClassProtocols
495 %type <protocol_> ClassProtocolsOpt
496 %type <expression_> MessageExpression
497 %type <messageParameter_> MessageParameter
498 %type <messageParameter_> MessageParameters
499 %type <messageParameter_> MessageParameterList
500 %type <messageParameter_> MessageParameterListOpt
501 %type <bool_> MessageScope
502 %type <argument_> SelectorCall
503 %type <argument_> SelectorCall_
504 %type <selector_> SelectorExpression
505 %type <selector_> SelectorExpression_
506 %type <selector_> SelectorExpressionOpt
507 %type <argument_> SelectorList
508 %type <word_> SelectorWordOpt
509 %type <expression_> TypeOpt
510 %type <argument_> VariadicCall
512 %type <word_> WordOpt
516 %type <propertyIdentifier_> PropertyIdentifier_
517 %type <selector_> PropertySelector
518 %type <selector_> PropertySelector_
519 %type <identifier_> QualifiedIdentifier
520 %type <identifier_> QualifiedIdentifier_
521 %type <identifier_> WildcardIdentifier
522 %type <identifier_> XMLComment
523 %type <identifier_> XMLCDATA
524 %type <identifier_> XMLElement
525 %type <identifier_> XMLElementContent
526 %type <identifier_> XMLMarkup
527 %type <identifier_> XMLPI
529 %type <attribute_> AttributeIdentifier
530 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
531 %type <expression_> PropertyIdentifier
532 %type <expression_> XMLListInitialiser
533 %type <expression_> XMLInitialiser
536 %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield"
546 %left "<<" ">>" ">>>"
547 %left "<" ">" "<=" ">=" "instanceof" "in"
548 %left "==" "!=" "===" "!=="
555 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
561 /* Lexer State {{{ */
563 : { driver.SetCondition(CYDriver::RegExpCondition); }
568 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
578 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
583 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
603 : Identifier { $$ = $1; }
604 | "break" NewLineOpt { $$ = $1; }
605 | "case" { $$ = $1; }
606 | "catch" { $$ = $1; }
607 | "class" { $$ = $1; }
608 | "const" { $$ = $1; }
609 | "continue" NewLineOpt { $$ = $1; }
610 | "debugger" { $$ = $1; }
611 | "default" { $$ = $1; }
612 | "delete" { $$ = $1; }
614 | "else" { $$ = $1; }
615 | "enum" { $$ = $1; }
616 | "export" { $$ = $1; }
617 | "extends" { $$ = $1; }
618 | "false" { $$ = $1; }
619 | "finally" { $$ = $1; }
620 /* XXX: | "for" { $$ = $1; } */
621 | "function" { $$ = $1; }
623 | "import" { $$ = $1; }
624 /* XXX: | "in" { $$ = $1; } */
625 /* XXX: | "instanceof" { $$ = $1; } */
627 | "null" { $$ = $1; }
628 | "return" NewLineOpt { $$ = $1; }
629 | "super" { $$ = $1; }
630 | "switch" { $$ = $1; }
631 | "this" { $$ = $1; }
632 | "throw" NewLineOpt { $$ = $1; }
633 | "true" { $$ = $1; }
635 | "typeof" { $$ = $1; }
637 | "void" { $$ = $1; }
638 | "while" { $$ = $1; }
639 | "with" { $$ = $1; }
644 : Identifier_ { $$ = $1; }
646 | "implements" { $$ = $1; }
647 | "interface" { $$ = $1; }
648 | "package" { $$ = $1; }
649 | "private" { $$ = $1; }
650 | "protected" { $$ = $1; }
651 | "public" { $$ = $1; }
652 | "static" { $$ = $1; }
654 | "abstract" { $$ = $1; }
655 | "boolean" { $$ = $1; }
656 | "byte" { $$ = $1; }
657 | "char" { $$ = $1; }
658 | "double" { $$ = $1; }
659 | "final" { $$ = $1; }
660 | "float" { $$ = $1; }
661 | "goto" { $$ = $1; }
663 | "long" { $$ = $1; }
664 | "native" { $$ = $1; }
665 | "short" { $$ = $1; }
666 | "synchronized" { $$ = $1; }
667 | "throws" { $$ = $1; }
668 | "transient" { $$ = $1; }
669 | "volatile" { $$ = $1; }
672 | "yield" { $$ = $1; }
674 | "each" { $$ = $1; }
678 : Identifier { $$ = $1; }
683 : NullLiteral { $$ = $1; }
684 | BooleanLiteral { $$ = $1; }
685 | NumericLiteral { $$ = $1; }
686 | StringLiteral { $$ = $1; }
687 | "@" StringLiteral { $$ = $2; }
691 : RegularExpressionLiteral { $$ = $1; }
695 : LiteralNoRE { $$ = $1; }
696 | LiteralRE { $$ = $1; }
700 : "null" { $$ = $1; }
704 : "true" { $$ = $1; }
705 | "false" { $$ = $1; }
708 /* 11.1 Primary Expressions {{{ */
710 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
713 PrimaryExpressionNoBF
714 : PrimaryExpressionNo { $$ = $1; }
717 PrimaryExpressionNoRE
718 : PrimaryExpressionBF { $$ = $1; }
719 | PrimaryExpressionNo { $$ = $1; }
723 : "this" { $$ = $1; }
724 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
725 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
726 | Literal { $$ = $1; }
727 | ArrayLiteral { $$ = $1; }
728 | "(" Expression ")" { $$ = $2; }
732 : ObjectLiteral { $$ = $1; }
735 /* 11.1.4 Array Initialiser {{{ */
737 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
741 : AssignmentExpression { $$ = $1; }
745 : Element { $$ = $1; }
746 | LexSetRegExp { $$ = NULL; }
750 : ElementList { $$ = $1; }
751 | LexSetRegExp { $$ = NULL; }
755 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
756 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
759 /* 11.1.5 Object Initialiser {{{ */
761 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
764 PropertyNameAndValueList_
765 : "," PropertyNameAndValueList { $$ = $2; }
769 PropertyNameAndValueListOpt
770 : PropertyNameAndValueList { $$ = $1; }
774 PropertyNameAndValueList
775 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
779 : Identifier { $$ = $1; }
780 | StringLiteral { $$ = $1; }
781 | NumericLiteral { $$ = $1; }
785 : LexSetRegExp PropertyName_ { $$ = $2; }
789 /* 11.2 Left-Hand-Side Expressions {{{ */
791 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
795 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
796 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
797 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
801 : PrimaryExpression { $$ = $1; }
802 | LexSetRegExp FunctionExpression { $$ = $2; }
803 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
804 | LexSetRegExp MemberExpression_ { $$ = $2; }
808 : PrimaryExpressionNoBF { $$ = $1; }
809 | MemberExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
810 | MemberExpression_ { $$ = $1; }
815 : PrimaryExpressionNoRE { $$ = $1; }
816 | FunctionExpression { $$ = $1; }
817 | MemberExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
818 | MemberExpression_ { $$ = $1; }
823 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
827 : MemberExpression { $$ = $1; }
828 | LexSetRegExp NewExpression_ { $$ = $2; }
832 : MemberExpressionNoBF { $$ = $1; }
833 | NewExpression_ { $$ = $1; }
838 : MemberExpressionNoRE { $$ = $1; }
839 | NewExpression_ { $$ = $1; }
844 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
845 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
846 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
850 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
851 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
852 | CallExpressionNoBF { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
857 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
858 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
859 | CallExpressionNoRE { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
864 : "," ArgumentList { $$ = $2; }
869 : ArgumentList { $$ = $1; }
870 | LexSetRegExp { $$ = NULL; }
874 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
878 : "(" ArgumentListOpt ")" { $$ = $2; }
881 LeftHandSideExpression
882 : NewExpression { $$ = $1; }
883 | CallExpression { $$ = $1; }
886 LeftHandSideExpressionNoBF
887 : NewExpressionNoBF { $$ = $1; }
888 | CallExpressionNoBF { $$ = $1; }
892 LeftHandSideExpressionNoRE
893 : NewExpressionNoRE { $$ = $1; }
894 | CallExpressionNoRE { $$ = $1; }
898 /* 11.3 Postfix Expressions {{{ */
900 : AssigneeExpression { $$ = $1; }
901 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
902 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
905 PostfixExpressionNoBF
906 : AssigneeExpressionNoBF { $$ = $1; }
907 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
908 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
912 PostfixExpressionNoRE
913 : AssigneeExpressionNoRE { $$ = $1; }
914 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
915 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
919 /* 11.4 Unary Operators {{{ */
921 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
922 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
923 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
924 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
925 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
926 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
927 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
928 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
929 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
930 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
931 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
935 : PostfixExpression { $$ = $1; }
936 | LexSetRegExp UnaryExpression_ { $$ = $2; }
940 : PostfixExpressionNoBF { $$ = $1; }
941 | UnaryExpression_ { $$ = $1; }
946 : PostfixExpressionNoRE { $$ = $1; }
947 | UnaryExpression_ { $$ = $1; }
951 /* 11.5 Multiplicative Operators {{{ */
952 MultiplicativeExpression
953 : UnaryExpression { $$ = $1; }
954 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
955 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
956 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
959 MultiplicativeExpressionNoBF
960 : UnaryExpressionNoBF { $$ = $1; }
961 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
962 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
963 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
966 /* 11.6 Additive Operators {{{ */
968 : MultiplicativeExpression { $$ = $1; }
969 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
970 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
973 AdditiveExpressionNoBF
974 : MultiplicativeExpressionNoBF { $$ = $1; }
975 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
976 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
979 /* 11.7 Bitwise Shift Operators {{{ */
981 : AdditiveExpression { $$ = $1; }
982 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
983 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
984 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
988 : AdditiveExpressionNoBF { $$ = $1; }
989 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
990 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
991 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
994 /* 11.8 Relational Operators {{{ */
995 RelationalExpressionNoIn_
996 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
997 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
998 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
999 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
1000 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
1003 RelationalExpression_
1004 : RelationalExpressionNoIn_ { $$ = $1; }
1005 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1008 RelationalExpression
1009 : ShiftExpression { $$ = $1; }
1010 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1013 RelationalExpressionNoIn
1014 : ShiftExpression { $$ = $1; }
1015 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1018 RelationalExpressionNoBF
1019 : ShiftExpressionNoBF { $$ = $1; }
1020 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1023 /* 11.9 Equality Operators {{{ */
1025 : RelationalExpression { $$ = $1; }
1026 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1027 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1028 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1029 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1032 EqualityExpressionNoIn
1033 : RelationalExpressionNoIn { $$ = $1; }
1034 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1035 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1036 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1037 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1040 EqualityExpressionNoBF
1041 : RelationalExpressionNoBF { $$ = $1; }
1042 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1043 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1044 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1045 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1048 /* 11.10 Binary Bitwise Operators {{{ */
1049 BitwiseANDExpression
1050 : EqualityExpression { $$ = $1; }
1051 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1054 BitwiseANDExpressionNoIn
1055 : EqualityExpressionNoIn { $$ = $1; }
1056 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1059 BitwiseANDExpressionNoBF
1060 : EqualityExpressionNoBF { $$ = $1; }
1061 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1064 BitwiseXORExpression
1065 : BitwiseANDExpression { $$ = $1; }
1066 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1069 BitwiseXORExpressionNoIn
1070 : BitwiseANDExpressionNoIn { $$ = $1; }
1071 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1074 BitwiseXORExpressionNoBF
1075 : BitwiseANDExpressionNoBF { $$ = $1; }
1076 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1080 : BitwiseXORExpression { $$ = $1; }
1081 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1084 BitwiseORExpressionNoIn
1085 : BitwiseXORExpressionNoIn { $$ = $1; }
1086 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1089 BitwiseORExpressionNoBF
1090 : BitwiseXORExpressionNoBF { $$ = $1; }
1091 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1094 /* 11.11 Binary Logical Operators {{{ */
1095 LogicalANDExpression
1096 : BitwiseORExpression { $$ = $1; }
1097 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1100 LogicalANDExpressionNoIn
1101 : BitwiseORExpressionNoIn { $$ = $1; }
1102 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1105 LogicalANDExpressionNoBF
1106 : BitwiseORExpressionNoBF { $$ = $1; }
1107 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1111 : LogicalANDExpression { $$ = $1; }
1112 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1115 LogicalORExpressionNoIn
1116 : LogicalANDExpressionNoIn { $$ = $1; }
1117 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1120 LogicalORExpressionNoBF
1121 : LogicalANDExpressionNoBF { $$ = $1; }
1122 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1125 /* 11.12 Conditional Operator ( ? : ) {{{ */
1126 ConditionalExpression
1127 : LogicalORExpression { $$ = $1; }
1128 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1131 ConditionalExpressionNoIn
1132 : LogicalORExpressionNoIn { $$ = $1; }
1133 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1136 ConditionalExpressionNoBF
1137 : LogicalORExpressionNoBF { $$ = $1; }
1138 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1141 /* 11.13 Assignment Operators {{{ */
1142 AssignmentExpression_
1143 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1144 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1145 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1146 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1147 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1148 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1149 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1150 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1151 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1152 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1153 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1154 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1158 : LeftHandSideExpression { $$ = $1; }
1160 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1164 AssigneeExpressionNoBF
1165 : LeftHandSideExpressionNoBF { $$ = $1; }
1167 | UnaryAssigneeExpression { $$ = $1; }
1172 AssigneeExpressionNoRE
1173 : LeftHandSideExpressionNoRE { $$ = $1; }
1174 | UnaryAssigneeExpression { $$ = $1; }
1178 AssignmentExpression
1179 : ConditionalExpression { $$ = $1; }
1180 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1183 AssignmentExpressionNoIn
1184 : ConditionalExpressionNoIn { $$ = $1; }
1185 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1186 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1187 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1188 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1189 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1190 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1191 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1192 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1193 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1194 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1195 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1196 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1199 AssignmentExpressionNoBF
1200 : ConditionalExpressionNoBF { $$ = $1; }
1201 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1204 /* 11.14 Comma Operator {{{ */
1206 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1211 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1216 : Expression { $$ = $1; }
1217 | LexSetRegExp { $$ = NULL; }
1221 : ExpressionNoIn { $$ = $1; }
1222 | LexSetRegExp { $$ = NULL; }
1226 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1230 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1234 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1238 /* 12 Statements {{{ */
1240 : Block { $$ = $1; }
1241 | VariableStatement { $$ = $1; }
1242 | EmptyStatement { $$ = $1; }
1243 | ExpressionStatement { $$ = $1; }
1244 | IfStatement { $$ = $1; }
1245 | IterationStatement { $$ = $1; }
1246 | ContinueStatement { $$ = $1; }
1247 | BreakStatement { $$ = $1; }
1248 | ReturnStatement { $$ = $1; }
1249 | WithStatement { $$ = $1; }
1250 | LabelledStatement { $$ = $1; }
1251 | SwitchStatement { $$ = $1; }
1252 | ThrowStatement { $$ = $1; }
1253 | TryStatement { $$ = $1; }
1257 : LexSetRegExp Statement_ { $$ = $2; }
1260 /* 12.1 Block {{{ */
1262 : "{" StatementListOpt "}" { $$ = $2; }
1266 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1270 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1274 : StatementList { $$ = $1; }
1275 | LexSetRegExp { $$ = NULL; }
1278 /* 12.2 Variable Statement {{{ */
1280 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1283 VariableDeclarationList_
1284 : "," VariableDeclarationList { $$ = $2; }
1288 VariableDeclarationListNoIn_
1289 : "," VariableDeclarationListNoIn { $$ = $2; }
1293 VariableDeclarationList
1294 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1297 VariableDeclarationListNoIn
1298 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1302 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1305 VariableDeclarationNoIn
1306 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1310 : Initialiser { $$ = $1; }
1315 : InitialiserNoIn { $$ = $1; }
1320 : "=" AssignmentExpression { $$ = $2; }
1324 : "=" AssignmentExpressionNoIn { $$ = $2; }
1327 /* 12.3 Empty Statement {{{ */
1329 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1332 /* 12.4 Expression Statement {{{ */
1334 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1337 /* 12.5 The if Statement {{{ */
1339 : "else" Statement { $$ = $2; }
1340 | %prec "if" { $$ = NULL; }
1344 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1348 /* 12.6 Iteration Statements {{{ */
1350 : DoWhileStatement { $$ = $1; }
1351 | WhileStatement { $$ = $1; }
1352 | ForStatement { $$ = $1; }
1353 | ForInStatement { $$ = $1; }
1356 /* 12.6.1 The do-while Statement {{{ */
1358 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1361 /* 12.6.2 The while Statement {{{ */
1363 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1366 /* 12.6.3 The for Statement {{{ */
1368 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1371 ForStatementInitialiser
1372 : ExpressionNoInOpt { $$ = $1; }
1373 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1376 /* 12.6.4 The for-in Statement {{{ */
1378 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1381 ForInStatementInitialiser
1382 : LeftHandSideExpression { $$ = $1; }
1383 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1387 /* 12.7 The continue Statement {{{ */
1389 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1392 /* 12.8 The break Statement {{{ */
1394 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1397 /* 12.9 The return Statement {{{ */
1399 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1402 /* 12.10 The with Statement {{{ */
1404 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1408 /* 12.11 The switch Statement {{{ */
1410 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1414 : "{" CaseClausesOpt "}" { $$ = $2; }
1418 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1419 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1424 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1428 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1431 /* 12.12 Labelled Statements {{{ */
1433 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1436 /* 12.13 The throw Statement {{{ */
1438 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1441 /* 12.14 The try Statement {{{ */
1443 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1447 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1452 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1457 /* 13 Function Definition {{{ */
1459 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1463 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1466 FormalParameterList_
1467 : "," FormalParameterList { $$ = $2; }
1472 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1477 : SourceElements { $$ = $1; }
1480 /* 14 Program {{{ */
1482 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1486 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1487 | LexSetRegExp { $$ = NULL; }
1491 : Statement_ { $$ = $1; }
1492 | FunctionDeclaration { $$ = $1; }
1496 : LexSetRegExp SourceElement_ { $$ = $2; }
1501 /* Cycript (Objective-C): @class Declaration {{{ */
1503 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1504 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1509 : "{" "}" { $$ = NULL; }
1513 : "+" { $$ = false; }
1514 | "-" { $$ = true; }
1518 : "(" Expression ")" { $$ = $2; }
1523 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1526 MessageParameterListOpt
1527 : MessageParameterList { $$ = $1; }
1531 MessageParameterList
1532 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1536 : MessageParameterList { $$ = $1; }
1537 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1540 ClassMessageDeclaration
1541 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1544 ClassMessageDeclarationListOpt
1545 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1550 : Identifier { $$ = $1; }
1551 | "(" AssignmentExpression ")" { $$ = $2; }
1555 : ClassName { $$ = $1; }
1559 // XXX: this should be AssignmentExpressionNoRight
1561 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1565 : "," ClassProtocols { $$ = $2; }
1569 ClassProtocolListOpt
1570 : "<" ClassProtocols ">" { $$ = $2; }
1575 : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1579 : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1583 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1587 : ClassExpression { $$ = $1; }
1591 : ClassStatement { $$ = $1; }
1592 | CategoryStatement { $$ = $1; }
1595 /* Cycript (Objective-C): Send Message {{{ */
1597 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1602 : SelectorCall { $$ = $1; }
1603 | VariadicCall { $$ = $1; }
1607 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1608 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1612 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1616 : SelectorCall { $$ = $1; }
1617 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1621 : "[" AssignmentExpression { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = new(driver.pool_) CYSendDirect($2, $4); }
1622 | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($5); }
1625 SelectorExpressionOpt
1626 : SelectorExpression_ { $$ = $1; }
1631 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1635 : SelectorExpression_ { $$ = $1; }
1636 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1640 : MessageExpression { $$ = $1; }
1641 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1647 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1648 UnaryAssigneeExpression
1649 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1653 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1657 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1658 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1659 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1664 /* YUI: Documentation Comments {{{ */
1666 : Comment { $$ = $1; }
1671 /* Lexer State {{{ */
1673 : { driver.PushCondition(CYDriver::RegExpCondition); }
1677 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1681 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1685 : { driver.PopCondition(); }
1689 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1693 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1702 /* 8.1 Context Keywords {{{ */
1704 : "namespace" { $$ = $1; }
1705 | "xml" { $$ = $1; }
1708 /* 8.3 XML Initialiser Input Elements {{{ */
1710 : XMLComment { $$ = $1; }
1711 | XMLCDATA { $$ = $1; }
1712 | XMLPI { $$ = $1; }
1715 /* 11.1 Primary Expressions {{{ */
1717 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1718 | XMLInitialiser { $$ = $1; }
1719 | XMLListInitialiser { $$ = $1; }
1723 : AttributeIdentifier { $$ = $1; }
1724 | QualifiedIdentifier { $$ = $1; }
1725 | WildcardIdentifier { $$ = $1; }
1728 /* 11.1.1 Attribute Identifiers {{{ */
1730 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1734 : PropertySelector { $$ = $1; }
1735 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1739 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1740 | WildcardIdentifier { $$ = $1; }
1743 /* 11.1.2 Qualified Identifiers {{{ */
1744 QualifiedIdentifier_
1745 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1746 | QualifiedIdentifier { $$ = $1; }
1750 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1753 /* 11.1.3 Wildcard Identifiers {{{ */
1755 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1758 /* 11.1.4 XML Initialiser {{{ */
1760 : XMLMarkup { $$ = $1; }
1761 | XMLElement { $$ = $1; }
1765 : "<" XMLTagContent "/>" LexPop
1766 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1770 : LexPushXMLTag XMLTagName XMLAttributes
1774 : "{" LexPushRegExp Expression "}" LexPop
1783 : XMLAttributes_ XMLAttribute
1788 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1789 | XMLAttributes_ XMLWhitespaceOpt
1798 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1802 : XMLExpression XMLElementContentOpt
1803 | XMLMarkup XMLElementContentOpt
1804 | XMLText XMLElementContentOpt
1805 | XMLElement XMLElementContentOpt
1808 XMLElementContentOpt
1813 /* 11.1.5 XMLList Initialiser {{{ */
1815 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1818 /* 11.2 Left-Hand-Side Expressions {{{ */
1820 : Identifier { $$ = $1; }
1821 | PropertyIdentifier { $$ = $1; }
1825 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1826 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1827 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1830 /* 12.1 The default xml namespace Statement {{{ */
1831 /* XXX: DefaultXMLNamespaceStatement
1832 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1836 : DefaultXMLNamespaceStatement { $$ = $1; }
1841 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1842 PropertyNameAndValueList_
1843 : "," { $$ = NULL; }
1846 /* JavaScript 1.7: Array Comprehensions {{{ */
1848 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1852 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1853 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1856 ComprehensionListOpt
1857 : ComprehensionList { $$ = $1; }
1858 | IfComprehension { $$ = $1; }
1863 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1867 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1870 /* JavaScript 1.7: for each {{{ */
1872 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1875 /* JavaScript 1.7: let Statements {{{ *//*
1877 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1884 /* JavaScript FTW: Function Statements {{{ */
1886 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }