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_;
78 CYProperty *property_;
79 CYPropertyName *propertyName_;
80 CYRubyProc *rubyProc_;
81 CYStatement *statement_;
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_> MessageExpression
475 %type <messageParameter_> MessageParameter
476 %type <messageParameter_> MessageParameters
477 %type <messageParameter_> MessageParameterList
478 %type <messageParameter_> MessageParameterListOpt
479 %type <bool_> MessageScope
480 %type <type_> ModifiedType
481 %type <part_> PrefixedType
482 %type <argument_> SelectorCall_
483 %type <argument_> SelectorCall
484 %type <selector_> SelectorExpression_
485 %type <selector_> SelectorExpression
486 %type <selector_> SelectorExpressionOpt
487 %type <argument_> SelectorList
488 %type <word_> SelectorWordOpt
489 %type <part_> SuffixedType
490 %type <expression_> TypeOpt
491 %type <type_> TypedIdentifier
492 %type <argument_> VariadicCall
496 %type <propertyIdentifier_> PropertyIdentifier_
497 %type <selector_> PropertySelector_
498 %type <selector_> PropertySelector
499 %type <identifier_> QualifiedIdentifier_
500 %type <identifier_> QualifiedIdentifier
501 %type <identifier_> WildcardIdentifier
502 %type <identifier_> XMLComment
503 %type <identifier_> XMLCDATA
504 %type <identifier_> XMLElement
505 %type <identifier_> XMLElementContent
506 %type <identifier_> XMLMarkup
507 %type <identifier_> XMLPI
509 %type <attribute_> AttributeIdentifier
510 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
511 %type <expression_> PropertyIdentifier
512 %type <expression_> XMLListInitialiser
513 %type <expression_> XMLInitialiser
516 /* Token Priorities {{{ */
528 /* Lexer State {{{ */
530 : { driver.in_.push(true); }
534 : { driver.in_.push(false); }
538 : { driver.in_.pop(); }
542 : { driver.SetCondition(CYDriver::RegExpCondition); }
546 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
550 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
553 LexNoAtImplementation
554 : { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
558 : LexNoBrace LexNoFunction LexNoAtImplementation
561 /* Virtual Tokens {{{ */
572 /* 7.6 Identifier Names and Identifiers {{{ */
583 : Identifier { $$ = $1; }
584 | "auto" { $$ = $1; }
585 | "break" NewLineOpt { $$ = $1; }
586 | "case" { $$ = $1; }
587 | "catch" { $$ = $1; }
588 | "class" { $$ = $1; }
589 | "const" { $$ = $1; }
590 | "continue" NewLineOpt { $$ = $1; }
591 | "debugger" { $$ = $1; }
592 | "default" { $$ = $1; }
593 | "delete" { $$ = $1; }
595 | "else" { $$ = $1; }
596 | "enum" { $$ = $1; }
597 | "export" { $$ = $1; }
598 | "extends" { $$ = $1; }
599 | "false" { $$ = $1; }
600 | "finally" { $$ = $1; }
601 /* XXX: | "for" { $$ = $1; } */
602 | "function" { $$ = $1; }
604 | "import" { $$ = $1; }
605 /* XXX: | "in" { $$ = $1; } */
607 /* XXX: | "instanceof" { $$ = $1; } */
609 // XXX: as it currently is not an Identifier
613 | "null" { $$ = $1; }
614 | "return" NewLineOpt { $$ = $1; }
615 | "super" { $$ = $1; }
616 | "switch" { $$ = $1; }
617 | "this" { $$ = $1; }
618 | "throw" NewLineOpt { $$ = $1; }
619 | "true" { $$ = $1; }
621 | "typeof" { $$ = $1; }
623 | "void" { $$ = $1; }
624 | "while" { $$ = $1; }
625 | "with" { $$ = $1; }
634 : Identifier_ { $$ = $1; }
636 | "implements" { $$ = $1; }
637 | "interface" { $$ = $1; }
638 | "package" { $$ = $1; }
639 | "private" { $$ = $1; }
640 | "protected" { $$ = $1; }
641 | "public" { $$ = $1; }
642 | "static" { $$ = $1; }
644 | "abstract" { $$ = $1; }
645 | "boolean" { $$ = $1; }
646 | "byte" { $$ = $1; }
647 | "char" { $$ = $1; }
648 | "double" { $$ = $1; }
649 | "final" { $$ = $1; }
650 | "float" { $$ = $1; }
651 | "goto" { $$ = $1; }
653 | "long" { $$ = $1; }
654 | "native" { $$ = $1; }
655 | "short" { $$ = $1; }
656 | "synchronized" { $$ = $1; }
657 | "throws" { $$ = $1; }
658 | "transient" { $$ = $1; }
659 | "volatile" { $$ = $1; }
661 // XXX: currently I only have this as Word
662 // | "let" { $$ = $1; }
664 | "yield" { $$ = $1; }
666 | "each" { $$ = $1; }
671 : Identifier { $$ = $1; }
676 /* 7.8 Literals {{{ */
678 : NullLiteral { $$ = $1; }
679 | ValueLiteral { $$ = $1; }
683 : BooleanLiteral { $$ = $1; }
684 | NumericLiteral { $$ = $1; }
685 | StringLiteral { $$ = $1; }
686 | RegularExpressionLiteral { $$ = $1; }
689 /* 7.8.1 Null Literals {{{ */
691 : "null" { $$ = $1; }
694 /* 7.8.2 Boolean Literals {{{ */
696 : "true" { $$ = $1; }
697 | "false" { $$ = $1; }
701 /* 7.9 Automatic Semicolon Insertion {{{ */
703 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
708 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
713 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
717 /* 11.1 Primary Expressions {{{ */
719 : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
723 : Parenthetical { $$ = $1; }
728 : Identifier { $$ = CYNew CYVariable($1); }
732 : "this" { $$ = $1; }
733 | Variable { $$ = $1; }
734 | Literal { $$ = $1; }
735 | ArrayLiteral { $$ = $1; }
736 | ObjectLiteral { $$ = $1; }
737 | FunctionExpression { $$ = $1; }
738 | Parenthetical { $$ = $1; }
739 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
742 /* 11.1.4.1 Array Initialiser {{{ */
744 : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
748 : AssignmentExpression { $$ = $1; }
752 : Element { $$ = $1; }
753 | LexSetRegExp { $$ = NULL; }
757 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
758 | Element { $$ = CYNew CYElement($1, NULL); }
762 : ElementList { $$ = $1; }
763 | LexSetRegExp { $$ = NULL; }
766 /* 11.1.4.2 Array Comprehension {{{ */
768 : "[" LexPushInOff AssignmentExpression ComprehensionForList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
772 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
773 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
776 ComprehensionForListOpt
777 : ComprehensionForList { $$ = $1; }
778 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
782 /* 11.1.5 Object Initialiser {{{ */
784 : BRACE LexPushInOff PropertyDefinitionListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
787 PropertyDefinitionList_
788 : "," PropertyDefinitionList { $$ = $2; }
793 PropertyDefinitionList
794 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
797 PropertyDefinitionListOpt
798 : PropertyDefinitionList { $$ = $1; }
803 // XXX: this should be IdentifierName
804 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
805 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
810 : IdentifierName { $$ = $1; }
811 | StringLiteral { $$ = $1; }
812 | NumericLiteral { $$ = $1; }
816 : LexSetRegExp PropertyName_ { $$ = $2; }
820 /* 11.2 Left-Hand-Side Expressions {{{ */
822 : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
823 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
824 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
828 : MemberExpression { $$ = $1; }
829 //| "super" { $$ = $1; }
833 : LexSetRegExp PrimaryExpression { $$ = $2; }
834 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
835 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
839 : MemberExpression { $$ = $1; }
840 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
849 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
850 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
854 : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
858 : "," ArgumentList { $$ = $2; }
863 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
867 : ArgumentList { $$ = $1; }
868 | LexSetRegExp { $$ = NULL; }
871 LeftHandSideExpression
872 : NewExpression { $$ = $1; }
873 | CallExpression { $$ = $1; }
876 /* 11.3 Postfix Expressions {{{ */
878 : %prec "" LeftHandSideExpression { $$ = $1; }
879 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
880 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
883 /* 11.4 Unary Operators {{{ */
885 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
886 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
887 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
888 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
889 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
890 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
891 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
892 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
893 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
894 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
895 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
899 : PostfixExpression { $$ = $1; }
900 | LexSetRegExp UnaryExpression_ { $$ = $2; }
903 /* 11.5 Multiplicative Operators {{{ */
904 MultiplicativeExpression
905 : UnaryExpression { $$ = $1; }
906 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
907 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
908 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
911 /* 11.6 Additive Operators {{{ */
913 : MultiplicativeExpression { $$ = $1; }
914 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
915 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
918 /* 11.7 Bitwise Shift Operators {{{ */
920 : AdditiveExpression { $$ = $1; }
921 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
922 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
923 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
926 /* 11.8 Relational Operators {{{ */
928 : ShiftExpression { $$ = $1; }
929 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
930 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
931 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
932 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
933 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
934 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
937 /* 11.9 Equality Operators {{{ */
939 : RelationalExpression { $$ = $1; }
940 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
941 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
942 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
943 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
946 /* 11.10 Binary Bitwise Operators {{{ */
948 : EqualityExpression { $$ = $1; }
949 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
953 : BitwiseANDExpression { $$ = $1; }
954 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
958 : BitwiseXORExpression { $$ = $1; }
959 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
962 /* 11.11 Binary Logical Operators {{{ */
964 : BitwiseORExpression { $$ = $1; }
965 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
969 : LogicalANDExpression { $$ = $1; }
970 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
973 /* 11.12 Conditional Operator ( ? : ) {{{ */
974 ConditionalExpression
975 : LogicalORExpression { $$ = $1; }
976 | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
979 /* 11.13 Assignment Operators {{{ */
981 : ConditionalExpression { $$ = $1; }
982 | ArrowFunction { $$ = $1; }
983 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
984 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
985 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
986 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
987 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
988 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
989 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
990 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
991 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
992 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
993 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
994 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
997 /* 11.14 Comma Operator {{{ */
999 : "," Expression { $$ = $2; }
1000 | { $$ = CYNew CYCompound(); }
1004 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1008 : Expression { $$ = $1; }
1009 | LexSetRegExp { $$ = NULL; }
1013 /* 12 Statements {{{ */
1015 : Block { $$ = $1; }
1016 | VariableStatement { $$ = $1; }
1017 | EmptyStatement { $$ = $1; }
1018 | IfStatement { $$ = $1; }
1019 | BreakableStatement { $$ = $1; }
1020 | ContinueStatement { $$ = $1; }
1021 | BreakStatement { $$ = $1; }
1022 | ReturnStatement { $$ = $1; }
1023 | WithStatement { $$ = $1; }
1024 | LabelledStatement { $$ = $1; }
1025 | ThrowStatement { $$ = $1; }
1026 | TryStatement { $$ = $1; }
1027 | DebuggerStatement { $$ = $1; }
1031 : LexSetRegExp Statement__ { $$ = $2; }
1032 | ExpressionStatement { $$ = $1; }
1036 : LexSetStatement Statement_ { $$ = $2; }
1040 : FunctionDeclaration { $$ = $1; }
1041 | LexicalDeclaration { $$ = $1; }
1045 : LexSetRegExp Declaration__ { $$ = $2; }
1049 : LexSetStatement Declaration_ { $$ = $2; }
1053 : IterationStatement { $$ = $1; }
1054 | SwitchStatement { $$ = $1; }
1057 /* 12.1 Block {{{ */
1059 : BRACE StatementListOpt "}" { $$ = $2; }
1063 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1067 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1071 : StatementList { $$ = $1; }
1072 | LexSetStatement LexSetRegExp { $$ = NULL; }
1076 : Statement { $$ = $1; }
1077 | Declaration { $$ = $1; }
1081 /* 12.2 Declarations {{{ */
1083 : Identifier { $$ = $1; }
1090 // XXX: BindingPattern
1092 /* 12.2.1 Let and Const Declarations {{{ */
1094 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1102 /* 12.2.2 Variable Statement {{{ */
1104 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1107 VariableDeclarationList_
1108 : "," VariableDeclarationList { $$ = $2; }
1112 VariableDeclarationList
1113 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1117 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1118 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1122 : "=" AssignmentExpression { $$ = $2; }
1126 : Initialiser { $$ = $1; }
1130 /* 12.2.4 Destructuring Binding Patterns {{{ */
1134 : SingleNameBinding { $$ = $1; }
1138 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1142 /* 12.3 Empty Statement {{{ */
1144 : ";" { $$ = CYNew CYEmpty(); }
1147 /* 12.4 Expression Statement {{{ */
1149 : Expression Terminator { $$ = CYNew CYExpress($1); }
1152 /* 12.5 The if Statement {{{ */
1154 : "else" Statement { $$ = $2; }
1155 | %prec "if" { $$ = NULL; }
1159 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1163 /* 12.6.1 The do-while Statement {{{ */
1165 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1168 /* 12.6.2 The while Statement {{{ */
1170 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1173 /* 12.6.3 The for Statement {{{ */
1175 : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1178 ForStatementInitialiser
1179 : ExpressionOpt { $$ = $1; }
1180 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1183 /* 12.6.4 The for-in and for-of Statements {{{ */
1185 : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1186 | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1189 ForInStatementInitialiser
1190 : LeftHandSideExpression { $$ = $1; }
1191 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1195 /* 12.7 The continue Statement {{{ */
1197 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1198 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1201 /* 12.8 The break Statement {{{ */
1203 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1204 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1207 /* 12.9 The return Statement {{{ */
1209 : "return" "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1210 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1213 /* 12.10 The with Statement {{{ */
1215 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1219 /* 12.11 The switch Statement {{{ */
1221 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1225 : BRACE CaseClausesOpt "}" { $$ = $2; }
1229 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1233 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1234 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1239 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1242 /* 12.12 Labelled Statements {{{ */
1244 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1247 /* 12.13 The throw Statement {{{ */
1249 : "throw" "\n" StrictSemi { YYABORT; }
1250 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1253 /* 12.14 The try Statement {{{ */
1255 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1259 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1264 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1268 /* 12.14 The debugger Statement {{{ */
1270 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1274 /* 13.1 Function Definitions {{{ */
1276 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1280 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1283 FormalParameterList_
1284 : "," FormalParameterList { $$ = $2; }
1289 // XXX: : FunctionRestParameter { $$ = $1; }
1290 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1293 FormalParameterListOpt
1294 : FormalParameterList
1298 /* XXX: FunctionRestParameter
1299 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1303 : BindingElement { $$ = $1; }
1307 : StatementListOpt { $$ = $1; }
1310 /* 13.2 Arrow Function Definitions {{{ */
1312 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1316 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1317 //| ParentheticalOpt { $$ = $1; }
1321 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1322 | ";{" LexPushInOff FunctionBody LexPopIn "}" { $$ = $3; }
1325 /* 14 Program {{{ */
1327 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1331 : StatementList { $$ = $1; }
1335 : ProgramBody { $$ = $1; }
1336 | LexSetStatement LexSetRegExp { $$ = NULL; }
1341 /* Cycript (Objective-C): Type Encoding {{{ */
1344 | "(" PrefixedType ")" { $$ = $2; }
1345 | SuffixedType "[" NumericLiteral "]" { $$ = CYNew CYEncodedPart($1, "arrayOf", CYNew CYArgument($3)); }
1349 : SuffixedType { $$ = $1; }
1350 | "*" PrefixedType { $$ = CYNew CYEncodedPart($2, "pointerTo"); }
1354 : Variable { $$ = CYNew CYEncodedType($1); }
1355 | "const" ModifiedType { $2->base_ = CYNew CYCall(CYNew CYDirectMember($2->base_, CYNew CYString("constant"))); $$ = $2; }
1359 : ModifiedType PrefixedType { $1->parts_ = $2; $$ = $1;}
1363 : AtEncode "(" TypedIdentifier ")" { $$ = $3; }
1366 /* Cycript (Objective-C): @class Declaration {{{ */
1368 /* XXX: why the hell did I choose MemberExpression? */
1369 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1374 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1379 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1383 : "+" { $$ = false; }
1384 | "-" { $$ = true; }
1388 : "(" TypedIdentifier ")" { $$ = $2; }
1389 | "(" LexSetRegExp "void" ")" { $$ = CYNew CYString("v"); }
1394 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1397 MessageParameterList
1398 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1401 MessageParameterListOpt
1402 : MessageParameterList { $$ = $1; }
1407 : MessageParameterList { $$ = $1; }
1408 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1411 ClassMessageDeclaration
1412 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1415 ClassMessageDeclarationListOpt
1416 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1417 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1422 : Identifier { $$ = $1; }
1423 | "(" AssignmentExpression ")" { $$ = $2; }
1427 : ClassName { $$ = $1; }
1431 // XXX: this should be AssignmentExpressionNoRight
1433 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1437 : "," ClassProtocols { $$ = $2; }
1441 ClassProtocolListOpt
1442 : "<" ClassProtocols ">" { $$ = $2; }
1447 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1451 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1459 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1463 : ClassExpression { $$ = $1; }
1467 : ClassStatement { $$ = $1; }
1468 | CategoryStatement { $$ = $1; }
1471 /* Cycript (Objective-C): Send Message {{{ */
1473 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1478 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1479 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1483 : SelectorCall { $$ = $1; }
1484 | VariadicCall { $$ = $1; }
1488 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1492 : SelectorCall { $$ = $1; }
1493 | Word { $$ = CYNew CYArgument($1, NULL); }
1497 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1498 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
1502 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1506 : SelectorExpression_ { $$ = $1; }
1507 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1510 SelectorExpressionOpt
1511 : SelectorExpression_ { $$ = $1; }
1516 : MessageExpression { $$ = $1; }
1517 | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
1520 /* Cycript (Objective-C): @import Directive {{{ */
1534 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1537 /* Cycript (Objective-C): Boxed Expressions {{{ */
1539 : NullLiteral { $$ = $1; }
1540 | BooleanLiteral { $$ = $1; }
1541 | NumericLiteral { $$ = $1; }
1542 | StringLiteral { $$ = $1; }
1543 | ArrayLiteral { $$ = $1; }
1544 | ObjectLiteral { $$ = $1; }
1545 | Parenthetical { $$ = $1; }
1549 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1555 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1556 LeftHandSideExpression
1557 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1561 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1565 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1566 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1567 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1570 /* Cycript (C): auto Compatibility {{{ */
1577 /* YUI: Documentation Comments {{{ */
1579 : Comment { $$ = $1; }
1584 /* Lexer State {{{ */
1586 : { driver.PushCondition(CYDriver::RegExpCondition); }
1590 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1594 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1598 : { driver.PopCondition(); }
1602 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1606 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1609 /* Virtual Tokens {{{ */
1616 /* 8.1 Context Keywords {{{ */
1618 : "namespace" { $$ = $1; }
1619 | "xml" { $$ = $1; }
1622 /* 8.3 XML Initialiser Input Elements {{{ */
1624 : XMLComment { $$ = $1; }
1625 | XMLCDATA { $$ = $1; }
1626 | XMLPI { $$ = $1; }
1630 /* 11.1 Primary Expressions {{{ */
1632 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1633 | XMLInitialiser { $$ = $1; }
1634 | XMLListInitialiser { $$ = $1; }
1638 : AttributeIdentifier { $$ = $1; }
1639 | QualifiedIdentifier { $$ = $1; }
1640 | WildcardIdentifier { $$ = $1; }
1643 /* 11.1.1 Attribute Identifiers {{{ */
1645 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1649 : PropertySelector { $$ = $1; }
1650 | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
1654 : Identifier { $$ = CYNew CYSelector($1); }
1655 | WildcardIdentifier { $$ = $1; }
1658 /* 11.1.2 Qualified Identifiers {{{ */
1659 QualifiedIdentifier_
1660 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1661 | QualifiedIdentifier { $$ = $1; }
1665 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1668 /* 11.1.3 Wildcard Identifiers {{{ */
1670 : "*" { $$ = CYNew CYWildcard(); }
1673 /* 11.1.4 XML Initialiser {{{ */
1675 : XMLMarkup { $$ = $1; }
1676 | XMLElement { $$ = $1; }
1680 : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
1681 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
1685 : LexPushXMLTag XMLTagName XMLAttributes
1689 : BRACE LexPushRegExp Expression LexPop "}"
1698 : XMLAttributes_ XMLAttribute
1703 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1704 | XMLAttributes_ XMLWhitespaceOpt
1713 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1717 : XMLExpression XMLElementContentOpt
1718 | XMLMarkup XMLElementContentOpt
1719 | XMLText XMLElementContentOpt
1720 | XMLElement XMLElementContentOpt
1723 XMLElementContentOpt
1728 /* 11.1.5 XMLList Initialiser {{{ */
1730 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
1734 /* 11.2 Left-Hand-Side Expressions {{{ */
1736 : Identifier { $$ = $1; }
1737 | PropertyIdentifier { $$ = $1; }
1741 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1742 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1743 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1746 /* 12.1 The default xml namespace Statement {{{ */
1747 /* XXX: DefaultXMLNamespaceStatement
1748 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1752 : DefaultXMLNamespaceStatement { $$ = $1; }
1757 /* JavaScript 1.7: Array Comprehensions {{{ */
1759 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1763 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1764 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1768 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1771 ComprehensionListOpt
1772 : ComprehensionList { $$ = $1; }
1773 | IfComprehension { $$ = $1; }
1778 : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
1781 /* JavaScript 1.7: for each {{{ */
1783 : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1786 /* JavaScript 1.7: let Statements {{{ */
1788 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1796 /* JavaScript FTW: Ruby Blocks {{{ */
1797 RubyProcParameterList_
1798 : "," RubyProcParameterList { $$ = $2; }
1802 RubyProcParameterList
1803 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1808 : "|" RubyProcParameterList "|" { $$ = $2; }
1809 | "||" { $$ = NULL; }
1812 RubyProcParametersOpt
1813 : RubyProcParameters
1818 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1822 : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
1826 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }