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 "]"
228 %token AtClass "@class"
232 %token AtImplementation "@implementation"
233 %token AtImplementation_ ";@implementation"
234 %token AtImport "@import"
235 %token AtEncode "@encode"
237 %token AtSelector "@selector"
240 %token <false_> False "false"
241 %token <null_> Null "null"
242 %token <true_> True "true"
244 // ES3/ES5/WIE/JSC Reserved
245 %token <word_> Auto "auto"
246 %token <word_> Break "break"
247 %token <word_> Case "case"
248 %token <word_> Catch "catch"
249 %token <word_> Continue "continue"
250 %token <word_> Default "default"
251 %token <word_> Delete "delete"
252 %token <word_> Do "do"
253 %token <word_> Else "else"
254 %token <word_> Finally "finally"
255 %token <word_> For "for"
256 %token <word_> Function "function"
257 %token <word_> Function_ ";function"
258 %token <word_> If "if"
259 %token <word_> In "in"
260 %token <word_> In_ "!in"
261 %token <word_> InstanceOf "instanceof"
262 %token <word_> New "new"
263 %token <word_> Return "return"
264 %token <word_> Switch "switch"
265 %token <this_> This "this"
266 %token <word_> Throw "throw"
267 %token <word_> Try "try"
268 %token <word_> TypeOf "typeof"
269 %token <word_> Var "var"
270 %token <word_> Void "void"
271 %token <word_> While "while"
272 %token <word_> With "with"
274 // ES3/IE6 Future, ES5/JSC Reserved
275 %token <word_> Debugger "debugger"
277 // ES3/ES5/IE6 Future, JSC Reserved
278 %token <word_> Const "const"
280 // ES3/ES5/IE6/JSC Future
281 %token <word_> Class "class"
282 %token <word_> Enum "enum"
283 %token <word_> Export "export"
284 %token <word_> Extends "extends"
285 %token <word_> Import "import"
286 %token <word_> Super "super"
288 // ES3 Future, ES5 Strict Future
289 %token <identifier_> Implements "implements"
290 %token <identifier_> Interface "interface"
291 %token <identifier_> Package "package"
292 %token <identifier_> Private "private"
293 %token <identifier_> Protected "protected"
294 %token <identifier_> Public "public"
295 %token <identifier_> Static "static"
298 %token <identifier_> Abstract "abstract"
299 %token <identifier_> Boolean "boolean"
300 %token <identifier_> Byte "byte"
301 %token <identifier_> Char "char"
302 %token <identifier_> Double "double"
303 %token <identifier_> Final "final"
304 %token <identifier_> Float "float"
305 %token <identifier_> Goto "goto"
306 %token <identifier_> Int "int"
307 %token <identifier_> Long "long"
308 %token <identifier_> Native "native"
309 %token <identifier_> Short "short"
310 %token <identifier_> Synchronized "synchronized"
311 %token <identifier_> Throws "throws"
312 %token <identifier_> Transient "transient"
313 %token <identifier_> Volatile "volatile"
316 %token <identifier_> Let "let"
317 %token <identifier_> Yield "yield"
320 %token <identifier_> Each "each"
321 %token <identifier_> Of "of"
325 %token <identifier_> Namespace "namespace"
326 %token <identifier_> XML "xml"
331 %token <identifier_> Identifier_
332 %token <number_> NumericLiteral
333 %token <string_> StringLiteral
334 %token <literal_> RegularExpressionLiteral
336 %type <expression_> AdditiveExpression
337 %type <argument_> ArgumentList_
338 %type <argument_> ArgumentList
339 %type <argument_> ArgumentListOpt
340 %type <argument_> Arguments
341 %type <literal_> ArrayLiteral
342 %type <expression_> ArrowFunction
343 %type <functionParameter_> ArrowParameters
344 %type <expression_> AssignmentExpression
345 %type <identifier_> Binding
346 %type <identifier_> BindingIdentifier
347 %type <expression_> BitwiseANDExpression
348 %type <statement_> Block_
349 %type <statement_> Block
350 %type <boolean_> BooleanLiteral
351 %type <declaration_> BindingElement
352 %type <expression_> BitwiseORExpression
353 %type <expression_> BitwiseXORExpression
354 %type <statement_> BreakStatement
355 %type <statement_> BreakableStatement
356 %type <expression_> CallExpression_
357 %type <expression_> CallExpression
358 %type <clause_> CaseBlock
359 %type <clause_> CaseClause
360 %type <clause_> CaseClausesOpt
361 %type <catch_> CatchOpt
362 %type <comprehension_> ComprehensionForList
363 %type <comprehension_> ComprehensionForListOpt
364 %type <comprehension_> ComprehensionList
365 %type <comprehension_> ComprehensionListOpt
366 %type <expression_> ConditionalExpression
367 %type <statement_> ContinueStatement
368 %type <statement_> ConciseBody
369 %type <statement_> DebuggerStatement
370 %type <statement_> Declaration__
371 %type <statement_> Declaration_
372 %type <statement_> Declaration
373 %type <clause_> DefaultClause
374 %type <expression_> Element
375 %type <expression_> ElementOpt
376 %type <element_> ElementList
377 %type <element_> ElementListOpt
378 %type <statement_> ElseStatementOpt
379 %type <statement_> EmptyStatement
380 %type <expression_> EqualityExpression
381 %type <compound_> Expression_
382 %type <compound_> Expression
383 %type <expression_> ExpressionOpt
384 %type <statement_> ExpressionStatement
385 %type <finally_> FinallyOpt
386 %type <comprehension_> ForComprehension
387 %type <for_> ForStatementInitialiser
388 %type <forin_> ForInStatementInitialiser
389 %type <declaration_> FormalParameter
390 %type <functionParameter_> FormalParameterList_
391 %type <functionParameter_> FormalParameterList
392 %type <functionParameter_> FormalParameterListOpt
393 %type <statement_> FunctionBody
394 %type <statement_> FunctionDeclaration
395 %type <expression_> FunctionExpression
396 %type <identifier_> Identifier
397 %type <identifier_> IdentifierOpt
398 %type <word_> IdentifierName
399 %type <comprehension_> IfComprehension
400 %type <statement_> IfStatement
401 %type <expression_> Initialiser
402 %type <expression_> InitialiserOpt
403 %type <statement_> IterationStatement
404 %type <statement_> LabelledStatement
405 %type <expression_> LeftHandSideExpression
406 %type <statement_> LetStatement
407 %type <statement_> LexicalDeclaration
408 %type <literal_> Literal
409 %type <literal_> ValueLiteral
410 %type <expression_> LogicalANDExpression
411 %type <expression_> LogicalORExpression
412 %type <member_> MemberAccess
413 %type <expression_> MemberExpression_
414 %type <expression_> MemberExpression
415 %type <expression_> MultiplicativeExpression
416 %type <expression_> NewExpression
417 %type <null_> NullLiteral
418 %type <literal_> ObjectLiteral
419 %type <compound_> Parenthetical
420 %type <compound_> ParentheticalOpt
421 %type <expression_> PostfixExpression
422 %type <expression_> PrimaryExpression
423 %type <statement_> Program
424 %type <statement_> ProgramBody
425 %type <statement_> ProgramBodyOpt
426 %type <propertyName_> PropertyName_
427 %type <propertyName_> PropertyName
428 %type <property_> PropertyDefinition
429 %type <property_> PropertyDefinitionList_
430 %type <property_> PropertyDefinitionList
431 %type <property_> PropertyDefinitionListOpt
432 %type <expression_> RelationalExpression
433 %type <statement_> ReturnStatement
434 %type <rubyProc_> RubyProcExpression
435 %type <functionParameter_> RubyProcParameterList_
436 %type <functionParameter_> RubyProcParameterList
437 %type <functionParameter_> RubyProcParameters
438 %type <functionParameter_> RubyProcParametersOpt
439 %type <expression_> ShiftExpression
440 %type <declaration_> SingleNameBinding
441 %type <statement_> Statement__
442 %type <statement_> Statement_
443 %type <statement_> Statement
444 %type <statement_> StatementList
445 %type <statement_> StatementListOpt
446 %type <statement_> StatementListItem
447 %type <statement_> SwitchStatement
448 %type <statement_> ThrowStatement
449 %type <statement_> TryStatement
450 %type <expression_> UnaryExpression_
451 %type <expression_> UnaryExpression
452 %type <declaration_> VariableDeclaration
453 %type <declarations_> VariableDeclarationList_
454 %type <declarations_> VariableDeclarationList
455 %type <statement_> VariableStatement
456 %type <statement_> WithStatement
458 %type <word_> WordOpt
459 %type <expression_> Variable
462 %type <expression_> BoxableExpression
463 %type <statement_> CategoryStatement
464 %type <expression_> ClassExpression
465 %type <field_> ClassFieldListOpt
466 %type <field_> ClassFields
467 %type <statement_> ClassStatement
468 %type <expression_> ClassSuperOpt
469 %type <message_> ClassMessageDeclaration
470 %type <message_> ClassMessageDeclarationListOpt
471 %type <className_> ClassName
472 %type <className_> ClassNameOpt
473 %type <protocol_> ClassProtocolListOpt
474 %type <protocol_> ClassProtocols
475 %type <protocol_> ClassProtocolsOpt
476 %type <expression_> EncodedType
477 %type <expression_> MessageExpression
478 %type <messageParameter_> MessageParameter
479 %type <messageParameter_> MessageParameters
480 %type <messageParameter_> MessageParameterList
481 %type <messageParameter_> MessageParameterListOpt
482 %type <bool_> MessageScope
483 %type <type_> ModifiedType
484 %type <typedIdentifier_> PrefixedType
485 %type <expression_> PrimitiveType
486 %type <type_> QualifiedType
487 %type <argument_> SelectorCall_
488 %type <argument_> SelectorCall
489 %type <selector_> SelectorExpression_
490 %type <selector_> SelectorExpression
491 %type <selector_> SelectorExpressionOpt
492 %type <argument_> SelectorList
493 %type <word_> SelectorWordOpt
494 %type <typedIdentifier_> SuffixedType
495 %type <expression_> TypeOpt
496 %type <typedIdentifier_> TypedIdentifier
497 %type <typedParameter_> TypedParameterList_
498 %type <typedParameter_> TypedParameterList
499 %type <typedParameter_> TypedParameterListOpt
500 %type <argument_> VariadicCall
504 %type <propertyIdentifier_> PropertyIdentifier_
505 %type <selector_> PropertySelector_
506 %type <selector_> PropertySelector
507 %type <identifier_> QualifiedIdentifier_
508 %type <identifier_> QualifiedIdentifier
509 %type <identifier_> WildcardIdentifier
510 %type <identifier_> XMLComment
511 %type <identifier_> XMLCDATA
512 %type <identifier_> XMLElement
513 %type <identifier_> XMLElementContent
514 %type <identifier_> XMLMarkup
515 %type <identifier_> XMLPI
517 %type <attribute_> AttributeIdentifier
518 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
519 %type <expression_> PropertyIdentifier
520 %type <expression_> XMLListInitialiser
521 %type <expression_> XMLInitialiser
524 /* Token Priorities {{{ */
536 /* Lexer State {{{ */
538 : { driver.in_.push(true); }
542 : { driver.in_.push(false); }
546 : { driver.in_.pop(); }
550 : { driver.SetCondition(CYDriver::RegExpCondition); }
554 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
558 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
561 LexNoAtImplementation :
563 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
568 : LexNoBrace LexNoFunction LexNoAtImplementation
571 /* Virtual Tokens {{{ */
582 /* 7.6 Identifier Names and Identifiers {{{ */
593 : Identifier { $$ = $1; }
594 | "auto" { $$ = $1; }
595 | "break" NewLineOpt { $$ = $1; }
596 | "case" { $$ = $1; }
597 | "catch" { $$ = $1; }
598 | "class" { $$ = $1; }
599 | "const" { $$ = $1; }
600 | "continue" NewLineOpt { $$ = $1; }
601 | "debugger" { $$ = $1; }
602 | "default" { $$ = $1; }
603 | "delete" { $$ = $1; }
605 | "else" { $$ = $1; }
606 | "enum" { $$ = $1; }
607 | "export" { $$ = $1; }
608 | "extends" { $$ = $1; }
609 | "false" { $$ = $1; }
610 | "finally" { $$ = $1; }
611 /* XXX: | "for" { $$ = $1; } */
612 | "function" { $$ = $1; }
614 | "import" { $$ = $1; }
615 /* XXX: | "in" { $$ = $1; } */
617 /* XXX: | "instanceof" { $$ = $1; } */
619 // XXX: as it currently is not an Identifier
623 | "null" { $$ = $1; }
624 | "return" NewLineOpt { $$ = $1; }
625 | "super" { $$ = $1; }
626 | "switch" { $$ = $1; }
627 | "this" { $$ = $1; }
628 | "throw" NewLineOpt { $$ = $1; }
629 | "true" { $$ = $1; }
631 | "typeof" { $$ = $1; }
633 | "void" { $$ = $1; }
634 | "while" { $$ = $1; }
635 | "with" { $$ = $1; }
644 : Identifier_ { $$ = $1; }
646 | "implements" { $$ = $1; }
647 | "interface" { $$ = $1; }
648 | "package" { $$ = $1; }
649 | "private" { $$ = $1; }
650 | "protected" { $$ = $1; }
651 | "public" { $$ = $1; }
652 | "static" { $$ = $1; }
654 | "abstract" { $$ = $1; }
655 | "boolean" { $$ = $1; }
656 | "byte" { $$ = $1; }
657 | "char" { $$ = $1; }
658 | "double" { $$ = $1; }
659 | "final" { $$ = $1; }
660 | "float" { $$ = $1; }
661 | "goto" { $$ = $1; }
663 | "long" { $$ = $1; }
664 | "native" { $$ = $1; }
665 | "short" { $$ = $1; }
666 | "synchronized" { $$ = $1; }
667 | "throws" { $$ = $1; }
668 | "transient" { $$ = $1; }
669 | "volatile" { $$ = $1; }
671 // XXX: currently I only have this as Word
672 // | "let" { $$ = $1; }
674 | "yield" { $$ = $1; }
676 | "each" { $$ = $1; }
681 : Identifier { $$ = $1; }
686 /* 7.8 Literals {{{ */
688 : NullLiteral { $$ = $1; }
689 | ValueLiteral { $$ = $1; }
693 : BooleanLiteral { $$ = $1; }
694 | NumericLiteral { $$ = $1; }
695 | StringLiteral { $$ = $1; }
696 | RegularExpressionLiteral { $$ = $1; }
699 /* 7.8.1 Null Literals {{{ */
701 : "null" { $$ = $1; }
704 /* 7.8.2 Boolean Literals {{{ */
706 : "true" { $$ = $1; }
707 | "false" { $$ = $1; }
711 /* 7.9 Automatic Semicolon Insertion {{{ */
713 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
718 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
723 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
727 /* 11.1 Primary Expressions {{{ */
729 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
733 : Parenthetical { $$ = $1; }
738 : Identifier { $$ = CYNew CYVariable($1); }
742 : "this" { $$ = $1; }
743 | Variable { $$ = $1; }
744 | Literal { $$ = $1; }
745 | ArrayLiteral { $$ = $1; }
746 | ObjectLiteral { $$ = $1; }
747 | FunctionExpression { $$ = $1; }
748 | Parenthetical { $$ = $1; }
749 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
752 /* 11.1.4.1 Array Initialiser {{{ */
754 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
758 : AssignmentExpression { $$ = $1; }
762 : Element { $$ = $1; }
763 | LexSetRegExp { $$ = NULL; }
767 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
768 | Element { $$ = CYNew CYElement($1, NULL); }
772 : ElementList { $$ = $1; }
773 | LexSetRegExp { $$ = NULL; }
776 /* 11.1.4.2 Array Comprehension {{{ */
778 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
782 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
783 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
786 ComprehensionForListOpt
787 : ComprehensionForList { $$ = $1; }
788 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
792 /* 11.1.5 Object Initialiser {{{ */
794 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
797 PropertyDefinitionList_
798 : "," PropertyDefinitionList { $$ = $2; }
799 | "," LexSetRegExp { $$ = NULL; }
803 PropertyDefinitionList
804 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
807 PropertyDefinitionListOpt
808 : PropertyDefinitionList { $$ = $1; }
809 | LexSetRegExp { $$ = NULL; }
813 // XXX: this should be IdentifierName
814 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
815 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
820 : IdentifierName { $$ = $1; }
821 | StringLiteral { $$ = $1; }
822 | NumericLiteral { $$ = $1; }
826 : LexSetRegExp PropertyName_ { $$ = $2; }
830 /* 11.2 Left-Hand-Side Expressions {{{ */
832 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
833 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
834 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
838 : MemberExpression { $$ = $1; }
839 //| "super" { $$ = $1; }
843 : LexSetRegExp PrimaryExpression { $$ = $2; }
844 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
845 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
849 : MemberExpression { $$ = $1; }
850 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
859 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
860 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
864 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
868 : "," ArgumentList { $$ = $2; }
873 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
877 : ArgumentList { $$ = $1; }
878 | LexSetRegExp { $$ = NULL; }
881 LeftHandSideExpression
882 : NewExpression { $$ = $1; }
883 | CallExpression { $$ = $1; }
886 /* 11.3 Postfix Expressions {{{ */
888 : %prec "" LeftHandSideExpression { $$ = $1; }
889 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
890 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
893 /* 11.4 Unary Operators {{{ */
895 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
896 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
897 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
898 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
899 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
900 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
901 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
902 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
903 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
904 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
905 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
909 : PostfixExpression { $$ = $1; }
910 | LexSetRegExp UnaryExpression_ { $$ = $2; }
913 /* 11.5 Multiplicative Operators {{{ */
914 MultiplicativeExpression
915 : UnaryExpression { $$ = $1; }
916 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
917 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
918 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
921 /* 11.6 Additive Operators {{{ */
923 : MultiplicativeExpression { $$ = $1; }
924 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
925 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
928 /* 11.7 Bitwise Shift Operators {{{ */
930 : AdditiveExpression { $$ = $1; }
931 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
932 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
933 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
936 /* 11.8 Relational Operators {{{ */
938 : ShiftExpression { $$ = $1; }
939 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
940 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
941 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
942 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
943 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
944 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
947 /* 11.9 Equality Operators {{{ */
949 : RelationalExpression { $$ = $1; }
950 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
951 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
952 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
953 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
956 /* 11.10 Binary Bitwise Operators {{{ */
958 : EqualityExpression { $$ = $1; }
959 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
963 : BitwiseANDExpression { $$ = $1; }
964 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
968 : BitwiseXORExpression { $$ = $1; }
969 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
972 /* 11.11 Binary Logical Operators {{{ */
974 : BitwiseORExpression { $$ = $1; }
975 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
979 : LogicalANDExpression { $$ = $1; }
980 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
983 /* 11.12 Conditional Operator ( ? : ) {{{ */
984 ConditionalExpression
985 : LogicalORExpression { $$ = $1; }
986 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
989 /* 11.13 Assignment Operators {{{ */
991 : ConditionalExpression { $$ = $1; }
992 | ArrowFunction { $$ = $1; }
993 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
994 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
995 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
996 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
997 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
998 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
999 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1000 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1001 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1002 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1003 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1004 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1007 /* 11.14 Comma Operator {{{ */
1009 : "," Expression { $$ = $2; }
1010 | { $$ = CYNew CYCompound(); }
1014 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1018 : Expression { $$ = $1; }
1019 | LexSetRegExp { $$ = NULL; }
1023 /* 12 Statements {{{ */
1025 : Block { $$ = $1; }
1026 | VariableStatement { $$ = $1; }
1027 | EmptyStatement { $$ = $1; }
1028 | IfStatement { $$ = $1; }
1029 | BreakableStatement { $$ = $1; }
1030 | ContinueStatement { $$ = $1; }
1031 | BreakStatement { $$ = $1; }
1032 | ReturnStatement { $$ = $1; }
1033 | WithStatement { $$ = $1; }
1034 | LabelledStatement { $$ = $1; }
1035 | ThrowStatement { $$ = $1; }
1036 | TryStatement { $$ = $1; }
1037 | DebuggerStatement { $$ = $1; }
1041 : LexSetRegExp Statement__ { $$ = $2; }
1042 | ExpressionStatement { $$ = $1; }
1046 : LexSetStatement Statement_ { $$ = $2; }
1050 : FunctionDeclaration { $$ = $1; }
1051 | LexicalDeclaration { $$ = $1; }
1055 : LexSetRegExp Declaration__ { $$ = $2; }
1059 : LexSetStatement Declaration_ { $$ = $2; }
1063 : IterationStatement { $$ = $1; }
1064 | SwitchStatement { $$ = $1; }
1067 /* 12.1 Block {{{ */
1069 : BRACE StatementListOpt "}" { $$ = $2; }
1073 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1077 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1081 : StatementList { $$ = $1; }
1082 | LexSetStatement LexSetRegExp { $$ = NULL; }
1086 : Statement { $$ = $1; }
1087 | Declaration { $$ = $1; }
1091 /* 12.2 Declarations {{{ */
1093 : Identifier { $$ = $1; }
1100 // XXX: BindingPattern
1102 /* 12.2.1 Let and Const Declarations {{{ */
1104 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1112 /* 12.2.2 Variable Statement {{{ */
1114 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1117 VariableDeclarationList_
1118 : "," VariableDeclarationList { $$ = $2; }
1122 VariableDeclarationList
1123 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1127 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1128 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1132 : "=" AssignmentExpression { $$ = $2; }
1136 : Initialiser { $$ = $1; }
1140 /* 12.2.4 Destructuring Binding Patterns {{{ */
1144 : SingleNameBinding { $$ = $1; }
1148 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1152 /* 12.3 Empty Statement {{{ */
1154 : ";" { $$ = CYNew CYEmpty(); }
1157 /* 12.4 Expression Statement {{{ */
1159 : Expression Terminator { $$ = CYNew CYExpress($1); }
1162 /* 12.5 The if Statement {{{ */
1164 : "else" Statement { $$ = $2; }
1165 | %prec "if" { $$ = NULL; }
1169 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1173 /* 12.6.1 The do-while Statement {{{ */
1175 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1178 /* 12.6.2 The while Statement {{{ */
1180 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1183 /* 12.6.3 The for Statement {{{ */
1185 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1188 ForStatementInitialiser
1189 : ExpressionOpt { $$ = $1; }
1190 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1193 /* 12.6.4 The for-in and for-of Statements {{{ */
1195 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1196 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1199 ForInStatementInitialiser
1200 : LeftHandSideExpression { $$ = $1; }
1201 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1205 /* 12.7 The continue Statement {{{ */
1207 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1208 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1211 /* 12.8 The break Statement {{{ */
1213 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1214 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1217 /* 12.9 The return Statement {{{ */
1219 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1220 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1223 /* 12.10 The with Statement {{{ */
1225 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1229 /* 12.11 The switch Statement {{{ */
1231 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1235 : BRACE CaseClausesOpt "}" { $$ = $2; }
1239 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1243 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1244 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1249 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1252 /* 12.12 Labelled Statements {{{ */
1254 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1257 /* 12.13 The throw Statement {{{ */
1259 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1260 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1263 /* 12.14 The try Statement {{{ */
1265 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1269 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1274 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1278 /* 12.14 The debugger Statement {{{ */
1280 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1284 /* 13.1 Function Definitions {{{ */
1286 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1290 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1293 FormalParameterList_
1294 : "," FormalParameterList { $$ = $2; }
1299 // XXX: : FunctionRestParameter { $$ = $1; }
1300 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1303 FormalParameterListOpt
1304 : FormalParameterList
1308 /* XXX: FunctionRestParameter
1309 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1313 : BindingElement { $$ = $1; }
1317 : StatementListOpt { $$ = $1; }
1320 /* 13.2 Arrow Function Definitions {{{ */
1322 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1326 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1327 //| ParentheticalOpt { $$ = $1; }
1331 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1332 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1335 /* 14 Program {{{ */
1337 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1341 : StatementList { $$ = $1; }
1345 : ProgramBody { $$ = $1; }
1346 | LexSetStatement LexSetRegExp { $$ = NULL; }
1351 /* Cycript (Objective-C): Type Encoding {{{ */
1353 : IdentifierOpt { $$ = CYNew CYTypedIdentifier($1); }
1354 | "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1355 | SuffixedType "[" NumericLiteral "]" { CYSetLast($1->type_) = CYNew CYTypeArrayOf($3); $$ = $1; }
1359 : SuffixedType { $$ = $1; }
1360 | "const" PrefixedType { CYSetLast($2->type_) = CYNew CYTypeConstant(); $$ = $2; }
1361 | "*" PrefixedType { CYSetLast($2->type_) = CYNew CYTypePointerTo(); $$ = $2; }
1365 : Variable { $$ = $1; }
1366 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1370 : PrimitiveType { $$ = CYNew CYTypeVariable($1); }
1371 | "const" QualifiedType { $$ = CYNew CYTypeConstant($2); }
1375 : QualifiedType { $$ = $1; }
1376 | QualifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1377 | QualifiedType "const" { $$ = CYNew CYTypeConstant($1); }
1381 : QualifiedType PrefixedType { CYSetLast($2->type_) = $1; $$ = $2;}
1385 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1389 : AtEncode "(" EncodedType ")" { $$ = $3; }
1392 /* Cycript (Objective-C): @class Declaration {{{ */
1394 /* XXX: why the hell did I choose MemberExpression? */
1395 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1400 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1401 | LexSetRegExp { $$ = NULL; }
1405 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1409 : "+" { $$ = false; }
1410 | "-" { $$ = true; }
1414 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1419 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1422 MessageParameterList
1423 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1426 MessageParameterListOpt
1427 : MessageParameterList { $$ = $1; }
1432 : MessageParameterList { $$ = $1; }
1433 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1436 ClassMessageDeclaration
1437 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1440 ClassMessageDeclarationListOpt
1441 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1442 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1447 : Identifier { $$ = $1; }
1448 | "(" AssignmentExpression ")" { $$ = $2; }
1452 : ClassName { $$ = $1; }
1456 // XXX: this should be AssignmentExpressionNoRight
1458 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1462 : "," ClassProtocols { $$ = $2; }
1466 ClassProtocolListOpt
1467 : "<" ClassProtocols ">" { $$ = $2; }
1472 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1476 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1484 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1488 : ClassExpression { $$ = $1; }
1492 : ClassStatement { $$ = $1; }
1493 | CategoryStatement { $$ = $1; }
1496 /* Cycript (Objective-C): Send Message {{{ */
1498 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1503 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1504 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1508 : SelectorCall { $$ = $1; }
1509 | VariadicCall { $$ = $1; }
1513 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1517 : SelectorCall { $$ = $1; }
1518 | Word { $$ = CYNew CYArgument($1, NULL); }
1522 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1523 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1527 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1531 : SelectorExpression_ { $$ = $1; }
1532 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1535 SelectorExpressionOpt
1536 : SelectorExpression_ { $$ = $1; }
1541 : MessageExpression { $$ = $1; }
1542 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1545 /* Cycript (Objective-C): @import Directive {{{ */
1559 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1562 /* Cycript (Objective-C): Boxed Expressions {{{ */
1564 : NullLiteral { $$ = $1; }
1565 | BooleanLiteral { $$ = $1; }
1566 | NumericLiteral { $$ = $1; }
1567 | StringLiteral { $$ = $1; }
1568 | ArrayLiteral { $$ = $1; }
1569 | ObjectLiteral { $$ = $1; }
1570 | Parenthetical { $$ = $1; }
1574 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1577 /* Cycript (Objective-C): Block Expressions {{{ */
1579 : "," TypedParameterList { $$ = $2; }
1584 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1587 TypedParameterListOpt
1588 : TypedParameterList { $$ = $1; }
1593 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1599 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1600 LeftHandSideExpression
1601 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1605 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1609 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1610 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1611 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1614 /* Cycript (C): auto Compatibility {{{ */
1621 /* YUI: Documentation Comments {{{ */
1623 : Comment { $$ = $1; }
1628 /* Lexer State {{{ */
1630 : { driver.PushCondition(CYDriver::RegExpCondition); }
1634 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1638 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1642 : { driver.PopCondition(); }
1646 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1650 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1653 /* Virtual Tokens {{{ */
1660 /* 8.1 Context Keywords {{{ */
1662 : "namespace" { $$ = $1; }
1663 | "xml" { $$ = $1; }
1666 /* 8.3 XML Initialiser Input Elements {{{ */
1668 : XMLComment { $$ = $1; }
1669 | XMLCDATA { $$ = $1; }
1670 | XMLPI { $$ = $1; }
1674 /* 11.1 Primary Expressions {{{ */
1676 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1677 | XMLInitialiser { $$ = $1; }
1678 | XMLListInitialiser { $$ = $1; }
1682 : AttributeIdentifier { $$ = $1; }
1683 | QualifiedIdentifier { $$ = $1; }
1684 | WildcardIdentifier { $$ = $1; }
1687 /* 11.1.1 Attribute Identifiers {{{ */
1689 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1693 : PropertySelector { $$ = $1; }
1694 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1698 : Identifier { $$ = CYNew CYSelector($1); }
1699 | WildcardIdentifier { $$ = $1; }
1702 /* 11.1.2 Qualified Identifiers {{{ */
1703 QualifiedIdentifier_
1704 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1705 | QualifiedIdentifier { $$ = $1; }
1709 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1712 /* 11.1.3 Wildcard Identifiers {{{ */
1714 : "*" { $$ = CYNew CYWildcard(); }
1717 /* 11.1.4 XML Initialiser {{{ */
1719 : XMLMarkup { $$ = $1; }
1720 | XMLElement { $$ = $1; }
1724 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1725 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1729 : LexPushXMLTag XMLTagName XMLAttributes
1733 : BRACE LexPushRegExp Expression LexPop "}"
1742 : XMLAttributes_ XMLAttribute
1747 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1748 | XMLAttributes_ XMLWhitespaceOpt
1757 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1761 : XMLExpression XMLElementContentOpt
1762 | XMLMarkup XMLElementContentOpt
1763 | XMLText XMLElementContentOpt
1764 | XMLElement XMLElementContentOpt
1767 XMLElementContentOpt
1772 /* 11.1.5 XMLList Initialiser {{{ */
1774 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1778 /* 11.2 Left-Hand-Side Expressions {{{ */
1780 : Identifier { $$ = $1; }
1781 | PropertyIdentifier { $$ = $1; }
1785 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1786 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1787 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1790 /* 12.1 The default xml namespace Statement {{{ */
1791 /* XXX: DefaultXMLNamespaceStatement
1792 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1796 : DefaultXMLNamespaceStatement { $$ = $1; }
1801 /* JavaScript 1.7: Array Comprehensions {{{ */
1803 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1807 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1808 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1812 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1815 ComprehensionListOpt
1816 : ComprehensionList { $$ = $1; }
1817 | IfComprehension { $$ = $1; }
1822 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1825 /* JavaScript 1.7: for each {{{ */
1827 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1830 /* JavaScript 1.7: let Statements {{{ */
1832 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1840 /* JavaScript FTW: Ruby Blocks {{{ */
1841 RubyProcParameterList_
1842 : "," RubyProcParameterList { $$ = $2; }
1846 RubyProcParameterList
1847 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1852 : "|" RubyProcParameterList "|" { $$ = $2; }
1853 | "||" { $$ = NULL; }
1856 RubyProcParametersOpt
1857 : RubyProcParameters
1862 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1866 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1870 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }