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 #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"
320 %token <identifier_> Identifier_
321 %token <number_> NumericLiteral
322 %token <string_> StringLiteral
323 %token <literal_> RegularExpressionLiteral
325 %type <expression_> AdditiveExpression
326 %type <expression_> AdditiveExpressionNoBF
327 %type <argument_> ArgumentList
328 %type <argument_> ArgumentList_
329 %type <argument_> ArgumentListOpt
330 %type <argument_> Arguments
331 %type <literal_> ArrayLiteral
332 %type <expression_> AssigneeExpression
333 %type <expression_> AssigneeExpressionNoBF
334 %type <expression_> AssignmentExpression
335 %type <assignment_> AssignmentExpression_
336 %type <expression_> AssignmentExpressionNoBF
337 %type <expression_> AssignmentExpressionNoIn
338 %type <expression_> BitwiseANDExpression
339 %type <expression_> BitwiseANDExpressionNoBF
340 %type <expression_> BitwiseANDExpressionNoIn
341 %type <statement_> Block
342 %type <statement_> Block_
343 %type <boolean_> BooleanLiteral
344 %type <expression_> BitwiseORExpression
345 %type <expression_> BitwiseORExpressionNoBF
346 %type <expression_> BitwiseORExpressionNoIn
347 %type <expression_> BitwiseXORExpression
348 %type <expression_> BitwiseXORExpressionNoBF
349 %type <expression_> BitwiseXORExpressionNoIn
350 %type <statement_> BreakStatement
351 %type <expression_> CallExpression
352 %type <expression_> CallExpressionNoBF
353 %type <clause_> CaseBlock
354 %type <clause_> CaseClause
355 %type <clause_> CaseClausesOpt
356 %type <catch_> CatchOpt
357 %type <comprehension_> ComprehensionList
358 %type <comprehension_> ComprehensionListOpt
359 %type <expression_> ConditionalExpression
360 %type <expression_> ConditionalExpressionNoBF
361 %type <expression_> ConditionalExpressionNoIn
362 %type <statement_> ContinueStatement
363 %type <clause_> DefaultClause
364 %type <statement_> DoWhileStatement
365 %type <expression_> Element
366 %type <expression_> ElementOpt
367 %type <element_> ElementList
368 %type <element_> ElementListOpt
369 %type <statement_> ElseStatementOpt
370 %type <statement_> EmptyStatement
371 %type <expression_> EqualityExpression
372 %type <expression_> EqualityExpressionNoBF
373 %type <expression_> EqualityExpressionNoIn
374 %type <expression_> Expression
375 %type <expression_> ExpressionOpt
376 %type <compound_> Expression_
377 %type <expression_> ExpressionNoBF
378 %type <expression_> ExpressionNoIn
379 %type <compound_> ExpressionNoIn_
380 %type <expression_> ExpressionNoInOpt
381 %type <statement_> ExpressionStatement
382 %type <finally_> FinallyOpt
383 %type <comprehension_> ForComprehension
384 %type <statement_> ForStatement
385 %type <for_> ForStatementInitialiser
386 %type <statement_> ForInStatement
387 %type <forin_> ForInStatementInitialiser
388 %type <functionParameter_> FormalParameterList
389 %type <functionParameter_> FormalParameterList_
390 %type <statement_> FunctionBody
391 %type <statement_> FunctionDeclaration
392 %type <expression_> FunctionExpression
393 %type <identifier_> Identifier
394 %type <identifier_> IdentifierOpt
395 %type <comprehension_> IfComprehension
396 %type <statement_> IfStatement
397 %type <expression_> Initialiser
398 %type <expression_> InitialiserOpt
399 %type <expression_> InitialiserNoIn
400 %type <expression_> InitialiserNoInOpt
401 %type <statement_> IterationStatement
402 %type <statement_> LabelledStatement
403 %type <expression_> LeftHandSideExpression
404 %type <expression_> LeftHandSideExpressionNoBF
405 //%type <statement_> LetStatement
406 %type <literal_> Literal
407 %type <literal_> LiteralNoRE
408 %type <literal_> LiteralRE
409 %type <expression_> LogicalANDExpression
410 %type <expression_> LogicalANDExpressionNoBF
411 %type <expression_> LogicalANDExpressionNoIn
412 %type <expression_> LogicalORExpression
413 %type <expression_> LogicalORExpressionNoBF
414 %type <expression_> LogicalORExpressionNoIn
415 %type <member_> MemberAccess
416 %type <expression_> MemberExpression
417 %type <expression_> MemberExpression_
418 %type <expression_> MemberExpressionNoBF
419 %type <expression_> MultiplicativeExpression
420 %type <expression_> MultiplicativeExpressionNoBF
421 %type <expression_> NewExpression
422 %type <expression_> NewExpression_
423 %type <expression_> NewExpressionNoBF
424 %type <null_> NullLiteral
425 %type <literal_> ObjectLiteral
426 %type <expression_> PostfixExpression
427 %type <expression_> PostfixExpressionNoBF
428 %type <expression_> PrimaryExpression
429 %type <expression_> PrimaryExpressionNo
430 %type <expression_> PrimaryExpressionNoBF
431 %type <expression_> PrimaryExpressionNoRE
432 %type <expression_> PrimaryExpressionBF
433 %type <statement_> Program
434 %type <propertyName_> PropertyName
435 %type <propertyName_> PropertyName_
436 %type <property_> PropertyNameAndValueList
437 %type <property_> PropertyNameAndValueList_
438 %type <property_> PropertyNameAndValueListOpt
439 %type <expression_> RelationalExpression
440 %type <infix_> RelationalExpression_
441 %type <expression_> RelationalExpressionNoBF
442 %type <expression_> RelationalExpressionNoIn
443 %type <infix_> RelationalExpressionNoIn_
444 %type <statement_> ReturnStatement
445 %type <expression_> ShiftExpression
446 %type <expression_> ShiftExpressionNoBF
447 %type <statement_> SourceElement
448 %type <statement_> SourceElement_
449 %type <statement_> SourceElements
450 %type <statement_> Statement
451 %type <statement_> Statement_
452 %type <statement_> StatementList
453 %type <statement_> StatementListOpt
454 %type <statement_> SwitchStatement
455 %type <statement_> ThrowStatement
456 %type <statement_> TryStatement
457 %type <expression_> UnaryExpression
458 %type <expression_> UnaryExpression_
459 %type <expression_> UnaryExpressionNoBF
460 %type <declaration_> VariableDeclaration
461 %type <declaration_> VariableDeclarationNoIn
462 %type <declarations_> VariableDeclarationList
463 %type <declarations_> VariableDeclarationList_
464 %type <declarations_> VariableDeclarationListNoIn
465 %type <declarations_> VariableDeclarationListNoIn_
466 %type <statement_> VariableStatement
467 %type <statement_> WhileStatement
468 %type <statement_> WithStatement
471 %type <expression_> AssigneeExpressionNoRE
472 %type <expression_> CallExpressionNoRE
473 %type <expression_> LeftHandSideExpressionNoRE
474 %type <expression_> MemberExpressionNoRE
475 %type <expression_> NewExpressionNoRE
476 %type <expression_> PostfixExpressionNoRE
477 %type <expression_> UnaryAssigneeExpression
478 %type <expression_> UnaryExpressionNoRE
482 %type <statement_> CategoryStatement
483 %type <expression_> ClassExpression
484 %type <statement_> ClassStatement
485 %type <expression_> ClassSuperOpt
486 %type <field_> ClassFieldList
487 %type <message_> ClassMessageDeclaration
488 %type <message_> ClassMessageDeclarationListOpt
489 %type <className_> ClassName
490 %type <className_> ClassNameOpt
491 %type <protocol_> ClassProtocolListOpt
492 %type <protocol_> ClassProtocols
493 %type <protocol_> ClassProtocolsOpt
494 %type <expression_> MessageExpression
495 %type <messageParameter_> MessageParameter
496 %type <messageParameter_> MessageParameters
497 %type <messageParameter_> MessageParameterList
498 %type <messageParameter_> MessageParameterListOpt
499 %type <bool_> MessageScope
500 %type <argument_> SelectorCall
501 %type <argument_> SelectorCall_
502 %type <selector_> SelectorExpression
503 %type <selector_> SelectorExpression_
504 %type <selector_> SelectorExpressionOpt
505 %type <argument_> SelectorList
506 %type <expression_> TypeOpt
507 %type <argument_> VariadicCall
509 %type <word_> WordOpt
513 %type <propertyIdentifier_> PropertyIdentifier_
514 %type <selector_> PropertySelector
515 %type <selector_> PropertySelector_
516 %type <identifier_> QualifiedIdentifier
517 %type <identifier_> QualifiedIdentifier_
518 %type <identifier_> WildcardIdentifier
519 %type <identifier_> XMLComment
520 %type <identifier_> XMLCDATA
521 %type <identifier_> XMLElement
522 %type <identifier_> XMLElementContent
523 %type <identifier_> XMLMarkup
524 %type <identifier_> XMLPI
526 %type <attribute_> AttributeIdentifier
527 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
528 %type <expression_> PropertyIdentifier
529 %type <expression_> XMLListInitialiser
530 %type <expression_> XMLInitialiser
533 %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"
543 %left "<<" ">>" ">>>"
544 %left "<" ">" "<=" ">=" "instanceof" "in"
545 %left "==" "!=" "===" "!=="
552 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
558 /* Lexer State {{{ */
560 : { driver.SetCondition(CYDriver::RegExpCondition); }
565 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
575 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
580 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
600 : Identifier { $$ = $1; }
601 | "break" NewLineOpt { $$ = $1; }
602 | "case" { $$ = $1; }
603 | "catch" { $$ = $1; }
604 | "class" { $$ = $1; }
605 | "const" { $$ = $1; }
606 | "continue" NewLineOpt { $$ = $1; }
607 | "debugger" { $$ = $1; }
608 | "default" { $$ = $1; }
609 | "delete" { $$ = $1; }
611 | "else" { $$ = $1; }
612 | "enum" { $$ = $1; }
613 | "export" { $$ = $1; }
614 | "extends" { $$ = $1; }
615 | "false" { $$ = $1; }
616 | "finally" { $$ = $1; }
617 /* XXX: | "for" { $$ = $1; } */
618 | "function" { $$ = $1; }
620 | "import" { $$ = $1; }
621 /* XXX: | "in" { $$ = $1; } */
622 /* XXX: | "instanceof" { $$ = $1; } */
624 | "null" { $$ = $1; }
625 | "return" NewLineOpt { $$ = $1; }
626 | "super" { $$ = $1; }
627 | "switch" { $$ = $1; }
628 | "this" { $$ = $1; }
629 | "throw" NewLineOpt { $$ = $1; }
630 | "true" { $$ = $1; }
632 | "typeof" { $$ = $1; }
634 | "void" { $$ = $1; }
635 | "while" { $$ = $1; }
636 | "with" { $$ = $1; }
641 : Identifier_ { $$ = $1; }
643 | "implements" { $$ = $1; }
644 | "interface" { $$ = $1; }
645 | "package" { $$ = $1; }
646 | "private" { $$ = $1; }
647 | "protected" { $$ = $1; }
648 | "public" { $$ = $1; }
649 | "static" { $$ = $1; }
651 | "abstract" { $$ = $1; }
652 | "boolean" { $$ = $1; }
653 | "byte" { $$ = $1; }
654 | "char" { $$ = $1; }
655 | "double" { $$ = $1; }
656 | "final" { $$ = $1; }
657 | "float" { $$ = $1; }
658 | "goto" { $$ = $1; }
660 | "long" { $$ = $1; }
661 | "native" { $$ = $1; }
662 | "short" { $$ = $1; }
663 | "synchronized" { $$ = $1; }
664 | "throws" { $$ = $1; }
665 | "transient" { $$ = $1; }
666 | "volatile" { $$ = $1; }
669 | "yield" { $$ = $1; }
671 | "each" { $$ = $1; }
675 : Identifier { $$ = $1; }
680 : NullLiteral { $$ = $1; }
681 | BooleanLiteral { $$ = $1; }
682 | NumericLiteral { $$ = $1; }
683 | StringLiteral { $$ = $1; }
684 | "@" StringLiteral { $$ = $2; }
688 : RegularExpressionLiteral { $$ = $1; }
692 : LiteralNoRE { $$ = $1; }
693 | LiteralRE { $$ = $1; }
697 : "null" { $$ = $1; }
701 : "true" { $$ = $1; }
702 | "false" { $$ = $1; }
705 /* 11.1 Primary Expressions {{{ */
707 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
710 PrimaryExpressionNoBF
711 : PrimaryExpressionNo { $$ = $1; }
714 PrimaryExpressionNoRE
715 : PrimaryExpressionBF { $$ = $1; }
716 | PrimaryExpressionNo { $$ = $1; }
720 : "this" { $$ = $1; }
721 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
722 | Literal { $$ = $1; }
723 | ArrayLiteral { $$ = $1; }
724 | "(" Expression ")" { $$ = $2; }
728 : ObjectLiteral { $$ = $1; }
731 /* 11.1.4 Array Initialiser {{{ */
733 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
737 : AssignmentExpression { $$ = $1; }
741 : Element { $$ = $1; }
742 | LexSetRegExp { $$ = NULL; }
746 : ElementList { $$ = $1; }
747 | LexSetRegExp { $$ = NULL; }
751 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
752 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
755 /* 11.1.5 Object Initialiser {{{ */
757 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
760 PropertyNameAndValueList_
761 : "," PropertyNameAndValueList { $$ = $2; }
765 PropertyNameAndValueListOpt
766 : PropertyNameAndValueList { $$ = $1; }
770 PropertyNameAndValueList
771 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
775 : Identifier { $$ = $1; }
776 | StringLiteral { $$ = $1; }
777 | NumericLiteral { $$ = $1; }
781 : LexSetRegExp PropertyName_ { $$ = $2; }
785 /* 11.2 Left-Hand-Side Expressions {{{ */
787 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
791 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
792 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
796 : PrimaryExpression { $$ = $1; }
797 | LexSetRegExp FunctionExpression { $$ = $2; }
798 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
799 | LexSetRegExp MemberExpression_ { $$ = $2; }
803 : PrimaryExpressionNoBF { $$ = $1; }
804 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
805 | MemberExpression_ { $$ = $1; }
810 : PrimaryExpressionNoRE { $$ = $1; }
811 | FunctionExpression { $$ = $1; }
812 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
813 | MemberExpression_ { $$ = $1; }
818 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
822 : MemberExpression { $$ = $1; }
823 | LexSetRegExp NewExpression_ { $$ = $2; }
827 : MemberExpressionNoBF { $$ = $1; }
828 | NewExpression_ { $$ = $1; }
833 : MemberExpressionNoRE { $$ = $1; }
834 | NewExpression_ { $$ = $1; }
839 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
840 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
841 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
845 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
846 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
847 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
852 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
853 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
854 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
859 : "," ArgumentList { $$ = $2; }
864 : ArgumentList { $$ = $1; }
865 | LexSetRegExp { $$ = NULL; }
869 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
873 : "(" ArgumentListOpt ")" { $$ = $2; }
876 LeftHandSideExpression
877 : NewExpression { $$ = $1; }
878 | CallExpression { $$ = $1; }
881 LeftHandSideExpressionNoBF
882 : NewExpressionNoBF { $$ = $1; }
883 | CallExpressionNoBF { $$ = $1; }
887 LeftHandSideExpressionNoRE
888 : NewExpressionNoRE { $$ = $1; }
889 | CallExpressionNoRE { $$ = $1; }
893 /* 11.3 Postfix Expressions {{{ */
895 : AssigneeExpression { $$ = $1; }
896 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
897 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
900 PostfixExpressionNoBF
901 : AssigneeExpressionNoBF { $$ = $1; }
902 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
903 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
907 PostfixExpressionNoRE
908 : AssigneeExpressionNoRE { $$ = $1; }
909 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
910 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
914 /* 11.4 Unary Operators {{{ */
916 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
917 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
918 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
919 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
920 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
921 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
922 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
923 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
924 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
925 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
926 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
930 : PostfixExpression { $$ = $1; }
931 | LexSetRegExp UnaryExpression_ { $$ = $2; }
935 : PostfixExpressionNoBF { $$ = $1; }
936 | UnaryExpression_ { $$ = $1; }
941 : PostfixExpressionNoRE { $$ = $1; }
942 | UnaryExpression_ { $$ = $1; }
946 /* 11.5 Multiplicative Operators {{{ */
947 MultiplicativeExpression
948 : UnaryExpression { $$ = $1; }
949 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
950 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
951 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
954 MultiplicativeExpressionNoBF
955 : UnaryExpressionNoBF { $$ = $1; }
956 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
957 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
958 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
961 /* 11.6 Additive Operators {{{ */
963 : MultiplicativeExpression { $$ = $1; }
964 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
965 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
968 AdditiveExpressionNoBF
969 : MultiplicativeExpressionNoBF { $$ = $1; }
970 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
971 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
974 /* 11.7 Bitwise Shift Operators {{{ */
976 : AdditiveExpression { $$ = $1; }
977 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
978 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
979 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
983 : AdditiveExpressionNoBF { $$ = $1; }
984 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
985 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
986 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
989 /* 11.8 Relational Operators {{{ */
990 RelationalExpressionNoIn_
991 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
992 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
993 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
994 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
995 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
998 RelationalExpression_
999 : RelationalExpressionNoIn_ { $$ = $1; }
1000 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1003 RelationalExpression
1004 : ShiftExpression { $$ = $1; }
1005 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1008 RelationalExpressionNoIn
1009 : ShiftExpression { $$ = $1; }
1010 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1013 RelationalExpressionNoBF
1014 : ShiftExpressionNoBF { $$ = $1; }
1015 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1018 /* 11.9 Equality Operators {{{ */
1020 : RelationalExpression { $$ = $1; }
1021 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1022 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1023 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1024 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1027 EqualityExpressionNoIn
1028 : RelationalExpressionNoIn { $$ = $1; }
1029 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1030 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1031 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1032 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1035 EqualityExpressionNoBF
1036 : RelationalExpressionNoBF { $$ = $1; }
1037 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1038 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1039 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1040 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1043 /* 11.10 Binary Bitwise Operators {{{ */
1044 BitwiseANDExpression
1045 : EqualityExpression { $$ = $1; }
1046 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1049 BitwiseANDExpressionNoIn
1050 : EqualityExpressionNoIn { $$ = $1; }
1051 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1054 BitwiseANDExpressionNoBF
1055 : EqualityExpressionNoBF { $$ = $1; }
1056 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1059 BitwiseXORExpression
1060 : BitwiseANDExpression { $$ = $1; }
1061 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1064 BitwiseXORExpressionNoIn
1065 : BitwiseANDExpressionNoIn { $$ = $1; }
1066 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1069 BitwiseXORExpressionNoBF
1070 : BitwiseANDExpressionNoBF { $$ = $1; }
1071 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1075 : BitwiseXORExpression { $$ = $1; }
1076 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1079 BitwiseORExpressionNoIn
1080 : BitwiseXORExpressionNoIn { $$ = $1; }
1081 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1084 BitwiseORExpressionNoBF
1085 : BitwiseXORExpressionNoBF { $$ = $1; }
1086 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1089 /* 11.11 Binary Logical Operators {{{ */
1090 LogicalANDExpression
1091 : BitwiseORExpression { $$ = $1; }
1092 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1095 LogicalANDExpressionNoIn
1096 : BitwiseORExpressionNoIn { $$ = $1; }
1097 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1100 LogicalANDExpressionNoBF
1101 : BitwiseORExpressionNoBF { $$ = $1; }
1102 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1106 : LogicalANDExpression { $$ = $1; }
1107 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1110 LogicalORExpressionNoIn
1111 : LogicalANDExpressionNoIn { $$ = $1; }
1112 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1115 LogicalORExpressionNoBF
1116 : LogicalANDExpressionNoBF { $$ = $1; }
1117 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1120 /* 11.12 Conditional Operator ( ? : ) {{{ */
1121 ConditionalExpression
1122 : LogicalORExpression { $$ = $1; }
1123 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1126 ConditionalExpressionNoIn
1127 : LogicalORExpressionNoIn { $$ = $1; }
1128 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1131 ConditionalExpressionNoBF
1132 : LogicalORExpressionNoBF { $$ = $1; }
1133 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1136 /* 11.13 Assignment Operators {{{ */
1137 AssignmentExpression_
1138 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1139 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1140 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1141 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1142 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1143 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1144 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1145 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1146 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1147 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1148 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1149 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1153 : LeftHandSideExpression { $$ = $1; }
1155 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1159 AssigneeExpressionNoBF
1160 : LeftHandSideExpressionNoBF { $$ = $1; }
1162 | UnaryAssigneeExpression { $$ = $1; }
1167 AssigneeExpressionNoRE
1168 : LeftHandSideExpressionNoRE { $$ = $1; }
1169 | UnaryAssigneeExpression { $$ = $1; }
1173 AssignmentExpression
1174 : ConditionalExpression { $$ = $1; }
1175 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1178 AssignmentExpressionNoIn
1179 : ConditionalExpressionNoIn { $$ = $1; }
1180 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1181 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1182 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1183 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1184 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1185 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1186 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1187 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1188 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1189 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1190 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1191 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1194 AssignmentExpressionNoBF
1195 : ConditionalExpressionNoBF { $$ = $1; }
1196 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1199 /* 11.14 Comma Operator {{{ */
1201 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1206 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1211 : Expression { $$ = $1; }
1212 | LexSetRegExp { $$ = NULL; }
1216 : ExpressionNoIn { $$ = $1; }
1217 | LexSetRegExp { $$ = NULL; }
1221 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1225 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1229 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1233 /* 12 Statements {{{ */
1235 : Block { $$ = $1; }
1236 | VariableStatement { $$ = $1; }
1237 | EmptyStatement { $$ = $1; }
1238 | ExpressionStatement { $$ = $1; }
1239 | IfStatement { $$ = $1; }
1240 | IterationStatement { $$ = $1; }
1241 | ContinueStatement { $$ = $1; }
1242 | BreakStatement { $$ = $1; }
1243 | ReturnStatement { $$ = $1; }
1244 | WithStatement { $$ = $1; }
1245 | LabelledStatement { $$ = $1; }
1246 | SwitchStatement { $$ = $1; }
1247 | ThrowStatement { $$ = $1; }
1248 | TryStatement { $$ = $1; }
1252 : LexSetRegExp Statement_ { $$ = $2; }
1255 /* 12.1 Block {{{ */
1257 : "{" StatementListOpt "}" { $$ = $2; }
1261 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1265 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1269 : StatementList { $$ = $1; }
1270 | LexSetRegExp { $$ = NULL; }
1273 /* 12.2 Variable Statement {{{ */
1275 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1278 VariableDeclarationList_
1279 : "," VariableDeclarationList { $$ = $2; }
1283 VariableDeclarationListNoIn_
1284 : "," VariableDeclarationListNoIn { $$ = $2; }
1288 VariableDeclarationList
1289 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1292 VariableDeclarationListNoIn
1293 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1297 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1300 VariableDeclarationNoIn
1301 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1305 : Initialiser { $$ = $1; }
1310 : InitialiserNoIn { $$ = $1; }
1315 : "=" AssignmentExpression { $$ = $2; }
1319 : "=" AssignmentExpressionNoIn { $$ = $2; }
1322 /* 12.3 Empty Statement {{{ */
1324 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1327 /* 12.4 Expression Statement {{{ */
1329 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1332 /* 12.5 The if Statement {{{ */
1334 : "else" Statement { $$ = $2; }
1335 | %prec "if" { $$ = NULL; }
1339 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1343 /* 12.6 Iteration Statements {{{ */
1345 : DoWhileStatement { $$ = $1; }
1346 | WhileStatement { $$ = $1; }
1347 | ForStatement { $$ = $1; }
1348 | ForInStatement { $$ = $1; }
1351 /* 12.6.1 The do-while Statement {{{ */
1353 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1356 /* 12.6.2 The while Statement {{{ */
1358 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1361 /* 12.6.3 The for Statement {{{ */
1363 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1366 ForStatementInitialiser
1367 : ExpressionNoInOpt { $$ = $1; }
1368 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1371 /* 12.6.4 The for-in Statement {{{ */
1373 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1376 ForInStatementInitialiser
1377 : LeftHandSideExpression { $$ = $1; }
1378 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1382 /* 12.7 The continue Statement {{{ */
1384 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1387 /* 12.8 The break Statement {{{ */
1389 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1392 /* 12.9 The return Statement {{{ */
1394 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1397 /* 12.10 The with Statement {{{ */
1399 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1403 /* 12.11 The switch Statement {{{ */
1405 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1409 : "{" CaseClausesOpt "}" { $$ = $2; }
1413 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1414 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1419 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1423 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1426 /* 12.12 Labelled Statements {{{ */
1428 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1431 /* 12.13 The throw Statement {{{ */
1433 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1436 /* 12.14 The try Statement {{{ */
1438 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1442 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1447 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1452 /* 13 Function Definition {{{ */
1454 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1458 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1461 FormalParameterList_
1462 : "," FormalParameterList { $$ = $2; }
1467 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1472 : SourceElements { $$ = $1; }
1475 /* 14 Program {{{ */
1477 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1481 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1482 | LexSetRegExp { $$ = NULL; }
1486 : Statement_ { $$ = $1; }
1487 | FunctionDeclaration { $$ = $1; }
1491 : LexSetRegExp SourceElement_ { $$ = $2; }
1496 /* Cycript (Objective-C): @class Declaration {{{ */
1498 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1499 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1504 : "{" "}" { $$ = NULL; }
1508 : "+" { $$ = false; }
1509 | "-" { $$ = true; }
1513 : "(" Expression ")" { $$ = $2; }
1518 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1521 MessageParameterListOpt
1522 : MessageParameterList { $$ = $1; }
1526 MessageParameterList
1527 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1531 : MessageParameterList { $$ = $1; }
1532 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1535 ClassMessageDeclaration
1536 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1539 ClassMessageDeclarationListOpt
1540 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1545 : Identifier { $$ = $1; }
1546 | "(" AssignmentExpression ")" { $$ = $2; }
1550 : ClassName { $$ = $1; }
1554 // XXX: this should be AssignmentExpressionNoRight
1556 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1560 : "," ClassProtocols { $$ = $2; }
1564 ClassProtocolListOpt
1565 : "<" ClassProtocols ">" { $$ = $2; }
1570 : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1574 : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1578 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1582 : ClassExpression { $$ = $1; }
1586 : ClassStatement { $$ = $1; }
1587 | CategoryStatement { $$ = $1; }
1590 /* Cycript (Objective-C): Send Message {{{ */
1592 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1597 : SelectorCall { $$ = $1; }
1598 | VariadicCall { $$ = $1; }
1602 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1606 : SelectorCall { $$ = $1; }
1607 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1611 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1612 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1615 SelectorExpressionOpt
1616 : SelectorExpression_ { $$ = $1; }
1621 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1625 : SelectorExpression_ { $$ = $1; }
1626 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1630 : MessageExpression { $$ = $1; }
1631 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1637 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1638 UnaryAssigneeExpression
1639 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1643 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1647 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1648 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1653 /* YUI: Documentation Comments {{{ */
1655 : Comment { $$ = $1; }
1660 /* Lexer State {{{ */
1662 : { driver.PushCondition(CYDriver::RegExpCondition); }
1666 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1670 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1674 : { driver.PopCondition(); }
1678 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1682 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1691 /* 8.1 Context Keywords {{{ */
1693 : "namespace" { $$ = $1; }
1694 | "xml" { $$ = $1; }
1697 /* 8.3 XML Initialiser Input Elements {{{ */
1699 : XMLComment { $$ = $1; }
1700 | XMLCDATA { $$ = $1; }
1701 | XMLPI { $$ = $1; }
1704 /* 11.1 Primary Expressions {{{ */
1706 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1707 | XMLInitialiser { $$ = $1; }
1708 | XMLListInitialiser { $$ = $1; }
1712 : AttributeIdentifier { $$ = $1; }
1713 | QualifiedIdentifier { $$ = $1; }
1714 | WildcardIdentifier { $$ = $1; }
1717 /* 11.1.1 Attribute Identifiers {{{ */
1719 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1723 : PropertySelector { $$ = $1; }
1724 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1728 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1729 | WildcardIdentifier { $$ = $1; }
1732 /* 11.1.2 Qualified Identifiers {{{ */
1733 QualifiedIdentifier_
1734 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1735 | QualifiedIdentifier { $$ = $1; }
1739 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1742 /* 11.1.3 Wildcard Identifiers {{{ */
1744 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1747 /* 11.1.4 XML Initialiser {{{ */
1749 : XMLMarkup { $$ = $1; }
1750 | XMLElement { $$ = $1; }
1754 : "<" XMLTagContent "/>" LexPop
1755 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1759 : LexPushXMLTag XMLTagName XMLAttributes
1763 : "{" LexPushRegExp Expression "}" LexPop
1772 : XMLAttributes_ XMLAttribute
1777 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1778 | XMLAttributes_ XMLWhitespaceOpt
1787 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1791 : XMLExpression XMLElementContentOpt
1792 | XMLMarkup XMLElementContentOpt
1793 | XMLText XMLElementContentOpt
1794 | XMLElement XMLElementContentOpt
1797 XMLElementContentOpt
1802 /* 11.1.5 XMLList Initialiser {{{ */
1804 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1807 /* 11.2 Left-Hand-Side Expressions {{{ */
1809 : Identifier { $$ = $1; }
1810 | PropertyIdentifier { $$ = $1; }
1814 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1815 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1816 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1819 /* 12.1 The default xml namespace Statement {{{ */
1820 /* XXX: DefaultXMLNamespaceStatement
1821 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1825 : DefaultXMLNamespaceStatement { $$ = $1; }
1830 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1831 PropertyNameAndValueList_
1832 : "," { $$ = NULL; }
1835 /* JavaScript 1.7: Array Comprehensions {{{ */
1837 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1841 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1842 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1845 ComprehensionListOpt
1846 : ComprehensionList { $$ = $1; }
1847 | IfComprehension { $$ = $1; }
1852 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1856 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1859 /* JavaScript 1.7: for each {{{ */
1861 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1864 /* JavaScript 1.7: let Statements {{{ *//*
1866 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1873 /* JavaScript FTW: Function Statements {{{ */
1875 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }