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"
42 #include "Highlight.hpp"
51 CYDriver::Condition condition_;
53 CYArgument *argument_;
54 CYAssignment *assignment_;
57 cy::Syntax::Catch *catch_;
59 CYComprehension *comprehension_;
60 CYCompound *compound_;
61 CYDeclaration *declaration_;
62 CYDeclarations *declarations_;
64 CYExpression *expression_;
67 CYForInitialiser *for_;
68 CYForInInitialiser *forin_;
69 CYFunctionParameter *functionParameter_;
70 CYIdentifier *identifier_;
77 CYProperty *property_;
78 CYPropertyName *propertyName_;
79 CYRubyProc *rubyProc_;
80 CYStatement *statement_;
84 CYTypeModifier *type_;
85 CYTypedIdentifier *typed_;
89 CYClassName *className_;
92 CYMessageParameter *messageParameter_;
93 CYProtocol *protocol_;
94 CYSelectorPart *selector_;
98 CYAttribute *attribute_;
99 CYPropertyIdentifier *propertyIdentifier_;
100 CYSelector *selector_;
105 #define YYSTYPE YYSTYPE
108 @if Bison24 %code provides {
109 int cylex(YYSTYPE *, cy::location *, void *);
116 @if Bison23 %skeleton "lalr1.cc"
117 @if Bison24 %language "C++"
120 @$.begin.filename = @$.end.filename = &driver.filename_;
131 %parse-param { CYDriver &driver }
132 %lex-param { void *cyscanner }
134 /* Token Declarations {{{ */
140 %token XMLAttributeValue
142 %token XMLTagCharacters
148 %token LeftRight "<>"
149 %token LeftSlashRight "</>"
151 %token SlashRight "/>"
152 %token LeftSlash "</"
154 %token ColonColon "::"
155 %token PeriodPeriod ".."
158 @begin E4X ObjectiveC
163 %token AmpersandAmpersand "&&"
164 %token AmpersandEqual "&="
166 %token CarrotEqual "^="
168 %token EqualEqual "=="
169 %token EqualEqualEqual "==="
170 %token EqualRight "=>"
171 %token Exclamation "!"
172 %token ExclamationEqual "!="
173 %token ExclamationEqualEqual "!=="
175 %token HyphenEqual "-="
176 %token HyphenHyphen "--"
177 %token HyphenHyphen_ "\n--"
178 %token HyphenRight "->"
180 %token LeftEqual "<="
182 %token LeftLeftEqual "<<="
184 %token PercentEqual "%="
186 %token PeriodPeriodPeriod "..."
188 %token PipeEqual "|="
191 %token PlusEqual "+="
193 %token PlusPlus_ "\n++"
195 %token RightEqual ">="
196 %token RightRight ">>"
197 %token RightRightEqual ">>="
198 %token RightRightRight ">>>"
199 %token RightRightRightEqual ">>>="
201 %token SlashEqual "/="
203 %token StarEqual "*="
212 %token <comment_> Comment
215 %token CloseParen ")"
218 %token OpenBrace_ "\n{"
219 %token OpenBrace__ ";{"
220 %token CloseBrace "}"
222 %token OpenBracket "["
223 %token CloseBracket "]"
226 %token AtClass "@class"
230 %token AtImplementation "@implementation"
231 %token AtImplementation_ ";@implementation"
232 %token AtImport "@import"
233 %token AtEncode "@encode"
235 %token AtSelector "@selector"
238 %token <false_> False "false"
239 %token <null_> Null "null"
240 %token <true_> True "true"
242 // ES3/ES5/WIE/JSC Reserved
243 %token <word_> Auto "auto"
244 %token <word_> Break "break"
245 %token <word_> Case "case"
246 %token <word_> Catch "catch"
247 %token <word_> Continue "continue"
248 %token <word_> Default "default"
249 %token <word_> Delete "delete"
250 %token <word_> Do "do"
251 %token <word_> Else "else"
252 %token <word_> Finally "finally"
253 %token <word_> For "for"
254 %token <word_> Function "function"
255 %token <word_> Function_ ";function"
256 %token <word_> If "if"
257 %token <word_> In "in"
258 %token <word_> In_ "!in"
259 %token <word_> InstanceOf "instanceof"
260 %token <word_> New "new"
261 %token <word_> Return "return"
262 %token <word_> Switch "switch"
263 %token <this_> This "this"
264 %token <word_> Throw "throw"
265 %token <word_> Try "try"
266 %token <word_> TypeOf "typeof"
267 %token <word_> Var "var"
268 %token <word_> Void "void"
269 %token <word_> While "while"
270 %token <word_> With "with"
272 // ES3/IE6 Future, ES5/JSC Reserved
273 %token <word_> Debugger "debugger"
275 // ES3/ES5/IE6 Future, JSC Reserved
276 %token <word_> Const "const"
278 // ES3/ES5/IE6/JSC Future
279 %token <word_> Class "class"
280 %token <word_> Enum "enum"
281 %token <word_> Export "export"
282 %token <word_> Extends "extends"
283 %token <word_> Import "import"
284 %token <word_> Super "super"
286 // ES3 Future, ES5 Strict Future
287 %token <identifier_> Implements "implements"
288 %token <identifier_> Interface "interface"
289 %token <identifier_> Package "package"
290 %token <identifier_> Private "private"
291 %token <identifier_> Protected "protected"
292 %token <identifier_> Public "public"
293 %token <identifier_> Static "static"
296 %token <identifier_> Abstract "abstract"
297 %token <identifier_> Boolean "boolean"
298 %token <identifier_> Byte "byte"
299 %token <identifier_> Char "char"
300 %token <identifier_> Double "double"
301 %token <identifier_> Final "final"
302 %token <identifier_> Float "float"
303 %token <identifier_> Goto "goto"
304 %token <identifier_> Int "int"
305 %token <identifier_> Long "long"
306 %token <identifier_> Native "native"
307 %token <identifier_> Short "short"
308 %token <identifier_> Synchronized "synchronized"
309 %token <identifier_> Throws "throws"
310 %token <identifier_> Transient "transient"
311 %token <identifier_> Volatile "volatile"
314 %token <identifier_> Let "let"
315 %token <identifier_> Yield "yield"
318 %token <identifier_> Each "each"
319 %token <identifier_> Of "of"
323 %token <identifier_> Namespace "namespace"
324 %token <identifier_> XML "xml"
329 %token <identifier_> Identifier_
330 %token <number_> NumericLiteral
331 %token <string_> StringLiteral
332 %token <literal_> RegularExpressionLiteral
334 %type <expression_> AdditiveExpression
335 %type <argument_> ArgumentList_
336 %type <argument_> ArgumentList
337 %type <argument_> ArgumentListOpt
338 %type <argument_> Arguments
339 %type <literal_> ArrayLiteral
340 %type <expression_> ArrowFunction
341 %type <functionParameter_> ArrowParameters
342 %type <expression_> AssignmentExpression
343 %type <identifier_> Binding
344 %type <identifier_> BindingIdentifier
345 %type <expression_> BitwiseANDExpression
346 %type <statement_> Block_
347 %type <statement_> Block
348 %type <boolean_> BooleanLiteral
349 %type <declaration_> BindingElement
350 %type <expression_> BitwiseORExpression
351 %type <expression_> BitwiseXORExpression
352 %type <statement_> BreakStatement
353 %type <statement_> BreakableStatement
354 %type <expression_> CallExpression_
355 %type <expression_> CallExpression
356 %type <clause_> CaseBlock
357 %type <clause_> CaseClause
358 %type <clause_> CaseClausesOpt
359 %type <catch_> CatchOpt
360 %type <comprehension_> ComprehensionForList
361 %type <comprehension_> ComprehensionForListOpt
362 %type <comprehension_> ComprehensionList
363 %type <comprehension_> ComprehensionListOpt
364 %type <expression_> ConditionalExpression
365 %type <statement_> ContinueStatement
366 %type <statement_> ConciseBody
367 %type <statement_> DebuggerStatement
368 %type <statement_> Declaration__
369 %type <statement_> Declaration_
370 %type <statement_> Declaration
371 %type <clause_> DefaultClause
372 %type <expression_> Element
373 %type <expression_> ElementOpt
374 %type <element_> ElementList
375 %type <element_> ElementListOpt
376 %type <statement_> ElseStatementOpt
377 %type <statement_> EmptyStatement
378 %type <expression_> EqualityExpression
379 %type <compound_> Expression_
380 %type <compound_> Expression
381 %type <expression_> ExpressionOpt
382 %type <statement_> ExpressionStatement
383 %type <finally_> FinallyOpt
384 %type <comprehension_> ForComprehension
385 %type <for_> ForStatementInitialiser
386 %type <forin_> ForInStatementInitialiser
387 %type <declaration_> FormalParameter
388 %type <functionParameter_> FormalParameterList_
389 %type <functionParameter_> FormalParameterList
390 %type <functionParameter_> FormalParameterListOpt
391 %type <statement_> FunctionBody
392 %type <statement_> FunctionDeclaration
393 %type <expression_> FunctionExpression
394 %type <identifier_> Identifier
395 %type <identifier_> IdentifierOpt
396 %type <word_> IdentifierName
397 %type <comprehension_> IfComprehension
398 %type <statement_> IfStatement
399 %type <expression_> Initialiser
400 %type <expression_> InitialiserOpt
401 %type <statement_> IterationStatement
402 %type <statement_> LabelledStatement
403 %type <expression_> LeftHandSideExpression
404 %type <statement_> LetStatement
405 %type <statement_> LexicalDeclaration
406 %type <literal_> Literal
407 %type <literal_> ValueLiteral
408 %type <expression_> LogicalANDExpression
409 %type <expression_> LogicalORExpression
410 %type <member_> MemberAccess
411 %type <expression_> MemberExpression_
412 %type <expression_> MemberExpression
413 %type <expression_> MultiplicativeExpression
414 %type <expression_> NewExpression
415 %type <null_> NullLiteral
416 %type <literal_> ObjectLiteral
417 %type <compound_> Parenthetical
418 %type <compound_> ParentheticalOpt
419 %type <expression_> PostfixExpression
420 %type <expression_> PrimaryExpression
421 %type <statement_> Program
422 %type <statement_> ProgramBody
423 %type <statement_> ProgramBodyOpt
424 %type <propertyName_> PropertyName_
425 %type <propertyName_> PropertyName
426 %type <property_> PropertyDefinition
427 %type <property_> PropertyDefinitionList_
428 %type <property_> PropertyDefinitionList
429 %type <property_> PropertyDefinitionListOpt
430 %type <expression_> RelationalExpression
431 %type <statement_> ReturnStatement
432 %type <rubyProc_> RubyProcExpression
433 %type <functionParameter_> RubyProcParameterList_
434 %type <functionParameter_> RubyProcParameterList
435 %type <functionParameter_> RubyProcParameters
436 %type <functionParameter_> RubyProcParametersOpt
437 %type <expression_> ShiftExpression
438 %type <declaration_> SingleNameBinding
439 %type <statement_> Statement__
440 %type <statement_> Statement_
441 %type <statement_> Statement
442 %type <statement_> StatementList
443 %type <statement_> StatementListOpt
444 %type <statement_> StatementListItem
445 %type <statement_> SwitchStatement
446 %type <statement_> ThrowStatement
447 %type <statement_> TryStatement
448 %type <expression_> UnaryExpression_
449 %type <expression_> UnaryExpression
450 %type <declaration_> VariableDeclaration
451 %type <declarations_> VariableDeclarationList_
452 %type <declarations_> VariableDeclarationList
453 %type <statement_> VariableStatement
454 %type <statement_> WithStatement
456 %type <word_> WordOpt
457 %type <expression_> Variable
460 %type <expression_> BoxableExpression
461 %type <statement_> CategoryStatement
462 %type <expression_> ClassExpression
463 %type <field_> ClassFieldListOpt
464 %type <field_> ClassFields
465 %type <statement_> ClassStatement
466 %type <expression_> ClassSuperOpt
467 %type <message_> ClassMessageDeclaration
468 %type <message_> ClassMessageDeclarationListOpt
469 %type <className_> ClassName
470 %type <className_> ClassNameOpt
471 %type <protocol_> ClassProtocolListOpt
472 %type <protocol_> ClassProtocols
473 %type <protocol_> ClassProtocolsOpt
474 %type <expression_> EncodedType
475 %type <expression_> MessageExpression
476 %type <messageParameter_> MessageParameter
477 %type <messageParameter_> MessageParameters
478 %type <messageParameter_> MessageParameterList
479 %type <messageParameter_> MessageParameterListOpt
480 %type <bool_> MessageScope
481 %type <type_> ModifiedType
482 %type <typed_> PrefixedType
483 %type <argument_> SelectorCall_
484 %type <argument_> SelectorCall
485 %type <selector_> SelectorExpression_
486 %type <selector_> SelectorExpression
487 %type <selector_> SelectorExpressionOpt
488 %type <argument_> SelectorList
489 %type <word_> SelectorWordOpt
490 %type <typed_> SuffixedType
491 %type <expression_> TypeOpt
492 %type <typed_> TypedIdentifier
493 %type <argument_> VariadicCall
497 %type <propertyIdentifier_> PropertyIdentifier_
498 %type <selector_> PropertySelector_
499 %type <selector_> PropertySelector
500 %type <identifier_> QualifiedIdentifier_
501 %type <identifier_> QualifiedIdentifier
502 %type <identifier_> WildcardIdentifier
503 %type <identifier_> XMLComment
504 %type <identifier_> XMLCDATA
505 %type <identifier_> XMLElement
506 %type <identifier_> XMLElementContent
507 %type <identifier_> XMLMarkup
508 %type <identifier_> XMLPI
510 %type <attribute_> AttributeIdentifier
511 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
512 %type <expression_> PropertyIdentifier
513 %type <expression_> XMLListInitialiser
514 %type <expression_> XMLInitialiser
517 /* Token Priorities {{{ */
529 /* Lexer State {{{ */
531 : { driver.in_.push(true); }
535 : { driver.in_.push(false); }
539 : { driver.in_.pop(); }
543 : { driver.SetCondition(CYDriver::RegExpCondition); }
547 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
551 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
554 LexNoAtImplementation
555 : { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
559 : LexNoBrace LexNoFunction LexNoAtImplementation
562 /* Virtual Tokens {{{ */
573 /* 7.6 Identifier Names and Identifiers {{{ */
584 : Identifier { $$ = $1; }
585 | "auto" { $$ = $1; }
586 | "break" NewLineOpt { $$ = $1; }
587 | "case" { $$ = $1; }
588 | "catch" { $$ = $1; }
589 | "class" { $$ = $1; }
590 | "const" { $$ = $1; }
591 | "continue" NewLineOpt { $$ = $1; }
592 | "debugger" { $$ = $1; }
593 | "default" { $$ = $1; }
594 | "delete" { $$ = $1; }
596 | "else" { $$ = $1; }
597 | "enum" { $$ = $1; }
598 | "export" { $$ = $1; }
599 | "extends" { $$ = $1; }
600 | "false" { $$ = $1; }
601 | "finally" { $$ = $1; }
602 /* XXX: | "for" { $$ = $1; } */
603 | "function" { $$ = $1; }
605 | "import" { $$ = $1; }
606 /* XXX: | "in" { $$ = $1; } */
608 /* XXX: | "instanceof" { $$ = $1; } */
610 // XXX: as it currently is not an Identifier
614 | "null" { $$ = $1; }
615 | "return" NewLineOpt { $$ = $1; }
616 | "super" { $$ = $1; }
617 | "switch" { $$ = $1; }
618 | "this" { $$ = $1; }
619 | "throw" NewLineOpt { $$ = $1; }
620 | "true" { $$ = $1; }
622 | "typeof" { $$ = $1; }
624 | "void" { $$ = $1; }
625 | "while" { $$ = $1; }
626 | "with" { $$ = $1; }
635 : Identifier_ { $$ = $1; }
637 | "implements" { $$ = $1; }
638 | "interface" { $$ = $1; }
639 | "package" { $$ = $1; }
640 | "private" { $$ = $1; }
641 | "protected" { $$ = $1; }
642 | "public" { $$ = $1; }
643 | "static" { $$ = $1; }
645 | "abstract" { $$ = $1; }
646 | "boolean" { $$ = $1; }
647 | "byte" { $$ = $1; }
648 | "char" { $$ = $1; }
649 | "double" { $$ = $1; }
650 | "final" { $$ = $1; }
651 | "float" { $$ = $1; }
652 | "goto" { $$ = $1; }
654 | "long" { $$ = $1; }
655 | "native" { $$ = $1; }
656 | "short" { $$ = $1; }
657 | "synchronized" { $$ = $1; }
658 | "throws" { $$ = $1; }
659 | "transient" { $$ = $1; }
660 | "volatile" { $$ = $1; }
662 // XXX: currently I only have this as Word
663 // | "let" { $$ = $1; }
665 | "yield" { $$ = $1; }
667 | "each" { $$ = $1; }
672 : Identifier { $$ = $1; }
677 /* 7.8 Literals {{{ */
679 : NullLiteral { $$ = $1; }
680 | ValueLiteral { $$ = $1; }
684 : BooleanLiteral { $$ = $1; }
685 | NumericLiteral { $$ = $1; }
686 | StringLiteral { $$ = $1; }
687 | RegularExpressionLiteral { $$ = $1; }
690 /* 7.8.1 Null Literals {{{ */
692 : "null" { $$ = $1; }
695 /* 7.8.2 Boolean Literals {{{ */
697 : "true" { $$ = $1; }
698 | "false" { $$ = $1; }
702 /* 7.9 Automatic Semicolon Insertion {{{ */
704 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
709 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
714 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
718 /* 11.1 Primary Expressions {{{ */
720 : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
724 : Parenthetical { $$ = $1; }
729 : Identifier { $$ = CYNew CYVariable($1); }
733 : "this" { $$ = $1; }
734 | Variable { $$ = $1; }
735 | Literal { $$ = $1; }
736 | ArrayLiteral { $$ = $1; }
737 | ObjectLiteral { $$ = $1; }
738 | FunctionExpression { $$ = $1; }
739 | Parenthetical { $$ = $1; }
740 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
743 /* 11.1.4.1 Array Initialiser {{{ */
745 : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
749 : AssignmentExpression { $$ = $1; }
753 : Element { $$ = $1; }
754 | LexSetRegExp { $$ = NULL; }
758 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
759 | Element { $$ = CYNew CYElement($1, NULL); }
763 : ElementList { $$ = $1; }
764 | LexSetRegExp { $$ = NULL; }
767 /* 11.1.4.2 Array Comprehension {{{ */
769 : "[" LexPushInOff AssignmentExpression ComprehensionForList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
773 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
774 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
777 ComprehensionForListOpt
778 : ComprehensionForList { $$ = $1; }
779 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
783 /* 11.1.5 Object Initialiser {{{ */
785 : BRACE LexPushInOff PropertyDefinitionListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
788 PropertyDefinitionList_
789 : "," PropertyDefinitionList { $$ = $2; }
794 PropertyDefinitionList
795 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
798 PropertyDefinitionListOpt
799 : PropertyDefinitionList { $$ = $1; }
804 // XXX: this should be IdentifierName
805 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
806 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
811 : IdentifierName { $$ = $1; }
812 | StringLiteral { $$ = $1; }
813 | NumericLiteral { $$ = $1; }
817 : LexSetRegExp PropertyName_ { $$ = $2; }
821 /* 11.2 Left-Hand-Side Expressions {{{ */
823 : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
824 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
825 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
829 : MemberExpression { $$ = $1; }
830 //| "super" { $$ = $1; }
834 : LexSetRegExp PrimaryExpression { $$ = $2; }
835 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
836 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
840 : MemberExpression { $$ = $1; }
841 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
850 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
851 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
855 : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
859 : "," ArgumentList { $$ = $2; }
864 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
868 : ArgumentList { $$ = $1; }
869 | LexSetRegExp { $$ = NULL; }
872 LeftHandSideExpression
873 : NewExpression { $$ = $1; }
874 | CallExpression { $$ = $1; }
877 /* 11.3 Postfix Expressions {{{ */
879 : %prec "" LeftHandSideExpression { $$ = $1; }
880 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
881 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
884 /* 11.4 Unary Operators {{{ */
886 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
887 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
888 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
889 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
890 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
891 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
892 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
893 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
894 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
895 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
896 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
900 : PostfixExpression { $$ = $1; }
901 | LexSetRegExp UnaryExpression_ { $$ = $2; }
904 /* 11.5 Multiplicative Operators {{{ */
905 MultiplicativeExpression
906 : UnaryExpression { $$ = $1; }
907 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
908 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
909 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
912 /* 11.6 Additive Operators {{{ */
914 : MultiplicativeExpression { $$ = $1; }
915 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
916 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
919 /* 11.7 Bitwise Shift Operators {{{ */
921 : AdditiveExpression { $$ = $1; }
922 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
923 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
924 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
927 /* 11.8 Relational Operators {{{ */
929 : ShiftExpression { $$ = $1; }
930 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
931 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
932 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
933 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
934 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
935 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
938 /* 11.9 Equality Operators {{{ */
940 : RelationalExpression { $$ = $1; }
941 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
942 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
943 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
944 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
947 /* 11.10 Binary Bitwise Operators {{{ */
949 : EqualityExpression { $$ = $1; }
950 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
954 : BitwiseANDExpression { $$ = $1; }
955 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
959 : BitwiseXORExpression { $$ = $1; }
960 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
963 /* 11.11 Binary Logical Operators {{{ */
965 : BitwiseORExpression { $$ = $1; }
966 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
970 : LogicalANDExpression { $$ = $1; }
971 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
974 /* 11.12 Conditional Operator ( ? : ) {{{ */
975 ConditionalExpression
976 : LogicalORExpression { $$ = $1; }
977 | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
980 /* 11.13 Assignment Operators {{{ */
982 : ConditionalExpression { $$ = $1; }
983 | ArrowFunction { $$ = $1; }
984 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
985 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
986 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
987 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
988 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
989 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
990 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
991 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
992 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
993 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
994 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
995 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
998 /* 11.14 Comma Operator {{{ */
1000 : "," Expression { $$ = $2; }
1001 | { $$ = CYNew CYCompound(); }
1005 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1009 : Expression { $$ = $1; }
1010 | LexSetRegExp { $$ = NULL; }
1014 /* 12 Statements {{{ */
1016 : Block { $$ = $1; }
1017 | VariableStatement { $$ = $1; }
1018 | EmptyStatement { $$ = $1; }
1019 | IfStatement { $$ = $1; }
1020 | BreakableStatement { $$ = $1; }
1021 | ContinueStatement { $$ = $1; }
1022 | BreakStatement { $$ = $1; }
1023 | ReturnStatement { $$ = $1; }
1024 | WithStatement { $$ = $1; }
1025 | LabelledStatement { $$ = $1; }
1026 | ThrowStatement { $$ = $1; }
1027 | TryStatement { $$ = $1; }
1028 | DebuggerStatement { $$ = $1; }
1032 : LexSetRegExp Statement__ { $$ = $2; }
1033 | ExpressionStatement { $$ = $1; }
1037 : LexSetStatement Statement_ { $$ = $2; }
1041 : FunctionDeclaration { $$ = $1; }
1042 | LexicalDeclaration { $$ = $1; }
1046 : LexSetRegExp Declaration__ { $$ = $2; }
1050 : LexSetStatement Declaration_ { $$ = $2; }
1054 : IterationStatement { $$ = $1; }
1055 | SwitchStatement { $$ = $1; }
1058 /* 12.1 Block {{{ */
1060 : BRACE StatementListOpt "}" { $$ = $2; }
1064 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1068 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1072 : StatementList { $$ = $1; }
1073 | LexSetStatement LexSetRegExp { $$ = NULL; }
1077 : Statement { $$ = $1; }
1078 | Declaration { $$ = $1; }
1082 /* 12.2 Declarations {{{ */
1084 : Identifier { $$ = $1; }
1091 // XXX: BindingPattern
1093 /* 12.2.1 Let and Const Declarations {{{ */
1095 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1103 /* 12.2.2 Variable Statement {{{ */
1105 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1108 VariableDeclarationList_
1109 : "," VariableDeclarationList { $$ = $2; }
1113 VariableDeclarationList
1114 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1118 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1119 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1123 : "=" AssignmentExpression { $$ = $2; }
1127 : Initialiser { $$ = $1; }
1131 /* 12.2.4 Destructuring Binding Patterns {{{ */
1135 : SingleNameBinding { $$ = $1; }
1139 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1143 /* 12.3 Empty Statement {{{ */
1145 : ";" { $$ = CYNew CYEmpty(); }
1148 /* 12.4 Expression Statement {{{ */
1150 : Expression Terminator { $$ = CYNew CYExpress($1); }
1153 /* 12.5 The if Statement {{{ */
1155 : "else" Statement { $$ = $2; }
1156 | %prec "if" { $$ = NULL; }
1160 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1164 /* 12.6.1 The do-while Statement {{{ */
1166 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1169 /* 12.6.2 The while Statement {{{ */
1171 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1174 /* 12.6.3 The for Statement {{{ */
1176 : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1179 ForStatementInitialiser
1180 : ExpressionOpt { $$ = $1; }
1181 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1184 /* 12.6.4 The for-in and for-of Statements {{{ */
1186 : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1187 | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1190 ForInStatementInitialiser
1191 : LeftHandSideExpression { $$ = $1; }
1192 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1196 /* 12.7 The continue Statement {{{ */
1198 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1199 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1202 /* 12.8 The break Statement {{{ */
1204 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1205 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1208 /* 12.9 The return Statement {{{ */
1210 : "return" "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1211 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1214 /* 12.10 The with Statement {{{ */
1216 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1220 /* 12.11 The switch Statement {{{ */
1222 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1226 : BRACE CaseClausesOpt "}" { $$ = $2; }
1230 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1234 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1235 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1240 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1243 /* 12.12 Labelled Statements {{{ */
1245 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1248 /* 12.13 The throw Statement {{{ */
1250 : "throw" "\n" StrictSemi { YYABORT; }
1251 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1254 /* 12.14 The try Statement {{{ */
1256 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1260 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1265 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1269 /* 12.14 The debugger Statement {{{ */
1271 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1275 /* 13.1 Function Definitions {{{ */
1277 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1281 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1284 FormalParameterList_
1285 : "," FormalParameterList { $$ = $2; }
1290 // XXX: : FunctionRestParameter { $$ = $1; }
1291 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1294 FormalParameterListOpt
1295 : FormalParameterList
1299 /* XXX: FunctionRestParameter
1300 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1304 : BindingElement { $$ = $1; }
1308 : StatementListOpt { $$ = $1; }
1311 /* 13.2 Arrow Function Definitions {{{ */
1313 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1317 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1318 //| ParentheticalOpt { $$ = $1; }
1322 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1323 | ";{" LexPushInOff FunctionBody LexPopIn "}" { $$ = $3; }
1326 /* 14 Program {{{ */
1328 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1332 : StatementList { $$ = $1; }
1336 : ProgramBody { $$ = $1; }
1337 | LexSetStatement LexSetRegExp { $$ = NULL; }
1342 /* Cycript (Objective-C): Type Encoding {{{ */
1344 : IdentifierOpt { $$ = CYNew CYTypedIdentifier($1); }
1345 | "(" PrefixedType ")" { $$ = $2; }
1346 | SuffixedType "[" NumericLiteral "]" { CYSetLast($1->type_) = CYNew CYTypeArrayOf($3->Value()); $$ = $1; }
1350 : SuffixedType { $$ = $1; }
1351 | "const" PrefixedType { CYSetLast($2->type_) = CYNew CYTypeConstant(); $$ = $2; }
1352 | "*" PrefixedType { CYSetLast($2->type_) = CYNew CYTypePointerTo(); $$ = $2; }
1356 : Variable { $$ = CYNew CYTypeVariable($1); }
1357 | "const" ModifiedType { $$ = CYNew CYTypeConstant($2); }
1361 : ModifiedType PrefixedType { CYSetLast($2->type_) = $1; $$ = $2;}
1365 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1369 : AtEncode "(" EncodedType ")" { $$ = $3; }
1372 /* Cycript (Objective-C): @class Declaration {{{ */
1374 /* XXX: why the hell did I choose MemberExpression? */
1375 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1380 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1385 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1389 : "+" { $$ = false; }
1390 | "-" { $$ = true; }
1394 : "(" EncodedType ")" { $$ = $2; }
1395 | "(" LexSetRegExp "void" ")" { $$ = CYNew CYString("v"); }
1400 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1403 MessageParameterList
1404 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1407 MessageParameterListOpt
1408 : MessageParameterList { $$ = $1; }
1413 : MessageParameterList { $$ = $1; }
1414 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1417 ClassMessageDeclaration
1418 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1421 ClassMessageDeclarationListOpt
1422 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1423 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1428 : Identifier { $$ = $1; }
1429 | "(" AssignmentExpression ")" { $$ = $2; }
1433 : ClassName { $$ = $1; }
1437 // XXX: this should be AssignmentExpressionNoRight
1439 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1443 : "," ClassProtocols { $$ = $2; }
1447 ClassProtocolListOpt
1448 : "<" ClassProtocols ">" { $$ = $2; }
1453 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1457 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1465 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1469 : ClassExpression { $$ = $1; }
1473 : ClassStatement { $$ = $1; }
1474 | CategoryStatement { $$ = $1; }
1477 /* Cycript (Objective-C): Send Message {{{ */
1479 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1484 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1485 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1489 : SelectorCall { $$ = $1; }
1490 | VariadicCall { $$ = $1; }
1494 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1498 : SelectorCall { $$ = $1; }
1499 | Word { $$ = CYNew CYArgument($1, NULL); }
1503 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1504 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
1508 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1512 : SelectorExpression_ { $$ = $1; }
1513 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1516 SelectorExpressionOpt
1517 : SelectorExpression_ { $$ = $1; }
1522 : MessageExpression { $$ = $1; }
1523 | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
1526 /* Cycript (Objective-C): @import Directive {{{ */
1540 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1543 /* Cycript (Objective-C): Boxed Expressions {{{ */
1545 : NullLiteral { $$ = $1; }
1546 | BooleanLiteral { $$ = $1; }
1547 | NumericLiteral { $$ = $1; }
1548 | StringLiteral { $$ = $1; }
1549 | ArrayLiteral { $$ = $1; }
1550 | ObjectLiteral { $$ = $1; }
1551 | Parenthetical { $$ = $1; }
1555 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1561 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1562 LeftHandSideExpression
1563 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1567 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1571 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1572 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1573 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1576 /* Cycript (C): auto Compatibility {{{ */
1583 /* YUI: Documentation Comments {{{ */
1585 : Comment { $$ = $1; }
1590 /* Lexer State {{{ */
1592 : { driver.PushCondition(CYDriver::RegExpCondition); }
1596 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1600 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1604 : { driver.PopCondition(); }
1608 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1612 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1615 /* Virtual Tokens {{{ */
1622 /* 8.1 Context Keywords {{{ */
1624 : "namespace" { $$ = $1; }
1625 | "xml" { $$ = $1; }
1628 /* 8.3 XML Initialiser Input Elements {{{ */
1630 : XMLComment { $$ = $1; }
1631 | XMLCDATA { $$ = $1; }
1632 | XMLPI { $$ = $1; }
1636 /* 11.1 Primary Expressions {{{ */
1638 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1639 | XMLInitialiser { $$ = $1; }
1640 | XMLListInitialiser { $$ = $1; }
1644 : AttributeIdentifier { $$ = $1; }
1645 | QualifiedIdentifier { $$ = $1; }
1646 | WildcardIdentifier { $$ = $1; }
1649 /* 11.1.1 Attribute Identifiers {{{ */
1651 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1655 : PropertySelector { $$ = $1; }
1656 | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
1660 : Identifier { $$ = CYNew CYSelector($1); }
1661 | WildcardIdentifier { $$ = $1; }
1664 /* 11.1.2 Qualified Identifiers {{{ */
1665 QualifiedIdentifier_
1666 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1667 | QualifiedIdentifier { $$ = $1; }
1671 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1674 /* 11.1.3 Wildcard Identifiers {{{ */
1676 : "*" { $$ = CYNew CYWildcard(); }
1679 /* 11.1.4 XML Initialiser {{{ */
1681 : XMLMarkup { $$ = $1; }
1682 | XMLElement { $$ = $1; }
1686 : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
1687 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
1691 : LexPushXMLTag XMLTagName XMLAttributes
1695 : BRACE LexPushRegExp Expression LexPop "}"
1704 : XMLAttributes_ XMLAttribute
1709 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1710 | XMLAttributes_ XMLWhitespaceOpt
1719 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1723 : XMLExpression XMLElementContentOpt
1724 | XMLMarkup XMLElementContentOpt
1725 | XMLText XMLElementContentOpt
1726 | XMLElement XMLElementContentOpt
1729 XMLElementContentOpt
1734 /* 11.1.5 XMLList Initialiser {{{ */
1736 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
1740 /* 11.2 Left-Hand-Side Expressions {{{ */
1742 : Identifier { $$ = $1; }
1743 | PropertyIdentifier { $$ = $1; }
1747 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1748 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1749 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1752 /* 12.1 The default xml namespace Statement {{{ */
1753 /* XXX: DefaultXMLNamespaceStatement
1754 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1758 : DefaultXMLNamespaceStatement { $$ = $1; }
1763 /* JavaScript 1.7: Array Comprehensions {{{ */
1765 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1769 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1770 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1774 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1777 ComprehensionListOpt
1778 : ComprehensionList { $$ = $1; }
1779 | IfComprehension { $$ = $1; }
1784 : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
1787 /* JavaScript 1.7: for each {{{ */
1789 : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1792 /* JavaScript 1.7: let Statements {{{ */
1794 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1802 /* JavaScript FTW: Ruby Blocks {{{ */
1803 RubyProcParameterList_
1804 : "," RubyProcParameterList { $$ = $2; }
1808 RubyProcParameterList
1809 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1814 : "|" RubyProcParameterList "|" { $$ = $2; }
1815 | "||" { $$ = NULL; }
1818 RubyProcParametersOpt
1819 : RubyProcParameters
1824 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1828 : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
1832 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }