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 CYTypeModifier *modifier_;
90 CYTypeSpecifier *specifier_;
91 CYTypedIdentifier *typedIdentifier_;
92 CYTypedParameter *typedParameter_;
96 CYClassName *className_;
99 CYMessageParameter *messageParameter_;
100 CYProtocol *protocol_;
101 CYSelectorPart *selector_;
105 CYAttribute *attribute_;
106 CYPropertyIdentifier *propertyIdentifier_;
107 CYSelector *selector_;
112 #define YYSTYPE YYSTYPE
115 @if Bison24 %code provides {
116 int cylex(YYSTYPE *, cy::location *, void *);
123 @if Bison23 %skeleton "lalr1.cc"
124 @if Bison24 %language "C++"
127 @$.begin.filename = @$.end.filename = &driver.filename_;
138 %parse-param { CYDriver &driver }
139 %lex-param { void *cyscanner }
141 /* Token Declarations {{{ */
147 %token XMLAttributeValue
149 %token XMLTagCharacters
155 %token LeftRight "<>"
156 %token LeftSlashRight "</>"
158 %token SlashRight "/>"
159 %token LeftSlash "</"
161 %token ColonColon "::"
162 %token PeriodPeriod ".."
165 @begin E4X ObjectiveC
171 %token AmpersandAmpersand "&&"
172 %token AmpersandEqual "&="
174 %token CarrotEqual "^="
176 %token EqualEqual "=="
177 %token EqualEqualEqual "==="
178 %token EqualRight "=>"
179 %token Exclamation "!"
180 %token ExclamationEqual "!="
181 %token ExclamationEqualEqual "!=="
183 %token HyphenEqual "-="
184 %token HyphenHyphen "--"
185 %token HyphenHyphen_ "\n--"
186 %token HyphenRight "->"
188 %token LeftEqual "<="
190 %token LeftLeftEqual "<<="
192 %token PercentEqual "%="
194 %token PeriodPeriodPeriod "..."
196 %token PipeEqual "|="
199 %token PlusEqual "+="
201 %token PlusPlus_ "\n++"
203 %token RightEqual ">="
204 %token RightRight ">>"
205 %token RightRightEqual ">>="
206 %token RightRightRight ">>>"
207 %token RightRightRightEqual ">>>="
209 %token SlashEqual "/="
211 %token StarEqual "*="
220 %token <comment_> Comment
223 %token CloseParen ")"
226 %token OpenBrace_ "\n{"
227 %token OpenBrace__ ";{"
228 %token CloseBrace "}"
230 %token OpenBracket "["
231 %token CloseBracket "]"
233 %token AtError "@error"
236 %token AtClass "@class"
240 %token <identifier_> Typedef "typedef"
241 %token <identifier_> Unsigned "unsigned"
242 %token <identifier_> Signed "signed"
246 %token AtEncode "@encode"
250 %token AtImplementation "@implementation"
251 %token AtImplementation_ ";@implementation"
252 %token AtImport "@import"
254 %token AtSelector "@selector"
255 %token <identifier_> Yes "YES"
256 %token <identifier_> No "NO"
259 %token <false_> False "false"
260 %token <null_> Null "null"
261 %token <true_> True "true"
263 // ES3/ES5/WIE/JSC Reserved
264 %token <word_> Auto "auto"
265 %token <word_> Break "break"
266 %token <word_> Case "case"
267 %token <word_> Catch "catch"
268 %token <word_> Continue "continue"
269 %token <word_> Default "default"
270 %token <word_> Delete "delete"
271 %token <word_> Do "do"
272 %token <word_> Else "else"
273 %token <word_> Finally "finally"
274 %token <word_> For "for"
275 %token <word_> Function "function"
276 %token <word_> Function_ ";function"
277 %token <word_> If "if"
278 %token <word_> In "in"
279 %token <word_> In_ "!in"
280 %token <word_> InstanceOf "instanceof"
281 %token <word_> New "new"
282 %token <word_> Return "return"
283 %token <word_> Switch "switch"
284 %token <this_> This "this"
285 %token <word_> Throw "throw"
286 %token <word_> Try "try"
287 %token <word_> TypeOf "typeof"
288 %token <word_> Var "var"
289 %token <word_> Void "void"
290 %token <word_> While "while"
291 %token <word_> With "with"
293 // ES3/IE6 Future, ES5/JSC Reserved
294 %token <word_> Debugger "debugger"
296 // ES3/ES5/IE6 Future, JSC Reserved
297 %token <word_> Const "const"
299 // ES3/ES5/IE6/JSC Future
300 %token <word_> Class "class"
301 %token <word_> Enum "enum"
302 %token <word_> Export "export"
303 %token <word_> Extends "extends"
304 %token <word_> Import "import"
305 %token <word_> Super "super"
307 // ES3 Future, ES5 Strict Future
308 %token <identifier_> Implements "implements"
309 %token <identifier_> Interface "interface"
310 %token <identifier_> Package "package"
311 %token <identifier_> Private "private"
312 %token <identifier_> Protected "protected"
313 %token <identifier_> Public "public"
314 %token <identifier_> Static "static"
317 %token <identifier_> Abstract "abstract"
318 %token <identifier_> Boolean "boolean"
319 %token <identifier_> Byte "byte"
320 %token <identifier_> Char "char"
321 %token <identifier_> Double "double"
322 %token <identifier_> Final "final"
323 %token <identifier_> Float "float"
324 %token <identifier_> Goto "goto"
325 %token <identifier_> Int "int"
326 %token <identifier_> Long "long"
327 %token <identifier_> Native "native"
328 %token <identifier_> Short "short"
329 %token <identifier_> Synchronized "synchronized"
330 %token <identifier_> Throws "throws"
331 %token <identifier_> Transient "transient"
332 %token <identifier_> Volatile "volatile"
335 %token <identifier_> Let "let"
336 %token <identifier_> Yield "yield"
339 %token <identifier_> Each "each"
340 %token <identifier_> Of "of"
344 %token <identifier_> Namespace "namespace"
345 %token <identifier_> XML "xml"
350 %token <identifier_> Identifier_
351 %token <number_> NumericLiteral
352 %token <string_> StringLiteral
353 %token <literal_> RegularExpressionLiteral
355 %type <expression_> AdditiveExpression
356 %type <argument_> ArgumentList_
357 %type <argument_> ArgumentList
358 %type <argument_> ArgumentListOpt
359 %type <argument_> Arguments
360 %type <expression_> ArrayComprehension
361 %type <expression_> ArrayInitialiser
362 %type <literal_> ArrayLiteral
363 %type <expression_> ArrowFunction
364 %type <functionParameter_> ArrowParameters
365 %type <expression_> AssignmentExpression
366 %type <identifier_> Binding
367 %type <identifier_> BindingIdentifier
368 %type <expression_> BitwiseANDExpression
369 %type <statement_> Block_
370 %type <statement_> Block
371 %type <boolean_> BooleanLiteral
372 %type <declaration_> BindingElement
373 %type <expression_> BitwiseORExpression
374 %type <expression_> BitwiseXORExpression
375 %type <statement_> BreakStatement
376 %type <statement_> BreakableStatement
377 %type <expression_> CallExpression_
378 %type <expression_> CallExpression
379 %type <clause_> CaseBlock
380 %type <clause_> CaseClause
381 %type <clause_> CaseClausesOpt
382 %type <catch_> CatchOpt
383 %type <expression_> Comprehension
384 %type <comprehension_> ComprehensionFor
385 %type <comprehension_> ComprehensionIf
386 %type <comprehension_> ComprehensionTail
387 %type <expression_> ConditionalExpression
388 %type <statement_> ContinueStatement
389 %type <statement_> ConciseBody
390 %type <statement_> DebuggerStatement
391 %type <statement_> Declaration__
392 %type <statement_> Declaration_
393 %type <statement_> Declaration
394 %type <clause_> DefaultClause
395 %type <expression_> Element
396 %type <expression_> ElementOpt
397 %type <element_> ElementList
398 %type <element_> ElementListOpt
399 %type <statement_> ElseStatementOpt
400 %type <statement_> EmptyStatement
401 %type <expression_> EqualityExpression
402 %type <compound_> Expression_
403 %type <compound_> Expression
404 %type <expression_> ExpressionOpt
405 %type <statement_> ExpressionStatement
406 %type <finally_> FinallyOpt
407 %type <for_> ForStatementInitialiser
408 %type <forin_> ForInStatementInitialiser
409 %type <declaration_> FormalParameter
410 %type <functionParameter_> FormalParameterList_
411 %type <functionParameter_> FormalParameterList
412 %type <functionParameter_> FormalParameterListOpt
413 %type <statement_> FunctionBody
414 %type <statement_> FunctionDeclaration
415 %type <expression_> FunctionExpression
416 %type <identifier_> Identifier
417 %type <identifier_> IdentifierOpt
418 %type <identifier_> IdentifierType
419 %type <word_> IdentifierName
420 %type <statement_> IfStatement
421 %type <expression_> Initialiser
422 %type <expression_> InitialiserOpt
423 %type <statement_> IterationStatement
424 %type <statement_> LabelledStatement
425 %type <expression_> LeftHandSideExpression
426 %type <statement_> LetStatement
427 %type <statement_> LexicalDeclaration
428 %type <literal_> Literal
429 %type <literal_> ValueLiteral
430 %type <expression_> LogicalANDExpression
431 %type <expression_> LogicalORExpression
432 %type <member_> MemberAccess
433 %type <expression_> MemberExpression_
434 %type <expression_> MemberExpression
435 %type <module_> Module
436 %type <expression_> MultiplicativeExpression
437 %type <expression_> NewExpression
438 %type <null_> NullLiteral
439 %type <literal_> ObjectLiteral
440 %type <compound_> Parenthetical
441 %type <compound_> ParentheticalOpt
442 %type <expression_> PostfixExpression
443 %type <expression_> PrimaryExpression
444 %type <statement_> Program
445 %type <statement_> ProgramBody
446 %type <statement_> ProgramBodyOpt
447 %type <propertyName_> PropertyName_
448 %type <propertyName_> PropertyName
449 %type <property_> PropertyDefinition
450 %type <property_> PropertyDefinitionList_
451 %type <property_> PropertyDefinitionList
452 %type <property_> PropertyDefinitionListOpt
453 %type <expression_> RelationalExpression
454 %type <statement_> ReturnStatement
455 %type <rubyProc_> RubyProcExpression
456 %type <functionParameter_> RubyProcParameterList_
457 %type <functionParameter_> RubyProcParameterList
458 %type <functionParameter_> RubyProcParameters
459 %type <functionParameter_> RubyProcParametersOpt
460 %type <expression_> ShiftExpression
461 %type <declaration_> SingleNameBinding
462 %type <statement_> Statement__
463 %type <statement_> Statement_
464 %type <statement_> Statement
465 %type <statement_> StatementList
466 %type <statement_> StatementListOpt
467 %type <statement_> StatementListItem
468 %type <statement_> SwitchStatement
469 %type <statement_> ThrowStatement
470 %type <statement_> TryStatement
471 %type <expression_> UnaryExpression_
472 %type <expression_> UnaryExpression
473 %type <declaration_> VariableDeclaration
474 %type <declarations_> VariableDeclarationList_
475 %type <declarations_> VariableDeclarationList
476 %type <statement_> VariableStatement
477 %type <statement_> WithStatement
479 %type <word_> WordOpt
480 %type <expression_> Variable
483 %type <typedIdentifier_> ArrayedType
484 %type <expression_> EncodedType
485 %type <modifier_> FunctionedType
486 %type <specifier_> IntegerType
487 %type <specifier_> IntegerTypeOpt
488 %type <typedIdentifier_> PrefixedType
489 %type <specifier_> PrimitiveType
490 %type <typedIdentifier_> TypeParenthetical
491 %type <typedIdentifier_> TypeSignifier
492 %type <typedIdentifier_> SuffixedType
493 %type <modifier_> TypeQualifierLeft
494 %type <typedIdentifier_> TypeQualifierRight
495 %type <typedIdentifier_> TypedIdentifier
496 %type <typedParameter_> TypedParameterList_
497 %type <typedParameter_> TypedParameterList
498 %type <typedParameter_> TypedParameterListOpt
502 %type <expression_> BoxableExpression
503 %type <statement_> CategoryStatement
504 %type <expression_> ClassExpression
505 %type <field_> ClassFieldListOpt
506 %type <field_> ClassFields
507 %type <statement_> ClassStatement
508 %type <expression_> ClassSuperOpt
509 %type <message_> ClassMessageDeclaration
510 %type <message_> ClassMessageDeclarationListOpt
511 %type <className_> ClassName
512 %type <className_> ClassNameOpt
513 %type <protocol_> ClassProtocolListOpt
514 %type <protocol_> ClassProtocols
515 %type <protocol_> ClassProtocolsOpt
516 %type <expression_> MessageExpression
517 %type <messageParameter_> MessageParameter
518 %type <messageParameter_> MessageParameters
519 %type <messageParameter_> MessageParameterList
520 %type <messageParameter_> MessageParameterListOpt
521 %type <bool_> MessageScope
522 %type <typedIdentifier_> ModifiedType
523 %type <argument_> SelectorCall_
524 %type <argument_> SelectorCall
525 %type <selector_> SelectorExpression_
526 %type <selector_> SelectorExpression
527 %type <selector_> SelectorExpressionOpt
528 %type <argument_> SelectorList
529 %type <word_> SelectorWordOpt
530 %type <expression_> TypeOpt
531 %type <argument_> VariadicCall
535 %type <propertyIdentifier_> PropertyIdentifier_
536 %type <selector_> PropertySelector_
537 %type <selector_> PropertySelector
538 %type <identifier_> QualifiedIdentifier_
539 %type <identifier_> QualifiedIdentifier
540 %type <identifier_> WildcardIdentifier
541 %type <identifier_> XMLComment
542 %type <identifier_> XMLCDATA
543 %type <identifier_> XMLElement
544 %type <identifier_> XMLElementContent
545 %type <identifier_> XMLMarkup
546 %type <identifier_> XMLPI
548 %type <attribute_> AttributeIdentifier
549 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
550 %type <expression_> PropertyIdentifier
551 %type <expression_> XMLListInitialiser
552 %type <expression_> XMLInitialiser
555 /* Token Priorities {{{ */
567 /* Lexer State {{{ */
569 : { driver.in_.push(true); }
573 : { driver.in_.push(false); }
577 : { driver.in_.pop(); }
581 : { driver.SetCondition(CYDriver::RegExpCondition); }
585 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
589 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
592 LexNoAtImplementation :
594 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
599 : LexNoBrace LexNoFunction LexNoAtImplementation
602 /* Virtual Tokens {{{ */
613 /* 7.6 Identifier Names and Identifiers {{{ */
624 : Identifier { $$ = $1; }
625 | "auto" { $$ = $1; }
626 | "break" NewLineOpt { $$ = $1; }
627 | "case" { $$ = $1; }
628 | "catch" { $$ = $1; }
629 | "class" { $$ = $1; }
630 | "const" { $$ = $1; }
631 | "continue" NewLineOpt { $$ = $1; }
632 | "debugger" { $$ = $1; }
633 | "default" { $$ = $1; }
634 | "delete" { $$ = $1; }
636 | "else" { $$ = $1; }
637 | "enum" { $$ = $1; }
638 | "export" { $$ = $1; }
639 | "extends" { $$ = $1; }
640 | "false" { $$ = $1; }
641 | "finally" { $$ = $1; }
642 /* XXX: | "for" { $$ = $1; } */
643 | "function" { $$ = $1; }
645 | "import" { $$ = $1; }
646 /* XXX: | "in" { $$ = $1; } */
648 /* XXX: | "instanceof" { $$ = $1; } */
650 // XXX: as it currently is not an Identifier
654 | "null" { $$ = $1; }
655 | "return" NewLineOpt { $$ = $1; }
656 | "super" { $$ = $1; }
657 | "switch" { $$ = $1; }
658 | "this" { $$ = $1; }
659 | "throw" NewLineOpt { $$ = $1; }
660 | "true" { $$ = $1; }
662 | "typeof" { $$ = $1; }
664 | "void" { $$ = $1; }
665 | "while" { $$ = $1; }
666 | "with" { $$ = $1; }
675 : Identifier_ { $$ = $1; }
677 | "implements" { $$ = $1; }
678 | "interface" { $$ = $1; }
679 | "package" { $$ = $1; }
680 | "private" { $$ = $1; }
681 | "protected" { $$ = $1; }
682 | "public" { $$ = $1; }
683 | "static" { $$ = $1; }
685 | "abstract" { $$ = $1; }
686 | "boolean" { $$ = $1; }
687 | "byte" { $$ = $1; }
688 | "double" { $$ = $1; }
689 | "final" { $$ = $1; }
690 | "float" { $$ = $1; }
691 | "goto" { $$ = $1; }
692 | "native" { $$ = $1; }
693 | "synchronized" { $$ = $1; }
694 | "throws" { $$ = $1; }
695 | "transient" { $$ = $1; }
697 // XXX: currently I only have this as Word
698 // | "let" { $$ = $1; }
700 | "yield" { $$ = $1; }
702 | "each" { $$ = $1; }
708 | "char" { $$ = $1; }
710 | "long" { $$ = $1; }
711 | "short" { $$ = $1; }
712 | "volatile" { $$ = $1; }
714 | "typedef" { $$ = $1; }
715 | "unsigned" { $$ = $1; }
716 | "signed" { $$ = $1; }
725 : Identifier { $$ = $1; }
730 /* 7.8 Literals {{{ */
732 : NullLiteral { $$ = $1; }
733 | ValueLiteral { $$ = $1; }
737 : BooleanLiteral { $$ = $1; }
738 | NumericLiteral { $$ = $1; }
739 | StringLiteral { $$ = $1; }
740 | RegularExpressionLiteral { $$ = $1; }
743 /* 7.8.1 Null Literals {{{ */
745 : "null" { $$ = $1; }
748 /* 7.8.2 Boolean Literals {{{ */
750 : "true" { $$ = $1; }
751 | "false" { $$ = $1; }
755 /* 7.9 Automatic Semicolon Insertion {{{ */
757 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
762 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
767 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
771 /* 11.1 Primary Expressions {{{ */
773 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
777 : Parenthetical { $$ = $1; }
782 : Identifier { $$ = CYNew CYVariable($1); }
786 : "this" { $$ = $1; }
787 | Variable { $$ = $1; }
788 | Literal { $$ = $1; }
789 | ArrayInitialiser { $$ = $1; }
790 | ObjectLiteral { $$ = $1; }
791 | Parenthetical { $$ = $1; }
792 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
795 /* 11.1.4 Array Initializer {{{ */
797 : ArrayLiteral { $$ = $1; }
798 | ArrayComprehension { $$ = $1; }
801 /* 11.1.4.1 Array Literal {{{ */
803 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
807 : AssignmentExpression { $$ = $1; }
811 : Element { $$ = $1; }
812 | LexSetRegExp { $$ = NULL; }
816 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
817 | Element { $$ = CYNew CYElement($1, NULL); }
821 : ElementList { $$ = $1; }
822 | LexSetRegExp { $$ = NULL; }
825 /* 11.1.4.2 Array Comprehension {{{ */
827 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
831 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
836 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
837 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
841 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
845 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
848 /* 11.1.5 Object Initialiser {{{ */
850 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
853 PropertyDefinitionList_
854 : "," PropertyDefinitionList { $$ = $2; }
855 | "," LexSetRegExp { $$ = NULL; }
859 PropertyDefinitionList
860 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
863 PropertyDefinitionListOpt
864 : PropertyDefinitionList { $$ = $1; }
865 | LexSetRegExp { $$ = NULL; }
869 // XXX: this should be IdentifierName
870 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
871 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
876 : IdentifierName { $$ = $1; }
877 | StringLiteral { $$ = $1; }
878 | NumericLiteral { $$ = $1; }
882 : LexSetRegExp PropertyName_ { $$ = $2; }
886 /* 11.2 Left-Hand-Side Expressions {{{ */
888 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
889 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
890 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
894 : MemberExpression { $$ = $1; }
895 //| "super" { $$ = $1; }
899 : LexSetRegExp PrimaryExpression { $$ = $2; }
900 | LexSetRegExp FunctionExpression { $$ = $2; }
901 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
902 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
906 : MemberExpression { $$ = $1; }
907 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
916 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
917 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
921 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
925 : "," ArgumentList { $$ = $2; }
930 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
934 : ArgumentList { $$ = $1; }
935 | LexSetRegExp { $$ = NULL; }
938 LeftHandSideExpression
939 : NewExpression { $$ = $1; }
940 | CallExpression { $$ = $1; }
943 /* 11.3 Postfix Expressions {{{ */
945 : %prec "" LeftHandSideExpression { $$ = $1; }
946 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
947 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
950 /* 11.4 Unary Operators {{{ */
952 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
953 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
954 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
955 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
956 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
957 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
958 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
959 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
960 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
961 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
962 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
966 : PostfixExpression { $$ = $1; }
967 | LexSetRegExp UnaryExpression_ { $$ = $2; }
970 /* 11.5 Multiplicative Operators {{{ */
971 MultiplicativeExpression
972 : UnaryExpression { $$ = $1; }
973 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
974 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
975 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
978 /* 11.6 Additive Operators {{{ */
980 : MultiplicativeExpression { $$ = $1; }
981 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
982 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
985 /* 11.7 Bitwise Shift Operators {{{ */
987 : AdditiveExpression { $$ = $1; }
988 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
989 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
990 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
993 /* 11.8 Relational Operators {{{ */
995 : ShiftExpression { $$ = $1; }
996 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
997 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
998 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
999 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1000 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1001 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1004 /* 11.9 Equality Operators {{{ */
1006 : RelationalExpression { $$ = $1; }
1007 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1008 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1009 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1010 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1013 /* 11.10 Binary Bitwise Operators {{{ */
1014 BitwiseANDExpression
1015 : EqualityExpression { $$ = $1; }
1016 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1019 BitwiseXORExpression
1020 : BitwiseANDExpression { $$ = $1; }
1021 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1025 : BitwiseXORExpression { $$ = $1; }
1026 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1029 /* 11.11 Binary Logical Operators {{{ */
1030 LogicalANDExpression
1031 : BitwiseORExpression { $$ = $1; }
1032 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1036 : LogicalANDExpression { $$ = $1; }
1037 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1040 /* 11.12 Conditional Operator ( ? : ) {{{ */
1041 ConditionalExpression
1042 : LogicalORExpression { $$ = $1; }
1043 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1044 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1047 /* 11.13 Assignment Operators {{{ */
1048 AssignmentExpression
1049 : ConditionalExpression { $$ = $1; }
1050 | ArrowFunction { $$ = $1; }
1051 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1052 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1053 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1054 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1055 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1056 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1057 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1058 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1059 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1060 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1061 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1062 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1065 /* 11.14 Comma Operator {{{ */
1067 : "," Expression { $$ = $2; }
1072 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1076 : Expression { $$ = $1; }
1077 | LexSetRegExp { $$ = NULL; }
1081 /* 12 Statements {{{ */
1083 : Block { $$ = $1; }
1084 | VariableStatement { $$ = $1; }
1085 | EmptyStatement { $$ = $1; }
1086 | IfStatement { $$ = $1; }
1087 | BreakableStatement { $$ = $1; }
1088 | ContinueStatement { $$ = $1; }
1089 | BreakStatement { $$ = $1; }
1090 | ReturnStatement { $$ = $1; }
1091 | WithStatement { $$ = $1; }
1092 | LabelledStatement { $$ = $1; }
1093 | ThrowStatement { $$ = $1; }
1094 | TryStatement { $$ = $1; }
1095 | DebuggerStatement { $$ = $1; }
1099 : LexSetRegExp Statement__ { $$ = $2; }
1100 | ExpressionStatement { $$ = $1; }
1104 : LexSetStatement Statement_ { $$ = $2; }
1108 : FunctionDeclaration { $$ = $1; }
1109 | LexicalDeclaration { $$ = $1; }
1113 : LexSetRegExp Declaration__ { $$ = $2; }
1117 : LexSetStatement Declaration_ { $$ = $2; }
1121 : IterationStatement { $$ = $1; }
1122 | SwitchStatement { $$ = $1; }
1125 /* 12.1 Block {{{ */
1127 : BRACE StatementListOpt "}" { $$ = $2; }
1131 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1135 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1139 : StatementList { $$ = $1; }
1140 | LexSetStatement LexSetRegExp { $$ = NULL; }
1144 : Statement { $$ = $1; }
1145 | Declaration { $$ = $1; }
1149 /* 12.2 Declarations {{{ */
1151 : Identifier { $$ = $1; }
1158 // XXX: BindingPattern
1160 /* 12.2.1 Let and Const Declarations {{{ */
1162 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1170 /* 12.2.2 Variable Statement {{{ */
1172 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1175 VariableDeclarationList_
1176 : "," VariableDeclarationList { $$ = $2; }
1180 VariableDeclarationList
1181 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1185 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1186 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1190 : "=" AssignmentExpression { $$ = $2; }
1194 : Initialiser { $$ = $1; }
1198 /* 12.2.4 Destructuring Binding Patterns {{{ */
1202 : SingleNameBinding { $$ = $1; }
1206 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1210 /* 12.3 Empty Statement {{{ */
1212 : ";" { $$ = CYNew CYEmpty(); }
1215 /* 12.4 Expression Statement {{{ */
1217 : Expression Terminator { $$ = CYNew CYExpress($1); }
1220 /* 12.5 The if Statement {{{ */
1222 : "else" Statement { $$ = $2; }
1223 | %prec "if" { $$ = NULL; }
1227 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1231 /* 12.6.1 The do-while Statement {{{ */
1233 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1236 /* 12.6.2 The while Statement {{{ */
1238 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1241 /* 12.6.3 The for Statement {{{ */
1243 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1246 ForStatementInitialiser
1247 : ExpressionOpt { $$ = $1; }
1248 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1251 /* 12.6.4 The for-in and for-of Statements {{{ */
1253 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1254 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1257 ForInStatementInitialiser
1258 : LeftHandSideExpression { $$ = $1; }
1259 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1263 /* 12.7 The continue Statement {{{ */
1265 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1266 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1269 /* 12.8 The break Statement {{{ */
1271 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1272 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1275 /* 12.9 The return Statement {{{ */
1277 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1278 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1281 /* 12.10 The with Statement {{{ */
1283 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1287 /* 12.11 The switch Statement {{{ */
1289 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1293 : BRACE CaseClausesOpt "}" { $$ = $2; }
1297 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1301 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1302 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1307 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1310 /* 12.12 Labelled Statements {{{ */
1312 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1315 /* 12.13 The throw Statement {{{ */
1317 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1318 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1321 /* 12.14 The try Statement {{{ */
1323 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1327 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1332 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1336 /* 12.14 The debugger Statement {{{ */
1338 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1342 /* 13.1 Function Definitions {{{ */
1344 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1348 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1351 FormalParameterList_
1352 : "," FormalParameterList { $$ = $2; }
1357 // XXX: : FunctionRestParameter { $$ = $1; }
1358 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1361 FormalParameterListOpt
1362 : FormalParameterList
1366 /* XXX: FunctionRestParameter
1367 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1371 : BindingElement { $$ = $1; }
1375 : StatementListOpt { $$ = $1; }
1378 /* 13.2 Arrow Function Definitions {{{ */
1380 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1384 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1385 //| ParentheticalOpt { $$ = $1; }
1389 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1390 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1393 /* 14 Program {{{ */
1395 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1399 : StatementList { $$ = $1; }
1403 : ProgramBody { $$ = $1; }
1404 | LexSetStatement LexSetRegExp { $$ = NULL; }
1409 /* Cycript (C): Type Encoding {{{ */
1411 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1415 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1416 | TypeParenthetical { $$ = $1; }
1420 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1421 | TypeSignifier { $$ = $1; }
1422 | { $$ = CYNew CYTypedIdentifier(); }
1426 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1430 : ArrayedType { $$ = $1; }
1431 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1432 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1433 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1437 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1442 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1443 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1447 : PrefixedType { $$ = $1; }
1448 | SuffixedType { $$ = $1; }
1449 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1450 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1454 : "int" { $$ = CYNew CYTypeVariable("int"); }
1455 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1456 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1457 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1458 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1462 : IntegerType { $$ = $1; }
1463 | { $$ = CYNew CYTypeVariable("int"); }
1467 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1468 | IntegerType { $$ = $1; }
1469 | "void" { $$ = CYNew CYTypeVoid(); }
1470 | "char" { $$ = CYNew CYTypeVariable("char"); }
1471 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1472 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1476 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1480 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1484 : "@encode" "(" EncodedType ")" { $$ = $3; }
1490 /* Cycript (Objective-C): @class Declaration {{{ */
1492 /* XXX: why the hell did I choose MemberExpression? */
1493 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1498 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1499 | LexSetRegExp { $$ = NULL; }
1503 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1507 : "+" { $$ = false; }
1508 | "-" { $$ = true; }
1512 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1517 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1520 MessageParameterList
1521 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1524 MessageParameterListOpt
1525 : MessageParameterList { $$ = $1; }
1530 : MessageParameterList { $$ = $1; }
1531 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1534 ClassMessageDeclaration
1535 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1538 ClassMessageDeclarationListOpt
1539 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1540 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1545 : Identifier { $$ = $1; }
1546 | "(" AssignmentExpression ")" { $$ = $2; }
1550 : ClassName { $$ = $1; }
1554 // XXX: this should be AssignmentExpressionNoRight
1556 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1560 : "," ClassProtocols { $$ = $2; }
1564 ClassProtocolListOpt
1565 : "<" ClassProtocols ">" { $$ = $2; }
1570 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1574 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1582 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1586 : ClassExpression { $$ = $1; }
1590 : ClassStatement { $$ = $1; }
1591 | CategoryStatement { $$ = $1; }
1594 /* Cycript (Objective-C): Send Message {{{ */
1596 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1601 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1602 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1606 : SelectorCall { $$ = $1; }
1607 | VariadicCall { $$ = $1; }
1611 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1615 : SelectorCall { $$ = $1; }
1616 | Word { $$ = CYNew CYArgument($1, NULL); }
1620 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1621 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1625 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1629 : SelectorExpression_ { $$ = $1; }
1630 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1633 SelectorExpressionOpt
1634 : SelectorExpression_ { $$ = $1; }
1639 : MessageExpression { $$ = $1; }
1640 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1645 /* Cycript: @import Directive {{{ */
1647 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1648 | Word { $$ = CYNew CYModule($1); }
1652 : "@import" Module { $$ = CYNew CYImport($2); }
1657 /* Cycript (Objective-C): Boxed Expressions {{{ */
1659 : NullLiteral { $$ = $1; }
1660 | BooleanLiteral { $$ = $1; }
1661 | NumericLiteral { $$ = $1; }
1662 | StringLiteral { $$ = $1; }
1663 | ArrayLiteral { $$ = $1; }
1664 | ObjectLiteral { $$ = $1; }
1665 | Parenthetical { $$ = $1; }
1666 | "YES" { $$ = CYNew CYTrue(); }
1667 | "NO" { $$ = CYNew CYFalse(); }
1671 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1674 /* Cycript (Objective-C): Block Expressions {{{ */
1676 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1677 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1681 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1684 /* Cycript (Objective-C): Instance Literals {{{ */
1686 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1692 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1693 LeftHandSideExpression
1694 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1698 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1702 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1703 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1704 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1707 /* Cycript (C): auto Compatibility {{{ */
1712 /* Cycript (C): Lambda Expressions {{{ */
1714 : "," TypedParameterList { $$ = $2; }
1719 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1722 TypedParameterListOpt
1723 : TypedParameterList { $$ = $1; }
1728 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1731 /* Cycript (C): Type Definitions {{{ */
1733 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1738 /* YUI: Documentation Comments {{{ */
1740 : Comment { $$ = $1; }
1745 /* Lexer State {{{ */
1747 : { driver.PushCondition(CYDriver::RegExpCondition); }
1751 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1755 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1759 : { driver.PopCondition(); }
1763 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1767 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1770 /* Virtual Tokens {{{ */
1777 /* 8.1 Context Keywords {{{ */
1779 : "namespace" { $$ = $1; }
1780 | "xml" { $$ = $1; }
1783 /* 8.3 XML Initialiser Input Elements {{{ */
1785 : XMLComment { $$ = $1; }
1786 | XMLCDATA { $$ = $1; }
1787 | XMLPI { $$ = $1; }
1791 /* 11.1 Primary Expressions {{{ */
1793 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1794 | XMLInitialiser { $$ = $1; }
1795 | XMLListInitialiser { $$ = $1; }
1799 : AttributeIdentifier { $$ = $1; }
1800 | QualifiedIdentifier { $$ = $1; }
1801 | WildcardIdentifier { $$ = $1; }
1804 /* 11.1.1 Attribute Identifiers {{{ */
1806 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1810 : PropertySelector { $$ = $1; }
1811 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1815 : Identifier { $$ = CYNew CYSelector($1); }
1816 | WildcardIdentifier { $$ = $1; }
1819 /* 11.1.2 Qualified Identifiers {{{ */
1820 QualifiedIdentifier_
1821 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1822 | QualifiedIdentifier { $$ = $1; }
1826 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1829 /* 11.1.3 Wildcard Identifiers {{{ */
1831 : "*" { $$ = CYNew CYWildcard(); }
1834 /* 11.1.4 XML Initialiser {{{ */
1836 : XMLMarkup { $$ = $1; }
1837 | XMLElement { $$ = $1; }
1841 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1842 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1846 : LexPushXMLTag XMLTagName XMLAttributes
1850 : BRACE LexPushRegExp Expression LexPop "}"
1859 : XMLAttributes_ XMLAttribute
1864 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1865 | XMLAttributes_ XMLWhitespaceOpt
1874 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1878 : XMLExpression XMLElementContentOpt
1879 | XMLMarkup XMLElementContentOpt
1880 | XMLText XMLElementContentOpt
1881 | XMLElement XMLElementContentOpt
1884 XMLElementContentOpt
1889 /* 11.1.5 XMLList Initialiser {{{ */
1891 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1895 /* 11.2 Left-Hand-Side Expressions {{{ */
1897 : Identifier { $$ = $1; }
1898 | PropertyIdentifier { $$ = $1; }
1902 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1903 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1904 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1907 /* 12.1 The default xml namespace Statement {{{ */
1908 /* XXX: DefaultXMLNamespaceStatement
1909 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1913 : DefaultXMLNamespaceStatement { $$ = $1; }
1918 /* JavaScript 1.7: Array Comprehensions {{{ */
1920 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1924 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1925 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1928 /* JavaScript 1.7: for each {{{ */
1930 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1933 /* JavaScript 1.7: let Statements {{{ */
1935 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1943 /* JavaScript FTW: Ruby Blocks {{{ */
1944 RubyProcParameterList_
1945 : "," RubyProcParameterList { $$ = $2; }
1949 RubyProcParameterList
1950 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1955 : "|" RubyProcParameterList "|" { $$ = $2; }
1956 | "||" { $$ = NULL; }
1959 RubyProcParametersOpt
1960 : RubyProcParameters
1965 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1969 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1973 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }