1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU 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 {
33 #define CYNew new($pool)
36 #include "ObjectiveC/Syntax.hpp"
40 #include "E4X/Syntax.hpp"
43 #include "Highlight.hpp"
52 CYDriver::Condition condition_;
54 CYArgument *argument_;
55 CYAssignment *assignment_;
58 cy::Syntax::Catch *catch_;
60 CYComprehension *comprehension_;
61 CYCompound *compound_;
62 CYDeclaration *declaration_;
63 CYDeclarations *declarations_;
65 CYExpression *expression_;
68 CYForInitialiser *for_;
69 CYForInInitialiser *forin_;
70 CYFunctionParameter *functionParameter_;
71 CYIdentifier *identifier_;
78 CYProperty *property_;
79 CYPropertyName *propertyName_;
80 CYRubyProc *rubyProc_;
81 CYStatement *statement_;
88 CYClassName *className_;
91 CYMessageParameter *messageParameter_;
92 CYProtocol *protocol_;
93 CYSelectorPart *selector_;
94 CYTypeModifier *type_;
95 CYTypedIdentifier *typedIdentifier_;
96 CYTypedParameter *typedParameter_;
100 CYAttribute *attribute_;
101 CYPropertyIdentifier *propertyIdentifier_;
102 CYSelector *selector_;
107 #define YYSTYPE YYSTYPE
110 @if Bison24 %code provides {
111 int cylex(YYSTYPE *, cy::location *, void *);
118 @if Bison23 %skeleton "lalr1.cc"
119 @if Bison24 %language "C++"
122 @$.begin.filename = @$.end.filename = &driver.filename_;
133 %parse-param { CYDriver &driver }
134 %lex-param { void *cyscanner }
136 /* Token Declarations {{{ */
142 %token XMLAttributeValue
144 %token XMLTagCharacters
150 %token LeftRight "<>"
151 %token LeftSlashRight "</>"
153 %token SlashRight "/>"
154 %token LeftSlash "</"
156 %token ColonColon "::"
157 %token PeriodPeriod ".."
160 @begin E4X ObjectiveC
165 %token AmpersandAmpersand "&&"
166 %token AmpersandEqual "&="
168 %token CarrotEqual "^="
170 %token EqualEqual "=="
171 %token EqualEqualEqual "==="
172 %token EqualRight "=>"
173 %token Exclamation "!"
174 %token ExclamationEqual "!="
175 %token ExclamationEqualEqual "!=="
177 %token HyphenEqual "-="
178 %token HyphenHyphen "--"
179 %token HyphenHyphen_ "\n--"
180 %token HyphenRight "->"
182 %token LeftEqual "<="
184 %token LeftLeftEqual "<<="
186 %token PercentEqual "%="
188 %token PeriodPeriodPeriod "..."
190 %token PipeEqual "|="
193 %token PlusEqual "+="
195 %token PlusPlus_ "\n++"
197 %token RightEqual ">="
198 %token RightRight ">>"
199 %token RightRightEqual ">>="
200 %token RightRightRight ">>>"
201 %token RightRightRightEqual ">>>="
203 %token SlashEqual "/="
205 %token StarEqual "*="
214 %token <comment_> Comment
217 %token CloseParen ")"
220 %token OpenBrace_ "\n{"
221 %token OpenBrace__ ";{"
222 %token CloseBrace "}"
224 %token OpenBracket "["
225 %token CloseBracket "]"
227 %token AtError "@error"
230 %token AtClass "@class"
234 %token AtImplementation "@implementation"
235 %token AtImplementation_ ";@implementation"
236 %token AtImport "@import"
237 %token AtEncode "@encode"
239 %token AtSelector "@selector"
242 %token <false_> False "false"
243 %token <null_> Null "null"
244 %token <true_> True "true"
246 // ES3/ES5/WIE/JSC Reserved
247 %token <word_> Auto "auto"
248 %token <word_> Break "break"
249 %token <word_> Case "case"
250 %token <word_> Catch "catch"
251 %token <word_> Continue "continue"
252 %token <word_> Default "default"
253 %token <word_> Delete "delete"
254 %token <word_> Do "do"
255 %token <word_> Else "else"
256 %token <word_> Finally "finally"
257 %token <word_> For "for"
258 %token <word_> Function "function"
259 %token <word_> Function_ ";function"
260 %token <word_> If "if"
261 %token <word_> In "in"
262 %token <word_> In_ "!in"
263 %token <word_> InstanceOf "instanceof"
264 %token <word_> New "new"
265 %token <word_> Return "return"
266 %token <word_> Switch "switch"
267 %token <this_> This "this"
268 %token <word_> Throw "throw"
269 %token <word_> Try "try"
270 %token <word_> TypeOf "typeof"
271 %token <word_> Var "var"
272 %token <word_> Void "void"
273 %token <word_> While "while"
274 %token <word_> With "with"
276 // ES3/IE6 Future, ES5/JSC Reserved
277 %token <word_> Debugger "debugger"
279 // ES3/ES5/IE6 Future, JSC Reserved
280 %token <word_> Const "const"
282 // ES3/ES5/IE6/JSC Future
283 %token <word_> Class "class"
284 %token <word_> Enum "enum"
285 %token <word_> Export "export"
286 %token <word_> Extends "extends"
287 %token <word_> Import "import"
288 %token <word_> Super "super"
290 // ES3 Future, ES5 Strict Future
291 %token <identifier_> Implements "implements"
292 %token <identifier_> Interface "interface"
293 %token <identifier_> Package "package"
294 %token <identifier_> Private "private"
295 %token <identifier_> Protected "protected"
296 %token <identifier_> Public "public"
297 %token <identifier_> Static "static"
300 %token <identifier_> Abstract "abstract"
301 %token <identifier_> Boolean "boolean"
302 %token <identifier_> Byte "byte"
303 %token <identifier_> Char "char"
304 %token <identifier_> Double "double"
305 %token <identifier_> Final "final"
306 %token <identifier_> Float "float"
307 %token <identifier_> Goto "goto"
308 %token <identifier_> Int "int"
309 %token <identifier_> Long "long"
310 %token <identifier_> Native "native"
311 %token <identifier_> Short "short"
312 %token <identifier_> Synchronized "synchronized"
313 %token <identifier_> Throws "throws"
314 %token <identifier_> Transient "transient"
315 %token <identifier_> Volatile "volatile"
318 %token <identifier_> Let "let"
319 %token <identifier_> Yield "yield"
322 %token <identifier_> Each "each"
323 %token <identifier_> Of "of"
327 %token <identifier_> Namespace "namespace"
328 %token <identifier_> XML "xml"
333 %token <identifier_> Identifier_
334 %token <number_> NumericLiteral
335 %token <string_> StringLiteral
336 %token <literal_> RegularExpressionLiteral
338 %type <expression_> AdditiveExpression
339 %type <argument_> ArgumentList_
340 %type <argument_> ArgumentList
341 %type <argument_> ArgumentListOpt
342 %type <argument_> Arguments
343 %type <literal_> ArrayLiteral
344 %type <expression_> ArrowFunction
345 %type <functionParameter_> ArrowParameters
346 %type <expression_> AssignmentExpression
347 %type <identifier_> Binding
348 %type <identifier_> BindingIdentifier
349 %type <expression_> BitwiseANDExpression
350 %type <statement_> Block_
351 %type <statement_> Block
352 %type <boolean_> BooleanLiteral
353 %type <declaration_> BindingElement
354 %type <expression_> BitwiseORExpression
355 %type <expression_> BitwiseXORExpression
356 %type <statement_> BreakStatement
357 %type <statement_> BreakableStatement
358 %type <expression_> CallExpression_
359 %type <expression_> CallExpression
360 %type <clause_> CaseBlock
361 %type <clause_> CaseClause
362 %type <clause_> CaseClausesOpt
363 %type <catch_> CatchOpt
364 %type <comprehension_> ComprehensionForList
365 %type <comprehension_> ComprehensionForListOpt
366 %type <comprehension_> ComprehensionList
367 %type <comprehension_> ComprehensionListOpt
368 %type <expression_> ConditionalExpression
369 %type <statement_> ContinueStatement
370 %type <statement_> ConciseBody
371 %type <statement_> DebuggerStatement
372 %type <statement_> Declaration__
373 %type <statement_> Declaration_
374 %type <statement_> Declaration
375 %type <clause_> DefaultClause
376 %type <expression_> Element
377 %type <expression_> ElementOpt
378 %type <element_> ElementList
379 %type <element_> ElementListOpt
380 %type <statement_> ElseStatementOpt
381 %type <statement_> EmptyStatement
382 %type <expression_> EqualityExpression
383 %type <compound_> Expression_
384 %type <compound_> Expression
385 %type <expression_> ExpressionOpt
386 %type <statement_> ExpressionStatement
387 %type <finally_> FinallyOpt
388 %type <comprehension_> ForComprehension
389 %type <for_> ForStatementInitialiser
390 %type <forin_> ForInStatementInitialiser
391 %type <declaration_> FormalParameter
392 %type <functionParameter_> FormalParameterList_
393 %type <functionParameter_> FormalParameterList
394 %type <functionParameter_> FormalParameterListOpt
395 %type <statement_> FunctionBody
396 %type <statement_> FunctionDeclaration
397 %type <expression_> FunctionExpression
398 %type <identifier_> Identifier
399 %type <identifier_> IdentifierOpt
400 %type <word_> IdentifierName
401 %type <comprehension_> IfComprehension
402 %type <statement_> IfStatement
403 %type <expression_> Initialiser
404 %type <expression_> InitialiserOpt
405 %type <statement_> IterationStatement
406 %type <statement_> LabelledStatement
407 %type <expression_> LeftHandSideExpression
408 %type <statement_> LetStatement
409 %type <statement_> LexicalDeclaration
410 %type <literal_> Literal
411 %type <literal_> ValueLiteral
412 %type <expression_> LogicalANDExpression
413 %type <expression_> LogicalORExpression
414 %type <member_> MemberAccess
415 %type <expression_> MemberExpression_
416 %type <expression_> MemberExpression
417 %type <expression_> MultiplicativeExpression
418 %type <expression_> NewExpression
419 %type <null_> NullLiteral
420 %type <literal_> ObjectLiteral
421 %type <compound_> Parenthetical
422 %type <compound_> ParentheticalOpt
423 %type <expression_> PostfixExpression
424 %type <expression_> PrimaryExpression
425 %type <statement_> Program
426 %type <statement_> ProgramBody
427 %type <statement_> ProgramBodyOpt
428 %type <propertyName_> PropertyName_
429 %type <propertyName_> PropertyName
430 %type <property_> PropertyDefinition
431 %type <property_> PropertyDefinitionList_
432 %type <property_> PropertyDefinitionList
433 %type <property_> PropertyDefinitionListOpt
434 %type <expression_> RelationalExpression
435 %type <statement_> ReturnStatement
436 %type <rubyProc_> RubyProcExpression
437 %type <functionParameter_> RubyProcParameterList_
438 %type <functionParameter_> RubyProcParameterList
439 %type <functionParameter_> RubyProcParameters
440 %type <functionParameter_> RubyProcParametersOpt
441 %type <expression_> ShiftExpression
442 %type <declaration_> SingleNameBinding
443 %type <statement_> Statement__
444 %type <statement_> Statement_
445 %type <statement_> Statement
446 %type <statement_> StatementList
447 %type <statement_> StatementListOpt
448 %type <statement_> StatementListItem
449 %type <statement_> SwitchStatement
450 %type <statement_> ThrowStatement
451 %type <statement_> TryStatement
452 %type <expression_> UnaryExpression_
453 %type <expression_> UnaryExpression
454 %type <declaration_> VariableDeclaration
455 %type <declarations_> VariableDeclarationList_
456 %type <declarations_> VariableDeclarationList
457 %type <statement_> VariableStatement
458 %type <statement_> WithStatement
460 %type <word_> WordOpt
461 %type <expression_> Variable
464 %type <expression_> BoxableExpression
465 %type <statement_> CategoryStatement
466 %type <expression_> ClassExpression
467 %type <field_> ClassFieldListOpt
468 %type <field_> ClassFields
469 %type <statement_> ClassStatement
470 %type <expression_> ClassSuperOpt
471 %type <message_> ClassMessageDeclaration
472 %type <message_> ClassMessageDeclarationListOpt
473 %type <className_> ClassName
474 %type <className_> ClassNameOpt
475 %type <protocol_> ClassProtocolListOpt
476 %type <protocol_> ClassProtocols
477 %type <protocol_> ClassProtocolsOpt
478 %type <expression_> EncodedType
479 %type <expression_> MessageExpression
480 %type <messageParameter_> MessageParameter
481 %type <messageParameter_> MessageParameters
482 %type <messageParameter_> MessageParameterList
483 %type <messageParameter_> MessageParameterListOpt
484 %type <bool_> MessageScope
485 %type <type_> ModifiedType
486 %type <typedIdentifier_> PrefixedType
487 %type <expression_> PrimitiveType
488 %type <type_> QualifiedType
489 %type <argument_> SelectorCall_
490 %type <argument_> SelectorCall
491 %type <selector_> SelectorExpression_
492 %type <selector_> SelectorExpression
493 %type <selector_> SelectorExpressionOpt
494 %type <argument_> SelectorList
495 %type <word_> SelectorWordOpt
496 %type <typedIdentifier_> SuffixedType
497 %type <expression_> TypeOpt
498 %type <typedIdentifier_> TypedIdentifier
499 %type <typedParameter_> TypedParameterList_
500 %type <typedParameter_> TypedParameterList
501 %type <typedParameter_> TypedParameterListOpt
502 %type <argument_> VariadicCall
506 %type <propertyIdentifier_> PropertyIdentifier_
507 %type <selector_> PropertySelector_
508 %type <selector_> PropertySelector
509 %type <identifier_> QualifiedIdentifier_
510 %type <identifier_> QualifiedIdentifier
511 %type <identifier_> WildcardIdentifier
512 %type <identifier_> XMLComment
513 %type <identifier_> XMLCDATA
514 %type <identifier_> XMLElement
515 %type <identifier_> XMLElementContent
516 %type <identifier_> XMLMarkup
517 %type <identifier_> XMLPI
519 %type <attribute_> AttributeIdentifier
520 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
521 %type <expression_> PropertyIdentifier
522 %type <expression_> XMLListInitialiser
523 %type <expression_> XMLInitialiser
526 /* Token Priorities {{{ */
538 /* Lexer State {{{ */
540 : { driver.in_.push(true); }
544 : { driver.in_.push(false); }
548 : { driver.in_.pop(); }
552 : { driver.SetCondition(CYDriver::RegExpCondition); }
556 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
560 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
563 LexNoAtImplementation :
565 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
570 : LexNoBrace LexNoFunction LexNoAtImplementation
573 /* Virtual Tokens {{{ */
584 /* 7.6 Identifier Names and Identifiers {{{ */
595 : Identifier { $$ = $1; }
596 | "auto" { $$ = $1; }
597 | "break" NewLineOpt { $$ = $1; }
598 | "case" { $$ = $1; }
599 | "catch" { $$ = $1; }
600 | "class" { $$ = $1; }
601 | "const" { $$ = $1; }
602 | "continue" NewLineOpt { $$ = $1; }
603 | "debugger" { $$ = $1; }
604 | "default" { $$ = $1; }
605 | "delete" { $$ = $1; }
607 | "else" { $$ = $1; }
608 | "enum" { $$ = $1; }
609 | "export" { $$ = $1; }
610 | "extends" { $$ = $1; }
611 | "false" { $$ = $1; }
612 | "finally" { $$ = $1; }
613 /* XXX: | "for" { $$ = $1; } */
614 | "function" { $$ = $1; }
616 | "import" { $$ = $1; }
617 /* XXX: | "in" { $$ = $1; } */
619 /* XXX: | "instanceof" { $$ = $1; } */
621 // XXX: as it currently is not an Identifier
625 | "null" { $$ = $1; }
626 | "return" NewLineOpt { $$ = $1; }
627 | "super" { $$ = $1; }
628 | "switch" { $$ = $1; }
629 | "this" { $$ = $1; }
630 | "throw" NewLineOpt { $$ = $1; }
631 | "true" { $$ = $1; }
633 | "typeof" { $$ = $1; }
635 | "void" { $$ = $1; }
636 | "while" { $$ = $1; }
637 | "with" { $$ = $1; }
646 : Identifier_ { $$ = $1; }
648 | "implements" { $$ = $1; }
649 | "interface" { $$ = $1; }
650 | "package" { $$ = $1; }
651 | "private" { $$ = $1; }
652 | "protected" { $$ = $1; }
653 | "public" { $$ = $1; }
654 | "static" { $$ = $1; }
656 | "abstract" { $$ = $1; }
657 | "boolean" { $$ = $1; }
658 | "byte" { $$ = $1; }
659 | "char" { $$ = $1; }
660 | "double" { $$ = $1; }
661 | "final" { $$ = $1; }
662 | "float" { $$ = $1; }
663 | "goto" { $$ = $1; }
665 | "long" { $$ = $1; }
666 | "native" { $$ = $1; }
667 | "short" { $$ = $1; }
668 | "synchronized" { $$ = $1; }
669 | "throws" { $$ = $1; }
670 | "transient" { $$ = $1; }
671 | "volatile" { $$ = $1; }
673 // XXX: currently I only have this as Word
674 // | "let" { $$ = $1; }
676 | "yield" { $$ = $1; }
678 | "each" { $$ = $1; }
683 : Identifier { $$ = $1; }
688 /* 7.8 Literals {{{ */
690 : NullLiteral { $$ = $1; }
691 | ValueLiteral { $$ = $1; }
695 : BooleanLiteral { $$ = $1; }
696 | NumericLiteral { $$ = $1; }
697 | StringLiteral { $$ = $1; }
698 | RegularExpressionLiteral { $$ = $1; }
701 /* 7.8.1 Null Literals {{{ */
703 : "null" { $$ = $1; }
706 /* 7.8.2 Boolean Literals {{{ */
708 : "true" { $$ = $1; }
709 | "false" { $$ = $1; }
713 /* 7.9 Automatic Semicolon Insertion {{{ */
715 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
720 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
725 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
729 /* 11.1 Primary Expressions {{{ */
731 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
735 : Parenthetical { $$ = $1; }
740 : Identifier { $$ = CYNew CYVariable($1); }
744 : "this" { $$ = $1; }
745 | Variable { $$ = $1; }
746 | Literal { $$ = $1; }
747 | ArrayLiteral { $$ = $1; }
748 | ObjectLiteral { $$ = $1; }
749 | FunctionExpression { $$ = $1; }
750 | Parenthetical { $$ = $1; }
751 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
754 /* 11.1.4.1 Array Initialiser {{{ */
756 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
760 : AssignmentExpression { $$ = $1; }
764 : Element { $$ = $1; }
765 | LexSetRegExp { $$ = NULL; }
769 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
770 | Element { $$ = CYNew CYElement($1, NULL); }
774 : ElementList { $$ = $1; }
775 | LexSetRegExp { $$ = NULL; }
778 /* 11.1.4.2 Array Comprehension {{{ */
780 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
784 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
785 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
788 ComprehensionForListOpt
789 : ComprehensionForList { $$ = $1; }
790 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
794 /* 11.1.5 Object Initialiser {{{ */
796 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
799 PropertyDefinitionList_
800 : "," PropertyDefinitionList { $$ = $2; }
801 | "," LexSetRegExp { $$ = NULL; }
805 PropertyDefinitionList
806 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
809 PropertyDefinitionListOpt
810 : PropertyDefinitionList { $$ = $1; }
811 | LexSetRegExp { $$ = NULL; }
815 // XXX: this should be IdentifierName
816 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
817 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
822 : IdentifierName { $$ = $1; }
823 | StringLiteral { $$ = $1; }
824 | NumericLiteral { $$ = $1; }
828 : LexSetRegExp PropertyName_ { $$ = $2; }
832 /* 11.2 Left-Hand-Side Expressions {{{ */
834 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
835 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
836 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
840 : MemberExpression { $$ = $1; }
841 //| "super" { $$ = $1; }
845 : LexSetRegExp PrimaryExpression { $$ = $2; }
846 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
847 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
851 : MemberExpression { $$ = $1; }
852 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
861 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
862 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
866 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
870 : "," ArgumentList { $$ = $2; }
875 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
879 : ArgumentList { $$ = $1; }
880 | LexSetRegExp { $$ = NULL; }
883 LeftHandSideExpression
884 : NewExpression { $$ = $1; }
885 | CallExpression { $$ = $1; }
888 /* 11.3 Postfix Expressions {{{ */
890 : %prec "" LeftHandSideExpression { $$ = $1; }
891 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
892 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
895 /* 11.4 Unary Operators {{{ */
897 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
898 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
899 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
900 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
901 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
902 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
903 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
904 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
905 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
906 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
907 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
911 : PostfixExpression { $$ = $1; }
912 | LexSetRegExp UnaryExpression_ { $$ = $2; }
915 /* 11.5 Multiplicative Operators {{{ */
916 MultiplicativeExpression
917 : UnaryExpression { $$ = $1; }
918 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
919 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
920 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
923 /* 11.6 Additive Operators {{{ */
925 : MultiplicativeExpression { $$ = $1; }
926 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
927 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
930 /* 11.7 Bitwise Shift Operators {{{ */
932 : AdditiveExpression { $$ = $1; }
933 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
934 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
935 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
938 /* 11.8 Relational Operators {{{ */
940 : ShiftExpression { $$ = $1; }
941 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
942 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
943 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
944 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
945 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
946 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
949 /* 11.9 Equality Operators {{{ */
951 : RelationalExpression { $$ = $1; }
952 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
953 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
954 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
955 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
958 /* 11.10 Binary Bitwise Operators {{{ */
960 : EqualityExpression { $$ = $1; }
961 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
965 : BitwiseANDExpression { $$ = $1; }
966 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
970 : BitwiseXORExpression { $$ = $1; }
971 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
974 /* 11.11 Binary Logical Operators {{{ */
976 : BitwiseORExpression { $$ = $1; }
977 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
981 : LogicalANDExpression { $$ = $1; }
982 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
985 /* 11.12 Conditional Operator ( ? : ) {{{ */
986 ConditionalExpression
987 : LogicalORExpression { $$ = $1; }
988 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
991 /* 11.13 Assignment Operators {{{ */
993 : ConditionalExpression { $$ = $1; }
994 | ArrowFunction { $$ = $1; }
995 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
996 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
997 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
998 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
999 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1000 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1001 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1002 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1003 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1004 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1005 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1006 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1009 /* 11.14 Comma Operator {{{ */
1011 : "," Expression { $$ = $2; }
1012 | { $$ = CYNew CYCompound(); }
1016 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1020 : Expression { $$ = $1; }
1021 | LexSetRegExp { $$ = NULL; }
1025 /* 12 Statements {{{ */
1027 : Block { $$ = $1; }
1028 | VariableStatement { $$ = $1; }
1029 | EmptyStatement { $$ = $1; }
1030 | IfStatement { $$ = $1; }
1031 | BreakableStatement { $$ = $1; }
1032 | ContinueStatement { $$ = $1; }
1033 | BreakStatement { $$ = $1; }
1034 | ReturnStatement { $$ = $1; }
1035 | WithStatement { $$ = $1; }
1036 | LabelledStatement { $$ = $1; }
1037 | ThrowStatement { $$ = $1; }
1038 | TryStatement { $$ = $1; }
1039 | DebuggerStatement { $$ = $1; }
1043 : LexSetRegExp Statement__ { $$ = $2; }
1044 | ExpressionStatement { $$ = $1; }
1048 : LexSetStatement Statement_ { $$ = $2; }
1052 : FunctionDeclaration { $$ = $1; }
1053 | LexicalDeclaration { $$ = $1; }
1057 : LexSetRegExp Declaration__ { $$ = $2; }
1061 : LexSetStatement Declaration_ { $$ = $2; }
1065 : IterationStatement { $$ = $1; }
1066 | SwitchStatement { $$ = $1; }
1069 /* 12.1 Block {{{ */
1071 : BRACE StatementListOpt "}" { $$ = $2; }
1075 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1079 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1083 : StatementList { $$ = $1; }
1084 | LexSetStatement LexSetRegExp { $$ = NULL; }
1088 : Statement { $$ = $1; }
1089 | Declaration { $$ = $1; }
1093 /* 12.2 Declarations {{{ */
1095 : Identifier { $$ = $1; }
1102 // XXX: BindingPattern
1104 /* 12.2.1 Let and Const Declarations {{{ */
1106 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1114 /* 12.2.2 Variable Statement {{{ */
1116 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1119 VariableDeclarationList_
1120 : "," VariableDeclarationList { $$ = $2; }
1124 VariableDeclarationList
1125 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1129 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1130 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1134 : "=" AssignmentExpression { $$ = $2; }
1138 : Initialiser { $$ = $1; }
1142 /* 12.2.4 Destructuring Binding Patterns {{{ */
1146 : SingleNameBinding { $$ = $1; }
1150 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1154 /* 12.3 Empty Statement {{{ */
1156 : ";" { $$ = CYNew CYEmpty(); }
1159 /* 12.4 Expression Statement {{{ */
1161 : Expression Terminator { $$ = CYNew CYExpress($1); }
1164 /* 12.5 The if Statement {{{ */
1166 : "else" Statement { $$ = $2; }
1167 | %prec "if" { $$ = NULL; }
1171 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1175 /* 12.6.1 The do-while Statement {{{ */
1177 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1180 /* 12.6.2 The while Statement {{{ */
1182 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1185 /* 12.6.3 The for Statement {{{ */
1187 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1190 ForStatementInitialiser
1191 : ExpressionOpt { $$ = $1; }
1192 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1195 /* 12.6.4 The for-in and for-of Statements {{{ */
1197 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1198 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1201 ForInStatementInitialiser
1202 : LeftHandSideExpression { $$ = $1; }
1203 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1207 /* 12.7 The continue Statement {{{ */
1209 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1210 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1213 /* 12.8 The break Statement {{{ */
1215 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1216 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1219 /* 12.9 The return Statement {{{ */
1221 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1222 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1225 /* 12.10 The with Statement {{{ */
1227 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1231 /* 12.11 The switch Statement {{{ */
1233 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1237 : BRACE CaseClausesOpt "}" { $$ = $2; }
1241 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1245 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1246 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1251 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1254 /* 12.12 Labelled Statements {{{ */
1256 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1259 /* 12.13 The throw Statement {{{ */
1261 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1262 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1265 /* 12.14 The try Statement {{{ */
1267 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1271 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1276 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1280 /* 12.14 The debugger Statement {{{ */
1282 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1286 /* 13.1 Function Definitions {{{ */
1288 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1292 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1295 FormalParameterList_
1296 : "," FormalParameterList { $$ = $2; }
1301 // XXX: : FunctionRestParameter { $$ = $1; }
1302 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1305 FormalParameterListOpt
1306 : FormalParameterList
1310 /* XXX: FunctionRestParameter
1311 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1315 : BindingElement { $$ = $1; }
1319 : StatementListOpt { $$ = $1; }
1322 /* 13.2 Arrow Function Definitions {{{ */
1324 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1328 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1329 //| ParentheticalOpt { $$ = $1; }
1333 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1334 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1337 /* 14 Program {{{ */
1339 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1343 : StatementList { $$ = $1; }
1347 : ProgramBody { $$ = $1; }
1348 | LexSetStatement LexSetRegExp { $$ = NULL; }
1353 /* Cycript (Objective-C): Type Encoding {{{ */
1355 : IdentifierOpt { $$ = CYNew CYTypedIdentifier($1); }
1356 | "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1357 | SuffixedType "[" NumericLiteral "]" { CYSetLast($1->type_) = CYNew CYTypeArrayOf($3); $$ = $1; }
1361 : SuffixedType { $$ = $1; }
1362 | "const" PrefixedType { CYSetLast($2->type_) = CYNew CYTypeConstant(); $$ = $2; }
1363 | "*" PrefixedType { CYSetLast($2->type_) = CYNew CYTypePointerTo(); $$ = $2; }
1367 : Variable { $$ = $1; }
1368 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1372 : PrimitiveType { $$ = CYNew CYTypeVariable($1); }
1373 | "const" QualifiedType { $$ = CYNew CYTypeConstant($2); }
1377 : QualifiedType { $$ = $1; }
1378 | QualifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1379 | QualifiedType "const" { $$ = CYNew CYTypeConstant($1); }
1383 : QualifiedType PrefixedType { CYSetLast($2->type_) = $1; $$ = $2;}
1387 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1391 : AtEncode "(" EncodedType ")" { $$ = $3; }
1394 /* Cycript (Objective-C): @class Declaration {{{ */
1396 /* XXX: why the hell did I choose MemberExpression? */
1397 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1402 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1403 | LexSetRegExp { $$ = NULL; }
1407 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1411 : "+" { $$ = false; }
1412 | "-" { $$ = true; }
1416 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1421 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1424 MessageParameterList
1425 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1428 MessageParameterListOpt
1429 : MessageParameterList { $$ = $1; }
1434 : MessageParameterList { $$ = $1; }
1435 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1438 ClassMessageDeclaration
1439 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1442 ClassMessageDeclarationListOpt
1443 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1444 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1449 : Identifier { $$ = $1; }
1450 | "(" AssignmentExpression ")" { $$ = $2; }
1454 : ClassName { $$ = $1; }
1458 // XXX: this should be AssignmentExpressionNoRight
1460 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1464 : "," ClassProtocols { $$ = $2; }
1468 ClassProtocolListOpt
1469 : "<" ClassProtocols ">" { $$ = $2; }
1474 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1478 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1486 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1490 : ClassExpression { $$ = $1; }
1494 : ClassStatement { $$ = $1; }
1495 | CategoryStatement { $$ = $1; }
1498 /* Cycript (Objective-C): Send Message {{{ */
1500 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1505 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1506 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1510 : SelectorCall { $$ = $1; }
1511 | VariadicCall { $$ = $1; }
1515 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1519 : SelectorCall { $$ = $1; }
1520 | Word { $$ = CYNew CYArgument($1, NULL); }
1524 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1525 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1529 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1533 : SelectorExpression_ { $$ = $1; }
1534 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1537 SelectorExpressionOpt
1538 : SelectorExpression_ { $$ = $1; }
1543 : MessageExpression { $$ = $1; }
1544 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1547 /* Cycript (Objective-C): @import Directive {{{ */
1561 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1564 /* Cycript (Objective-C): Boxed Expressions {{{ */
1566 : NullLiteral { $$ = $1; }
1567 | BooleanLiteral { $$ = $1; }
1568 | NumericLiteral { $$ = $1; }
1569 | StringLiteral { $$ = $1; }
1570 | ArrayLiteral { $$ = $1; }
1571 | ObjectLiteral { $$ = $1; }
1572 | Parenthetical { $$ = $1; }
1576 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1579 /* Cycript (Objective-C): Block Expressions {{{ */
1581 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1587 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1588 LeftHandSideExpression
1589 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1593 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1597 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1598 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1599 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1602 /* Cycript (C): auto Compatibility {{{ */
1607 /* Cycript (C): Lambda Expressions {{{ */
1609 : "," TypedParameterList { $$ = $2; }
1614 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1617 TypedParameterListOpt
1618 : TypedParameterList { $$ = $1; }
1623 : "[" LexPushInOff LexSetRegExp "=" "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" ModifiedType BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($13, $9, $16); }
1628 /* YUI: Documentation Comments {{{ */
1630 : Comment { $$ = $1; }
1635 /* Lexer State {{{ */
1637 : { driver.PushCondition(CYDriver::RegExpCondition); }
1641 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1645 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1649 : { driver.PopCondition(); }
1653 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1657 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1660 /* Virtual Tokens {{{ */
1667 /* 8.1 Context Keywords {{{ */
1669 : "namespace" { $$ = $1; }
1670 | "xml" { $$ = $1; }
1673 /* 8.3 XML Initialiser Input Elements {{{ */
1675 : XMLComment { $$ = $1; }
1676 | XMLCDATA { $$ = $1; }
1677 | XMLPI { $$ = $1; }
1681 /* 11.1 Primary Expressions {{{ */
1683 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1684 | XMLInitialiser { $$ = $1; }
1685 | XMLListInitialiser { $$ = $1; }
1689 : AttributeIdentifier { $$ = $1; }
1690 | QualifiedIdentifier { $$ = $1; }
1691 | WildcardIdentifier { $$ = $1; }
1694 /* 11.1.1 Attribute Identifiers {{{ */
1696 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1700 : PropertySelector { $$ = $1; }
1701 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1705 : Identifier { $$ = CYNew CYSelector($1); }
1706 | WildcardIdentifier { $$ = $1; }
1709 /* 11.1.2 Qualified Identifiers {{{ */
1710 QualifiedIdentifier_
1711 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1712 | QualifiedIdentifier { $$ = $1; }
1716 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1719 /* 11.1.3 Wildcard Identifiers {{{ */
1721 : "*" { $$ = CYNew CYWildcard(); }
1724 /* 11.1.4 XML Initialiser {{{ */
1726 : XMLMarkup { $$ = $1; }
1727 | XMLElement { $$ = $1; }
1731 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1732 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1736 : LexPushXMLTag XMLTagName XMLAttributes
1740 : BRACE LexPushRegExp Expression LexPop "}"
1749 : XMLAttributes_ XMLAttribute
1754 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1755 | XMLAttributes_ XMLWhitespaceOpt
1764 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1768 : XMLExpression XMLElementContentOpt
1769 | XMLMarkup XMLElementContentOpt
1770 | XMLText XMLElementContentOpt
1771 | XMLElement XMLElementContentOpt
1774 XMLElementContentOpt
1779 /* 11.1.5 XMLList Initialiser {{{ */
1781 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1785 /* 11.2 Left-Hand-Side Expressions {{{ */
1787 : Identifier { $$ = $1; }
1788 | PropertyIdentifier { $$ = $1; }
1792 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1793 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1794 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1797 /* 12.1 The default xml namespace Statement {{{ */
1798 /* XXX: DefaultXMLNamespaceStatement
1799 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1803 : DefaultXMLNamespaceStatement { $$ = $1; }
1808 /* JavaScript 1.7: Array Comprehensions {{{ */
1810 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1814 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1815 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1819 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1822 ComprehensionListOpt
1823 : ComprehensionList { $$ = $1; }
1824 | IfComprehension { $$ = $1; }
1829 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1832 /* JavaScript 1.7: for each {{{ */
1834 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1837 /* JavaScript 1.7: let Statements {{{ */
1839 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1847 /* JavaScript FTW: Ruby Blocks {{{ */
1848 RubyProcParameterList_
1849 : "," RubyProcParameterList { $$ = $2; }
1853 RubyProcParameterList
1854 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1859 : "|" RubyProcParameterList "|" { $$ = $2; }
1860 | "||" { $$ = NULL; }
1863 RubyProcParametersOpt
1864 : RubyProcParameters
1869 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1873 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1877 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }