1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2012 Jay Freeman (saurik)
5 /* GNU Lesser General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
24 @if Bison24 %code top {
25 #define cyscanner driver.scanner_
26 #define YYSTACKEXPANDABLE 1
27 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
30 @if Bison24 %code requires {
32 #define CYNew new($pool)
35 #include "ObjectiveC/Syntax.hpp"
39 #include "E4X/Syntax.hpp"
42 #include "Highlight.hpp"
51 CYDriver::Condition condition_;
53 CYArgument *argument_;
54 CYAssignment *assignment_;
57 cy::Syntax::Catch *catch_;
59 CYComprehension *comprehension_;
60 CYCompound *compound_;
61 CYDeclaration *declaration_;
62 CYDeclarations *declarations_;
64 CYExpression *expression_;
67 CYForInitialiser *for_;
68 CYForInInitialiser *forin_;
69 CYFunctionParameter *functionParameter_;
70 CYIdentifier *identifier_;
77 CYProperty *property_;
78 CYPropertyName *propertyName_;
79 CYRubyProc *rubyProc_;
80 CYStatement *statement_;
84 CYTypeModifier *type_;
85 CYTypedIdentifier *typedIdentifier_;
86 CYTypedParameter *typedParameter_;
90 CYClassName *className_;
93 CYMessageParameter *messageParameter_;
94 CYProtocol *protocol_;
95 CYSelectorPart *selector_;
99 CYAttribute *attribute_;
100 CYPropertyIdentifier *propertyIdentifier_;
101 CYSelector *selector_;
106 #define YYSTYPE YYSTYPE
109 @if Bison24 %code provides {
110 int cylex(YYSTYPE *, cy::location *, void *);
117 @if Bison23 %skeleton "lalr1.cc"
118 @if Bison24 %language "C++"
121 @$.begin.filename = @$.end.filename = &driver.filename_;
132 %parse-param { CYDriver &driver }
133 %lex-param { void *cyscanner }
135 /* Token Declarations {{{ */
141 %token XMLAttributeValue
143 %token XMLTagCharacters
149 %token LeftRight "<>"
150 %token LeftSlashRight "</>"
152 %token SlashRight "/>"
153 %token LeftSlash "</"
155 %token ColonColon "::"
156 %token PeriodPeriod ".."
159 @begin E4X ObjectiveC
164 %token AmpersandAmpersand "&&"
165 %token AmpersandEqual "&="
167 %token CarrotEqual "^="
169 %token EqualEqual "=="
170 %token EqualEqualEqual "==="
171 %token EqualRight "=>"
172 %token Exclamation "!"
173 %token ExclamationEqual "!="
174 %token ExclamationEqualEqual "!=="
176 %token HyphenEqual "-="
177 %token HyphenHyphen "--"
178 %token HyphenHyphen_ "\n--"
179 %token HyphenRight "->"
181 %token LeftEqual "<="
183 %token LeftLeftEqual "<<="
185 %token PercentEqual "%="
187 %token PeriodPeriodPeriod "..."
189 %token PipeEqual "|="
192 %token PlusEqual "+="
194 %token PlusPlus_ "\n++"
196 %token RightEqual ">="
197 %token RightRight ">>"
198 %token RightRightEqual ">>="
199 %token RightRightRight ">>>"
200 %token RightRightRightEqual ">>>="
202 %token SlashEqual "/="
204 %token StarEqual "*="
213 %token <comment_> Comment
216 %token CloseParen ")"
219 %token OpenBrace_ "\n{"
220 %token OpenBrace__ ";{"
221 %token CloseBrace "}"
223 %token OpenBracket "["
224 %token CloseBracket "]"
227 %token AtClass "@class"
231 %token AtImplementation "@implementation"
232 %token AtImplementation_ ";@implementation"
233 %token AtImport "@import"
234 %token AtEncode "@encode"
236 %token AtSelector "@selector"
239 %token <false_> False "false"
240 %token <null_> Null "null"
241 %token <true_> True "true"
243 // ES3/ES5/WIE/JSC Reserved
244 %token <word_> Auto "auto"
245 %token <word_> Break "break"
246 %token <word_> Case "case"
247 %token <word_> Catch "catch"
248 %token <word_> Continue "continue"
249 %token <word_> Default "default"
250 %token <word_> Delete "delete"
251 %token <word_> Do "do"
252 %token <word_> Else "else"
253 %token <word_> Finally "finally"
254 %token <word_> For "for"
255 %token <word_> Function "function"
256 %token <word_> Function_ ";function"
257 %token <word_> If "if"
258 %token <word_> In "in"
259 %token <word_> In_ "!in"
260 %token <word_> InstanceOf "instanceof"
261 %token <word_> New "new"
262 %token <word_> Return "return"
263 %token <word_> Switch "switch"
264 %token <this_> This "this"
265 %token <word_> Throw "throw"
266 %token <word_> Try "try"
267 %token <word_> TypeOf "typeof"
268 %token <word_> Var "var"
269 %token <word_> Void "void"
270 %token <word_> While "while"
271 %token <word_> With "with"
273 // ES3/IE6 Future, ES5/JSC Reserved
274 %token <word_> Debugger "debugger"
276 // ES3/ES5/IE6 Future, JSC Reserved
277 %token <word_> Const "const"
279 // ES3/ES5/IE6/JSC Future
280 %token <word_> Class "class"
281 %token <word_> Enum "enum"
282 %token <word_> Export "export"
283 %token <word_> Extends "extends"
284 %token <word_> Import "import"
285 %token <word_> Super "super"
287 // ES3 Future, ES5 Strict Future
288 %token <identifier_> Implements "implements"
289 %token <identifier_> Interface "interface"
290 %token <identifier_> Package "package"
291 %token <identifier_> Private "private"
292 %token <identifier_> Protected "protected"
293 %token <identifier_> Public "public"
294 %token <identifier_> Static "static"
297 %token <identifier_> Abstract "abstract"
298 %token <identifier_> Boolean "boolean"
299 %token <identifier_> Byte "byte"
300 %token <identifier_> Char "char"
301 %token <identifier_> Double "double"
302 %token <identifier_> Final "final"
303 %token <identifier_> Float "float"
304 %token <identifier_> Goto "goto"
305 %token <identifier_> Int "int"
306 %token <identifier_> Long "long"
307 %token <identifier_> Native "native"
308 %token <identifier_> Short "short"
309 %token <identifier_> Synchronized "synchronized"
310 %token <identifier_> Throws "throws"
311 %token <identifier_> Transient "transient"
312 %token <identifier_> Volatile "volatile"
315 %token <identifier_> Let "let"
316 %token <identifier_> Yield "yield"
319 %token <identifier_> Each "each"
320 %token <identifier_> Of "of"
324 %token <identifier_> Namespace "namespace"
325 %token <identifier_> XML "xml"
330 %token <identifier_> Identifier_
331 %token <number_> NumericLiteral
332 %token <string_> StringLiteral
333 %token <literal_> RegularExpressionLiteral
335 %type <expression_> AdditiveExpression
336 %type <argument_> ArgumentList_
337 %type <argument_> ArgumentList
338 %type <argument_> ArgumentListOpt
339 %type <argument_> Arguments
340 %type <literal_> ArrayLiteral
341 %type <expression_> ArrowFunction
342 %type <functionParameter_> ArrowParameters
343 %type <expression_> AssignmentExpression
344 %type <identifier_> Binding
345 %type <identifier_> BindingIdentifier
346 %type <expression_> BitwiseANDExpression
347 %type <statement_> Block_
348 %type <statement_> Block
349 %type <boolean_> BooleanLiteral
350 %type <declaration_> BindingElement
351 %type <expression_> BitwiseORExpression
352 %type <expression_> BitwiseXORExpression
353 %type <statement_> BreakStatement
354 %type <statement_> BreakableStatement
355 %type <expression_> CallExpression_
356 %type <expression_> CallExpression
357 %type <clause_> CaseBlock
358 %type <clause_> CaseClause
359 %type <clause_> CaseClausesOpt
360 %type <catch_> CatchOpt
361 %type <comprehension_> ComprehensionForList
362 %type <comprehension_> ComprehensionForListOpt
363 %type <comprehension_> ComprehensionList
364 %type <comprehension_> ComprehensionListOpt
365 %type <expression_> ConditionalExpression
366 %type <statement_> ContinueStatement
367 %type <statement_> ConciseBody
368 %type <statement_> DebuggerStatement
369 %type <statement_> Declaration__
370 %type <statement_> Declaration_
371 %type <statement_> Declaration
372 %type <clause_> DefaultClause
373 %type <expression_> Element
374 %type <expression_> ElementOpt
375 %type <element_> ElementList
376 %type <element_> ElementListOpt
377 %type <statement_> ElseStatementOpt
378 %type <statement_> EmptyStatement
379 %type <expression_> EqualityExpression
380 %type <compound_> Expression_
381 %type <compound_> Expression
382 %type <expression_> ExpressionOpt
383 %type <statement_> ExpressionStatement
384 %type <finally_> FinallyOpt
385 %type <comprehension_> ForComprehension
386 %type <for_> ForStatementInitialiser
387 %type <forin_> ForInStatementInitialiser
388 %type <declaration_> FormalParameter
389 %type <functionParameter_> FormalParameterList_
390 %type <functionParameter_> FormalParameterList
391 %type <functionParameter_> FormalParameterListOpt
392 %type <statement_> FunctionBody
393 %type <statement_> FunctionDeclaration
394 %type <expression_> FunctionExpression
395 %type <identifier_> Identifier
396 %type <identifier_> IdentifierOpt
397 %type <word_> IdentifierName
398 %type <comprehension_> IfComprehension
399 %type <statement_> IfStatement
400 %type <expression_> Initialiser
401 %type <expression_> InitialiserOpt
402 %type <statement_> IterationStatement
403 %type <statement_> LabelledStatement
404 %type <expression_> LeftHandSideExpression
405 %type <statement_> LetStatement
406 %type <statement_> LexicalDeclaration
407 %type <literal_> Literal
408 %type <literal_> ValueLiteral
409 %type <expression_> LogicalANDExpression
410 %type <expression_> LogicalORExpression
411 %type <member_> MemberAccess
412 %type <expression_> MemberExpression_
413 %type <expression_> MemberExpression
414 %type <expression_> MultiplicativeExpression
415 %type <expression_> NewExpression
416 %type <null_> NullLiteral
417 %type <literal_> ObjectLiteral
418 %type <compound_> Parenthetical
419 %type <compound_> ParentheticalOpt
420 %type <expression_> PostfixExpression
421 %type <expression_> PrimaryExpression
422 %type <statement_> Program
423 %type <statement_> ProgramBody
424 %type <statement_> ProgramBodyOpt
425 %type <propertyName_> PropertyName_
426 %type <propertyName_> PropertyName
427 %type <property_> PropertyDefinition
428 %type <property_> PropertyDefinitionList_
429 %type <property_> PropertyDefinitionList
430 %type <property_> PropertyDefinitionListOpt
431 %type <expression_> RelationalExpression
432 %type <statement_> ReturnStatement
433 %type <rubyProc_> RubyProcExpression
434 %type <functionParameter_> RubyProcParameterList_
435 %type <functionParameter_> RubyProcParameterList
436 %type <functionParameter_> RubyProcParameters
437 %type <functionParameter_> RubyProcParametersOpt
438 %type <expression_> ShiftExpression
439 %type <declaration_> SingleNameBinding
440 %type <statement_> Statement__
441 %type <statement_> Statement_
442 %type <statement_> Statement
443 %type <statement_> StatementList
444 %type <statement_> StatementListOpt
445 %type <statement_> StatementListItem
446 %type <statement_> SwitchStatement
447 %type <statement_> ThrowStatement
448 %type <statement_> TryStatement
449 %type <expression_> UnaryExpression_
450 %type <expression_> UnaryExpression
451 %type <declaration_> VariableDeclaration
452 %type <declarations_> VariableDeclarationList_
453 %type <declarations_> VariableDeclarationList
454 %type <statement_> VariableStatement
455 %type <statement_> WithStatement
457 %type <word_> WordOpt
458 %type <expression_> Variable
461 %type <expression_> BoxableExpression
462 %type <statement_> CategoryStatement
463 %type <expression_> ClassExpression
464 %type <field_> ClassFieldListOpt
465 %type <field_> ClassFields
466 %type <statement_> ClassStatement
467 %type <expression_> ClassSuperOpt
468 %type <message_> ClassMessageDeclaration
469 %type <message_> ClassMessageDeclarationListOpt
470 %type <className_> ClassName
471 %type <className_> ClassNameOpt
472 %type <protocol_> ClassProtocolListOpt
473 %type <protocol_> ClassProtocols
474 %type <protocol_> ClassProtocolsOpt
475 %type <expression_> EncodedType
476 %type <expression_> MessageExpression
477 %type <messageParameter_> MessageParameter
478 %type <messageParameter_> MessageParameters
479 %type <messageParameter_> MessageParameterList
480 %type <messageParameter_> MessageParameterListOpt
481 %type <bool_> MessageScope
482 %type <type_> ModifiedType
483 %type <typedIdentifier_> PrefixedType
484 %type <type_> QualifiedType
485 %type <argument_> SelectorCall_
486 %type <argument_> SelectorCall
487 %type <selector_> SelectorExpression_
488 %type <selector_> SelectorExpression
489 %type <selector_> SelectorExpressionOpt
490 %type <argument_> SelectorList
491 %type <word_> SelectorWordOpt
492 %type <typedIdentifier_> SuffixedType
493 %type <expression_> TypeOpt
494 %type <typedIdentifier_> TypedIdentifier
495 %type <typedParameter_> TypedParameterList_
496 %type <typedParameter_> TypedParameterList
497 %type <typedParameter_> TypedParameterListOpt
498 %type <argument_> VariadicCall
502 %type <propertyIdentifier_> PropertyIdentifier_
503 %type <selector_> PropertySelector_
504 %type <selector_> PropertySelector
505 %type <identifier_> QualifiedIdentifier_
506 %type <identifier_> QualifiedIdentifier
507 %type <identifier_> WildcardIdentifier
508 %type <identifier_> XMLComment
509 %type <identifier_> XMLCDATA
510 %type <identifier_> XMLElement
511 %type <identifier_> XMLElementContent
512 %type <identifier_> XMLMarkup
513 %type <identifier_> XMLPI
515 %type <attribute_> AttributeIdentifier
516 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
517 %type <expression_> PropertyIdentifier
518 %type <expression_> XMLListInitialiser
519 %type <expression_> XMLInitialiser
522 /* Token Priorities {{{ */
534 /* Lexer State {{{ */
536 : { driver.in_.push(true); }
540 : { driver.in_.push(false); }
544 : { driver.in_.pop(); }
548 : { driver.SetCondition(CYDriver::RegExpCondition); }
552 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
556 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
559 LexNoAtImplementation
560 : { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
564 : LexNoBrace LexNoFunction LexNoAtImplementation
567 /* Virtual Tokens {{{ */
578 /* 7.6 Identifier Names and Identifiers {{{ */
589 : Identifier { $$ = $1; }
590 | "auto" { $$ = $1; }
591 | "break" NewLineOpt { $$ = $1; }
592 | "case" { $$ = $1; }
593 | "catch" { $$ = $1; }
594 | "class" { $$ = $1; }
595 | "const" { $$ = $1; }
596 | "continue" NewLineOpt { $$ = $1; }
597 | "debugger" { $$ = $1; }
598 | "default" { $$ = $1; }
599 | "delete" { $$ = $1; }
601 | "else" { $$ = $1; }
602 | "enum" { $$ = $1; }
603 | "export" { $$ = $1; }
604 | "extends" { $$ = $1; }
605 | "false" { $$ = $1; }
606 | "finally" { $$ = $1; }
607 /* XXX: | "for" { $$ = $1; } */
608 | "function" { $$ = $1; }
610 | "import" { $$ = $1; }
611 /* XXX: | "in" { $$ = $1; } */
613 /* XXX: | "instanceof" { $$ = $1; } */
615 // XXX: as it currently is not an Identifier
619 | "null" { $$ = $1; }
620 | "return" NewLineOpt { $$ = $1; }
621 | "super" { $$ = $1; }
622 | "switch" { $$ = $1; }
623 | "this" { $$ = $1; }
624 | "throw" NewLineOpt { $$ = $1; }
625 | "true" { $$ = $1; }
627 | "typeof" { $$ = $1; }
629 | "void" { $$ = $1; }
630 | "while" { $$ = $1; }
631 | "with" { $$ = $1; }
640 : Identifier_ { $$ = $1; }
642 | "implements" { $$ = $1; }
643 | "interface" { $$ = $1; }
644 | "package" { $$ = $1; }
645 | "private" { $$ = $1; }
646 | "protected" { $$ = $1; }
647 | "public" { $$ = $1; }
648 | "static" { $$ = $1; }
650 | "abstract" { $$ = $1; }
651 | "boolean" { $$ = $1; }
652 | "byte" { $$ = $1; }
653 | "char" { $$ = $1; }
654 | "double" { $$ = $1; }
655 | "final" { $$ = $1; }
656 | "float" { $$ = $1; }
657 | "goto" { $$ = $1; }
659 | "long" { $$ = $1; }
660 | "native" { $$ = $1; }
661 | "short" { $$ = $1; }
662 | "synchronized" { $$ = $1; }
663 | "throws" { $$ = $1; }
664 | "transient" { $$ = $1; }
665 | "volatile" { $$ = $1; }
667 // XXX: currently I only have this as Word
668 // | "let" { $$ = $1; }
670 | "yield" { $$ = $1; }
672 | "each" { $$ = $1; }
677 : Identifier { $$ = $1; }
682 /* 7.8 Literals {{{ */
684 : NullLiteral { $$ = $1; }
685 | ValueLiteral { $$ = $1; }
689 : BooleanLiteral { $$ = $1; }
690 | NumericLiteral { $$ = $1; }
691 | StringLiteral { $$ = $1; }
692 | RegularExpressionLiteral { $$ = $1; }
695 /* 7.8.1 Null Literals {{{ */
697 : "null" { $$ = $1; }
700 /* 7.8.2 Boolean Literals {{{ */
702 : "true" { $$ = $1; }
703 | "false" { $$ = $1; }
707 /* 7.9 Automatic Semicolon Insertion {{{ */
709 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
714 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
719 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
723 /* 11.1 Primary Expressions {{{ */
725 : "(" LexPushInOff Expression LexPopIn ")" { $$ = $3; }
729 : Parenthetical { $$ = $1; }
734 : Identifier { $$ = CYNew CYVariable($1); }
738 : "this" { $$ = $1; }
739 | Variable { $$ = $1; }
740 | Literal { $$ = $1; }
741 | ArrayLiteral { $$ = $1; }
742 | ObjectLiteral { $$ = $1; }
743 | FunctionExpression { $$ = $1; }
744 | Parenthetical { $$ = $1; }
745 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
748 /* 11.1.4.1 Array Initialiser {{{ */
750 : "[" LexPushInOff ElementListOpt LexPopIn "]" { $$ = CYNew CYArray($3); }
754 : AssignmentExpression { $$ = $1; }
758 : Element { $$ = $1; }
759 | LexSetRegExp { $$ = NULL; }
763 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
764 | Element { $$ = CYNew CYElement($1, NULL); }
768 : ElementList { $$ = $1; }
769 | LexSetRegExp { $$ = NULL; }
772 /* 11.1.4.2 Array Comprehension {{{ */
774 : "[" LexPushInOff AssignmentExpression ComprehensionForList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
778 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
779 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
782 ComprehensionForListOpt
783 : ComprehensionForList { $$ = $1; }
784 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
788 /* 11.1.5 Object Initialiser {{{ */
790 : BRACE LexPushInOff PropertyDefinitionListOpt LexPopIn "}" { $$ = CYNew CYObject($3); }
793 PropertyDefinitionList_
794 : "," PropertyDefinitionList { $$ = $2; }
799 PropertyDefinitionList
800 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
803 PropertyDefinitionListOpt
804 : PropertyDefinitionList { $$ = $1; }
809 // XXX: this should be IdentifierName
810 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
811 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
816 : IdentifierName { $$ = $1; }
817 | StringLiteral { $$ = $1; }
818 | NumericLiteral { $$ = $1; }
822 : LexSetRegExp PropertyName_ { $$ = $2; }
826 /* 11.2 Left-Hand-Side Expressions {{{ */
828 : "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYDirectMember(NULL, $3); }
829 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
830 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
834 : MemberExpression { $$ = $1; }
835 //| "super" { $$ = $1; }
839 : LexSetRegExp PrimaryExpression { $$ = $2; }
840 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
841 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
845 : MemberExpression { $$ = $1; }
846 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
855 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
856 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
860 : "(" LexPushInOff ArgumentListOpt LexPopIn ")" { $$ = $3; }
864 : "," ArgumentList { $$ = $2; }
869 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
873 : ArgumentList { $$ = $1; }
874 | LexSetRegExp { $$ = NULL; }
877 LeftHandSideExpression
878 : NewExpression { $$ = $1; }
879 | CallExpression { $$ = $1; }
882 /* 11.3 Postfix Expressions {{{ */
884 : %prec "" LeftHandSideExpression { $$ = $1; }
885 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
886 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
889 /* 11.4 Unary Operators {{{ */
891 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
892 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
893 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
894 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
895 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
896 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
897 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
898 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
899 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
900 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
901 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
905 : PostfixExpression { $$ = $1; }
906 | LexSetRegExp UnaryExpression_ { $$ = $2; }
909 /* 11.5 Multiplicative Operators {{{ */
910 MultiplicativeExpression
911 : UnaryExpression { $$ = $1; }
912 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
913 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
914 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
917 /* 11.6 Additive Operators {{{ */
919 : MultiplicativeExpression { $$ = $1; }
920 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
921 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
924 /* 11.7 Bitwise Shift Operators {{{ */
926 : AdditiveExpression { $$ = $1; }
927 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
928 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
929 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
932 /* 11.8 Relational Operators {{{ */
934 : ShiftExpression { $$ = $1; }
935 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
936 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
937 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
938 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
939 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
940 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
943 /* 11.9 Equality Operators {{{ */
945 : RelationalExpression { $$ = $1; }
946 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
947 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
948 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
949 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
952 /* 11.10 Binary Bitwise Operators {{{ */
954 : EqualityExpression { $$ = $1; }
955 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
959 : BitwiseANDExpression { $$ = $1; }
960 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
964 : BitwiseXORExpression { $$ = $1; }
965 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
968 /* 11.11 Binary Logical Operators {{{ */
970 : BitwiseORExpression { $$ = $1; }
971 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
975 : LogicalANDExpression { $$ = $1; }
976 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
979 /* 11.12 Conditional Operator ( ? : ) {{{ */
980 ConditionalExpression
981 : LogicalORExpression { $$ = $1; }
982 | LogicalORExpression "?" LexPushInOff AssignmentExpression LexPopIn ":" AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
985 /* 11.13 Assignment Operators {{{ */
987 : ConditionalExpression { $$ = $1; }
988 | ArrowFunction { $$ = $1; }
989 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
990 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
991 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
992 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
993 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
994 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
995 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
996 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
997 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
998 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
999 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1000 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1003 /* 11.14 Comma Operator {{{ */
1005 : "," Expression { $$ = $2; }
1006 | { $$ = CYNew CYCompound(); }
1010 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1014 : Expression { $$ = $1; }
1015 | LexSetRegExp { $$ = NULL; }
1019 /* 12 Statements {{{ */
1021 : Block { $$ = $1; }
1022 | VariableStatement { $$ = $1; }
1023 | EmptyStatement { $$ = $1; }
1024 | IfStatement { $$ = $1; }
1025 | BreakableStatement { $$ = $1; }
1026 | ContinueStatement { $$ = $1; }
1027 | BreakStatement { $$ = $1; }
1028 | ReturnStatement { $$ = $1; }
1029 | WithStatement { $$ = $1; }
1030 | LabelledStatement { $$ = $1; }
1031 | ThrowStatement { $$ = $1; }
1032 | TryStatement { $$ = $1; }
1033 | DebuggerStatement { $$ = $1; }
1037 : LexSetRegExp Statement__ { $$ = $2; }
1038 | ExpressionStatement { $$ = $1; }
1042 : LexSetStatement Statement_ { $$ = $2; }
1046 : FunctionDeclaration { $$ = $1; }
1047 | LexicalDeclaration { $$ = $1; }
1051 : LexSetRegExp Declaration__ { $$ = $2; }
1055 : LexSetStatement Declaration_ { $$ = $2; }
1059 : IterationStatement { $$ = $1; }
1060 | SwitchStatement { $$ = $1; }
1063 /* 12.1 Block {{{ */
1065 : BRACE StatementListOpt "}" { $$ = $2; }
1069 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1073 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1077 : StatementList { $$ = $1; }
1078 | LexSetStatement LexSetRegExp { $$ = NULL; }
1082 : Statement { $$ = $1; }
1083 | Declaration { $$ = $1; }
1087 /* 12.2 Declarations {{{ */
1089 : Identifier { $$ = $1; }
1096 // XXX: BindingPattern
1098 /* 12.2.1 Let and Const Declarations {{{ */
1100 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1108 /* 12.2.2 Variable Statement {{{ */
1110 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1113 VariableDeclarationList_
1114 : "," VariableDeclarationList { $$ = $2; }
1118 VariableDeclarationList
1119 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1123 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1124 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1128 : "=" AssignmentExpression { $$ = $2; }
1132 : Initialiser { $$ = $1; }
1136 /* 12.2.4 Destructuring Binding Patterns {{{ */
1140 : SingleNameBinding { $$ = $1; }
1144 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1148 /* 12.3 Empty Statement {{{ */
1150 : ";" { $$ = CYNew CYEmpty(); }
1153 /* 12.4 Expression Statement {{{ */
1155 : Expression Terminator { $$ = CYNew CYExpress($1); }
1158 /* 12.5 The if Statement {{{ */
1160 : "else" Statement { $$ = $2; }
1161 | %prec "if" { $$ = NULL; }
1165 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1169 /* 12.6.1 The do-while Statement {{{ */
1171 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1174 /* 12.6.2 The while Statement {{{ */
1176 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1179 /* 12.6.3 The for Statement {{{ */
1181 : "for" "(" LexPushInOn ForStatementInitialiser LexPopIn ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1184 ForStatementInitialiser
1185 : ExpressionOpt { $$ = $1; }
1186 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1189 /* 12.6.4 The for-in and for-of Statements {{{ */
1191 : "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1192 | "for" "(" LexPushInOn ForInStatementInitialiser LexPopIn "of" Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1195 ForInStatementInitialiser
1196 : LeftHandSideExpression { $$ = $1; }
1197 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1201 /* 12.7 The continue Statement {{{ */
1203 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1204 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1207 /* 12.8 The break Statement {{{ */
1209 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1210 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1213 /* 12.9 The return Statement {{{ */
1215 : "return" "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1216 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1219 /* 12.10 The with Statement {{{ */
1221 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1225 /* 12.11 The switch Statement {{{ */
1227 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1231 : BRACE CaseClausesOpt "}" { $$ = $2; }
1235 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1239 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1240 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1245 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1248 /* 12.12 Labelled Statements {{{ */
1250 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1253 /* 12.13 The throw Statement {{{ */
1255 : "throw" "\n" StrictSemi { YYABORT; }
1256 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1259 /* 12.14 The try Statement {{{ */
1261 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1265 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1270 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1274 /* 12.14 The debugger Statement {{{ */
1276 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1280 /* 13.1 Function Definitions {{{ */
1282 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1286 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1289 FormalParameterList_
1290 : "," FormalParameterList { $$ = $2; }
1295 // XXX: : FunctionRestParameter { $$ = $1; }
1296 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1299 FormalParameterListOpt
1300 : FormalParameterList
1304 /* XXX: FunctionRestParameter
1305 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1309 : BindingElement { $$ = $1; }
1313 : StatementListOpt { $$ = $1; }
1316 /* 13.2 Arrow Function Definitions {{{ */
1318 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1322 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1323 //| ParentheticalOpt { $$ = $1; }
1327 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1328 | ";{" LexPushInOff FunctionBody LexPopIn "}" { $$ = $3; }
1331 /* 14 Program {{{ */
1333 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1337 : StatementList { $$ = $1; }
1341 : ProgramBody { $$ = $1; }
1342 | LexSetStatement LexSetRegExp { $$ = NULL; }
1347 /* Cycript (Objective-C): Type Encoding {{{ */
1349 : IdentifierOpt { $$ = CYNew CYTypedIdentifier($1); }
1350 | "(" LexPushInOff PrefixedType LexPopIn ")" { $$ = $3; }
1351 | SuffixedType "[" NumericLiteral "]" { CYSetLast($1->type_) = CYNew CYTypeArrayOf($3->Value()); $$ = $1; }
1355 : SuffixedType { $$ = $1; }
1356 | "const" PrefixedType { CYSetLast($2->type_) = CYNew CYTypeConstant(); $$ = $2; }
1357 | "*" PrefixedType { CYSetLast($2->type_) = CYNew CYTypePointerTo(); $$ = $2; }
1361 : Variable { $$ = CYNew CYTypeVariable($1); }
1362 | "const" QualifiedType { $$ = CYNew CYTypeConstant($2); }
1366 : QualifiedType { $$ = $1; }
1367 | QualifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1368 | QualifiedType "const" { $$ = CYNew CYTypeConstant($1); }
1372 : QualifiedType PrefixedType { CYSetLast($2->type_) = $1; $$ = $2;}
1376 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1380 : AtEncode "(" EncodedType ")" { $$ = $3; }
1383 /* Cycript (Objective-C): @class Declaration {{{ */
1385 /* XXX: why the hell did I choose MemberExpression? */
1386 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1391 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1396 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1400 : "+" { $$ = false; }
1401 | "-" { $$ = true; }
1405 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1406 | "(" LexSetRegExp "void" ")" { $$ = CYNew CYString("v"); }
1411 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1414 MessageParameterList
1415 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1418 MessageParameterListOpt
1419 : MessageParameterList { $$ = $1; }
1424 : MessageParameterList { $$ = $1; }
1425 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1428 ClassMessageDeclaration
1429 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1432 ClassMessageDeclarationListOpt
1433 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1434 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1439 : Identifier { $$ = $1; }
1440 | "(" AssignmentExpression ")" { $$ = $2; }
1444 : ClassName { $$ = $1; }
1448 // XXX: this should be AssignmentExpressionNoRight
1450 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1454 : "," ClassProtocols { $$ = $2; }
1458 ClassProtocolListOpt
1459 : "<" ClassProtocols ">" { $$ = $2; }
1464 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt LexPopIn "@end" { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1468 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1476 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1480 : ClassExpression { $$ = $1; }
1484 : ClassStatement { $$ = $1; }
1485 | CategoryStatement { $$ = $1; }
1488 /* Cycript (Objective-C): Send Message {{{ */
1490 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1495 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1496 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1500 : SelectorCall { $$ = $1; }
1501 | VariadicCall { $$ = $1; }
1505 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1509 : SelectorCall { $$ = $1; }
1510 | Word { $$ = CYNew CYArgument($1, NULL); }
1514 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList LexPopIn "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1515 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList LexPopIn "]" { $$ = CYNew CYSendSuper($6); }
1519 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1523 : SelectorExpression_ { $$ = $1; }
1524 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1527 SelectorExpressionOpt
1528 : SelectorExpression_ { $$ = $1; }
1533 : MessageExpression { $$ = $1; }
1534 | "@selector" "(" LexPushInOff SelectorExpression LexPopIn ")" { $$ = CYNew CYSelector($4); }
1537 /* Cycript (Objective-C): @import Directive {{{ */
1551 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1554 /* Cycript (Objective-C): Boxed Expressions {{{ */
1556 : NullLiteral { $$ = $1; }
1557 | BooleanLiteral { $$ = $1; }
1558 | NumericLiteral { $$ = $1; }
1559 | StringLiteral { $$ = $1; }
1560 | ArrayLiteral { $$ = $1; }
1561 | ObjectLiteral { $$ = $1; }
1562 | Parenthetical { $$ = $1; }
1566 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1569 /* Cycript (Objective-C): Block Expressions {{{ */
1571 : "," TypedParameterList { $$ = $2; }
1576 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1579 TypedParameterListOpt
1580 : TypedParameterList { $$ = $1; }
1585 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt LexPopIn ")" BRACE LexPushInOff FunctionBody LexPopIn "}" { $$ = CYNew CYObjCBlock($2, $5, $10); }
1591 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1592 LeftHandSideExpression
1593 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1597 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1601 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1602 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1603 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1606 /* Cycript (C): auto Compatibility {{{ */
1613 /* YUI: Documentation Comments {{{ */
1615 : Comment { $$ = $1; }
1620 /* Lexer State {{{ */
1622 : { driver.PushCondition(CYDriver::RegExpCondition); }
1626 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1630 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1634 : { driver.PopCondition(); }
1638 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1642 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1645 /* Virtual Tokens {{{ */
1652 /* 8.1 Context Keywords {{{ */
1654 : "namespace" { $$ = $1; }
1655 | "xml" { $$ = $1; }
1658 /* 8.3 XML Initialiser Input Elements {{{ */
1660 : XMLComment { $$ = $1; }
1661 | XMLCDATA { $$ = $1; }
1662 | XMLPI { $$ = $1; }
1666 /* 11.1 Primary Expressions {{{ */
1668 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1669 | XMLInitialiser { $$ = $1; }
1670 | XMLListInitialiser { $$ = $1; }
1674 : AttributeIdentifier { $$ = $1; }
1675 | QualifiedIdentifier { $$ = $1; }
1676 | WildcardIdentifier { $$ = $1; }
1679 /* 11.1.1 Attribute Identifiers {{{ */
1681 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1685 : PropertySelector { $$ = $1; }
1686 | "[" LexPushInOff Expression LexPopIn "]" { $$ = CYNew CYSelector($3); }
1690 : Identifier { $$ = CYNew CYSelector($1); }
1691 | WildcardIdentifier { $$ = $1; }
1694 /* 11.1.2 Qualified Identifiers {{{ */
1695 QualifiedIdentifier_
1696 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1697 | QualifiedIdentifier { $$ = $1; }
1701 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1704 /* 11.1.3 Wildcard Identifiers {{{ */
1706 : "*" { $$ = CYNew CYWildcard(); }
1709 /* 11.1.4 XML Initialiser {{{ */
1711 : XMLMarkup { $$ = $1; }
1712 | XMLElement { $$ = $1; }
1716 : "<" LexPushInOff XMLTagContent LexPop LexPopIn "/>"
1717 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop LexPopIn ">"
1721 : LexPushXMLTag XMLTagName XMLAttributes
1725 : BRACE LexPushRegExp Expression LexPop "}"
1734 : XMLAttributes_ XMLAttribute
1739 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1740 | XMLAttributes_ XMLWhitespaceOpt
1749 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1753 : XMLExpression XMLElementContentOpt
1754 | XMLMarkup XMLElementContentOpt
1755 | XMLText XMLElementContentOpt
1756 | XMLElement XMLElementContentOpt
1759 XMLElementContentOpt
1764 /* 11.1.5 XMLList Initialiser {{{ */
1766 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop LexPopIn "</>" { $$ = CYNew CYXMLList($4); }
1770 /* 11.2 Left-Hand-Side Expressions {{{ */
1772 : Identifier { $$ = $1; }
1773 | PropertyIdentifier { $$ = $1; }
1777 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1778 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1779 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1782 /* 12.1 The default xml namespace Statement {{{ */
1783 /* XXX: DefaultXMLNamespaceStatement
1784 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1788 : DefaultXMLNamespaceStatement { $$ = $1; }
1793 /* JavaScript 1.7: Array Comprehensions {{{ */
1795 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1799 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1800 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1804 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1807 ComprehensionListOpt
1808 : ComprehensionList { $$ = $1; }
1809 | IfComprehension { $$ = $1; }
1814 : "[" LexPushInOff AssignmentExpression ComprehensionList LexPopIn "]" { $$ = CYNew CYArrayComprehension($3, $4); }
1817 /* JavaScript 1.7: for each {{{ */
1819 : "for" "each" "(" LexPushInOn ForInStatementInitialiser LexPopIn "!in" Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1822 /* JavaScript 1.7: let Statements {{{ */
1824 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1832 /* JavaScript FTW: Ruby Blocks {{{ */
1833 RubyProcParameterList_
1834 : "," RubyProcParameterList { $$ = $2; }
1838 RubyProcParameterList
1839 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1844 : "|" RubyProcParameterList "|" { $$ = $2; }
1845 | "||" { $$ = NULL; }
1848 RubyProcParametersOpt
1849 : RubyProcParameters
1854 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1858 : "{" LexPushInOff RubyProcParameters StatementListOpt LexPopIn "}" { $$ = CYNew CYRubyProc($3, $4); }
1862 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }