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 CYTypeSpecifier *specifier_;
83 CYStatement *statement_;
90 CYClassName *className_;
93 CYMessageParameter *messageParameter_;
94 CYProtocol *protocol_;
95 CYSelectorPart *selector_;
96 CYTypeModifier *modifier_;
97 CYTypedIdentifier *typedIdentifier_;
98 CYTypedParameter *typedParameter_;
102 CYAttribute *attribute_;
103 CYPropertyIdentifier *propertyIdentifier_;
104 CYSelector *selector_;
109 #define YYSTYPE YYSTYPE
112 @if Bison24 %code provides {
113 int cylex(YYSTYPE *, cy::location *, void *);
120 @if Bison23 %skeleton "lalr1.cc"
121 @if Bison24 %language "C++"
124 @$.begin.filename = @$.end.filename = &driver.filename_;
135 %parse-param { CYDriver &driver }
136 %lex-param { void *cyscanner }
138 /* Token Declarations {{{ */
144 %token XMLAttributeValue
146 %token XMLTagCharacters
152 %token LeftRight "<>"
153 %token LeftSlashRight "</>"
155 %token SlashRight "/>"
156 %token LeftSlash "</"
158 %token ColonColon "::"
159 %token PeriodPeriod ".."
162 @begin E4X ObjectiveC
167 %token AmpersandAmpersand "&&"
168 %token AmpersandEqual "&="
170 %token CarrotEqual "^="
172 %token EqualEqual "=="
173 %token EqualEqualEqual "==="
174 %token EqualRight "=>"
175 %token Exclamation "!"
176 %token ExclamationEqual "!="
177 %token ExclamationEqualEqual "!=="
179 %token HyphenEqual "-="
180 %token HyphenHyphen "--"
181 %token HyphenHyphen_ "\n--"
182 %token HyphenRight "->"
184 %token LeftEqual "<="
186 %token LeftLeftEqual "<<="
188 %token PercentEqual "%="
190 %token PeriodPeriodPeriod "..."
192 %token PipeEqual "|="
195 %token PlusEqual "+="
197 %token PlusPlus_ "\n++"
199 %token RightEqual ">="
200 %token RightRight ">>"
201 %token RightRightEqual ">>="
202 %token RightRightRight ">>>"
203 %token RightRightRightEqual ">>>="
205 %token SlashEqual "/="
207 %token StarEqual "*="
216 %token <comment_> Comment
219 %token CloseParen ")"
222 %token OpenBrace_ "\n{"
223 %token OpenBrace__ ";{"
224 %token CloseBrace "}"
226 %token OpenBracket "["
227 %token CloseBracket "]"
229 %token AtError "@error"
232 %token AtClass "@class"
236 %token <identifier_> Typedef "typedef"
237 %token <identifier_> Unsigned "unsigned"
238 %token <identifier_> Signed "signed"
242 %token AtImplementation "@implementation"
243 %token AtImplementation_ ";@implementation"
244 %token AtImport "@import"
245 %token AtEncode "@encode"
247 %token AtSelector "@selector"
248 %token <identifier_> Yes "YES"
249 %token <identifier_> No "NO"
252 %token <false_> False "false"
253 %token <null_> Null "null"
254 %token <true_> True "true"
256 // ES3/ES5/WIE/JSC Reserved
257 %token <word_> Auto "auto"
258 %token <word_> Break "break"
259 %token <word_> Case "case"
260 %token <word_> Catch "catch"
261 %token <word_> Continue "continue"
262 %token <word_> Default "default"
263 %token <word_> Delete "delete"
264 %token <word_> Do "do"
265 %token <word_> Else "else"
266 %token <word_> Finally "finally"
267 %token <word_> For "for"
268 %token <word_> Function "function"
269 %token <word_> Function_ ";function"
270 %token <word_> If "if"
271 %token <word_> In "in"
272 %token <word_> In_ "!in"
273 %token <word_> InstanceOf "instanceof"
274 %token <word_> New "new"
275 %token <word_> Return "return"
276 %token <word_> Switch "switch"
277 %token <this_> This "this"
278 %token <word_> Throw "throw"
279 %token <word_> Try "try"
280 %token <word_> TypeOf "typeof"
281 %token <word_> Var "var"
282 %token <word_> Void "void"
283 %token <word_> While "while"
284 %token <word_> With "with"
286 // ES3/IE6 Future, ES5/JSC Reserved
287 %token <word_> Debugger "debugger"
289 // ES3/ES5/IE6 Future, JSC Reserved
290 %token <word_> Const "const"
292 // ES3/ES5/IE6/JSC Future
293 %token <word_> Class "class"
294 %token <word_> Enum "enum"
295 %token <word_> Export "export"
296 %token <word_> Extends "extends"
297 %token <word_> Import "import"
298 %token <word_> Super "super"
300 // ES3 Future, ES5 Strict Future
301 %token <identifier_> Implements "implements"
302 %token <identifier_> Interface "interface"
303 %token <identifier_> Package "package"
304 %token <identifier_> Private "private"
305 %token <identifier_> Protected "protected"
306 %token <identifier_> Public "public"
307 %token <identifier_> Static "static"
310 %token <identifier_> Abstract "abstract"
311 %token <identifier_> Boolean "boolean"
312 %token <identifier_> Byte "byte"
313 %token <identifier_> Char "char"
314 %token <identifier_> Double "double"
315 %token <identifier_> Final "final"
316 %token <identifier_> Float "float"
317 %token <identifier_> Goto "goto"
318 %token <identifier_> Int "int"
319 %token <identifier_> Long "long"
320 %token <identifier_> Native "native"
321 %token <identifier_> Short "short"
322 %token <identifier_> Synchronized "synchronized"
323 %token <identifier_> Throws "throws"
324 %token <identifier_> Transient "transient"
325 %token <identifier_> Volatile "volatile"
328 %token <identifier_> Let "let"
329 %token <identifier_> Yield "yield"
332 %token <identifier_> Each "each"
333 %token <identifier_> Of "of"
337 %token <identifier_> Namespace "namespace"
338 %token <identifier_> XML "xml"
343 %token <identifier_> Identifier_
344 %token <number_> NumericLiteral
345 %token <string_> StringLiteral
346 %token <literal_> RegularExpressionLiteral
348 %type <expression_> AdditiveExpression
349 %type <argument_> ArgumentList_
350 %type <argument_> ArgumentList
351 %type <argument_> ArgumentListOpt
352 %type <argument_> Arguments
353 %type <expression_> ArrayComprehension
354 %type <expression_> ArrayInitialiser
355 %type <literal_> ArrayLiteral
356 %type <expression_> ArrowFunction
357 %type <functionParameter_> ArrowParameters
358 %type <expression_> AssignmentExpression
359 %type <identifier_> Binding
360 %type <identifier_> BindingIdentifier
361 %type <expression_> BitwiseANDExpression
362 %type <statement_> Block_
363 %type <statement_> Block
364 %type <boolean_> BooleanLiteral
365 %type <declaration_> BindingElement
366 %type <expression_> BitwiseORExpression
367 %type <expression_> BitwiseXORExpression
368 %type <statement_> BreakStatement
369 %type <statement_> BreakableStatement
370 %type <expression_> CallExpression_
371 %type <expression_> CallExpression
372 %type <clause_> CaseBlock
373 %type <clause_> CaseClause
374 %type <clause_> CaseClausesOpt
375 %type <catch_> CatchOpt
376 %type <expression_> Comprehension
377 %type <comprehension_> ComprehensionFor
378 %type <comprehension_> ComprehensionIf
379 %type <comprehension_> ComprehensionTail
380 %type <expression_> ConditionalExpression
381 %type <statement_> ContinueStatement
382 %type <statement_> ConciseBody
383 %type <statement_> DebuggerStatement
384 %type <statement_> Declaration__
385 %type <statement_> Declaration_
386 %type <statement_> Declaration
387 %type <clause_> DefaultClause
388 %type <expression_> Element
389 %type <expression_> ElementOpt
390 %type <element_> ElementList
391 %type <element_> ElementListOpt
392 %type <statement_> ElseStatementOpt
393 %type <statement_> EmptyStatement
394 %type <expression_> EqualityExpression
395 %type <compound_> Expression_
396 %type <compound_> Expression
397 %type <expression_> ExpressionOpt
398 %type <statement_> ExpressionStatement
399 %type <finally_> FinallyOpt
400 %type <for_> ForStatementInitialiser
401 %type <forin_> ForInStatementInitialiser
402 %type <declaration_> FormalParameter
403 %type <functionParameter_> FormalParameterList_
404 %type <functionParameter_> FormalParameterList
405 %type <functionParameter_> FormalParameterListOpt
406 %type <statement_> FunctionBody
407 %type <statement_> FunctionDeclaration
408 %type <expression_> FunctionExpression
409 %type <identifier_> Identifier
410 %type <identifier_> IdentifierOpt
411 %type <identifier_> IdentifierType
412 %type <word_> IdentifierName
413 %type <statement_> IfStatement
414 %type <expression_> Initialiser
415 %type <expression_> InitialiserOpt
416 %type <statement_> IterationStatement
417 %type <statement_> LabelledStatement
418 %type <expression_> LeftHandSideExpression
419 %type <statement_> LetStatement
420 %type <statement_> LexicalDeclaration
421 %type <literal_> Literal
422 %type <literal_> ValueLiteral
423 %type <expression_> LogicalANDExpression
424 %type <expression_> LogicalORExpression
425 %type <member_> MemberAccess
426 %type <expression_> MemberExpression_
427 %type <expression_> MemberExpression
428 %type <expression_> MultiplicativeExpression
429 %type <expression_> NewExpression
430 %type <null_> NullLiteral
431 %type <literal_> ObjectLiteral
432 %type <compound_> Parenthetical
433 %type <compound_> ParentheticalOpt
434 %type <expression_> PostfixExpression
435 %type <expression_> PrimaryExpression
436 %type <statement_> Program
437 %type <statement_> ProgramBody
438 %type <statement_> ProgramBodyOpt
439 %type <propertyName_> PropertyName_
440 %type <propertyName_> PropertyName
441 %type <property_> PropertyDefinition
442 %type <property_> PropertyDefinitionList_
443 %type <property_> PropertyDefinitionList
444 %type <property_> PropertyDefinitionListOpt
445 %type <expression_> RelationalExpression
446 %type <statement_> ReturnStatement
447 %type <rubyProc_> RubyProcExpression
448 %type <functionParameter_> RubyProcParameterList_
449 %type <functionParameter_> RubyProcParameterList
450 %type <functionParameter_> RubyProcParameters
451 %type <functionParameter_> RubyProcParametersOpt
452 %type <expression_> ShiftExpression
453 %type <declaration_> SingleNameBinding
454 %type <statement_> Statement__
455 %type <statement_> Statement_
456 %type <statement_> Statement
457 %type <statement_> StatementList
458 %type <statement_> StatementListOpt
459 %type <statement_> StatementListItem
460 %type <statement_> SwitchStatement
461 %type <statement_> ThrowStatement
462 %type <statement_> TryStatement
463 %type <expression_> UnaryExpression_
464 %type <expression_> UnaryExpression
465 %type <declaration_> VariableDeclaration
466 %type <declarations_> VariableDeclarationList_
467 %type <declarations_> VariableDeclarationList
468 %type <statement_> VariableStatement
469 %type <statement_> WithStatement
471 %type <word_> WordOpt
472 %type <expression_> Variable
475 %type <typedIdentifier_> ArrayedType
476 %type <expression_> BoxableExpression
477 %type <statement_> CategoryStatement
478 %type <expression_> ClassExpression
479 %type <field_> ClassFieldListOpt
480 %type <field_> ClassFields
481 %type <statement_> ClassStatement
482 %type <expression_> ClassSuperOpt
483 %type <message_> ClassMessageDeclaration
484 %type <message_> ClassMessageDeclarationListOpt
485 %type <className_> ClassName
486 %type <className_> ClassNameOpt
487 %type <protocol_> ClassProtocolListOpt
488 %type <protocol_> ClassProtocols
489 %type <protocol_> ClassProtocolsOpt
490 %type <expression_> EncodedType
491 %type <modifier_> FunctionedType
492 %type <specifier_> IntegerType
493 %type <specifier_> IntegerTypeOpt
494 %type <expression_> MessageExpression
495 %type <messageParameter_> MessageParameter
496 %type <messageParameter_> MessageParameters
497 %type <messageParameter_> MessageParameterList
498 %type <messageParameter_> MessageParameterListOpt
499 %type <bool_> MessageScope
500 %type <typedIdentifier_> ModifiedType
501 %type <module_> Module
502 %type <typedIdentifier_> PrefixedType
503 %type <specifier_> PrimitiveType
504 %type <argument_> SelectorCall_
505 %type <argument_> SelectorCall
506 %type <selector_> SelectorExpression_
507 %type <selector_> SelectorExpression
508 %type <selector_> SelectorExpressionOpt
509 %type <argument_> SelectorList
510 %type <word_> SelectorWordOpt
511 %type <typedIdentifier_> SuffixedType
512 %type <expression_> TypeOpt
513 %type <typedIdentifier_> TypeParenthetical
514 %type <modifier_> TypeQualifierLeft
515 %type <typedIdentifier_> TypeQualifierRight
516 %type <typedIdentifier_> TypeSignifier
517 %type <typedIdentifier_> TypedIdentifier
518 %type <typedParameter_> TypedParameterList_
519 %type <typedParameter_> TypedParameterList
520 %type <typedParameter_> TypedParameterListOpt
521 %type <argument_> VariadicCall
525 %type <propertyIdentifier_> PropertyIdentifier_
526 %type <selector_> PropertySelector_
527 %type <selector_> PropertySelector
528 %type <identifier_> QualifiedIdentifier_
529 %type <identifier_> QualifiedIdentifier
530 %type <identifier_> WildcardIdentifier
531 %type <identifier_> XMLComment
532 %type <identifier_> XMLCDATA
533 %type <identifier_> XMLElement
534 %type <identifier_> XMLElementContent
535 %type <identifier_> XMLMarkup
536 %type <identifier_> XMLPI
538 %type <attribute_> AttributeIdentifier
539 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
540 %type <expression_> PropertyIdentifier
541 %type <expression_> XMLListInitialiser
542 %type <expression_> XMLInitialiser
545 /* Token Priorities {{{ */
557 /* Lexer State {{{ */
559 : { driver.in_.push(true); }
563 : { driver.in_.push(false); }
567 : { driver.in_.pop(); }
571 : { driver.SetCondition(CYDriver::RegExpCondition); }
575 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
579 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
582 LexNoAtImplementation :
584 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
589 : LexNoBrace LexNoFunction LexNoAtImplementation
592 /* Virtual Tokens {{{ */
603 /* 7.6 Identifier Names and Identifiers {{{ */
614 : Identifier { $$ = $1; }
615 | "auto" { $$ = $1; }
616 | "break" NewLineOpt { $$ = $1; }
617 | "case" { $$ = $1; }
618 | "catch" { $$ = $1; }
619 | "class" { $$ = $1; }
620 | "const" { $$ = $1; }
621 | "continue" NewLineOpt { $$ = $1; }
622 | "debugger" { $$ = $1; }
623 | "default" { $$ = $1; }
624 | "delete" { $$ = $1; }
626 | "else" { $$ = $1; }
627 | "enum" { $$ = $1; }
628 | "export" { $$ = $1; }
629 | "extends" { $$ = $1; }
630 | "false" { $$ = $1; }
631 | "finally" { $$ = $1; }
632 /* XXX: | "for" { $$ = $1; } */
633 | "function" { $$ = $1; }
635 | "import" { $$ = $1; }
636 /* XXX: | "in" { $$ = $1; } */
638 /* XXX: | "instanceof" { $$ = $1; } */
640 // XXX: as it currently is not an Identifier
644 | "null" { $$ = $1; }
645 | "return" NewLineOpt { $$ = $1; }
646 | "super" { $$ = $1; }
647 | "switch" { $$ = $1; }
648 | "this" { $$ = $1; }
649 | "throw" NewLineOpt { $$ = $1; }
650 | "true" { $$ = $1; }
652 | "typeof" { $$ = $1; }
654 | "void" { $$ = $1; }
655 | "while" { $$ = $1; }
656 | "with" { $$ = $1; }
665 : Identifier_ { $$ = $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 | "double" { $$ = $1; }
679 | "final" { $$ = $1; }
680 | "float" { $$ = $1; }
681 | "goto" { $$ = $1; }
682 | "native" { $$ = $1; }
683 | "synchronized" { $$ = $1; }
684 | "throws" { $$ = $1; }
685 | "transient" { $$ = $1; }
687 // XXX: currently I only have this as Word
688 // | "let" { $$ = $1; }
690 | "yield" { $$ = $1; }
692 | "each" { $$ = $1; }
698 | "char" { $$ = $1; }
700 | "long" { $$ = $1; }
701 | "short" { $$ = $1; }
702 | "volatile" { $$ = $1; }
704 | "typedef" { $$ = $1; }
705 | "unsigned" { $$ = $1; }
706 | "signed" { $$ = $1; }
713 : Identifier { $$ = $1; }
718 /* 7.8 Literals {{{ */
720 : NullLiteral { $$ = $1; }
721 | ValueLiteral { $$ = $1; }
725 : BooleanLiteral { $$ = $1; }
726 | NumericLiteral { $$ = $1; }
727 | StringLiteral { $$ = $1; }
728 | RegularExpressionLiteral { $$ = $1; }
731 /* 7.8.1 Null Literals {{{ */
733 : "null" { $$ = $1; }
736 /* 7.8.2 Boolean Literals {{{ */
738 : "true" { $$ = $1; }
739 | "false" { $$ = $1; }
743 /* 7.9 Automatic Semicolon Insertion {{{ */
745 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
750 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
755 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
759 /* 11.1 Primary Expressions {{{ */
761 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
765 : Parenthetical { $$ = $1; }
770 : Identifier { $$ = CYNew CYVariable($1); }
774 : "this" { $$ = $1; }
775 | Variable { $$ = $1; }
776 | Literal { $$ = $1; }
777 | ArrayInitialiser { $$ = $1; }
778 | ObjectLiteral { $$ = $1; }
779 | Parenthetical { $$ = $1; }
780 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
783 /* 11.1.4 Array Initializer {{{ */
785 : ArrayLiteral { $$ = $1; }
786 | ArrayComprehension { $$ = $1; }
789 /* 11.1.4.1 Array Literal {{{ */
791 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
795 : AssignmentExpression { $$ = $1; }
799 : Element { $$ = $1; }
800 | LexSetRegExp { $$ = NULL; }
804 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
805 | Element { $$ = CYNew CYElement($1, NULL); }
809 : ElementList { $$ = $1; }
810 | LexSetRegExp { $$ = NULL; }
813 /* 11.1.4.2 Array Comprehension {{{ */
815 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
819 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
824 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
825 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
829 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
833 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
836 /* 11.1.5 Object Initialiser {{{ */
838 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
841 PropertyDefinitionList_
842 : "," PropertyDefinitionList { $$ = $2; }
843 | "," LexSetRegExp { $$ = NULL; }
847 PropertyDefinitionList
848 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
851 PropertyDefinitionListOpt
852 : PropertyDefinitionList { $$ = $1; }
853 | LexSetRegExp { $$ = NULL; }
857 // XXX: this should be IdentifierName
858 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
859 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
864 : IdentifierName { $$ = $1; }
865 | StringLiteral { $$ = $1; }
866 | NumericLiteral { $$ = $1; }
870 : LexSetRegExp PropertyName_ { $$ = $2; }
874 /* 11.2 Left-Hand-Side Expressions {{{ */
876 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
877 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
878 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
882 : MemberExpression { $$ = $1; }
883 //| "super" { $$ = $1; }
887 : LexSetRegExp PrimaryExpression { $$ = $2; }
888 | LexSetRegExp FunctionExpression { $$ = $2; }
889 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
890 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
894 : MemberExpression { $$ = $1; }
895 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
904 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
905 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
909 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
913 : "," ArgumentList { $$ = $2; }
918 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
922 : ArgumentList { $$ = $1; }
923 | LexSetRegExp { $$ = NULL; }
926 LeftHandSideExpression
927 : NewExpression { $$ = $1; }
928 | CallExpression { $$ = $1; }
931 /* 11.3 Postfix Expressions {{{ */
933 : %prec "" LeftHandSideExpression { $$ = $1; }
934 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
935 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
938 /* 11.4 Unary Operators {{{ */
940 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
941 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
942 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
943 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
944 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
945 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
946 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
947 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
948 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
949 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
950 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
954 : PostfixExpression { $$ = $1; }
955 | LexSetRegExp UnaryExpression_ { $$ = $2; }
958 /* 11.5 Multiplicative Operators {{{ */
959 MultiplicativeExpression
960 : UnaryExpression { $$ = $1; }
961 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
962 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
963 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
966 /* 11.6 Additive Operators {{{ */
968 : MultiplicativeExpression { $$ = $1; }
969 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
970 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
973 /* 11.7 Bitwise Shift Operators {{{ */
975 : AdditiveExpression { $$ = $1; }
976 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
977 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
978 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
981 /* 11.8 Relational Operators {{{ */
983 : ShiftExpression { $$ = $1; }
984 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
985 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
986 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
987 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
988 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
989 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
992 /* 11.9 Equality Operators {{{ */
994 : RelationalExpression { $$ = $1; }
995 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
996 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
997 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
998 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1001 /* 11.10 Binary Bitwise Operators {{{ */
1002 BitwiseANDExpression
1003 : EqualityExpression { $$ = $1; }
1004 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1007 BitwiseXORExpression
1008 : BitwiseANDExpression { $$ = $1; }
1009 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1013 : BitwiseXORExpression { $$ = $1; }
1014 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1017 /* 11.11 Binary Logical Operators {{{ */
1018 LogicalANDExpression
1019 : BitwiseORExpression { $$ = $1; }
1020 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1024 : LogicalANDExpression { $$ = $1; }
1025 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1028 /* 11.12 Conditional Operator ( ? : ) {{{ */
1029 ConditionalExpression
1030 : LogicalORExpression { $$ = $1; }
1031 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1032 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1035 /* 11.13 Assignment Operators {{{ */
1036 AssignmentExpression
1037 : ConditionalExpression { $$ = $1; }
1038 | ArrowFunction { $$ = $1; }
1039 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1040 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1041 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1042 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1043 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1044 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1045 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1046 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1047 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1048 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1049 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1050 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1053 /* 11.14 Comma Operator {{{ */
1055 : "," Expression { $$ = $2; }
1060 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1064 : Expression { $$ = $1; }
1065 | LexSetRegExp { $$ = NULL; }
1069 /* 12 Statements {{{ */
1071 : Block { $$ = $1; }
1072 | VariableStatement { $$ = $1; }
1073 | EmptyStatement { $$ = $1; }
1074 | IfStatement { $$ = $1; }
1075 | BreakableStatement { $$ = $1; }
1076 | ContinueStatement { $$ = $1; }
1077 | BreakStatement { $$ = $1; }
1078 | ReturnStatement { $$ = $1; }
1079 | WithStatement { $$ = $1; }
1080 | LabelledStatement { $$ = $1; }
1081 | ThrowStatement { $$ = $1; }
1082 | TryStatement { $$ = $1; }
1083 | DebuggerStatement { $$ = $1; }
1087 : LexSetRegExp Statement__ { $$ = $2; }
1088 | ExpressionStatement { $$ = $1; }
1092 : LexSetStatement Statement_ { $$ = $2; }
1096 : FunctionDeclaration { $$ = $1; }
1097 | LexicalDeclaration { $$ = $1; }
1101 : LexSetRegExp Declaration__ { $$ = $2; }
1105 : LexSetStatement Declaration_ { $$ = $2; }
1109 : IterationStatement { $$ = $1; }
1110 | SwitchStatement { $$ = $1; }
1113 /* 12.1 Block {{{ */
1115 : BRACE StatementListOpt "}" { $$ = $2; }
1119 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1123 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1127 : StatementList { $$ = $1; }
1128 | LexSetStatement LexSetRegExp { $$ = NULL; }
1132 : Statement { $$ = $1; }
1133 | Declaration { $$ = $1; }
1137 /* 12.2 Declarations {{{ */
1139 : Identifier { $$ = $1; }
1146 // XXX: BindingPattern
1148 /* 12.2.1 Let and Const Declarations {{{ */
1150 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1158 /* 12.2.2 Variable Statement {{{ */
1160 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1163 VariableDeclarationList_
1164 : "," VariableDeclarationList { $$ = $2; }
1168 VariableDeclarationList
1169 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1173 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1174 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1178 : "=" AssignmentExpression { $$ = $2; }
1182 : Initialiser { $$ = $1; }
1186 /* 12.2.4 Destructuring Binding Patterns {{{ */
1190 : SingleNameBinding { $$ = $1; }
1194 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1198 /* 12.3 Empty Statement {{{ */
1200 : ";" { $$ = CYNew CYEmpty(); }
1203 /* 12.4 Expression Statement {{{ */
1205 : Expression Terminator { $$ = CYNew CYExpress($1); }
1208 /* 12.5 The if Statement {{{ */
1210 : "else" Statement { $$ = $2; }
1211 | %prec "if" { $$ = NULL; }
1215 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1219 /* 12.6.1 The do-while Statement {{{ */
1221 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1224 /* 12.6.2 The while Statement {{{ */
1226 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1229 /* 12.6.3 The for Statement {{{ */
1231 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1234 ForStatementInitialiser
1235 : ExpressionOpt { $$ = $1; }
1236 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1239 /* 12.6.4 The for-in and for-of Statements {{{ */
1241 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1242 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1245 ForInStatementInitialiser
1246 : LeftHandSideExpression { $$ = $1; }
1247 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1251 /* 12.7 The continue Statement {{{ */
1253 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1254 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1257 /* 12.8 The break Statement {{{ */
1259 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1260 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1263 /* 12.9 The return Statement {{{ */
1265 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1266 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1269 /* 12.10 The with Statement {{{ */
1271 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1275 /* 12.11 The switch Statement {{{ */
1277 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1281 : BRACE CaseClausesOpt "}" { $$ = $2; }
1285 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1289 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1290 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1295 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1298 /* 12.12 Labelled Statements {{{ */
1300 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1303 /* 12.13 The throw Statement {{{ */
1305 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1306 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1309 /* 12.14 The try Statement {{{ */
1311 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1315 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1320 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1324 /* 12.14 The debugger Statement {{{ */
1326 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1330 /* 13.1 Function Definitions {{{ */
1332 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1336 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1339 FormalParameterList_
1340 : "," FormalParameterList { $$ = $2; }
1345 // XXX: : FunctionRestParameter { $$ = $1; }
1346 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1349 FormalParameterListOpt
1350 : FormalParameterList
1354 /* XXX: FunctionRestParameter
1355 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1359 : BindingElement { $$ = $1; }
1363 : StatementListOpt { $$ = $1; }
1366 /* 13.2 Arrow Function Definitions {{{ */
1368 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1372 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1373 //| ParentheticalOpt { $$ = $1; }
1377 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1378 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1381 /* 14 Program {{{ */
1383 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1387 : StatementList { $$ = $1; }
1391 : ProgramBody { $$ = $1; }
1392 | LexSetStatement LexSetRegExp { $$ = NULL; }
1397 /* Cycript (Objective-C): Type Encoding {{{ */
1399 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1403 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1404 | TypeParenthetical { $$ = $1; }
1408 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1409 | TypeSignifier { $$ = $1; }
1410 | { $$ = CYNew CYTypedIdentifier(); }
1414 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1418 : ArrayedType { $$ = $1; }
1419 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1420 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1421 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1425 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1430 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1431 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1435 : PrefixedType { $$ = $1; }
1436 | SuffixedType { $$ = $1; }
1437 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1438 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1442 : "int" { $$ = CYNew CYTypeVariable("int"); }
1443 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1444 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1445 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1446 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1450 : IntegerType { $$ = $1; }
1451 | { $$ = CYNew CYTypeVariable("int"); }
1455 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1456 | IntegerType { $$ = $1; }
1457 | "void" { $$ = CYNew CYTypeVoid(); }
1458 | "char" { $$ = CYNew CYTypeVariable("char"); }
1459 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1460 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1464 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1468 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1472 : "@encode" "(" EncodedType ")" { $$ = $3; }
1475 /* Cycript (Objective-C): @class Declaration {{{ */
1477 /* XXX: why the hell did I choose MemberExpression? */
1478 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1483 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1484 | LexSetRegExp { $$ = NULL; }
1488 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1492 : "+" { $$ = false; }
1493 | "-" { $$ = true; }
1497 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1502 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1505 MessageParameterList
1506 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1509 MessageParameterListOpt
1510 : MessageParameterList { $$ = $1; }
1515 : MessageParameterList { $$ = $1; }
1516 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1519 ClassMessageDeclaration
1520 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1523 ClassMessageDeclarationListOpt
1524 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1525 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1530 : Identifier { $$ = $1; }
1531 | "(" AssignmentExpression ")" { $$ = $2; }
1535 : ClassName { $$ = $1; }
1539 // XXX: this should be AssignmentExpressionNoRight
1541 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1545 : "," ClassProtocols { $$ = $2; }
1549 ClassProtocolListOpt
1550 : "<" ClassProtocols ">" { $$ = $2; }
1555 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1559 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1567 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1571 : ClassExpression { $$ = $1; }
1575 : ClassStatement { $$ = $1; }
1576 | CategoryStatement { $$ = $1; }
1579 /* Cycript (Objective-C): Send Message {{{ */
1581 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1586 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1587 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1591 : SelectorCall { $$ = $1; }
1592 | VariadicCall { $$ = $1; }
1596 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1600 : SelectorCall { $$ = $1; }
1601 | Word { $$ = CYNew CYArgument($1, NULL); }
1605 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1606 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1610 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1614 : SelectorExpression_ { $$ = $1; }
1615 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1618 SelectorExpressionOpt
1619 : SelectorExpression_ { $$ = $1; }
1624 : MessageExpression { $$ = $1; }
1625 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1628 /* Cycript (Objective-C): @import Directive {{{ */
1630 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1631 | Word { $$ = CYNew CYModule($1); }
1635 : "@import" Module { $$ = CYNew CYImport($2); }
1638 /* Cycript (Objective-C): Boxed Expressions {{{ */
1640 : NullLiteral { $$ = $1; }
1641 | BooleanLiteral { $$ = $1; }
1642 | NumericLiteral { $$ = $1; }
1643 | StringLiteral { $$ = $1; }
1644 | ArrayLiteral { $$ = $1; }
1645 | ObjectLiteral { $$ = $1; }
1646 | Parenthetical { $$ = $1; }
1647 | "YES" { $$ = CYNew CYTrue(); }
1648 | "NO" { $$ = CYNew CYFalse(); }
1652 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1655 /* Cycript (Objective-C): Block Expressions {{{ */
1657 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1658 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1662 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1665 /* Cycript (Objective-C): Instance Literals {{{ */
1667 : "^" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1673 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1674 LeftHandSideExpression
1675 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1679 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1683 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1684 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1685 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1688 /* Cycript (C): auto Compatibility {{{ */
1693 /* Cycript (C): Lambda Expressions {{{ */
1695 : "," TypedParameterList { $$ = $2; }
1700 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1703 TypedParameterListOpt
1704 : TypedParameterList { $$ = $1; }
1709 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1712 /* Cycript (C): Type Definitions {{{ */
1714 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1719 /* YUI: Documentation Comments {{{ */
1721 : Comment { $$ = $1; }
1726 /* Lexer State {{{ */
1728 : { driver.PushCondition(CYDriver::RegExpCondition); }
1732 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1736 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1740 : { driver.PopCondition(); }
1744 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1748 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1751 /* Virtual Tokens {{{ */
1758 /* 8.1 Context Keywords {{{ */
1760 : "namespace" { $$ = $1; }
1761 | "xml" { $$ = $1; }
1764 /* 8.3 XML Initialiser Input Elements {{{ */
1766 : XMLComment { $$ = $1; }
1767 | XMLCDATA { $$ = $1; }
1768 | XMLPI { $$ = $1; }
1772 /* 11.1 Primary Expressions {{{ */
1774 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1775 | XMLInitialiser { $$ = $1; }
1776 | XMLListInitialiser { $$ = $1; }
1780 : AttributeIdentifier { $$ = $1; }
1781 | QualifiedIdentifier { $$ = $1; }
1782 | WildcardIdentifier { $$ = $1; }
1785 /* 11.1.1 Attribute Identifiers {{{ */
1787 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1791 : PropertySelector { $$ = $1; }
1792 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1796 : Identifier { $$ = CYNew CYSelector($1); }
1797 | WildcardIdentifier { $$ = $1; }
1800 /* 11.1.2 Qualified Identifiers {{{ */
1801 QualifiedIdentifier_
1802 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1803 | QualifiedIdentifier { $$ = $1; }
1807 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1810 /* 11.1.3 Wildcard Identifiers {{{ */
1812 : "*" { $$ = CYNew CYWildcard(); }
1815 /* 11.1.4 XML Initialiser {{{ */
1817 : XMLMarkup { $$ = $1; }
1818 | XMLElement { $$ = $1; }
1822 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1823 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1827 : LexPushXMLTag XMLTagName XMLAttributes
1831 : BRACE LexPushRegExp Expression LexPop "}"
1840 : XMLAttributes_ XMLAttribute
1845 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1846 | XMLAttributes_ XMLWhitespaceOpt
1855 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1859 : XMLExpression XMLElementContentOpt
1860 | XMLMarkup XMLElementContentOpt
1861 | XMLText XMLElementContentOpt
1862 | XMLElement XMLElementContentOpt
1865 XMLElementContentOpt
1870 /* 11.1.5 XMLList Initialiser {{{ */
1872 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1876 /* 11.2 Left-Hand-Side Expressions {{{ */
1878 : Identifier { $$ = $1; }
1879 | PropertyIdentifier { $$ = $1; }
1883 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1884 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1885 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1888 /* 12.1 The default xml namespace Statement {{{ */
1889 /* XXX: DefaultXMLNamespaceStatement
1890 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1894 : DefaultXMLNamespaceStatement { $$ = $1; }
1899 /* JavaScript 1.7: Array Comprehensions {{{ */
1901 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1905 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1906 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1909 /* JavaScript 1.7: for each {{{ */
1911 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1914 /* JavaScript 1.7: let Statements {{{ */
1916 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1924 /* JavaScript FTW: Ruby Blocks {{{ */
1925 RubyProcParameterList_
1926 : "," RubyProcParameterList { $$ = $2; }
1930 RubyProcParameterList
1931 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1936 : "|" RubyProcParameterList "|" { $$ = $2; }
1937 | "||" { $$ = NULL; }
1940 RubyProcParametersOpt
1941 : RubyProcParameters
1946 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1950 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1954 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }