1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2012 Jay Freeman (saurik)
5 /* GNU Lesser General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
24 @if Bison24 %code top {
25 #define cyscanner driver.scanner_
26 #define YYSTACKEXPANDABLE 1
27 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
30 @if Bison24 %code requires {
32 #define CYNew new($pool)
35 #include "ObjectiveC/Syntax.hpp"
39 #include "E4X/Syntax.hpp"
48 CYDriver::Condition condition_;
50 CYArgument *argument_;
51 CYAssignment *assignment_;
54 cy::Syntax::Catch *catch_;
56 CYComprehension *comprehension_;
57 CYCompound *compound_;
58 CYDeclaration *declaration_;
59 CYDeclarations *declarations_;
61 CYExpression *expression_;
64 CYForInitialiser *for_;
65 CYForInInitialiser *forin_;
66 CYFunctionParameter *functionParameter_;
67 CYIdentifier *identifier_;
74 CYProperty *property_;
75 CYPropertyName *propertyName_;
76 CYRubyProc *rubyProc_;
77 CYStatement *statement_;
84 CYClassName *className_;
87 CYMessageParameter *messageParameter_;
88 CYProtocol *protocol_;
89 CYSelectorPart *selector_;
93 CYAttribute *attribute_;
94 CYPropertyIdentifier *propertyIdentifier_;
95 CYSelector *selector_;
100 #define YYSTYPE YYSTYPE
103 @if Bison24 %code provides {
104 int cylex(YYSTYPE *, cy::location *, void *);
111 @if Bison23 %skeleton "lalr1.cc"
112 @if Bison24 %language "C++"
115 @$.begin.filename = @$.end.filename = &driver.filename_;
126 %parse-param { CYDriver &driver }
127 %lex-param { void *cyscanner }
129 /* Token Declarations {{{ */
135 %token XMLAttributeValue
137 %token XMLTagCharacters
143 %token LeftRight "<>"
144 %token LeftSlashRight "</>"
146 %token SlashRight "/>"
147 %token LeftSlash "</"
149 %token ColonColon "::"
150 %token PeriodPeriod ".."
153 @begin E4X ObjectiveC
158 %token AmpersandAmpersand "&&"
159 %token AmpersandEqual "&="
161 %token CarrotEqual "^="
163 %token EqualEqual "=="
164 %token EqualEqualEqual "==="
165 %token EqualRight "=>"
166 %token Exclamation "!"
167 %token ExclamationEqual "!="
168 %token ExclamationEqualEqual "!=="
170 %token HyphenEqual "-="
171 %token HyphenHyphen "--"
172 %token HyphenHyphen_ "\n--"
173 %token HyphenRight "->"
175 %token LeftEqual "<="
177 %token LeftLeftEqual "<<="
179 %token PercentEqual "%="
181 %token PeriodPeriodPeriod "..."
183 %token PipeEqual "|="
186 %token PlusEqual "+="
188 %token PlusPlus_ "\n++"
190 %token RightEqual ">="
191 %token RightRight ">>"
192 %token RightRightEqual ">>="
193 %token RightRightRight ">>>"
194 %token RightRightRightEqual ">>>="
196 %token SlashEqual "/="
198 %token StarEqual "*="
207 %token <comment_> Comment
210 %token CloseParen ")"
213 %token OpenBrace_ "\n{"
214 %token OpenBrace__ ";{"
215 %token CloseBrace "}"
217 %token OpenBracket "["
218 %token CloseBracket "]"
221 %token AtClass "@class"
225 %token AtImplementation "@implementation"
226 %token AtImplementation_ ";@implementation"
227 %token AtImport "@import"
229 %token AtSelector "@selector"
232 %token <false_> False "false"
233 %token <null_> Null "null"
234 %token <true_> True "true"
236 // ES3/ES5/WIE/JSC Reserved
237 %token <word_> Break "break"
238 %token <word_> Case "case"
239 %token <word_> Catch "catch"
240 %token <word_> Continue "continue"
241 %token <word_> Default "default"
242 %token <word_> Delete "delete"
243 %token <word_> Do "do"
244 %token <word_> Else "else"
245 %token <word_> Finally "finally"
246 %token <word_> For "for"
247 %token <word_> Function "function"
248 %token <word_> Function_ ";function"
249 %token <word_> If "if"
250 %token <word_> In "in"
251 %token <word_> In_ "!in"
252 %token <word_> InstanceOf "instanceof"
253 %token <word_> New "new"
254 %token <word_> Return "return"
255 %token <word_> Switch "switch"
256 %token <this_> This "this"
257 %token <word_> Throw "throw"
258 %token <word_> Try "try"
259 %token <word_> TypeOf "typeof"
260 %token <word_> Var "var"
261 %token <word_> Void "void"
262 %token <word_> While "while"
263 %token <word_> With "with"
265 // ES3/IE6 Future, ES5/JSC Reserved
266 %token <word_> Debugger "debugger"
268 // ES3/ES5/IE6 Future, JSC Reserved
269 %token <word_> Const "const"
271 // ES3/ES5/IE6/JSC Future
272 %token <word_> Class "class"
273 %token <word_> Enum "enum"
274 %token <word_> Export "export"
275 %token <word_> Extends "extends"
276 %token <word_> Import "import"
277 %token <word_> Super "super"
279 // ES3 Future, ES5 Strict Future
280 %token <identifier_> Implements "implements"
281 %token <identifier_> Interface "interface"
282 %token <identifier_> Package "package"
283 %token <identifier_> Private "private"
284 %token <identifier_> Protected "protected"
285 %token <identifier_> Public "public"
286 %token <identifier_> Static "static"
289 %token <identifier_> Abstract "abstract"
290 %token <identifier_> Boolean "boolean"
291 %token <identifier_> Byte "byte"
292 %token <identifier_> Char "char"
293 %token <identifier_> Double "double"
294 %token <identifier_> Final "final"
295 %token <identifier_> Float "float"
296 %token <identifier_> Goto "goto"
297 %token <identifier_> Int "int"
298 %token <identifier_> Long "long"
299 %token <identifier_> Native "native"
300 %token <identifier_> Short "short"
301 %token <identifier_> Synchronized "synchronized"
302 %token <identifier_> Throws "throws"
303 %token <identifier_> Transient "transient"
304 %token <identifier_> Volatile "volatile"
307 %token <identifier_> Let "let"
308 %token <identifier_> Yield "yield"
311 %token <identifier_> Each "each"
312 %token <identifier_> Of "of"
316 %token <identifier_> Namespace "namespace"
317 %token <identifier_> XML "xml"
322 %token <identifier_> Identifier_
323 %token <number_> NumericLiteral
324 %token <string_> StringLiteral
325 %token <literal_> RegularExpressionLiteral
327 %type <expression_> AdditiveExpression
328 %type <argument_> ArgumentList_
329 %type <argument_> ArgumentList
330 %type <argument_> ArgumentListOpt
331 %type <argument_> Arguments
332 %type <literal_> ArrayLiteral
333 %type <expression_> ArrowFunction
334 %type <functionParameter_> ArrowParameters
335 %type <expression_> AssignmentExpression
336 %type <identifier_> Binding
337 %type <identifier_> BindingIdentifier
338 %type <expression_> BitwiseANDExpression
339 %type <statement_> Block_
340 %type <statement_> Block
341 %type <boolean_> BooleanLiteral
342 %type <declaration_> BindingElement
343 %type <expression_> BitwiseORExpression
344 %type <expression_> BitwiseXORExpression
345 %type <statement_> BreakStatement
346 %type <statement_> BreakableStatement
347 %type <expression_> CallExpression_
348 %type <expression_> CallExpression
349 %type <clause_> CaseBlock
350 %type <clause_> CaseClause
351 %type <clause_> CaseClausesOpt
352 %type <catch_> CatchOpt
353 %type <comprehension_> ComprehensionForList
354 %type <comprehension_> ComprehensionForListOpt
355 %type <comprehension_> ComprehensionList
356 %type <comprehension_> ComprehensionListOpt
357 %type <expression_> ConditionalExpression
358 %type <statement_> ContinueStatement
359 %type <statement_> ConciseBody
360 %type <statement_> DebuggerStatement
361 %type <statement_> Declaration__
362 %type <statement_> Declaration_
363 %type <statement_> Declaration
364 %type <clause_> DefaultClause
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 <compound_> Expression_
373 %type <compound_> Expression
374 %type <expression_> ExpressionOpt
375 %type <statement_> ExpressionStatement
376 %type <finally_> FinallyOpt
377 %type <comprehension_> ForComprehension
378 %type <for_> ForStatementInitialiser
379 %type <forin_> ForInStatementInitialiser
380 %type <declaration_> FormalParameter
381 %type <functionParameter_> FormalParameterList_
382 %type <functionParameter_> FormalParameterList
383 %type <functionParameter_> FormalParameterListOpt
384 %type <statement_> FunctionBody
385 %type <statement_> FunctionDeclaration
386 %type <expression_> FunctionExpression
387 %type <identifier_> Identifier
388 %type <identifier_> IdentifierOpt
389 %type <word_> IdentifierName
390 %type <comprehension_> IfComprehension
391 %type <statement_> IfStatement
392 %type <expression_> Initialiser
393 %type <expression_> InitialiserOpt
394 %type <statement_> IterationStatement
395 %type <statement_> LabelledStatement
396 %type <expression_> LeftHandSideExpression
397 %type <statement_> LetStatement
398 %type <statement_> LexicalDeclaration
399 %type <literal_> Literal
400 %type <literal_> ValueLiteral
401 %type <expression_> LogicalANDExpression
402 %type <expression_> LogicalORExpression
403 %type <member_> MemberAccess
404 %type <expression_> MemberExpression_
405 %type <expression_> MemberExpression
406 %type <expression_> MultiplicativeExpression
407 %type <expression_> NewExpression
408 %type <null_> NullLiteral
409 %type <literal_> ObjectLiteral
410 %type <compound_> Parenthetical
411 %type <compound_> ParentheticalOpt
412 %type <expression_> PostfixExpression
413 %type <expression_> PrimaryExpression
414 %type <statement_> Program
415 %type <statement_> ProgramBody
416 %type <statement_> ProgramBodyOpt
417 %type <propertyName_> PropertyName_
418 %type <propertyName_> PropertyName
419 %type <property_> PropertyDefinition
420 %type <property_> PropertyDefinitionList_
421 %type <property_> PropertyDefinitionList
422 %type <property_> PropertyDefinitionListOpt
423 %type <expression_> RelationalExpression
424 %type <statement_> ReturnStatement
425 %type <rubyProc_> RubyProcExpression
426 %type <functionParameter_> RubyProcParameterList_
427 %type <functionParameter_> RubyProcParameterList
428 %type <functionParameter_> RubyProcParameters
429 %type <functionParameter_> RubyProcParametersOpt
430 %type <expression_> ShiftExpression
431 %type <declaration_> SingleNameBinding
432 %type <statement_> Statement__
433 %type <statement_> Statement_
434 %type <statement_> Statement
435 %type <statement_> StatementList
436 %type <statement_> StatementListOpt
437 %type <statement_> StatementListItem
438 %type <statement_> SwitchStatement
439 %type <statement_> ThrowStatement
440 %type <statement_> TryStatement
441 %type <expression_> UnaryExpression_
442 %type <expression_> UnaryExpression
443 %type <declaration_> VariableDeclaration
444 %type <declarations_> VariableDeclarationList_
445 %type <declarations_> VariableDeclarationList
446 %type <statement_> VariableStatement
447 %type <statement_> WithStatement
449 %type <word_> WordOpt
452 %type <expression_> BoxableExpression
453 %type <statement_> CategoryStatement
454 %type <expression_> ClassExpression
455 %type <field_> ClassFieldListOpt
456 %type <field_> ClassFields
457 %type <statement_> ClassStatement
458 %type <expression_> ClassSuperOpt
459 %type <message_> ClassMessageDeclaration
460 %type <message_> ClassMessageDeclarationListOpt
461 %type <className_> ClassName
462 %type <className_> ClassNameOpt
463 %type <protocol_> ClassProtocolListOpt
464 %type <protocol_> ClassProtocols
465 %type <protocol_> ClassProtocolsOpt
466 %type <expression_> MessageExpression
467 %type <messageParameter_> MessageParameter
468 %type <messageParameter_> MessageParameters
469 %type <messageParameter_> MessageParameterList
470 %type <messageParameter_> MessageParameterListOpt
471 %type <bool_> MessageScope
472 %type <argument_> SelectorCall_
473 %type <argument_> SelectorCall
474 %type <selector_> SelectorExpression_
475 %type <selector_> SelectorExpression
476 %type <selector_> SelectorExpressionOpt
477 %type <argument_> SelectorList
478 %type <word_> SelectorWordOpt
479 %type <expression_> TypeOpt
480 %type <argument_> VariadicCall
484 %type <propertyIdentifier_> PropertyIdentifier_
485 %type <selector_> PropertySelector_
486 %type <selector_> PropertySelector
487 %type <identifier_> QualifiedIdentifier_
488 %type <identifier_> QualifiedIdentifier
489 %type <identifier_> WildcardIdentifier
490 %type <identifier_> XMLComment
491 %type <identifier_> XMLCDATA
492 %type <identifier_> XMLElement
493 %type <identifier_> XMLElementContent
494 %type <identifier_> XMLMarkup
495 %type <identifier_> XMLPI
497 %type <attribute_> AttributeIdentifier
498 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
499 %type <expression_> PropertyIdentifier
500 %type <expression_> XMLListInitialiser
501 %type <expression_> XMLInitialiser
504 /* Token Priorities {{{ */
516 /* Lexer State {{{ */
518 : { driver.in_.push(true); }
522 : { driver.in_.push(false); }
526 : { driver.in_.pop(); }
530 : { driver.SetCondition(CYDriver::RegExpCondition); }
534 : { if (yychar == yyempty_) driver.nobrace_ = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
538 : { if (yychar == token::Function) yychar = token::Function_; }
541 LexNoAtImplementation
542 : { if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
546 : LexNoBrace LexNoFunction LexNoAtImplementation
549 /* Virtual Tokens {{{ */
556 /* 7.6 Identifier Names and Identifiers {{{ */
567 : Identifier { $$ = $1; }
568 | "break" NewLineOpt { $$ = $1; }
569 | "case" { $$ = $1; }
570 | "catch" { $$ = $1; }
571 | "class" { $$ = $1; }
572 | "const" { $$ = $1; }
573 | "continue" NewLineOpt { $$ = $1; }
574 | "debugger" { $$ = $1; }
575 | "default" { $$ = $1; }
576 | "delete" { $$ = $1; }
578 | "else" { $$ = $1; }
579 | "enum" { $$ = $1; }
580 | "export" { $$ = $1; }
581 | "extends" { $$ = $1; }
582 | "false" { $$ = $1; }
583 | "finally" { $$ = $1; }
584 /* XXX: | "for" { $$ = $1; } */
585 | "function" { $$ = $1; }
587 | "import" { $$ = $1; }
588 /* XXX: | "in" { $$ = $1; } */
590 /* XXX: | "instanceof" { $$ = $1; } */
592 // XXX: as it currently is not an Identifier
596 | "null" { $$ = $1; }
597 | "return" NewLineOpt { $$ = $1; }
598 | "super" { $$ = $1; }
599 | "switch" { $$ = $1; }
600 | "this" { $$ = $1; }
601 | "throw" NewLineOpt { $$ = $1; }
602 | "true" { $$ = $1; }
604 | "typeof" { $$ = $1; }
606 | "void" { $$ = $1; }
607 | "while" { $$ = $1; }
608 | "with" { $$ = $1; }
617 : Identifier_ { $$ = $1; }
619 | "implements" { $$ = $1; }
620 | "interface" { $$ = $1; }
621 | "package" { $$ = $1; }
622 | "private" { $$ = $1; }
623 | "protected" { $$ = $1; }
624 | "public" { $$ = $1; }
625 | "static" { $$ = $1; }
627 | "abstract" { $$ = $1; }
628 | "boolean" { $$ = $1; }
629 | "byte" { $$ = $1; }
630 | "char" { $$ = $1; }
631 | "double" { $$ = $1; }
632 | "final" { $$ = $1; }
633 | "float" { $$ = $1; }
634 | "goto" { $$ = $1; }
636 | "long" { $$ = $1; }
637 | "native" { $$ = $1; }
638 | "short" { $$ = $1; }
639 | "synchronized" { $$ = $1; }
640 | "throws" { $$ = $1; }
641 | "transient" { $$ = $1; }
642 | "volatile" { $$ = $1; }
644 // XXX: currently I only have this as Word
645 // | "let" { $$ = $1; }
647 | "yield" { $$ = $1; }
649 | "each" { $$ = $1; }
654 : Identifier { $$ = $1; }
659 /* 7.8 Literals {{{ */
661 : NullLiteral { $$ = $1; }
662 | ValueLiteral { $$ = $1; }
666 : BooleanLiteral { $$ = $1; }
667 | NumericLiteral { $$ = $1; }
668 | StringLiteral { $$ = $1; }
669 | RegularExpressionLiteral { $$ = $1; }
672 /* 7.8.1 Null Literals {{{ */
674 : "null" { $$ = $1; }
677 /* 7.8.2 Boolean Literals {{{ */
679 : "true" { $$ = $1; }
680 | "false" { $$ = $1; }
684 /* 7.9 Automatic Semicolon Insertion {{{ */
686 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
691 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
696 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
700 /* 11.1 Primary Expressions {{{ */
702 : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
706 : Parenthetical { $$ = $1; }
711 : "this" { $$ = $1; }
712 | Identifier { $$ = CYNew CYVariable($1); }
713 | Literal { $$ = $1; }
714 | ArrayLiteral { $$ = $1; }
715 | ObjectLiteral { $$ = $1; }
716 | FunctionExpression { $$ = $1; }
717 | Parenthetical { $$ = $1; }
718 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
721 /* 11.1.4.1 Array Initialiser {{{ */
723 : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
727 : AssignmentExpression { $$ = $1; }
731 : Element { $$ = $1; }
732 | LexSetRegExp { $$ = NULL; }
736 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
737 | Element { $$ = CYNew CYElement($1, NULL); }
741 : ElementList { $$ = $1; }
742 | LexSetRegExp { $$ = NULL; }
745 /* 11.1.4.2 Array Comprehension {{{ */
747 : "[" LexPushInOff AssignmentExpression ComprehensionForList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
751 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
752 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
755 ComprehensionForListOpt
756 : ComprehensionForList { $$ = $1; }
757 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
761 /* 11.1.5 Object Initialiser {{{ */
763 : BRACE LexPushInOff PropertyDefinitionListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
766 PropertyDefinitionList_
767 : "," PropertyDefinitionList { $$ = $2; }
772 PropertyDefinitionList
773 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
776 PropertyDefinitionListOpt
777 : PropertyDefinitionList { $$ = $1; }
782 // XXX: this should be IdentifierName
783 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
784 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
789 : IdentifierName { $$ = $1; }
790 | StringLiteral { $$ = $1; }
791 | NumericLiteral { $$ = $1; }
795 : LexSetRegExp PropertyName_ { $$ = $2; }
799 /* 11.2 Left-Hand-Side Expressions {{{ */
801 : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
802 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
803 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
807 : MemberExpression { $$ = $1; }
808 //| "super" { $$ = $1; }
812 : LexSetRegExp PrimaryExpression { $$ = $2; }
813 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
814 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
818 : MemberExpression { $$ = $1; }
819 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
828 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
829 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
833 : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
837 : "," ArgumentList { $$ = $2; }
842 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
846 : ArgumentList { $$ = $1; }
847 | LexSetRegExp { $$ = NULL; }
850 LeftHandSideExpression
851 : NewExpression { $$ = $1; }
852 | CallExpression { $$ = $1; }
855 /* 11.3 Postfix Expressions {{{ */
857 : %prec "" LeftHandSideExpression { $$ = $1; }
858 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
859 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
862 /* 11.4 Unary Operators {{{ */
864 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
865 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
866 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
867 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
868 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
869 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
870 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
871 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
872 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
873 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
874 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
878 : PostfixExpression { $$ = $1; }
879 | LexSetRegExp UnaryExpression_ { $$ = $2; }
882 /* 11.5 Multiplicative Operators {{{ */
883 MultiplicativeExpression
884 : UnaryExpression { $$ = $1; }
885 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
886 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
887 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
890 /* 11.6 Additive Operators {{{ */
892 : MultiplicativeExpression { $$ = $1; }
893 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
894 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
897 /* 11.7 Bitwise Shift Operators {{{ */
899 : AdditiveExpression { $$ = $1; }
900 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
901 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
902 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
905 /* 11.8 Relational Operators {{{ */
907 : ShiftExpression { $$ = $1; }
908 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
909 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
910 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
911 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
912 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
913 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
916 /* 11.9 Equality Operators {{{ */
918 : RelationalExpression { $$ = $1; }
919 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
920 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
921 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
922 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
925 /* 11.10 Binary Bitwise Operators {{{ */
927 : EqualityExpression { $$ = $1; }
928 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
932 : BitwiseANDExpression { $$ = $1; }
933 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
937 : BitwiseXORExpression { $$ = $1; }
938 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
941 /* 11.11 Binary Logical Operators {{{ */
943 : BitwiseORExpression { $$ = $1; }
944 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
948 : LogicalANDExpression { $$ = $1; }
949 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
952 /* 11.12 Conditional Operator ( ? : ) {{{ */
953 ConditionalExpression
954 : LogicalORExpression { $$ = $1; }
955 | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
958 /* 11.13 Assignment Operators {{{ */
960 : ConditionalExpression { $$ = $1; }
961 | ArrowFunction { $$ = $1; }
962 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
963 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
964 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
965 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
966 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
967 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
968 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
969 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
970 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
971 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
972 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
973 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
976 /* 11.14 Comma Operator {{{ */
978 : "," Expression { $$ = $2; }
979 | { $$ = CYNew CYCompound(); }
983 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
987 : Expression { $$ = $1; }
988 | LexSetRegExp { $$ = NULL; }
992 /* 12 Statements {{{ */
995 | VariableStatement { $$ = $1; }
996 | EmptyStatement { $$ = $1; }
997 | IfStatement { $$ = $1; }
998 | BreakableStatement { $$ = $1; }
999 | ContinueStatement { $$ = $1; }
1000 | BreakStatement { $$ = $1; }
1001 | ReturnStatement { $$ = $1; }
1002 | WithStatement { $$ = $1; }
1003 | LabelledStatement { $$ = $1; }
1004 | ThrowStatement { $$ = $1; }
1005 | TryStatement { $$ = $1; }
1006 | DebuggerStatement { $$ = $1; }
1010 : LexSetRegExp Statement__ { $$ = $2; }
1011 | ExpressionStatement { $$ = $1; }
1015 : LexSetStatement Statement_ { $$ = $2; }
1019 : FunctionDeclaration { $$ = $1; }
1020 | LexicalDeclaration { $$ = $1; }
1024 : LexSetRegExp Declaration__ { $$ = $2; }
1028 : LexSetStatement Declaration_ { $$ = $2; }
1032 : IterationStatement { $$ = $1; }
1033 | SwitchStatement { $$ = $1; }
1036 /* 12.1 Block {{{ */
1038 : BRACE StatementListOpt "}" { $$ = $2; }
1042 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1046 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1050 : StatementList { $$ = $1; }
1051 | LexSetRegExp { $$ = NULL; }
1055 : Statement { $$ = $1; }
1056 | Declaration { $$ = $1; }
1060 /* 12.2 Declarations {{{ */
1062 : Identifier { $$ = $1; }
1069 // XXX: BindingPattern
1071 /* 12.2.1 Let and Const Declarations {{{ */
1073 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1081 /* 12.2.2 Variable Statement {{{ */
1083 : "var" VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1086 VariableDeclarationList_
1087 : "," VariableDeclarationList { $$ = $2; }
1091 VariableDeclarationList
1092 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1096 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1097 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1101 : "=" AssignmentExpression { $$ = $2; }
1105 : Initialiser { $$ = $1; }
1109 /* 12.2.4 Destructuring Binding Patterns {{{ */
1113 : SingleNameBinding { $$ = $1; }
1117 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1121 /* 12.3 Empty Statement {{{ */
1123 : ";" { $$ = CYNew CYEmpty(); }
1126 /* 12.4 Expression Statement {{{ */
1128 : Expression Terminator { $$ = CYNew CYExpress($1); }
1131 /* 12.5 The if Statement {{{ */
1133 : "else" Statement { $$ = $2; }
1134 | %prec "if" { $$ = NULL; }
1138 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1142 /* 12.6.1 The do-while Statement {{{ */
1144 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1147 /* 12.6.2 The while Statement {{{ */
1149 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1152 /* 12.6.3 The for Statement {{{ */
1154 : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1157 ForStatementInitialiser
1158 : ExpressionOpt { $$ = $1; }
1159 | LexSetRegExp "var" VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1162 /* 12.6.4 The for-in and for-of Statements {{{ */
1164 : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1165 | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1168 ForInStatementInitialiser
1169 : LeftHandSideExpression { $$ = $1; }
1170 | LexSetRegExp "var" VariableDeclaration { $$ = $3; }
1174 /* 12.7 The continue Statement {{{ */
1176 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1177 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1180 /* 12.8 The break Statement {{{ */
1182 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1183 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1186 /* 12.9 The return Statement {{{ */
1188 : "return" "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1189 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1192 /* 12.10 The with Statement {{{ */
1194 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1198 /* 12.11 The switch Statement {{{ */
1200 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1204 : BRACE CaseClausesOpt "}" { $$ = $2; }
1208 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1212 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1213 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1218 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1221 /* 12.12 Labelled Statements {{{ */
1223 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1226 /* 12.13 The throw Statement {{{ */
1228 : "throw" "\n" StrictSemi { YYABORT; }
1229 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1232 /* 12.14 The try Statement {{{ */
1234 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1238 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1243 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1247 /* 12.14 The debugger Statement {{{ */
1249 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1253 /* 13.1 Function Definitions {{{ */
1255 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1259 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1262 FormalParameterList_
1263 : "," FormalParameterList { $$ = $2; }
1268 // XXX: : FunctionRestParameter { $$ = $1; }
1269 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1272 FormalParameterListOpt
1273 : FormalParameterList
1277 /* XXX: FunctionRestParameter
1278 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1282 : BindingElement { $$ = $1; }
1286 : StatementListOpt { $$ = $1; }
1289 /* 13.2 Arrow Function Definitions {{{ */
1291 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFunctionExpression(NULL, $2, $5); }
1295 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1296 //| ParentheticalOpt { $$ = $1; }
1300 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1301 | ";{" LexPushInOff FunctionBody LexPopIn "}" { $$ = $3; }
1304 /* 14 Program {{{ */
1306 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1310 : StatementList { $$ = $1; }
1314 : ProgramBody { $$ = $1; }
1320 /* Cycript (Objective-C): @class Declaration {{{ */
1322 /* XXX: why the hell did I choose MemberExpression? */
1323 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1328 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1333 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1337 : "+" { $$ = false; }
1338 | "-" { $$ = true; }
1342 : "(" Expression ")" { $$ = $2; }
1343 | "(" LexSetRegExp "void" ")" { $$ = CYNew CYString("v"); }
1348 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1351 MessageParameterList
1352 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1355 MessageParameterListOpt
1356 : MessageParameterList { $$ = $1; }
1361 : MessageParameterList { $$ = $1; }
1362 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1365 ClassMessageDeclaration
1366 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1369 ClassMessageDeclarationListOpt
1370 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1371 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1376 : Identifier { $$ = $1; }
1377 | "(" AssignmentExpression ")" { $$ = $2; }
1381 : ClassName { $$ = $1; }
1385 // XXX: this should be AssignmentExpressionNoRight
1387 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1391 : "," ClassProtocols { $$ = $2; }
1395 ClassProtocolListOpt
1396 : "<" ClassProtocols ">" { $$ = $2; }
1401 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1405 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1413 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1417 : ClassExpression { $$ = $1; }
1421 : ClassStatement { $$ = $1; }
1422 | CategoryStatement { $$ = $1; }
1425 /* Cycript (Objective-C): Send Message {{{ */
1427 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1432 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1433 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1437 : SelectorCall { $$ = $1; }
1438 | VariadicCall { $$ = $1; }
1442 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1446 : SelectorCall { $$ = $1; }
1447 | Word { $$ = CYNew CYArgument($1, NULL); }
1451 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1452 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
1456 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1460 : SelectorExpression_ { $$ = $1; }
1461 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1464 SelectorExpressionOpt
1465 : SelectorExpression_ { $$ = $1; }
1470 : MessageExpression { $$ = $1; }
1471 | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
1474 /* Cycript (Objective-C): @import Directive {{{ */
1488 : "@import" ImportPath { $$ = CYNew CYImport(); }
1491 /* Cycript (Objective-C): Boxed Expressions {{{ */
1493 : NullLiteral { $$ = $1; }
1494 | BooleanLiteral { $$ = $1; }
1495 | NumericLiteral { $$ = $1; }
1496 | StringLiteral { $$ = $1; }
1497 | ArrayLiteral { $$ = $1; }
1498 | ObjectLiteral { $$ = $1; }
1499 | Parenthetical { $$ = $1; }
1503 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1509 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1510 LeftHandSideExpression
1511 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1515 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1519 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1520 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1521 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1526 /* YUI: Documentation Comments {{{ */
1528 : Comment { $$ = $1; }
1533 /* Lexer State {{{ */
1535 : { driver.PushCondition(CYDriver::RegExpCondition); }
1539 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1543 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1547 : { driver.PopCondition(); }
1551 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1555 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1558 /* Virtual Tokens {{{ */
1565 /* 8.1 Context Keywords {{{ */
1567 : "namespace" { $$ = $1; }
1568 | "xml" { $$ = $1; }
1571 /* 8.3 XML Initialiser Input Elements {{{ */
1573 : XMLComment { $$ = $1; }
1574 | XMLCDATA { $$ = $1; }
1575 | XMLPI { $$ = $1; }
1579 /* 11.1 Primary Expressions {{{ */
1581 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1582 | XMLInitialiser { $$ = $1; }
1583 | XMLListInitialiser { $$ = $1; }
1587 : AttributeIdentifier { $$ = $1; }
1588 | QualifiedIdentifier { $$ = $1; }
1589 | WildcardIdentifier { $$ = $1; }
1592 /* 11.1.1 Attribute Identifiers {{{ */
1594 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1598 : PropertySelector { $$ = $1; }
1599 | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
1603 : Identifier { $$ = CYNew CYSelector($1); }
1604 | WildcardIdentifier { $$ = $1; }
1607 /* 11.1.2 Qualified Identifiers {{{ */
1608 QualifiedIdentifier_
1609 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1610 | QualifiedIdentifier { $$ = $1; }
1614 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1617 /* 11.1.3 Wildcard Identifiers {{{ */
1619 : "*" { $$ = CYNew CYWildcard(); }
1622 /* 11.1.4 XML Initialiser {{{ */
1624 : XMLMarkup { $$ = $1; }
1625 | XMLElement { $$ = $1; }
1629 : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
1630 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
1634 : LexPushXMLTag XMLTagName XMLAttributes
1638 : BRACE LexPushRegExp Expression LexPop "}"
1647 : XMLAttributes_ XMLAttribute
1652 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1653 | XMLAttributes_ XMLWhitespaceOpt
1662 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1666 : XMLExpression XMLElementContentOpt
1667 | XMLMarkup XMLElementContentOpt
1668 | XMLText XMLElementContentOpt
1669 | XMLElement XMLElementContentOpt
1672 XMLElementContentOpt
1677 /* 11.1.5 XMLList Initialiser {{{ */
1679 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
1683 /* 11.2 Left-Hand-Side Expressions {{{ */
1685 : Identifier { $$ = $1; }
1686 | PropertyIdentifier { $$ = $1; }
1690 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1691 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1692 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1695 /* 12.1 The default xml namespace Statement {{{ */
1696 /* XXX: DefaultXMLNamespaceStatement
1697 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1701 : DefaultXMLNamespaceStatement { $$ = $1; }
1706 /* JavaScript 1.7: Array Comprehensions {{{ */
1708 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1712 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1713 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1717 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1720 ComprehensionListOpt
1721 : ComprehensionList { $$ = $1; }
1722 | IfComprehension { $$ = $1; }
1727 : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
1730 /* JavaScript 1.7: for each {{{ */
1732 : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1735 /* JavaScript 1.7: let Statements {{{ */
1737 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1745 /* JavaScript FTW: Ruby Blocks {{{ */
1746 RubyProcParameterList_
1747 : "," RubyProcParameterList { $$ = $2; }
1751 RubyProcParameterList
1752 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1757 : "|" RubyProcParameterList "|" { $$ = $2; }
1758 | "||" { $$ = NULL; }
1761 RubyProcParametersOpt
1762 : RubyProcParameters
1767 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1771 : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
1775 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }