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_;
79 CYProperty *property_;
80 CYPropertyName *propertyName_;
81 CYRubyProc *rubyProc_;
82 CYStatement *statement_;
89 CYClassName *className_;
92 CYMessageParameter *messageParameter_;
93 CYProtocol *protocol_;
94 CYSelectorPart *selector_;
95 CYTypeModifier *modifier_;
96 CYTypedIdentifier *typedIdentifier_;
97 CYTypedParameter *typedParameter_;
101 CYAttribute *attribute_;
102 CYPropertyIdentifier *propertyIdentifier_;
103 CYSelector *selector_;
108 #define YYSTYPE YYSTYPE
111 @if Bison24 %code provides {
112 int cylex(YYSTYPE *, cy::location *, void *);
119 @if Bison23 %skeleton "lalr1.cc"
120 @if Bison24 %language "C++"
123 @$.begin.filename = @$.end.filename = &driver.filename_;
134 %parse-param { CYDriver &driver }
135 %lex-param { void *cyscanner }
137 /* Token Declarations {{{ */
143 %token XMLAttributeValue
145 %token XMLTagCharacters
151 %token LeftRight "<>"
152 %token LeftSlashRight "</>"
154 %token SlashRight "/>"
155 %token LeftSlash "</"
157 %token ColonColon "::"
158 %token PeriodPeriod ".."
161 @begin E4X ObjectiveC
166 %token AmpersandAmpersand "&&"
167 %token AmpersandEqual "&="
169 %token CarrotEqual "^="
171 %token EqualEqual "=="
172 %token EqualEqualEqual "==="
173 %token EqualRight "=>"
174 %token Exclamation "!"
175 %token ExclamationEqual "!="
176 %token ExclamationEqualEqual "!=="
178 %token HyphenEqual "-="
179 %token HyphenHyphen "--"
180 %token HyphenHyphen_ "\n--"
181 %token HyphenRight "->"
183 %token LeftEqual "<="
185 %token LeftLeftEqual "<<="
187 %token PercentEqual "%="
189 %token PeriodPeriodPeriod "..."
191 %token PipeEqual "|="
194 %token PlusEqual "+="
196 %token PlusPlus_ "\n++"
198 %token RightEqual ">="
199 %token RightRight ">>"
200 %token RightRightEqual ">>="
201 %token RightRightRight ">>>"
202 %token RightRightRightEqual ">>>="
204 %token SlashEqual "/="
206 %token StarEqual "*="
215 %token <comment_> Comment
218 %token CloseParen ")"
221 %token OpenBrace_ "\n{"
222 %token OpenBrace__ ";{"
223 %token CloseBrace "}"
225 %token OpenBracket "["
226 %token CloseBracket "]"
228 %token AtError "@error"
231 %token AtClass "@class"
235 %token <identifier_> Typedef "typedef"
239 %token AtImplementation "@implementation"
240 %token AtImplementation_ ";@implementation"
241 %token AtImport "@import"
242 %token AtEncode "@encode"
244 %token AtSelector "@selector"
245 %token <identifier_> Yes "YES"
246 %token <identifier_> No "NO"
249 %token <false_> False "false"
250 %token <null_> Null "null"
251 %token <true_> True "true"
253 // ES3/ES5/WIE/JSC Reserved
254 %token <word_> Auto "auto"
255 %token <word_> Break "break"
256 %token <word_> Case "case"
257 %token <word_> Catch "catch"
258 %token <word_> Continue "continue"
259 %token <word_> Default "default"
260 %token <word_> Delete "delete"
261 %token <word_> Do "do"
262 %token <word_> Else "else"
263 %token <word_> Finally "finally"
264 %token <word_> For "for"
265 %token <word_> Function "function"
266 %token <word_> Function_ ";function"
267 %token <word_> If "if"
268 %token <word_> In "in"
269 %token <word_> In_ "!in"
270 %token <word_> InstanceOf "instanceof"
271 %token <word_> New "new"
272 %token <word_> Return "return"
273 %token <word_> Switch "switch"
274 %token <this_> This "this"
275 %token <word_> Throw "throw"
276 %token <word_> Try "try"
277 %token <word_> TypeOf "typeof"
278 %token <word_> Var "var"
279 %token <word_> Void "void"
280 %token <word_> While "while"
281 %token <word_> With "with"
283 // ES3/IE6 Future, ES5/JSC Reserved
284 %token <word_> Debugger "debugger"
286 // ES3/ES5/IE6 Future, JSC Reserved
287 %token <word_> Const "const"
289 // ES3/ES5/IE6/JSC Future
290 %token <word_> Class "class"
291 %token <word_> Enum "enum"
292 %token <word_> Export "export"
293 %token <word_> Extends "extends"
294 %token <word_> Import "import"
295 %token <word_> Super "super"
297 // ES3 Future, ES5 Strict Future
298 %token <identifier_> Implements "implements"
299 %token <identifier_> Interface "interface"
300 %token <identifier_> Package "package"
301 %token <identifier_> Private "private"
302 %token <identifier_> Protected "protected"
303 %token <identifier_> Public "public"
304 %token <identifier_> Static "static"
307 %token <identifier_> Abstract "abstract"
308 %token <identifier_> Boolean "boolean"
309 %token <identifier_> Byte "byte"
310 %token <identifier_> Char "char"
311 %token <identifier_> Double "double"
312 %token <identifier_> Final "final"
313 %token <identifier_> Float "float"
314 %token <identifier_> Goto "goto"
315 %token <identifier_> Int "int"
316 %token <identifier_> Long "long"
317 %token <identifier_> Native "native"
318 %token <identifier_> Short "short"
319 %token <identifier_> Synchronized "synchronized"
320 %token <identifier_> Throws "throws"
321 %token <identifier_> Transient "transient"
322 %token <identifier_> Volatile "volatile"
325 %token <identifier_> Let "let"
326 %token <identifier_> Yield "yield"
329 %token <identifier_> Each "each"
330 %token <identifier_> Of "of"
334 %token <identifier_> Namespace "namespace"
335 %token <identifier_> XML "xml"
340 %token <identifier_> Identifier_
341 %token <number_> NumericLiteral
342 %token <string_> StringLiteral
343 %token <literal_> RegularExpressionLiteral
345 %type <expression_> AdditiveExpression
346 %type <argument_> ArgumentList_
347 %type <argument_> ArgumentList
348 %type <argument_> ArgumentListOpt
349 %type <argument_> Arguments
350 %type <literal_> ArrayLiteral
351 %type <expression_> ArrowFunction
352 %type <functionParameter_> ArrowParameters
353 %type <expression_> AssignmentExpression
354 %type <identifier_> Binding
355 %type <identifier_> BindingIdentifier
356 %type <expression_> BitwiseANDExpression
357 %type <statement_> Block_
358 %type <statement_> Block
359 %type <boolean_> BooleanLiteral
360 %type <declaration_> BindingElement
361 %type <expression_> BitwiseORExpression
362 %type <expression_> BitwiseXORExpression
363 %type <statement_> BreakStatement
364 %type <statement_> BreakableStatement
365 %type <expression_> CallExpression_
366 %type <expression_> CallExpression
367 %type <clause_> CaseBlock
368 %type <clause_> CaseClause
369 %type <clause_> CaseClausesOpt
370 %type <catch_> CatchOpt
371 %type <comprehension_> ComprehensionForList
372 %type <comprehension_> ComprehensionForListOpt
373 %type <comprehension_> ComprehensionList
374 %type <comprehension_> ComprehensionListOpt
375 %type <expression_> ConditionalExpression
376 %type <statement_> ContinueStatement
377 %type <statement_> ConciseBody
378 %type <statement_> DebuggerStatement
379 %type <statement_> Declaration__
380 %type <statement_> Declaration_
381 %type <statement_> Declaration
382 %type <clause_> DefaultClause
383 %type <expression_> Element
384 %type <expression_> ElementOpt
385 %type <element_> ElementList
386 %type <element_> ElementListOpt
387 %type <statement_> ElseStatementOpt
388 %type <statement_> EmptyStatement
389 %type <expression_> EqualityExpression
390 %type <compound_> Expression_
391 %type <compound_> Expression
392 %type <expression_> ExpressionOpt
393 %type <statement_> ExpressionStatement
394 %type <finally_> FinallyOpt
395 %type <comprehension_> ForComprehension
396 %type <for_> ForStatementInitialiser
397 %type <forin_> ForInStatementInitialiser
398 %type <declaration_> FormalParameter
399 %type <functionParameter_> FormalParameterList_
400 %type <functionParameter_> FormalParameterList
401 %type <functionParameter_> FormalParameterListOpt
402 %type <statement_> FunctionBody
403 %type <statement_> FunctionDeclaration
404 %type <expression_> FunctionExpression
405 %type <identifier_> Identifier
406 %type <identifier_> IdentifierOpt
407 %type <word_> IdentifierName
408 %type <comprehension_> IfComprehension
409 %type <statement_> IfStatement
410 %type <expression_> Initialiser
411 %type <expression_> InitialiserOpt
412 %type <statement_> IterationStatement
413 %type <statement_> LabelledStatement
414 %type <expression_> LeftHandSideExpression
415 %type <statement_> LetStatement
416 %type <statement_> LexicalDeclaration
417 %type <literal_> Literal
418 %type <literal_> ValueLiteral
419 %type <expression_> LogicalANDExpression
420 %type <expression_> LogicalORExpression
421 %type <member_> MemberAccess
422 %type <expression_> MemberExpression_
423 %type <expression_> MemberExpression
424 %type <expression_> MultiplicativeExpression
425 %type <expression_> NewExpression
426 %type <null_> NullLiteral
427 %type <literal_> ObjectLiteral
428 %type <compound_> Parenthetical
429 %type <compound_> ParentheticalOpt
430 %type <expression_> PostfixExpression
431 %type <expression_> PrimaryExpression
432 %type <statement_> Program
433 %type <statement_> ProgramBody
434 %type <statement_> ProgramBodyOpt
435 %type <propertyName_> PropertyName_
436 %type <propertyName_> PropertyName
437 %type <property_> PropertyDefinition
438 %type <property_> PropertyDefinitionList_
439 %type <property_> PropertyDefinitionList
440 %type <property_> PropertyDefinitionListOpt
441 %type <expression_> RelationalExpression
442 %type <statement_> ReturnStatement
443 %type <rubyProc_> RubyProcExpression
444 %type <functionParameter_> RubyProcParameterList_
445 %type <functionParameter_> RubyProcParameterList
446 %type <functionParameter_> RubyProcParameters
447 %type <functionParameter_> RubyProcParametersOpt
448 %type <expression_> ShiftExpression
449 %type <declaration_> SingleNameBinding
450 %type <statement_> Statement__
451 %type <statement_> Statement_
452 %type <statement_> Statement
453 %type <statement_> StatementList
454 %type <statement_> StatementListOpt
455 %type <statement_> StatementListItem
456 %type <statement_> SwitchStatement
457 %type <statement_> ThrowStatement
458 %type <statement_> TryStatement
459 %type <expression_> UnaryExpression_
460 %type <expression_> UnaryExpression
461 %type <declaration_> VariableDeclaration
462 %type <declarations_> VariableDeclarationList_
463 %type <declarations_> VariableDeclarationList
464 %type <statement_> VariableStatement
465 %type <statement_> WithStatement
467 %type <word_> WordOpt
468 %type <expression_> Variable
471 %type <typedIdentifier_> ArrayedType
472 %type <expression_> BoxableExpression
473 %type <statement_> CategoryStatement
474 %type <expression_> ClassExpression
475 %type <field_> ClassFieldListOpt
476 %type <field_> ClassFields
477 %type <statement_> ClassStatement
478 %type <expression_> ClassSuperOpt
479 %type <message_> ClassMessageDeclaration
480 %type <message_> ClassMessageDeclarationListOpt
481 %type <className_> ClassName
482 %type <className_> ClassNameOpt
483 %type <protocol_> ClassProtocolListOpt
484 %type <protocol_> ClassProtocols
485 %type <protocol_> ClassProtocolsOpt
486 %type <expression_> EncodedType
487 %type <modifier_> FunctionedType
488 %type <expression_> MessageExpression
489 %type <messageParameter_> MessageParameter
490 %type <messageParameter_> MessageParameters
491 %type <messageParameter_> MessageParameterList
492 %type <messageParameter_> MessageParameterListOpt
493 %type <bool_> MessageScope
494 %type <typedIdentifier_> ModifiedType
495 %type <module_> Module
496 %type <typedIdentifier_> PrefixedType
497 %type <expression_> PrimitiveType
498 %type <argument_> SelectorCall_
499 %type <argument_> SelectorCall
500 %type <selector_> SelectorExpression_
501 %type <selector_> SelectorExpression
502 %type <selector_> SelectorExpressionOpt
503 %type <argument_> SelectorList
504 %type <word_> SelectorWordOpt
505 %type <typedIdentifier_> SuffixedType
506 %type <expression_> TypeOpt
507 %type <typedIdentifier_> TypeParenthetical
508 %type <modifier_> TypeQualifierLeft
509 %type <typedIdentifier_> TypeQualifierRight
510 %type <typedIdentifier_> TypeSignifier
511 %type <typedIdentifier_> TypedIdentifier
512 %type <typedParameter_> TypedParameterList_
513 %type <typedParameter_> TypedParameterList
514 %type <typedParameter_> TypedParameterListOpt
515 %type <argument_> VariadicCall
519 %type <propertyIdentifier_> PropertyIdentifier_
520 %type <selector_> PropertySelector_
521 %type <selector_> PropertySelector
522 %type <identifier_> QualifiedIdentifier_
523 %type <identifier_> QualifiedIdentifier
524 %type <identifier_> WildcardIdentifier
525 %type <identifier_> XMLComment
526 %type <identifier_> XMLCDATA
527 %type <identifier_> XMLElement
528 %type <identifier_> XMLElementContent
529 %type <identifier_> XMLMarkup
530 %type <identifier_> XMLPI
532 %type <attribute_> AttributeIdentifier
533 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
534 %type <expression_> PropertyIdentifier
535 %type <expression_> XMLListInitialiser
536 %type <expression_> XMLInitialiser
539 /* Token Priorities {{{ */
551 /* Lexer State {{{ */
553 : { driver.in_.push(true); }
557 : { driver.in_.push(false); }
561 : { driver.in_.pop(); }
565 : { driver.SetCondition(CYDriver::RegExpCondition); }
569 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
573 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
576 LexNoAtImplementation :
578 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
583 : LexNoBrace LexNoFunction LexNoAtImplementation
586 /* Virtual Tokens {{{ */
597 /* 7.6 Identifier Names and Identifiers {{{ */
608 : Identifier { $$ = $1; }
609 | "auto" { $$ = $1; }
610 | "break" NewLineOpt { $$ = $1; }
611 | "case" { $$ = $1; }
612 | "catch" { $$ = $1; }
613 | "class" { $$ = $1; }
614 | "const" { $$ = $1; }
615 | "continue" NewLineOpt { $$ = $1; }
616 | "debugger" { $$ = $1; }
617 | "default" { $$ = $1; }
618 | "delete" { $$ = $1; }
620 | "else" { $$ = $1; }
621 | "enum" { $$ = $1; }
622 | "export" { $$ = $1; }
623 | "extends" { $$ = $1; }
624 | "false" { $$ = $1; }
625 | "finally" { $$ = $1; }
626 /* XXX: | "for" { $$ = $1; } */
627 | "function" { $$ = $1; }
629 | "import" { $$ = $1; }
630 /* XXX: | "in" { $$ = $1; } */
632 /* XXX: | "instanceof" { $$ = $1; } */
634 // XXX: as it currently is not an Identifier
638 | "null" { $$ = $1; }
639 | "return" NewLineOpt { $$ = $1; }
640 | "super" { $$ = $1; }
641 | "switch" { $$ = $1; }
642 | "this" { $$ = $1; }
643 | "throw" NewLineOpt { $$ = $1; }
644 | "true" { $$ = $1; }
646 | "typeof" { $$ = $1; }
648 | "void" { $$ = $1; }
649 | "while" { $$ = $1; }
650 | "with" { $$ = $1; }
659 : Identifier_ { $$ = $1; }
662 | "typedef" { $$ = $1; }
667 | "implements" { $$ = $1; }
668 | "interface" { $$ = $1; }
669 | "package" { $$ = $1; }
670 | "private" { $$ = $1; }
671 | "protected" { $$ = $1; }
672 | "public" { $$ = $1; }
673 | "static" { $$ = $1; }
675 | "abstract" { $$ = $1; }
676 | "boolean" { $$ = $1; }
677 | "byte" { $$ = $1; }
678 | "char" { $$ = $1; }
679 | "double" { $$ = $1; }
680 | "final" { $$ = $1; }
681 | "float" { $$ = $1; }
682 | "goto" { $$ = $1; }
684 | "long" { $$ = $1; }
685 | "native" { $$ = $1; }
686 | "short" { $$ = $1; }
687 | "synchronized" { $$ = $1; }
688 | "throws" { $$ = $1; }
689 | "transient" { $$ = $1; }
690 | "volatile" { $$ = $1; }
692 // XXX: currently I only have this as Word
693 // | "let" { $$ = $1; }
695 | "yield" { $$ = $1; }
697 | "each" { $$ = $1; }
702 : Identifier { $$ = $1; }
707 /* 7.8 Literals {{{ */
709 : NullLiteral { $$ = $1; }
710 | ValueLiteral { $$ = $1; }
714 : BooleanLiteral { $$ = $1; }
715 | NumericLiteral { $$ = $1; }
716 | StringLiteral { $$ = $1; }
717 | RegularExpressionLiteral { $$ = $1; }
720 /* 7.8.1 Null Literals {{{ */
722 : "null" { $$ = $1; }
725 /* 7.8.2 Boolean Literals {{{ */
727 : "true" { $$ = $1; }
728 | "false" { $$ = $1; }
732 /* 7.9 Automatic Semicolon Insertion {{{ */
734 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
739 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
744 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
748 /* 11.1 Primary Expressions {{{ */
750 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
754 : Parenthetical { $$ = $1; }
759 : Identifier { $$ = CYNew CYVariable($1); }
763 : "this" { $$ = $1; }
764 | Variable { $$ = $1; }
765 | Literal { $$ = $1; }
766 | ArrayLiteral { $$ = $1; }
767 | ObjectLiteral { $$ = $1; }
768 | Parenthetical { $$ = $1; }
769 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
772 /* 11.1.4.1 Array Initialiser {{{ */
774 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
778 : AssignmentExpression { $$ = $1; }
782 : Element { $$ = $1; }
783 | LexSetRegExp { $$ = NULL; }
787 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
788 | Element { $$ = CYNew CYElement($1, NULL); }
792 : ElementList { $$ = $1; }
793 | LexSetRegExp { $$ = NULL; }
796 /* 11.1.4.2 Array Comprehension {{{ */
798 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
802 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
803 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
806 ComprehensionForListOpt
807 : ComprehensionForList { $$ = $1; }
808 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
812 /* 11.1.5 Object Initialiser {{{ */
814 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
817 PropertyDefinitionList_
818 : "," PropertyDefinitionList { $$ = $2; }
819 | "," LexSetRegExp { $$ = NULL; }
823 PropertyDefinitionList
824 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
827 PropertyDefinitionListOpt
828 : PropertyDefinitionList { $$ = $1; }
829 | LexSetRegExp { $$ = NULL; }
833 // XXX: this should be IdentifierName
834 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
835 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
840 : IdentifierName { $$ = $1; }
841 | StringLiteral { $$ = $1; }
842 | NumericLiteral { $$ = $1; }
846 : LexSetRegExp PropertyName_ { $$ = $2; }
850 /* 11.2 Left-Hand-Side Expressions {{{ */
852 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
853 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
854 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
858 : MemberExpression { $$ = $1; }
859 //| "super" { $$ = $1; }
863 : LexSetRegExp PrimaryExpression { $$ = $2; }
864 | LexSetRegExp FunctionExpression { $$ = $2; }
865 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
866 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
870 : MemberExpression { $$ = $1; }
871 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
880 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
881 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
885 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
889 : "," ArgumentList { $$ = $2; }
894 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
898 : ArgumentList { $$ = $1; }
899 | LexSetRegExp { $$ = NULL; }
902 LeftHandSideExpression
903 : NewExpression { $$ = $1; }
904 | CallExpression { $$ = $1; }
907 /* 11.3 Postfix Expressions {{{ */
909 : %prec "" LeftHandSideExpression { $$ = $1; }
910 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
911 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
914 /* 11.4 Unary Operators {{{ */
916 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
917 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
918 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
919 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
920 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
921 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
922 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
923 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
924 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
925 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
926 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
930 : PostfixExpression { $$ = $1; }
931 | LexSetRegExp UnaryExpression_ { $$ = $2; }
934 /* 11.5 Multiplicative Operators {{{ */
935 MultiplicativeExpression
936 : UnaryExpression { $$ = $1; }
937 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
938 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
939 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
942 /* 11.6 Additive Operators {{{ */
944 : MultiplicativeExpression { $$ = $1; }
945 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
946 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
949 /* 11.7 Bitwise Shift Operators {{{ */
951 : AdditiveExpression { $$ = $1; }
952 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
953 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
954 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
957 /* 11.8 Relational Operators {{{ */
959 : ShiftExpression { $$ = $1; }
960 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
961 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
962 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
963 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
964 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
965 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
968 /* 11.9 Equality Operators {{{ */
970 : RelationalExpression { $$ = $1; }
971 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
972 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
973 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
974 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
977 /* 11.10 Binary Bitwise Operators {{{ */
979 : EqualityExpression { $$ = $1; }
980 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
984 : BitwiseANDExpression { $$ = $1; }
985 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
989 : BitwiseXORExpression { $$ = $1; }
990 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
993 /* 11.11 Binary Logical Operators {{{ */
995 : BitwiseORExpression { $$ = $1; }
996 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1000 : LogicalANDExpression { $$ = $1; }
1001 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1004 /* 11.12 Conditional Operator ( ? : ) {{{ */
1005 ConditionalExpression
1006 : LogicalORExpression { $$ = $1; }
1007 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1010 /* 11.13 Assignment Operators {{{ */
1011 AssignmentExpression
1012 : ConditionalExpression { $$ = $1; }
1013 | ArrowFunction { $$ = $1; }
1014 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1015 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1016 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1017 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1018 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1019 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1020 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1021 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1022 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1023 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1024 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1025 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1028 /* 11.14 Comma Operator {{{ */
1030 : "," Expression { $$ = $2; }
1031 | { $$ = CYNew CYCompound(); }
1035 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1039 : Expression { $$ = $1; }
1040 | LexSetRegExp { $$ = NULL; }
1044 /* 12 Statements {{{ */
1046 : Block { $$ = $1; }
1047 | VariableStatement { $$ = $1; }
1048 | EmptyStatement { $$ = $1; }
1049 | IfStatement { $$ = $1; }
1050 | BreakableStatement { $$ = $1; }
1051 | ContinueStatement { $$ = $1; }
1052 | BreakStatement { $$ = $1; }
1053 | ReturnStatement { $$ = $1; }
1054 | WithStatement { $$ = $1; }
1055 | LabelledStatement { $$ = $1; }
1056 | ThrowStatement { $$ = $1; }
1057 | TryStatement { $$ = $1; }
1058 | DebuggerStatement { $$ = $1; }
1062 : LexSetRegExp Statement__ { $$ = $2; }
1063 | ExpressionStatement { $$ = $1; }
1067 : LexSetStatement Statement_ { $$ = $2; }
1071 : FunctionDeclaration { $$ = $1; }
1072 | LexicalDeclaration { $$ = $1; }
1076 : LexSetRegExp Declaration__ { $$ = $2; }
1080 : LexSetStatement Declaration_ { $$ = $2; }
1084 : IterationStatement { $$ = $1; }
1085 | SwitchStatement { $$ = $1; }
1088 /* 12.1 Block {{{ */
1090 : BRACE StatementListOpt "}" { $$ = $2; }
1094 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1098 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1102 : StatementList { $$ = $1; }
1103 | LexSetStatement LexSetRegExp { $$ = NULL; }
1107 : Statement { $$ = $1; }
1108 | Declaration { $$ = $1; }
1112 /* 12.2 Declarations {{{ */
1114 : Identifier { $$ = $1; }
1121 // XXX: BindingPattern
1123 /* 12.2.1 Let and Const Declarations {{{ */
1125 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1133 /* 12.2.2 Variable Statement {{{ */
1135 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1138 VariableDeclarationList_
1139 : "," VariableDeclarationList { $$ = $2; }
1143 VariableDeclarationList
1144 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1148 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1149 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1153 : "=" AssignmentExpression { $$ = $2; }
1157 : Initialiser { $$ = $1; }
1161 /* 12.2.4 Destructuring Binding Patterns {{{ */
1165 : SingleNameBinding { $$ = $1; }
1169 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1173 /* 12.3 Empty Statement {{{ */
1175 : ";" { $$ = CYNew CYEmpty(); }
1178 /* 12.4 Expression Statement {{{ */
1180 : Expression Terminator { $$ = CYNew CYExpress($1); }
1183 /* 12.5 The if Statement {{{ */
1185 : "else" Statement { $$ = $2; }
1186 | %prec "if" { $$ = NULL; }
1190 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1194 /* 12.6.1 The do-while Statement {{{ */
1196 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1199 /* 12.6.2 The while Statement {{{ */
1201 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1204 /* 12.6.3 The for Statement {{{ */
1206 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1209 ForStatementInitialiser
1210 : ExpressionOpt { $$ = $1; }
1211 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1214 /* 12.6.4 The for-in and for-of Statements {{{ */
1216 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1217 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1220 ForInStatementInitialiser
1221 : LeftHandSideExpression { $$ = $1; }
1222 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1226 /* 12.7 The continue Statement {{{ */
1228 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1229 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1232 /* 12.8 The break Statement {{{ */
1234 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1235 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1238 /* 12.9 The return Statement {{{ */
1240 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1241 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1244 /* 12.10 The with Statement {{{ */
1246 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1250 /* 12.11 The switch Statement {{{ */
1252 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1256 : BRACE CaseClausesOpt "}" { $$ = $2; }
1260 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1264 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1265 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1270 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1273 /* 12.12 Labelled Statements {{{ */
1275 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1278 /* 12.13 The throw Statement {{{ */
1280 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1281 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1284 /* 12.14 The try Statement {{{ */
1286 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1290 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1295 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1299 /* 12.14 The debugger Statement {{{ */
1301 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1305 /* 13.1 Function Definitions {{{ */
1307 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1311 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1314 FormalParameterList_
1315 : "," FormalParameterList { $$ = $2; }
1320 // XXX: : FunctionRestParameter { $$ = $1; }
1321 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1324 FormalParameterListOpt
1325 : FormalParameterList
1329 /* XXX: FunctionRestParameter
1330 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1334 : BindingElement { $$ = $1; }
1338 : StatementListOpt { $$ = $1; }
1341 /* 13.2 Arrow Function Definitions {{{ */
1343 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1347 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1348 //| ParentheticalOpt { $$ = $1; }
1352 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1353 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1356 /* 14 Program {{{ */
1358 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1362 : StatementList { $$ = $1; }
1366 : ProgramBody { $$ = $1; }
1367 | LexSetStatement LexSetRegExp { $$ = NULL; }
1372 /* Cycript (Objective-C): Type Encoding {{{ */
1374 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1378 : Identifier { $$ = CYNew CYTypedIdentifier($1); }
1379 | TypeParenthetical { $$ = $1; }
1383 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1384 | TypeSignifier { $$ = $1; }
1385 | { $$ = CYNew CYTypedIdentifier(); }
1389 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1393 : ArrayedType { $$ = $1; }
1394 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1395 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1396 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1400 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1404 : "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1405 /* XXX: | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); } */
1410 : "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1411 | PrefixedType { $$ = $1; }
1412 | SuffixedType { $$ = $1; }
1416 : Variable { $$ = $1; }
1417 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1421 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->type_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1425 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1429 : AtEncode "(" EncodedType ")" { $$ = $3; }
1432 /* Cycript (Objective-C): @class Declaration {{{ */
1434 /* XXX: why the hell did I choose MemberExpression? */
1435 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1440 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1441 | LexSetRegExp { $$ = NULL; }
1445 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1449 : "+" { $$ = false; }
1450 | "-" { $$ = true; }
1454 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1459 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1462 MessageParameterList
1463 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1466 MessageParameterListOpt
1467 : MessageParameterList { $$ = $1; }
1472 : MessageParameterList { $$ = $1; }
1473 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1476 ClassMessageDeclaration
1477 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1480 ClassMessageDeclarationListOpt
1481 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1482 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1487 : Identifier { $$ = $1; }
1488 | "(" AssignmentExpression ")" { $$ = $2; }
1492 : ClassName { $$ = $1; }
1496 // XXX: this should be AssignmentExpressionNoRight
1498 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1502 : "," ClassProtocols { $$ = $2; }
1506 ClassProtocolListOpt
1507 : "<" ClassProtocols ">" { $$ = $2; }
1512 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1516 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1524 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1528 : ClassExpression { $$ = $1; }
1532 : ClassStatement { $$ = $1; }
1533 | CategoryStatement { $$ = $1; }
1536 /* Cycript (Objective-C): Send Message {{{ */
1538 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1543 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1544 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1548 : SelectorCall { $$ = $1; }
1549 | VariadicCall { $$ = $1; }
1553 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1557 : SelectorCall { $$ = $1; }
1558 | Word { $$ = CYNew CYArgument($1, NULL); }
1562 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1563 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1567 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1571 : SelectorExpression_ { $$ = $1; }
1572 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1575 SelectorExpressionOpt
1576 : SelectorExpression_ { $$ = $1; }
1581 : MessageExpression { $$ = $1; }
1582 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1585 /* Cycript (Objective-C): @import Directive {{{ */
1587 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1588 | Word { $$ = CYNew CYModule($1); }
1592 : "@import" Module { $$ = CYNew CYImport($2); }
1595 /* Cycript (Objective-C): Boxed Expressions {{{ */
1597 : NullLiteral { $$ = $1; }
1598 | BooleanLiteral { $$ = $1; }
1599 | NumericLiteral { $$ = $1; }
1600 | StringLiteral { $$ = $1; }
1601 | ArrayLiteral { $$ = $1; }
1602 | ObjectLiteral { $$ = $1; }
1603 | Parenthetical { $$ = $1; }
1604 | "YES" { $$ = CYNew CYTrue(); }
1605 | "NO" { $$ = CYNew CYFalse(); }
1609 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1612 /* Cycript (Objective-C): Block Expressions {{{ */
1614 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->type_ = $2; $$->modifier_ = $1; }
1615 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1619 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1625 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1626 LeftHandSideExpression
1627 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1631 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1635 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1636 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1637 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1640 /* Cycript (C): auto Compatibility {{{ */
1645 /* Cycript (C): Lambda Expressions {{{ */
1647 : "," TypedParameterList { $$ = $2; }
1652 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1655 TypedParameterListOpt
1656 : TypedParameterList { $$ = $1; }
1661 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1664 /* Cycript (C): Type Definitions {{{ */
1666 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1671 /* YUI: Documentation Comments {{{ */
1673 : Comment { $$ = $1; }
1678 /* Lexer State {{{ */
1680 : { driver.PushCondition(CYDriver::RegExpCondition); }
1684 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1688 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1692 : { driver.PopCondition(); }
1696 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1700 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1703 /* Virtual Tokens {{{ */
1710 /* 8.1 Context Keywords {{{ */
1712 : "namespace" { $$ = $1; }
1713 | "xml" { $$ = $1; }
1716 /* 8.3 XML Initialiser Input Elements {{{ */
1718 : XMLComment { $$ = $1; }
1719 | XMLCDATA { $$ = $1; }
1720 | XMLPI { $$ = $1; }
1724 /* 11.1 Primary Expressions {{{ */
1726 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1727 | XMLInitialiser { $$ = $1; }
1728 | XMLListInitialiser { $$ = $1; }
1732 : AttributeIdentifier { $$ = $1; }
1733 | QualifiedIdentifier { $$ = $1; }
1734 | WildcardIdentifier { $$ = $1; }
1737 /* 11.1.1 Attribute Identifiers {{{ */
1739 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1743 : PropertySelector { $$ = $1; }
1744 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1748 : Identifier { $$ = CYNew CYSelector($1); }
1749 | WildcardIdentifier { $$ = $1; }
1752 /* 11.1.2 Qualified Identifiers {{{ */
1753 QualifiedIdentifier_
1754 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1755 | QualifiedIdentifier { $$ = $1; }
1759 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1762 /* 11.1.3 Wildcard Identifiers {{{ */
1764 : "*" { $$ = CYNew CYWildcard(); }
1767 /* 11.1.4 XML Initialiser {{{ */
1769 : XMLMarkup { $$ = $1; }
1770 | XMLElement { $$ = $1; }
1774 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1775 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1779 : LexPushXMLTag XMLTagName XMLAttributes
1783 : BRACE LexPushRegExp Expression LexPop "}"
1792 : XMLAttributes_ XMLAttribute
1797 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1798 | XMLAttributes_ XMLWhitespaceOpt
1807 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1811 : XMLExpression XMLElementContentOpt
1812 | XMLMarkup XMLElementContentOpt
1813 | XMLText XMLElementContentOpt
1814 | XMLElement XMLElementContentOpt
1817 XMLElementContentOpt
1822 /* 11.1.5 XMLList Initialiser {{{ */
1824 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1828 /* 11.2 Left-Hand-Side Expressions {{{ */
1830 : Identifier { $$ = $1; }
1831 | PropertyIdentifier { $$ = $1; }
1835 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1836 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1837 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1840 /* 12.1 The default xml namespace Statement {{{ */
1841 /* XXX: DefaultXMLNamespaceStatement
1842 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1846 : DefaultXMLNamespaceStatement { $$ = $1; }
1851 /* JavaScript 1.7: Array Comprehensions {{{ */
1853 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1857 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1858 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1862 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1865 ComprehensionListOpt
1866 : ComprehensionList { $$ = $1; }
1867 | IfComprehension { $$ = $1; }
1872 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1875 /* JavaScript 1.7: for each {{{ */
1877 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1880 /* JavaScript 1.7: let Statements {{{ */
1882 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1890 /* JavaScript FTW: Ruby Blocks {{{ */
1891 RubyProcParameterList_
1892 : "," RubyProcParameterList { $$ = $2; }
1896 RubyProcParameterList
1897 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1902 : "|" RubyProcParameterList "|" { $$ = $2; }
1903 | "||" { $$ = NULL; }
1906 RubyProcParametersOpt
1907 : RubyProcParameters
1912 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1916 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1920 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }