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 <identifier_> Typedef "typedef"
238 %token AtImplementation "@implementation"
239 %token AtImplementation_ ";@implementation"
240 %token AtImport "@import"
241 %token AtEncode "@encode"
243 %token AtSelector "@selector"
244 %token <identifier_> Yes "YES"
245 %token <identifier_> No "NO"
248 %token <false_> False "false"
249 %token <null_> Null "null"
250 %token <true_> True "true"
252 // ES3/ES5/WIE/JSC Reserved
253 %token <word_> Auto "auto"
254 %token <word_> Break "break"
255 %token <word_> Case "case"
256 %token <word_> Catch "catch"
257 %token <word_> Continue "continue"
258 %token <word_> Default "default"
259 %token <word_> Delete "delete"
260 %token <word_> Do "do"
261 %token <word_> Else "else"
262 %token <word_> Finally "finally"
263 %token <word_> For "for"
264 %token <word_> Function "function"
265 %token <word_> Function_ ";function"
266 %token <word_> If "if"
267 %token <word_> In "in"
268 %token <word_> In_ "!in"
269 %token <word_> InstanceOf "instanceof"
270 %token <word_> New "new"
271 %token <word_> Return "return"
272 %token <word_> Switch "switch"
273 %token <this_> This "this"
274 %token <word_> Throw "throw"
275 %token <word_> Try "try"
276 %token <word_> TypeOf "typeof"
277 %token <word_> Var "var"
278 %token <word_> Void "void"
279 %token <word_> While "while"
280 %token <word_> With "with"
282 // ES3/IE6 Future, ES5/JSC Reserved
283 %token <word_> Debugger "debugger"
285 // ES3/ES5/IE6 Future, JSC Reserved
286 %token <word_> Const "const"
288 // ES3/ES5/IE6/JSC Future
289 %token <word_> Class "class"
290 %token <word_> Enum "enum"
291 %token <word_> Export "export"
292 %token <word_> Extends "extends"
293 %token <word_> Import "import"
294 %token <word_> Super "super"
296 // ES3 Future, ES5 Strict Future
297 %token <identifier_> Implements "implements"
298 %token <identifier_> Interface "interface"
299 %token <identifier_> Package "package"
300 %token <identifier_> Private "private"
301 %token <identifier_> Protected "protected"
302 %token <identifier_> Public "public"
303 %token <identifier_> Static "static"
306 %token <identifier_> Abstract "abstract"
307 %token <identifier_> Boolean "boolean"
308 %token <identifier_> Byte "byte"
309 %token <identifier_> Char "char"
310 %token <identifier_> Double "double"
311 %token <identifier_> Final "final"
312 %token <identifier_> Float "float"
313 %token <identifier_> Goto "goto"
314 %token <identifier_> Int "int"
315 %token <identifier_> Long "long"
316 %token <identifier_> Native "native"
317 %token <identifier_> Short "short"
318 %token <identifier_> Synchronized "synchronized"
319 %token <identifier_> Throws "throws"
320 %token <identifier_> Transient "transient"
321 %token <identifier_> Volatile "volatile"
324 %token <identifier_> Let "let"
325 %token <identifier_> Yield "yield"
328 %token <identifier_> Each "each"
329 %token <identifier_> Of "of"
333 %token <identifier_> Namespace "namespace"
334 %token <identifier_> XML "xml"
339 %token <identifier_> Identifier_
340 %token <number_> NumericLiteral
341 %token <string_> StringLiteral
342 %token <literal_> RegularExpressionLiteral
344 %type <expression_> AdditiveExpression
345 %type <argument_> ArgumentList_
346 %type <argument_> ArgumentList
347 %type <argument_> ArgumentListOpt
348 %type <argument_> Arguments
349 %type <literal_> ArrayLiteral
350 %type <expression_> ArrowFunction
351 %type <functionParameter_> ArrowParameters
352 %type <expression_> AssignmentExpression
353 %type <identifier_> Binding
354 %type <identifier_> BindingIdentifier
355 %type <expression_> BitwiseANDExpression
356 %type <statement_> Block_
357 %type <statement_> Block
358 %type <boolean_> BooleanLiteral
359 %type <declaration_> BindingElement
360 %type <expression_> BitwiseORExpression
361 %type <expression_> BitwiseXORExpression
362 %type <statement_> BreakStatement
363 %type <statement_> BreakableStatement
364 %type <expression_> CallExpression_
365 %type <expression_> CallExpression
366 %type <clause_> CaseBlock
367 %type <clause_> CaseClause
368 %type <clause_> CaseClausesOpt
369 %type <catch_> CatchOpt
370 %type <comprehension_> ComprehensionForList
371 %type <comprehension_> ComprehensionForListOpt
372 %type <comprehension_> ComprehensionList
373 %type <comprehension_> ComprehensionListOpt
374 %type <expression_> ConditionalExpression
375 %type <statement_> ContinueStatement
376 %type <statement_> ConciseBody
377 %type <statement_> DebuggerStatement
378 %type <statement_> Declaration__
379 %type <statement_> Declaration_
380 %type <statement_> Declaration
381 %type <clause_> DefaultClause
382 %type <expression_> Element
383 %type <expression_> ElementOpt
384 %type <element_> ElementList
385 %type <element_> ElementListOpt
386 %type <statement_> ElseStatementOpt
387 %type <statement_> EmptyStatement
388 %type <expression_> EqualityExpression
389 %type <compound_> Expression_
390 %type <compound_> Expression
391 %type <expression_> ExpressionOpt
392 %type <statement_> ExpressionStatement
393 %type <finally_> FinallyOpt
394 %type <comprehension_> ForComprehension
395 %type <for_> ForStatementInitialiser
396 %type <forin_> ForInStatementInitialiser
397 %type <declaration_> FormalParameter
398 %type <functionParameter_> FormalParameterList_
399 %type <functionParameter_> FormalParameterList
400 %type <functionParameter_> FormalParameterListOpt
401 %type <statement_> FunctionBody
402 %type <statement_> FunctionDeclaration
403 %type <expression_> FunctionExpression
404 %type <identifier_> Identifier
405 %type <identifier_> IdentifierOpt
406 %type <word_> IdentifierName
407 %type <comprehension_> IfComprehension
408 %type <statement_> IfStatement
409 %type <expression_> Initialiser
410 %type <expression_> InitialiserOpt
411 %type <statement_> IterationStatement
412 %type <statement_> LabelledStatement
413 %type <expression_> LeftHandSideExpression
414 %type <statement_> LetStatement
415 %type <statement_> LexicalDeclaration
416 %type <literal_> Literal
417 %type <literal_> ValueLiteral
418 %type <expression_> LogicalANDExpression
419 %type <expression_> LogicalORExpression
420 %type <member_> MemberAccess
421 %type <expression_> MemberExpression_
422 %type <expression_> MemberExpression
423 %type <expression_> MultiplicativeExpression
424 %type <expression_> NewExpression
425 %type <null_> NullLiteral
426 %type <literal_> ObjectLiteral
427 %type <compound_> Parenthetical
428 %type <compound_> ParentheticalOpt
429 %type <expression_> PostfixExpression
430 %type <expression_> PrimaryExpression
431 %type <statement_> Program
432 %type <statement_> ProgramBody
433 %type <statement_> ProgramBodyOpt
434 %type <propertyName_> PropertyName_
435 %type <propertyName_> PropertyName
436 %type <property_> PropertyDefinition
437 %type <property_> PropertyDefinitionList_
438 %type <property_> PropertyDefinitionList
439 %type <property_> PropertyDefinitionListOpt
440 %type <expression_> RelationalExpression
441 %type <statement_> ReturnStatement
442 %type <rubyProc_> RubyProcExpression
443 %type <functionParameter_> RubyProcParameterList_
444 %type <functionParameter_> RubyProcParameterList
445 %type <functionParameter_> RubyProcParameters
446 %type <functionParameter_> RubyProcParametersOpt
447 %type <expression_> ShiftExpression
448 %type <declaration_> SingleNameBinding
449 %type <statement_> Statement__
450 %type <statement_> Statement_
451 %type <statement_> Statement
452 %type <statement_> StatementList
453 %type <statement_> StatementListOpt
454 %type <statement_> StatementListItem
455 %type <statement_> SwitchStatement
456 %type <statement_> ThrowStatement
457 %type <statement_> TryStatement
458 %type <expression_> UnaryExpression_
459 %type <expression_> UnaryExpression
460 %type <declaration_> VariableDeclaration
461 %type <declarations_> VariableDeclarationList_
462 %type <declarations_> VariableDeclarationList
463 %type <statement_> VariableStatement
464 %type <statement_> WithStatement
466 %type <word_> WordOpt
467 %type <expression_> Variable
470 %type <typedIdentifier_> ArrayedType
471 %type <expression_> BoxableExpression
472 %type <statement_> CategoryStatement
473 %type <expression_> ClassExpression
474 %type <field_> ClassFieldListOpt
475 %type <field_> ClassFields
476 %type <statement_> ClassStatement
477 %type <expression_> ClassSuperOpt
478 %type <message_> ClassMessageDeclaration
479 %type <message_> ClassMessageDeclarationListOpt
480 %type <className_> ClassName
481 %type <className_> ClassNameOpt
482 %type <protocol_> ClassProtocolListOpt
483 %type <protocol_> ClassProtocols
484 %type <protocol_> ClassProtocolsOpt
485 %type <type_> ConcreteType
486 %type <expression_> EncodedType
487 %type <expression_> MessageExpression
488 %type <messageParameter_> MessageParameter
489 %type <messageParameter_> MessageParameters
490 %type <messageParameter_> MessageParameterList
491 %type <messageParameter_> MessageParameterListOpt
492 %type <bool_> MessageScope
493 %type <type_> ModifiedType_
494 %type <type_> ModifiedType
495 %type <typedIdentifier_> PrefixedType
496 %type <expression_> PrimitiveType
497 %type <argument_> SelectorCall_
498 %type <argument_> SelectorCall
499 %type <selector_> SelectorExpression_
500 %type <selector_> SelectorExpression
501 %type <selector_> SelectorExpressionOpt
502 %type <argument_> SelectorList
503 %type <word_> SelectorWordOpt
504 %type <typedIdentifier_> SuffixedType
505 %type <expression_> TypeOpt
506 %type <typedIdentifier_> TypeParenthetical
507 %type <type_> TypeQualifierLeft
508 %type <type_> TypeQualifierRight
509 %type <typedIdentifier_> TypeSignifier
510 %type <typedIdentifier_> TypedIdentifier
511 %type <typedParameter_> TypedParameterList_
512 %type <typedParameter_> TypedParameterList
513 %type <typedParameter_> TypedParameterListOpt
514 %type <argument_> VariadicCall
518 %type <propertyIdentifier_> PropertyIdentifier_
519 %type <selector_> PropertySelector_
520 %type <selector_> PropertySelector
521 %type <identifier_> QualifiedIdentifier_
522 %type <identifier_> QualifiedIdentifier
523 %type <identifier_> WildcardIdentifier
524 %type <identifier_> XMLComment
525 %type <identifier_> XMLCDATA
526 %type <identifier_> XMLElement
527 %type <identifier_> XMLElementContent
528 %type <identifier_> XMLMarkup
529 %type <identifier_> XMLPI
531 %type <attribute_> AttributeIdentifier
532 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
533 %type <expression_> PropertyIdentifier
534 %type <expression_> XMLListInitialiser
535 %type <expression_> XMLInitialiser
538 /* Token Priorities {{{ */
550 /* Lexer State {{{ */
552 : { driver.in_.push(true); }
556 : { driver.in_.push(false); }
560 : { driver.in_.pop(); }
564 : { driver.SetCondition(CYDriver::RegExpCondition); }
568 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
572 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
575 LexNoAtImplementation :
577 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
582 : LexNoBrace LexNoFunction LexNoAtImplementation
585 /* Virtual Tokens {{{ */
596 /* 7.6 Identifier Names and Identifiers {{{ */
607 : Identifier { $$ = $1; }
608 | "auto" { $$ = $1; }
609 | "break" NewLineOpt { $$ = $1; }
610 | "case" { $$ = $1; }
611 | "catch" { $$ = $1; }
612 | "class" { $$ = $1; }
613 | "const" { $$ = $1; }
614 | "continue" NewLineOpt { $$ = $1; }
615 | "debugger" { $$ = $1; }
616 | "default" { $$ = $1; }
617 | "delete" { $$ = $1; }
619 | "else" { $$ = $1; }
620 | "enum" { $$ = $1; }
621 | "export" { $$ = $1; }
622 | "extends" { $$ = $1; }
623 | "false" { $$ = $1; }
624 | "finally" { $$ = $1; }
625 /* XXX: | "for" { $$ = $1; } */
626 | "function" { $$ = $1; }
628 | "import" { $$ = $1; }
629 /* XXX: | "in" { $$ = $1; } */
631 /* XXX: | "instanceof" { $$ = $1; } */
633 // XXX: as it currently is not an Identifier
637 | "null" { $$ = $1; }
638 | "return" NewLineOpt { $$ = $1; }
639 | "super" { $$ = $1; }
640 | "switch" { $$ = $1; }
641 | "this" { $$ = $1; }
642 | "throw" NewLineOpt { $$ = $1; }
643 | "true" { $$ = $1; }
645 | "typeof" { $$ = $1; }
647 | "void" { $$ = $1; }
648 | "while" { $$ = $1; }
649 | "with" { $$ = $1; }
658 : Identifier_ { $$ = $1; }
661 | "typedef" { $$ = $1; }
666 | "implements" { $$ = $1; }
667 | "interface" { $$ = $1; }
668 | "package" { $$ = $1; }
669 | "private" { $$ = $1; }
670 | "protected" { $$ = $1; }
671 | "public" { $$ = $1; }
672 | "static" { $$ = $1; }
674 | "abstract" { $$ = $1; }
675 | "boolean" { $$ = $1; }
676 | "byte" { $$ = $1; }
677 | "char" { $$ = $1; }
678 | "double" { $$ = $1; }
679 | "final" { $$ = $1; }
680 | "float" { $$ = $1; }
681 | "goto" { $$ = $1; }
683 | "long" { $$ = $1; }
684 | "native" { $$ = $1; }
685 | "short" { $$ = $1; }
686 | "synchronized" { $$ = $1; }
687 | "throws" { $$ = $1; }
688 | "transient" { $$ = $1; }
689 | "volatile" { $$ = $1; }
691 // XXX: currently I only have this as Word
692 // | "let" { $$ = $1; }
694 | "yield" { $$ = $1; }
696 | "each" { $$ = $1; }
701 : Identifier { $$ = $1; }
706 /* 7.8 Literals {{{ */
708 : NullLiteral { $$ = $1; }
709 | ValueLiteral { $$ = $1; }
713 : BooleanLiteral { $$ = $1; }
714 | NumericLiteral { $$ = $1; }
715 | StringLiteral { $$ = $1; }
716 | RegularExpressionLiteral { $$ = $1; }
719 /* 7.8.1 Null Literals {{{ */
721 : "null" { $$ = $1; }
724 /* 7.8.2 Boolean Literals {{{ */
726 : "true" { $$ = $1; }
727 | "false" { $$ = $1; }
731 /* 7.9 Automatic Semicolon Insertion {{{ */
733 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
738 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
743 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
747 /* 11.1 Primary Expressions {{{ */
749 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
753 : Parenthetical { $$ = $1; }
758 : Identifier { $$ = CYNew CYVariable($1); }
762 : "this" { $$ = $1; }
763 | Variable { $$ = $1; }
764 | Literal { $$ = $1; }
765 | ArrayLiteral { $$ = $1; }
766 | ObjectLiteral { $$ = $1; }
767 | Parenthetical { $$ = $1; }
768 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
771 /* 11.1.4.1 Array Initialiser {{{ */
773 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
777 : AssignmentExpression { $$ = $1; }
781 : Element { $$ = $1; }
782 | LexSetRegExp { $$ = NULL; }
786 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
787 | Element { $$ = CYNew CYElement($1, NULL); }
791 : ElementList { $$ = $1; }
792 | LexSetRegExp { $$ = NULL; }
795 /* 11.1.4.2 Array Comprehension {{{ */
797 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
801 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
802 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
805 ComprehensionForListOpt
806 : ComprehensionForList { $$ = $1; }
807 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
811 /* 11.1.5 Object Initialiser {{{ */
813 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
816 PropertyDefinitionList_
817 : "," PropertyDefinitionList { $$ = $2; }
818 | "," LexSetRegExp { $$ = NULL; }
822 PropertyDefinitionList
823 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
826 PropertyDefinitionListOpt
827 : PropertyDefinitionList { $$ = $1; }
828 | LexSetRegExp { $$ = NULL; }
832 // XXX: this should be IdentifierName
833 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
834 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
839 : IdentifierName { $$ = $1; }
840 | StringLiteral { $$ = $1; }
841 | NumericLiteral { $$ = $1; }
845 : LexSetRegExp PropertyName_ { $$ = $2; }
849 /* 11.2 Left-Hand-Side Expressions {{{ */
851 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
852 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
853 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
857 : MemberExpression { $$ = $1; }
858 //| "super" { $$ = $1; }
862 : LexSetRegExp PrimaryExpression { $$ = $2; }
863 | LexSetRegExp FunctionExpression { $$ = $2; }
864 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
865 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
869 : MemberExpression { $$ = $1; }
870 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
879 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
880 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
884 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
888 : "," ArgumentList { $$ = $2; }
893 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
897 : ArgumentList { $$ = $1; }
898 | LexSetRegExp { $$ = NULL; }
901 LeftHandSideExpression
902 : NewExpression { $$ = $1; }
903 | CallExpression { $$ = $1; }
906 /* 11.3 Postfix Expressions {{{ */
908 : %prec "" LeftHandSideExpression { $$ = $1; }
909 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
910 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
913 /* 11.4 Unary Operators {{{ */
915 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
916 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
917 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
918 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
919 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
920 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
921 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
922 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
923 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
924 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
925 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
929 : PostfixExpression { $$ = $1; }
930 | LexSetRegExp UnaryExpression_ { $$ = $2; }
933 /* 11.5 Multiplicative Operators {{{ */
934 MultiplicativeExpression
935 : UnaryExpression { $$ = $1; }
936 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
937 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
938 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
941 /* 11.6 Additive Operators {{{ */
943 : MultiplicativeExpression { $$ = $1; }
944 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
945 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
948 /* 11.7 Bitwise Shift Operators {{{ */
950 : AdditiveExpression { $$ = $1; }
951 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
952 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
953 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
956 /* 11.8 Relational Operators {{{ */
958 : ShiftExpression { $$ = $1; }
959 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
960 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
961 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
962 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
963 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
964 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
967 /* 11.9 Equality Operators {{{ */
969 : RelationalExpression { $$ = $1; }
970 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
971 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
972 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
973 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
976 /* 11.10 Binary Bitwise Operators {{{ */
978 : EqualityExpression { $$ = $1; }
979 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
983 : BitwiseANDExpression { $$ = $1; }
984 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
988 : BitwiseXORExpression { $$ = $1; }
989 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
992 /* 11.11 Binary Logical Operators {{{ */
994 : BitwiseORExpression { $$ = $1; }
995 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
999 : LogicalANDExpression { $$ = $1; }
1000 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1003 /* 11.12 Conditional Operator ( ? : ) {{{ */
1004 ConditionalExpression
1005 : LogicalORExpression { $$ = $1; }
1006 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1009 /* 11.13 Assignment Operators {{{ */
1010 AssignmentExpression
1011 : ConditionalExpression { $$ = $1; }
1012 | ArrowFunction { $$ = $1; }
1013 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1014 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1015 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1016 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1017 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1018 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1019 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1020 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1021 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1022 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1023 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1024 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1027 /* 11.14 Comma Operator {{{ */
1029 : "," Expression { $$ = $2; }
1030 | { $$ = CYNew CYCompound(); }
1034 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1038 : Expression { $$ = $1; }
1039 | LexSetRegExp { $$ = NULL; }
1043 /* 12 Statements {{{ */
1045 : Block { $$ = $1; }
1046 | VariableStatement { $$ = $1; }
1047 | EmptyStatement { $$ = $1; }
1048 | IfStatement { $$ = $1; }
1049 | BreakableStatement { $$ = $1; }
1050 | ContinueStatement { $$ = $1; }
1051 | BreakStatement { $$ = $1; }
1052 | ReturnStatement { $$ = $1; }
1053 | WithStatement { $$ = $1; }
1054 | LabelledStatement { $$ = $1; }
1055 | ThrowStatement { $$ = $1; }
1056 | TryStatement { $$ = $1; }
1057 | DebuggerStatement { $$ = $1; }
1061 : LexSetRegExp Statement__ { $$ = $2; }
1062 | ExpressionStatement { $$ = $1; }
1066 : LexSetStatement Statement_ { $$ = $2; }
1070 : FunctionDeclaration { $$ = $1; }
1071 | LexicalDeclaration { $$ = $1; }
1075 : LexSetRegExp Declaration__ { $$ = $2; }
1079 : LexSetStatement Declaration_ { $$ = $2; }
1083 : IterationStatement { $$ = $1; }
1084 | SwitchStatement { $$ = $1; }
1087 /* 12.1 Block {{{ */
1089 : BRACE StatementListOpt "}" { $$ = $2; }
1093 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1097 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1101 : StatementList { $$ = $1; }
1102 | LexSetStatement LexSetRegExp { $$ = NULL; }
1106 : Statement { $$ = $1; }
1107 | Declaration { $$ = $1; }
1111 /* 12.2 Declarations {{{ */
1113 : Identifier { $$ = $1; }
1120 // XXX: BindingPattern
1122 /* 12.2.1 Let and Const Declarations {{{ */
1124 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1132 /* 12.2.2 Variable Statement {{{ */
1134 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1137 VariableDeclarationList_
1138 : "," VariableDeclarationList { $$ = $2; }
1142 VariableDeclarationList
1143 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1147 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1148 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1152 : "=" AssignmentExpression { $$ = $2; }
1156 : Initialiser { $$ = $1; }
1160 /* 12.2.4 Destructuring Binding Patterns {{{ */
1164 : SingleNameBinding { $$ = $1; }
1168 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1172 /* 12.3 Empty Statement {{{ */
1174 : ";" { $$ = CYNew CYEmpty(); }
1177 /* 12.4 Expression Statement {{{ */
1179 : Expression Terminator { $$ = CYNew CYExpress($1); }
1182 /* 12.5 The if Statement {{{ */
1184 : "else" Statement { $$ = $2; }
1185 | %prec "if" { $$ = NULL; }
1189 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1193 /* 12.6.1 The do-while Statement {{{ */
1195 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1198 /* 12.6.2 The while Statement {{{ */
1200 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1203 /* 12.6.3 The for Statement {{{ */
1205 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1208 ForStatementInitialiser
1209 : ExpressionOpt { $$ = $1; }
1210 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1213 /* 12.6.4 The for-in and for-of Statements {{{ */
1215 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1216 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1219 ForInStatementInitialiser
1220 : LeftHandSideExpression { $$ = $1; }
1221 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1225 /* 12.7 The continue Statement {{{ */
1227 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1228 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1231 /* 12.8 The break Statement {{{ */
1233 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1234 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1237 /* 12.9 The return Statement {{{ */
1239 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1240 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1243 /* 12.10 The with Statement {{{ */
1245 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1249 /* 12.11 The switch Statement {{{ */
1251 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1255 : BRACE CaseClausesOpt "}" { $$ = $2; }
1259 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1263 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1264 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1269 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1272 /* 12.12 Labelled Statements {{{ */
1274 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1277 /* 12.13 The throw Statement {{{ */
1279 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1280 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1283 /* 12.14 The try Statement {{{ */
1285 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1289 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1294 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1298 /* 12.14 The debugger Statement {{{ */
1300 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1304 /* 13.1 Function Definitions {{{ */
1306 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1310 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1313 FormalParameterList_
1314 : "," FormalParameterList { $$ = $2; }
1319 // XXX: : FunctionRestParameter { $$ = $1; }
1320 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1323 FormalParameterListOpt
1324 : FormalParameterList
1328 /* XXX: FunctionRestParameter
1329 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1333 : BindingElement { $$ = $1; }
1337 : StatementListOpt { $$ = $1; }
1340 /* 13.2 Arrow Function Definitions {{{ */
1342 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1346 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1347 //| ParentheticalOpt { $$ = $1; }
1351 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1352 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1355 /* 14 Program {{{ */
1357 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1361 : StatementList { $$ = $1; }
1365 : ProgramBody { $$ = $1; }
1366 | LexSetStatement LexSetRegExp { $$ = NULL; }
1371 /* Cycript (Objective-C): Type Encoding {{{ */
1373 : "(" PrefixedType ")" { $$ = $2; }
1377 : Identifier { $$ = CYNew CYTypedIdentifier($1); }
1382 : ArrayedType "[" NumericLiteral "]" { $$ = $1; CYSetLast($$->type_) = CYNew CYTypeArrayOf($3); }
1383 | TypeSignifier { $$ = $1; }
1384 | { $$ = CYNew CYTypedIdentifier(NULL); }
1388 : ArrayedType { $$ = $1; }
1389 | TypeParenthetical "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; CYSetLast($$->type_) = CYNew CYTypeFunctionWith($4); }
1393 : "*" TypeQualifierRight PrefixedType { $$ = $3; CYSetLast($$->type_) = $2; CYSetLast($$->type_) = CYNew CYTypePointerTo(); }
1394 | SuffixedType { $$ = $1; }
1398 : "const" TypeQualifierLeft { $$ = CYNew CYTypeConstant(); CYSetLast($$) = $2; }
1403 : TypeQualifierRight "const" { $$ = CYNew CYTypeConstant($1); }
1408 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; CYSetLast($$) = $1; CYSetLast($$) = CYNew CYTypeVariable($2); }
1412 : Variable { $$ = $1; }
1413 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1417 : ConcreteType PrefixedType { $$ = $2; CYSetLast($$->type_) = $1; }
1421 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1425 : TypeQualifierLeft PrimitiveType { $$ = $1; CYSetLast($$) = CYNew CYTypeVariable($2); }
1426 | ModifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1430 : ModifiedType_ TypeQualifierRight { $$ = $2; CYSetLast($$) = $1; }
1434 : AtEncode "(" EncodedType ")" { $$ = $3; }
1437 /* Cycript (Objective-C): @class Declaration {{{ */
1439 /* XXX: why the hell did I choose MemberExpression? */
1440 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1445 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1446 | LexSetRegExp { $$ = NULL; }
1450 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1454 : "+" { $$ = false; }
1455 | "-" { $$ = true; }
1459 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1464 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1467 MessageParameterList
1468 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1471 MessageParameterListOpt
1472 : MessageParameterList { $$ = $1; }
1477 : MessageParameterList { $$ = $1; }
1478 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1481 ClassMessageDeclaration
1482 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1485 ClassMessageDeclarationListOpt
1486 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1487 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1492 : Identifier { $$ = $1; }
1493 | "(" AssignmentExpression ")" { $$ = $2; }
1497 : ClassName { $$ = $1; }
1501 // XXX: this should be AssignmentExpressionNoRight
1503 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1507 : "," ClassProtocols { $$ = $2; }
1511 ClassProtocolListOpt
1512 : "<" ClassProtocols ">" { $$ = $2; }
1517 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1521 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1529 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1533 : ClassExpression { $$ = $1; }
1537 : ClassStatement { $$ = $1; }
1538 | CategoryStatement { $$ = $1; }
1541 /* Cycript (Objective-C): Send Message {{{ */
1543 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1548 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1549 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1553 : SelectorCall { $$ = $1; }
1554 | VariadicCall { $$ = $1; }
1558 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1562 : SelectorCall { $$ = $1; }
1563 | Word { $$ = CYNew CYArgument($1, NULL); }
1567 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1568 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1572 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1576 : SelectorExpression_ { $$ = $1; }
1577 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1580 SelectorExpressionOpt
1581 : SelectorExpression_ { $$ = $1; }
1586 : MessageExpression { $$ = $1; }
1587 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1590 /* Cycript (Objective-C): @import Directive {{{ */
1604 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1607 /* Cycript (Objective-C): Boxed Expressions {{{ */
1609 : NullLiteral { $$ = $1; }
1610 | BooleanLiteral { $$ = $1; }
1611 | NumericLiteral { $$ = $1; }
1612 | StringLiteral { $$ = $1; }
1613 | ArrayLiteral { $$ = $1; }
1614 | ObjectLiteral { $$ = $1; }
1615 | Parenthetical { $$ = $1; }
1616 | "YES" { $$ = CYNew CYTrue(); }
1617 | "NO" { $$ = CYNew CYFalse(); }
1621 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1624 /* Cycript (Objective-C): Block Expressions {{{ */
1626 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1632 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1633 LeftHandSideExpression
1634 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1638 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1642 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1643 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1644 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1647 /* Cycript (C): auto Compatibility {{{ */
1652 /* Cycript (C): Lambda Expressions {{{ */
1654 : "," TypedParameterList { $$ = $2; }
1659 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1662 TypedParameterListOpt
1663 : TypedParameterList { $$ = $1; }
1668 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14->type_, $10, $17); }
1671 /* Cycript (C): Type Definitions {{{ */
1673 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1678 /* YUI: Documentation Comments {{{ */
1680 : Comment { $$ = $1; }
1685 /* Lexer State {{{ */
1687 : { driver.PushCondition(CYDriver::RegExpCondition); }
1691 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1695 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1699 : { driver.PopCondition(); }
1703 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1707 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1710 /* Virtual Tokens {{{ */
1717 /* 8.1 Context Keywords {{{ */
1719 : "namespace" { $$ = $1; }
1720 | "xml" { $$ = $1; }
1723 /* 8.3 XML Initialiser Input Elements {{{ */
1725 : XMLComment { $$ = $1; }
1726 | XMLCDATA { $$ = $1; }
1727 | XMLPI { $$ = $1; }
1731 /* 11.1 Primary Expressions {{{ */
1733 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1734 | XMLInitialiser { $$ = $1; }
1735 | XMLListInitialiser { $$ = $1; }
1739 : AttributeIdentifier { $$ = $1; }
1740 | QualifiedIdentifier { $$ = $1; }
1741 | WildcardIdentifier { $$ = $1; }
1744 /* 11.1.1 Attribute Identifiers {{{ */
1746 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1750 : PropertySelector { $$ = $1; }
1751 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1755 : Identifier { $$ = CYNew CYSelector($1); }
1756 | WildcardIdentifier { $$ = $1; }
1759 /* 11.1.2 Qualified Identifiers {{{ */
1760 QualifiedIdentifier_
1761 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1762 | QualifiedIdentifier { $$ = $1; }
1766 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1769 /* 11.1.3 Wildcard Identifiers {{{ */
1771 : "*" { $$ = CYNew CYWildcard(); }
1774 /* 11.1.4 XML Initialiser {{{ */
1776 : XMLMarkup { $$ = $1; }
1777 | XMLElement { $$ = $1; }
1781 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1782 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1786 : LexPushXMLTag XMLTagName XMLAttributes
1790 : BRACE LexPushRegExp Expression LexPop "}"
1799 : XMLAttributes_ XMLAttribute
1804 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1805 | XMLAttributes_ XMLWhitespaceOpt
1814 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1818 : XMLExpression XMLElementContentOpt
1819 | XMLMarkup XMLElementContentOpt
1820 | XMLText XMLElementContentOpt
1821 | XMLElement XMLElementContentOpt
1824 XMLElementContentOpt
1829 /* 11.1.5 XMLList Initialiser {{{ */
1831 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1835 /* 11.2 Left-Hand-Side Expressions {{{ */
1837 : Identifier { $$ = $1; }
1838 | PropertyIdentifier { $$ = $1; }
1842 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1843 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1844 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1847 /* 12.1 The default xml namespace Statement {{{ */
1848 /* XXX: DefaultXMLNamespaceStatement
1849 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1853 : DefaultXMLNamespaceStatement { $$ = $1; }
1858 /* JavaScript 1.7: Array Comprehensions {{{ */
1860 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1864 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1865 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1869 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1872 ComprehensionListOpt
1873 : ComprehensionList { $$ = $1; }
1874 | IfComprehension { $$ = $1; }
1879 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1882 /* JavaScript 1.7: for each {{{ */
1884 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1887 /* JavaScript 1.7: let Statements {{{ */
1889 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1897 /* JavaScript FTW: Ruby Blocks {{{ */
1898 RubyProcParameterList_
1899 : "," RubyProcParameterList { $$ = $2; }
1903 RubyProcParameterList
1904 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1909 : "|" RubyProcParameterList "|" { $$ = $2; }
1910 | "||" { $$ = NULL; }
1913 RubyProcParametersOpt
1914 : RubyProcParameters
1919 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1923 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1927 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }