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.
41 #define cyscanner driver.scanner_
42 #define YYSTACKEXPANDABLE 1
43 #define yyerrok (yyerrstatus_ = 0)
50 #include "ObjectiveC/Syntax.hpp"
54 #include "E4X/Syntax.hpp"
63 CYDriver::Condition condition_;
65 CYArgument *argument_;
66 CYAssignment *assignment_;
69 cy::Syntax::Catch *catch_;
71 CYComprehension *comprehension_;
72 CYCompound *compound_;
73 CYDeclaration *declaration_;
74 CYDeclarations *declarations_;
76 CYExpression *expression_;
79 CYForInitialiser *for_;
80 CYForInInitialiser *forin_;
81 CYFunctionParameter *functionParameter_;
82 CYIdentifier *identifier_;
89 CYProperty *property_;
90 CYPropertyName *propertyName_;
91 CYStatement *statement_;
98 CYClassName *className_;
101 CYMessageParameter *messageParameter_;
102 CYProtocol *protocol_;
103 CYSelectorPart *selector_;
107 CYAttribute *attribute_;
108 CYPropertyIdentifier *propertyIdentifier_;
109 CYSelector *selector_;
114 #define YYSTYPE YYSTYPE
119 int cylex(YYSTYPE *, cy::location *, void *);
128 @$.begin.filename = @$.end.filename = &driver.filename_;
138 %parse-param { CYDriver &driver }
139 %lex-param { void *cyscanner }
146 %token XMLAttributeValue
148 %token XMLTagCharacters
154 %token LeftRight "<>"
155 %token LeftSlashRight "</>"
157 %token SlashRight "/>"
158 %token LeftSlash "</"
160 %token ColonColon "::"
161 %token PeriodPeriod ".."
164 @begin E4X ObjectiveC
169 %token AmpersandAmpersand "&&"
170 %token AmpersandEqual "&="
172 %token CarrotEqual "^="
174 %token EqualEqual "=="
175 %token EqualEqualEqual "==="
176 %token Exclamation "!"
177 %token ExclamationEqual "!="
178 %token ExclamationEqualEqual "!=="
180 %token HyphenEqual "-="
181 %token HyphenHyphen "--"
182 %token HyphenHyphen_ "\n--"
183 %token HyphenRight "->"
185 %token LeftEqual "<="
187 %token LeftLeftEqual "<<="
189 %token PercentEqual "%="
192 %token PipeEqual "|="
195 %token PlusEqual "+="
197 %token PlusPlus_ "\n++"
199 %token RightEqual ">="
200 %token RightRight ">>"
201 %token RightRightEqual ">>="
202 %token RightRightRight ">>>"
203 %token RightRightRightEqual ">>>="
205 %token SlashEqual "/="
207 %token StarEqual "*="
216 %token <comment_> Comment
219 %token CloseParen ")"
222 %token CloseBrace "}"
224 %token OpenBracket "["
225 %token CloseBracket "]"
227 %token AtClass "@class"
228 %token AtSelector "@selector"
231 %token <false_> False "false"
232 %token <null_> Null "null"
233 %token <true_> True "true"
235 // ES3/ES5/WIE/JSC Reserved
236 %token <word_> Break "break"
237 %token <word_> Case "case"
238 %token <word_> Catch "catch"
239 %token <word_> Continue "continue"
240 %token <word_> Default "default"
241 %token <word_> Delete "delete"
242 %token <word_> Do "do"
243 %token <word_> Else "else"
244 %token <word_> Finally "finally"
245 %token <word_> For "for"
246 %token <word_> Function "function"
247 %token <word_> If "if"
248 %token <word_> In "in"
249 %token <word_> InstanceOf "instanceof"
250 %token <word_> New "new"
251 %token <word_> Return "return"
252 %token <word_> Switch "switch"
253 %token <this_> This "this"
254 %token <word_> Throw "throw"
255 %token <word_> Try "try"
256 %token <word_> TypeOf "typeof"
257 %token <word_> Var "var"
258 %token <word_> Void "void"
259 %token <word_> While "while"
260 %token <word_> With "with"
262 // ES3/IE6 Future, ES5/JSC Reserved
263 %token <word_> Debugger "debugger"
265 // ES3/ES5/IE6 Future, JSC Reserved
266 %token <word_> Const "const"
268 // ES3/ES5/IE6/JSC Future
269 %token <word_> Class "class"
270 %token <word_> Enum "enum"
271 %token <word_> Export "export"
272 %token <word_> Extends "extends"
273 %token <word_> Import "import"
274 %token <word_> Super "super"
276 // ES3 Future, ES5 Strict Future
277 %token <identifier_> Implements "implements"
278 %token <identifier_> Interface "interface"
279 %token <identifier_> Package "package"
280 %token <identifier_> Private "private"
281 %token <identifier_> Protected "protected"
282 %token <identifier_> Public "public"
283 %token <identifier_> Static "static"
286 %token <identifier_> Abstract "abstract"
287 %token <identifier_> Boolean "boolean"
288 %token <identifier_> Byte "byte"
289 %token <identifier_> Char "char"
290 %token <identifier_> Double "double"
291 %token <identifier_> Final "final"
292 %token <identifier_> Float "float"
293 %token <identifier_> Goto "goto"
294 %token <identifier_> Int "int"
295 %token <identifier_> Long "long"
296 %token <identifier_> Native "native"
297 %token <identifier_> Short "short"
298 %token <identifier_> Synchronized "synchronized"
299 %token <identifier_> Throws "throws"
300 %token <identifier_> Transient "transient"
301 %token <identifier_> Volatile "volatile"
304 %token <identifier_> Let "let"
305 %token <identifier_> Yield "yield"
308 %token <identifier_> Each "each"
312 %token <identifier_> Namespace "namespace"
313 %token <identifier_> XML "xml"
316 %token <identifier_> Identifier_
317 %token <number_> NumericLiteral
318 %token <string_> StringLiteral
319 %token <literal_> RegularExpressionLiteral
321 %type <expression_> AdditiveExpression
322 %type <expression_> AdditiveExpressionNoBF
323 %type <argument_> ArgumentList
324 %type <argument_> ArgumentList_
325 %type <argument_> ArgumentListOpt
326 %type <argument_> Arguments
327 %type <literal_> ArrayLiteral
328 %type <expression_> AssigneeExpression
329 %type <expression_> AssigneeExpressionNoBF
330 %type <expression_> AssignmentExpression
331 %type <assignment_> AssignmentExpression_
332 %type <expression_> AssignmentExpressionNoBF
333 %type <expression_> AssignmentExpressionNoIn
334 %type <expression_> BitwiseANDExpression
335 %type <expression_> BitwiseANDExpressionNoBF
336 %type <expression_> BitwiseANDExpressionNoIn
337 %type <statement_> Block
338 %type <statement_> Block_
339 %type <boolean_> BooleanLiteral
340 %type <expression_> BitwiseORExpression
341 %type <expression_> BitwiseORExpressionNoBF
342 %type <expression_> BitwiseORExpressionNoIn
343 %type <expression_> BitwiseXORExpression
344 %type <expression_> BitwiseXORExpressionNoBF
345 %type <expression_> BitwiseXORExpressionNoIn
346 %type <statement_> BreakStatement
347 %type <expression_> CallExpression
348 %type <expression_> CallExpressionNoBF
349 %type <clause_> CaseBlock
350 %type <clause_> CaseClause
351 %type <clause_> CaseClausesOpt
352 %type <catch_> CatchOpt
353 %type <comprehension_> ComprehensionList
354 %type <comprehension_> ComprehensionListOpt
355 %type <expression_> ConditionalExpression
356 %type <expression_> ConditionalExpressionNoBF
357 %type <expression_> ConditionalExpressionNoIn
358 %type <statement_> ContinueStatement
359 %type <clause_> DefaultClause
360 %type <statement_> DoWhileStatement
361 %type <expression_> Element
362 %type <expression_> ElementOpt
363 %type <element_> ElementList
364 %type <element_> ElementListOpt
365 %type <statement_> ElseStatementOpt
366 %type <statement_> EmptyStatement
367 %type <expression_> EqualityExpression
368 %type <expression_> EqualityExpressionNoBF
369 %type <expression_> EqualityExpressionNoIn
370 %type <expression_> Expression
371 %type <expression_> ExpressionOpt
372 %type <compound_> Expression_
373 %type <expression_> ExpressionNoBF
374 %type <expression_> ExpressionNoIn
375 %type <compound_> ExpressionNoIn_
376 %type <expression_> ExpressionNoInOpt
377 %type <statement_> ExpressionStatement
378 %type <finally_> FinallyOpt
379 %type <comprehension_> ForComprehension
380 %type <statement_> ForStatement
381 %type <for_> ForStatementInitialiser
382 %type <statement_> ForInStatement
383 %type <forin_> ForInStatementInitialiser
384 %type <functionParameter_> FormalParameterList
385 %type <functionParameter_> FormalParameterList_
386 %type <statement_> FunctionBody
387 %type <statement_> FunctionDeclaration
388 %type <expression_> FunctionExpression
389 %type <identifier_> Identifier
390 %type <identifier_> IdentifierOpt
391 %type <comprehension_> IfComprehension
392 %type <statement_> IfStatement
393 %type <expression_> Initialiser
394 %type <expression_> InitialiserOpt
395 %type <expression_> InitialiserNoIn
396 %type <expression_> InitialiserNoInOpt
397 %type <statement_> IterationStatement
398 %type <statement_> LabelledStatement
399 %type <expression_> LeftHandSideExpression
400 %type <expression_> LeftHandSideExpressionNoBF
401 //%type <statement_> LetStatement
402 %type <literal_> Literal
403 %type <literal_> LiteralNoRE
404 %type <literal_> LiteralRE
405 %type <expression_> LogicalANDExpression
406 %type <expression_> LogicalANDExpressionNoBF
407 %type <expression_> LogicalANDExpressionNoIn
408 %type <expression_> LogicalORExpression
409 %type <expression_> LogicalORExpressionNoBF
410 %type <expression_> LogicalORExpressionNoIn
411 %type <member_> MemberAccess
412 %type <expression_> MemberExpression
413 %type <expression_> MemberExpression_
414 %type <expression_> MemberExpressionNoBF
415 %type <expression_> MultiplicativeExpression
416 %type <expression_> MultiplicativeExpressionNoBF
417 %type <expression_> NewExpression
418 %type <expression_> NewExpression_
419 %type <expression_> NewExpressionNoBF
420 %type <null_> NullLiteral
421 %type <literal_> ObjectLiteral
422 %type <expression_> PostfixExpression
423 %type <expression_> PostfixExpressionNoBF
424 %type <expression_> PrimaryExpression
425 %type <expression_> PrimaryExpressionNo
426 %type <expression_> PrimaryExpressionNoBF
427 %type <expression_> PrimaryExpressionNoRE
428 %type <expression_> PrimaryExpressionBF
429 %type <statement_> Program
430 %type <propertyName_> PropertyName
431 %type <propertyName_> PropertyName_
432 %type <property_> PropertyNameAndValueList
433 %type <property_> PropertyNameAndValueList_
434 %type <property_> PropertyNameAndValueListOpt
435 %type <expression_> RelationalExpression
436 %type <infix_> RelationalExpression_
437 %type <expression_> RelationalExpressionNoBF
438 %type <expression_> RelationalExpressionNoIn
439 %type <infix_> RelationalExpressionNoIn_
440 %type <statement_> ReturnStatement
441 %type <expression_> ShiftExpression
442 %type <expression_> ShiftExpressionNoBF
443 %type <statement_> SourceElement
444 %type <statement_> SourceElement_
445 %type <statement_> SourceElements
446 %type <statement_> Statement
447 %type <statement_> Statement_
448 %type <statement_> StatementList
449 %type <statement_> StatementListOpt
450 %type <statement_> SwitchStatement
451 %type <statement_> ThrowStatement
452 %type <statement_> TryStatement
453 %type <expression_> UnaryExpression
454 %type <expression_> UnaryExpression_
455 %type <expression_> UnaryExpressionNoBF
456 %type <declaration_> VariableDeclaration
457 %type <declaration_> VariableDeclarationNoIn
458 %type <declarations_> VariableDeclarationList
459 %type <declarations_> VariableDeclarationList_
460 %type <declarations_> VariableDeclarationListNoIn
461 %type <declarations_> VariableDeclarationListNoIn_
462 %type <statement_> VariableStatement
463 %type <statement_> WhileStatement
464 %type <statement_> WithStatement
467 %type <expression_> AssigneeExpressionNoRE
468 %type <expression_> CallExpressionNoRE
469 %type <expression_> LeftHandSideExpressionNoRE
470 %type <expression_> MemberExpressionNoRE
471 %type <expression_> NewExpressionNoRE
472 %type <expression_> PostfixExpressionNoRE
473 %type <expression_> UnaryAssigneeExpression
474 %type <expression_> UnaryExpressionNoRE
478 %type <statement_> CategoryStatement
479 %type <expression_> ClassExpression
480 %type <statement_> ClassStatement
481 %type <expression_> ClassSuperOpt
482 %type <field_> ClassFieldList
483 %type <message_> ClassMessageDeclaration
484 %type <message_> ClassMessageDeclarationListOpt
485 %type <className_> ClassName
486 %type <className_> ClassNameOpt
487 %type <protocol_> ClassProtocolListOpt
488 %type <protocol_> ClassProtocols
489 %type <protocol_> ClassProtocolsOpt
490 %type <expression_> MessageExpression
491 %type <messageParameter_> MessageParameter
492 %type <messageParameter_> MessageParameters
493 %type <messageParameter_> MessageParameterList
494 %type <messageParameter_> MessageParameterListOpt
495 %type <bool_> MessageScope
496 %type <argument_> SelectorCall
497 %type <argument_> SelectorCall_
498 %type <selector_> SelectorExpression
499 %type <selector_> SelectorExpression_
500 %type <selector_> SelectorExpressionOpt
501 %type <argument_> SelectorList
502 %type <expression_> TypeOpt
503 %type <argument_> VariadicCall
505 %type <word_> WordOpt
509 %type <propertyIdentifier_> PropertyIdentifier_
510 %type <selector_> PropertySelector
511 %type <selector_> PropertySelector_
512 %type <identifier_> QualifiedIdentifier
513 %type <identifier_> QualifiedIdentifier_
514 %type <identifier_> WildcardIdentifier
515 %type <identifier_> XMLComment
516 %type <identifier_> XMLCDATA
517 %type <identifier_> XMLElement
518 %type <identifier_> XMLElementContent
519 %type <identifier_> XMLMarkup
520 %type <identifier_> XMLPI
522 %type <attribute_> AttributeIdentifier
523 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
524 %type <expression_> PropertyIdentifier
525 %type <expression_> XMLListInitialiser
526 %type <expression_> XMLInitialiser
529 %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"
539 %left "<<" ">>" ">>>"
540 %left "<" ">" "<=" ">=" "instanceof" "in"
541 %left "==" "!=" "===" "!=="
548 %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
554 /* Lexer State {{{ */
556 : { driver.SetCondition(CYDriver::RegExpCondition); }
561 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
571 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
576 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
596 : Identifier { $$ = $1; }
597 | "break" NewLineOpt { $$ = $1; }
598 | "case" { $$ = $1; }
599 | "catch" { $$ = $1; }
600 | "class" { $$ = $1; }
601 | "const" { $$ = $1; }
602 | "continue" NewLineOpt { $$ = $1; }
603 | "debugger" { $$ = $1; }
604 | "default" { $$ = $1; }
605 | "delete" { $$ = $1; }
607 | "else" { $$ = $1; }
608 | "enum" { $$ = $1; }
609 | "export" { $$ = $1; }
610 | "extends" { $$ = $1; }
611 | "false" { $$ = $1; }
612 | "finally" { $$ = $1; }
613 /* XXX: | "for" { $$ = $1; } */
614 | "function" { $$ = $1; }
616 | "import" { $$ = $1; }
617 /* XXX: | "in" { $$ = $1; } */
618 /* XXX: | "instanceof" { $$ = $1; } */
620 | "null" { $$ = $1; }
621 | "return" NewLineOpt { $$ = $1; }
622 | "super" { $$ = $1; }
623 | "switch" { $$ = $1; }
624 | "this" { $$ = $1; }
625 | "throw" NewLineOpt { $$ = $1; }
626 | "true" { $$ = $1; }
628 | "typeof" { $$ = $1; }
630 | "void" { $$ = $1; }
631 | "while" { $$ = $1; }
632 | "with" { $$ = $1; }
637 : Identifier_ { $$ = $1; }
639 | "implements" { $$ = $1; }
640 | "interface" { $$ = $1; }
641 | "package" { $$ = $1; }
642 | "private" { $$ = $1; }
643 | "protected" { $$ = $1; }
644 | "public" { $$ = $1; }
645 | "static" { $$ = $1; }
647 | "abstract" { $$ = $1; }
648 | "boolean" { $$ = $1; }
649 | "byte" { $$ = $1; }
650 | "char" { $$ = $1; }
651 | "double" { $$ = $1; }
652 | "final" { $$ = $1; }
653 | "float" { $$ = $1; }
654 | "goto" { $$ = $1; }
656 | "long" { $$ = $1; }
657 | "native" { $$ = $1; }
658 | "short" { $$ = $1; }
659 | "synchronized" { $$ = $1; }
660 | "throws" { $$ = $1; }
661 | "transient" { $$ = $1; }
662 | "volatile" { $$ = $1; }
665 | "yield" { $$ = $1; }
667 | "each" { $$ = $1; }
671 : Identifier { $$ = $1; }
676 : NullLiteral { $$ = $1; }
677 | BooleanLiteral { $$ = $1; }
678 | NumericLiteral { $$ = $1; }
679 | StringLiteral { $$ = $1; }
680 | "@" StringLiteral { $$ = $2; }
684 : RegularExpressionLiteral { $$ = $1; }
688 : LiteralNoRE { $$ = $1; }
689 | LiteralRE { $$ = $1; }
693 : "null" { $$ = $1; }
697 : "true" { $$ = $1; }
698 | "false" { $$ = $1; }
701 /* 11.1 Primary Expressions {{{ */
703 : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; }
706 PrimaryExpressionNoBF
707 : PrimaryExpressionNo { $$ = $1; }
710 PrimaryExpressionNoRE
711 : PrimaryExpressionBF { $$ = $1; }
712 | PrimaryExpressionNo { $$ = $1; }
716 : "this" { $$ = $1; }
717 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
718 | Literal { $$ = $1; }
719 | ArrayLiteral { $$ = $1; }
720 | "(" Expression ")" { $$ = $2; }
724 : ObjectLiteral { $$ = $1; }
727 /* 11.1.4 Array Initialiser {{{ */
729 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
733 : AssignmentExpression { $$ = $1; }
737 : Element { $$ = $1; }
738 | LexSetRegExp { $$ = NULL; }
742 : ElementList { $$ = $1; }
743 | LexSetRegExp { $$ = NULL; }
747 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
748 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
751 /* 11.1.5 Object Initialiser {{{ */
753 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
756 PropertyNameAndValueList_
757 : "," PropertyNameAndValueList { $$ = $2; }
761 PropertyNameAndValueListOpt
762 : PropertyNameAndValueList { $$ = $1; }
766 PropertyNameAndValueList
767 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
771 : Identifier { $$ = $1; }
772 | StringLiteral { $$ = $1; }
773 | NumericLiteral { $$ = $1; }
777 : LexSetRegExp PropertyName_ { $$ = $2; }
781 /* 11.2 Left-Hand-Side Expressions {{{ */
783 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
787 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
788 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
792 : PrimaryExpression { $$ = $1; }
793 | LexSetRegExp FunctionExpression { $$ = $2; }
794 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
795 | LexSetRegExp MemberExpression_ { $$ = $2; }
799 : PrimaryExpressionNoBF { $$ = $1; }
800 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
801 | MemberExpression_ { $$ = $1; }
806 : PrimaryExpressionNoRE { $$ = $1; }
807 | FunctionExpression { $$ = $1; }
808 | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
809 | MemberExpression_ { $$ = $1; }
814 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
818 : MemberExpression { $$ = $1; }
819 | LexSetRegExp NewExpression_ { $$ = $2; }
823 : MemberExpressionNoBF { $$ = $1; }
824 | NewExpression_ { $$ = $1; }
829 : MemberExpressionNoRE { $$ = $1; }
830 | NewExpression_ { $$ = $1; }
835 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
836 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
837 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
841 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
842 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
843 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
848 : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
849 | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
850 | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; }
855 : "," ArgumentList { $$ = $2; }
860 : ArgumentList { $$ = $1; }
861 | LexSetRegExp { $$ = NULL; }
865 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
869 : "(" ArgumentListOpt ")" { $$ = $2; }
872 LeftHandSideExpression
873 : NewExpression { $$ = $1; }
874 | CallExpression { $$ = $1; }
877 LeftHandSideExpressionNoBF
878 : NewExpressionNoBF { $$ = $1; }
879 | CallExpressionNoBF { $$ = $1; }
883 LeftHandSideExpressionNoRE
884 : NewExpressionNoRE { $$ = $1; }
885 | CallExpressionNoRE { $$ = $1; }
889 /* 11.3 Postfix Expressions {{{ */
891 : AssigneeExpression { $$ = $1; }
892 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
893 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
896 PostfixExpressionNoBF
897 : AssigneeExpressionNoBF { $$ = $1; }
898 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
899 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
903 PostfixExpressionNoRE
904 : AssigneeExpressionNoRE { $$ = $1; }
905 | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
906 | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
910 /* 11.4 Unary Operators {{{ */
912 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
913 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
914 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
915 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
916 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
917 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
918 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
919 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
920 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
921 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
922 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
926 : PostfixExpression { $$ = $1; }
927 | LexSetRegExp UnaryExpression_ { $$ = $2; }
931 : PostfixExpressionNoBF { $$ = $1; }
932 | UnaryExpression_ { $$ = $1; }
937 : PostfixExpressionNoRE { $$ = $1; }
938 | UnaryExpression_ { $$ = $1; }
942 /* 11.5 Multiplicative Operators {{{ */
943 MultiplicativeExpression
944 : UnaryExpression { $$ = $1; }
945 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
946 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
947 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
950 MultiplicativeExpressionNoBF
951 : UnaryExpressionNoBF { $$ = $1; }
952 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
953 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
954 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
957 /* 11.6 Additive Operators {{{ */
959 : MultiplicativeExpression { $$ = $1; }
960 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
961 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
964 AdditiveExpressionNoBF
965 : MultiplicativeExpressionNoBF { $$ = $1; }
966 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
967 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
970 /* 11.7 Bitwise Shift Operators {{{ */
972 : AdditiveExpression { $$ = $1; }
973 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
974 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
975 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
979 : AdditiveExpressionNoBF { $$ = $1; }
980 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
981 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
982 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
985 /* 11.8 Relational Operators {{{ */
986 RelationalExpressionNoIn_
987 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
988 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
989 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
990 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
991 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
994 RelationalExpression_
995 : RelationalExpressionNoIn_ { $$ = $1; }
996 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
1000 : ShiftExpression { $$ = $1; }
1001 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1004 RelationalExpressionNoIn
1005 : ShiftExpression { $$ = $1; }
1006 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
1009 RelationalExpressionNoBF
1010 : ShiftExpressionNoBF { $$ = $1; }
1011 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1014 /* 11.9 Equality Operators {{{ */
1016 : RelationalExpression { $$ = $1; }
1017 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1018 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1019 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1020 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1023 EqualityExpressionNoIn
1024 : RelationalExpressionNoIn { $$ = $1; }
1025 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
1026 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1027 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
1028 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1031 EqualityExpressionNoBF
1032 : RelationalExpressionNoBF { $$ = $1; }
1033 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
1034 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
1035 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
1036 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1039 /* 11.10 Binary Bitwise Operators {{{ */
1040 BitwiseANDExpression
1041 : EqualityExpression { $$ = $1; }
1042 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1045 BitwiseANDExpressionNoIn
1046 : EqualityExpressionNoIn { $$ = $1; }
1047 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1050 BitwiseANDExpressionNoBF
1051 : EqualityExpressionNoBF { $$ = $1; }
1052 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1055 BitwiseXORExpression
1056 : BitwiseANDExpression { $$ = $1; }
1057 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1060 BitwiseXORExpressionNoIn
1061 : BitwiseANDExpressionNoIn { $$ = $1; }
1062 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1065 BitwiseXORExpressionNoBF
1066 : BitwiseANDExpressionNoBF { $$ = $1; }
1067 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1071 : BitwiseXORExpression { $$ = $1; }
1072 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1075 BitwiseORExpressionNoIn
1076 : BitwiseXORExpressionNoIn { $$ = $1; }
1077 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1080 BitwiseORExpressionNoBF
1081 : BitwiseXORExpressionNoBF { $$ = $1; }
1082 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1085 /* 11.11 Binary Logical Operators {{{ */
1086 LogicalANDExpression
1087 : BitwiseORExpression { $$ = $1; }
1088 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1091 LogicalANDExpressionNoIn
1092 : BitwiseORExpressionNoIn { $$ = $1; }
1093 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1096 LogicalANDExpressionNoBF
1097 : BitwiseORExpressionNoBF { $$ = $1; }
1098 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1102 : LogicalANDExpression { $$ = $1; }
1103 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1106 LogicalORExpressionNoIn
1107 : LogicalANDExpressionNoIn { $$ = $1; }
1108 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1111 LogicalORExpressionNoBF
1112 : LogicalANDExpressionNoBF { $$ = $1; }
1113 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1116 /* 11.12 Conditional Operator ( ? : ) {{{ */
1117 ConditionalExpression
1118 : LogicalORExpression { $$ = $1; }
1119 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1122 ConditionalExpressionNoIn
1123 : LogicalORExpressionNoIn { $$ = $1; }
1124 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1127 ConditionalExpressionNoBF
1128 : LogicalORExpressionNoBF { $$ = $1; }
1129 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1132 /* 11.13 Assignment Operators {{{ */
1133 AssignmentExpression_
1134 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
1135 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
1136 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
1137 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
1138 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
1139 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
1140 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
1141 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
1142 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
1143 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
1144 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
1145 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
1149 : LeftHandSideExpression { $$ = $1; }
1151 | LexSetRegExp UnaryAssigneeExpression { $$ = $2; }
1155 AssigneeExpressionNoBF
1156 : LeftHandSideExpressionNoBF { $$ = $1; }
1158 | UnaryAssigneeExpression { $$ = $1; }
1163 AssigneeExpressionNoRE
1164 : LeftHandSideExpressionNoRE { $$ = $1; }
1165 | UnaryAssigneeExpression { $$ = $1; }
1169 AssignmentExpression
1170 : ConditionalExpression { $$ = $1; }
1171 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1174 AssignmentExpressionNoIn
1175 : ConditionalExpressionNoIn { $$ = $1; }
1176 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1177 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1178 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1179 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1180 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1181 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1182 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1183 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1184 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1185 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1186 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1187 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
1190 AssignmentExpressionNoBF
1191 : ConditionalExpressionNoBF { $$ = $1; }
1192 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
1195 /* 11.14 Comma Operator {{{ */
1197 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
1202 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
1207 : Expression { $$ = $1; }
1208 | LexSetRegExp { $$ = NULL; }
1212 : ExpressionNoIn { $$ = $1; }
1213 | LexSetRegExp { $$ = NULL; }
1217 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1221 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1225 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1229 /* 12 Statements {{{ */
1231 : Block { $$ = $1; }
1232 | VariableStatement { $$ = $1; }
1233 | EmptyStatement { $$ = $1; }
1234 | ExpressionStatement { $$ = $1; }
1235 | IfStatement { $$ = $1; }
1236 | IterationStatement { $$ = $1; }
1237 | ContinueStatement { $$ = $1; }
1238 | BreakStatement { $$ = $1; }
1239 | ReturnStatement { $$ = $1; }
1240 | WithStatement { $$ = $1; }
1241 | LabelledStatement { $$ = $1; }
1242 | SwitchStatement { $$ = $1; }
1243 | ThrowStatement { $$ = $1; }
1244 | TryStatement { $$ = $1; }
1248 : LexSetRegExp Statement_ { $$ = $2; }
1251 /* 12.1 Block {{{ */
1253 : "{" StatementListOpt "}" { $$ = $2; }
1257 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1261 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
1265 : StatementList { $$ = $1; }
1266 | LexSetRegExp { $$ = NULL; }
1269 /* 12.2 Variable Statement {{{ */
1271 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1274 VariableDeclarationList_
1275 : "," VariableDeclarationList { $$ = $2; }
1279 VariableDeclarationListNoIn_
1280 : "," VariableDeclarationListNoIn { $$ = $2; }
1284 VariableDeclarationList
1285 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1288 VariableDeclarationListNoIn
1289 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1293 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1296 VariableDeclarationNoIn
1297 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1301 : Initialiser { $$ = $1; }
1306 : InitialiserNoIn { $$ = $1; }
1311 : "=" AssignmentExpression { $$ = $2; }
1315 : "=" AssignmentExpressionNoIn { $$ = $2; }
1318 /* 12.3 Empty Statement {{{ */
1320 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1323 /* 12.4 Expression Statement {{{ */
1325 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1328 /* 12.5 The if Statement {{{ */
1330 : "else" Statement { $$ = $2; }
1331 | %prec "if" { $$ = NULL; }
1335 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1339 /* 12.6 Iteration Statements {{{ */
1341 : DoWhileStatement { $$ = $1; }
1342 | WhileStatement { $$ = $1; }
1343 | ForStatement { $$ = $1; }
1344 | ForInStatement { $$ = $1; }
1347 /* 12.6.1 The do-while Statement {{{ */
1349 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1352 /* 12.6.2 The while Statement {{{ */
1354 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1357 /* 12.6.3 The for Statement {{{ */
1359 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1362 ForStatementInitialiser
1363 : ExpressionNoInOpt { $$ = $1; }
1364 | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; }
1367 /* 12.6.4 The for-in Statement {{{ */
1369 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1372 ForInStatementInitialiser
1373 : LeftHandSideExpression { $$ = $1; }
1374 | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; }
1378 /* 12.7 The continue Statement {{{ */
1380 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1383 /* 12.8 The break Statement {{{ */
1385 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1388 /* 12.9 The return Statement {{{ */
1390 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1393 /* 12.10 The with Statement {{{ */
1395 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1399 /* 12.11 The switch Statement {{{ */
1401 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1405 : "{" CaseClausesOpt "}" { $$ = $2; }
1409 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1410 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1415 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1419 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1422 /* 12.12 Labelled Statements {{{ */
1424 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1427 /* 12.13 The throw Statement {{{ */
1429 : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); }
1432 /* 12.14 The try Statement {{{ */
1434 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); }
1438 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); }
1443 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
1448 /* 13 Function Definition {{{ */
1450 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1454 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1457 FormalParameterList_
1458 : "," FormalParameterList { $$ = $2; }
1463 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1468 : SourceElements { $$ = $1; }
1471 /* 14 Program {{{ */
1473 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1477 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1478 | LexSetRegExp { $$ = NULL; }
1482 : Statement_ { $$ = $1; }
1483 | FunctionDeclaration { $$ = $1; }
1487 : LexSetRegExp SourceElement_ { $$ = $2; }
1492 /* Cycript (Objective-C): @class Declaration {{{ */
1494 /* XXX: why the hell did I choose MemberExpressionNoBF? */
1495 : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; }
1500 : "{" "}" { $$ = NULL; }
1504 : "+" { $$ = false; }
1505 | "-" { $$ = true; }
1509 : "(" Expression ")" { $$ = $2; }
1514 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
1517 MessageParameterListOpt
1518 : MessageParameterList { $$ = $1; }
1522 MessageParameterList
1523 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1527 : MessageParameterList { $$ = $1; }
1528 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
1531 ClassMessageDeclaration
1532 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
1535 ClassMessageDeclarationListOpt
1536 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1541 : Identifier { $$ = $1; }
1542 | "(" AssignmentExpression ")" { $$ = $2; }
1546 : ClassName { $$ = $1; }
1550 // XXX: this should be AssignmentExpressionNoRight
1552 : ShiftExpression ClassProtocolsOpt { $$ = new(driver.pool_) CYProtocol($1, $2); }
1556 : "," ClassProtocols { $$ = $2; }
1560 ClassProtocolListOpt
1561 : "<" ClassProtocols ">" { $$ = $2; }
1566 : "@class" ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5, $6); }
1570 : "@class" ClassName ClassSuperOpt ClassProtocolListOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5, $6); }
1574 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
1578 : ClassExpression { $$ = $1; }
1582 : ClassStatement { $$ = $1; }
1583 | CategoryStatement { $$ = $1; }
1586 /* Cycript (Objective-C): Send Message {{{ */
1588 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1593 : SelectorCall { $$ = $1; }
1594 | VariadicCall { $$ = $1; }
1598 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1602 : SelectorCall { $$ = $1; }
1603 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1607 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); }
1608 | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); }
1611 SelectorExpressionOpt
1612 : SelectorExpression_ { $$ = $1; }
1617 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1621 : SelectorExpression_ { $$ = $1; }
1622 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1626 : MessageExpression { $$ = $1; }
1627 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
1633 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1634 UnaryAssigneeExpression
1635 : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); }
1639 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1643 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1644 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
1649 /* YUI: Documentation Comments {{{ */
1651 : Comment { $$ = $1; }
1656 /* Lexer State {{{ */
1658 : { driver.PushCondition(CYDriver::RegExpCondition); }
1662 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1666 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1670 : { driver.PopCondition(); }
1674 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1678 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1687 /* 8.1 Context Keywords {{{ */
1689 : "namespace" { $$ = $1; }
1690 | "xml" { $$ = $1; }
1693 /* 8.3 XML Initialiser Input Elements {{{ */
1695 : XMLComment { $$ = $1; }
1696 | XMLCDATA { $$ = $1; }
1697 | XMLPI { $$ = $1; }
1700 /* 11.1 Primary Expressions {{{ */
1702 : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); }
1703 | XMLInitialiser { $$ = $1; }
1704 | XMLListInitialiser { $$ = $1; }
1708 : AttributeIdentifier { $$ = $1; }
1709 | QualifiedIdentifier { $$ = $1; }
1710 | WildcardIdentifier { $$ = $1; }
1713 /* 11.1.1 Attribute Identifiers {{{ */
1715 : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); }
1719 : PropertySelector { $$ = $1; }
1720 | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); }
1724 : Identifier { $$ = new(driver.pool_) CYSelector($1); }
1725 | WildcardIdentifier { $$ = $1; }
1728 /* 11.1.2 Qualified Identifiers {{{ */
1729 QualifiedIdentifier_
1730 : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); }
1731 | QualifiedIdentifier { $$ = $1; }
1735 : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); }
1738 /* 11.1.3 Wildcard Identifiers {{{ */
1740 : "*" { $$ = new(driver.pool_) CYWildcard(); }
1743 /* 11.1.4 XML Initialiser {{{ */
1745 : XMLMarkup { $$ = $1; }
1746 | XMLElement { $$ = $1; }
1750 : "<" XMLTagContent "/>" LexPop
1751 | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop
1755 : LexPushXMLTag XMLTagName XMLAttributes
1759 : "{" LexPushRegExp Expression "}" LexPop
1768 : XMLAttributes_ XMLAttribute
1773 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1774 | XMLAttributes_ XMLWhitespaceOpt
1783 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1787 : XMLExpression XMLElementContentOpt
1788 | XMLMarkup XMLElementContentOpt
1789 | XMLText XMLElementContentOpt
1790 | XMLElement XMLElementContentOpt
1793 XMLElementContentOpt
1798 /* 11.1.5 XMLList Initialiser {{{ */
1800 : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); }
1803 /* 11.2 Left-Hand-Side Expressions {{{ */
1805 : Identifier { $$ = $1; }
1806 | PropertyIdentifier { $$ = $1; }
1810 : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); }
1811 | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); }
1812 | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); }
1815 /* 12.1 The default xml namespace Statement {{{ */
1816 /* XXX: DefaultXMLNamespaceStatement
1817 : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); }
1821 : DefaultXMLNamespaceStatement { $$ = $1; }
1826 /* ECMAScript5: Object Literal Trailing Comma {{{ */
1827 PropertyNameAndValueList_
1828 : "," { $$ = NULL; }
1831 /* JavaScript 1.7: Array Comprehensions {{{ */
1833 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
1837 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1838 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
1841 ComprehensionListOpt
1842 : ComprehensionList { $$ = $1; }
1843 | IfComprehension { $$ = $1; }
1848 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1852 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
1855 /* JavaScript 1.7: for each {{{ */
1857 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1860 /* JavaScript 1.7: let Statements {{{ *//*
1862 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1869 /* JavaScript FTW: Function Statements {{{ */
1871 : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; }