1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. 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
114 @if Bison24 %code provides {
115 int cylex(YYSTYPE *, cy::location *, void *);
128 @if Bison23 %skeleton "lalr1.cc"
129 @if Bison24 %language "C++"
132 @$.begin.filename = @$.end.filename = &driver.filename_;
143 %parse-param { CYDriver &driver }
144 %lex-param { void *cyscanner }
146 /* Token Declarations {{{ */
152 %token XMLAttributeValue
154 %token XMLTagCharacters
160 %token LeftRight "<>"
161 %token LeftSlashRight "</>"
163 %token SlashRight "/>"
164 %token LeftSlash "</"
166 %token ColonColon "::"
167 %token PeriodPeriod ".."
170 @begin E4X ObjectiveC
176 %token AmpersandAmpersand "&&"
177 %token AmpersandEqual "&="
179 %token CarrotEqual "^="
181 %token EqualEqual "=="
182 %token EqualEqualEqual "==="
183 %token EqualRight "=>"
184 %token Exclamation "!"
185 %token ExclamationEqual "!="
186 %token ExclamationEqualEqual "!=="
188 %token HyphenEqual "-="
189 %token HyphenHyphen "--"
190 %token HyphenHyphen_ "\n--"
191 %token HyphenRight "->"
193 %token LeftEqual "<="
195 %token LeftLeftEqual "<<="
197 %token PercentEqual "%="
199 %token PeriodPeriodPeriod "..."
201 %token PipeEqual "|="
204 %token PlusEqual "+="
206 %token PlusPlus_ "\n++"
208 %token RightEqual ">="
209 %token RightRight ">>"
210 %token RightRightEqual ">>="
211 %token RightRightRight ">>>"
212 %token RightRightRightEqual ">>>="
214 %token SlashEqual "/="
216 %token StarEqual "*="
225 %token <comment_> Comment
228 %token CloseParen ")"
231 %token OpenBrace_ "\n{"
232 %token OpenBrace__ ";{"
233 %token CloseBrace "}"
235 %token OpenBracket "["
236 %token CloseBracket "]"
238 %token AtError "@error"
241 %token AtClass "@class"
245 %token <identifier_> Typedef "typedef"
246 %token <identifier_> Unsigned "unsigned"
247 %token <identifier_> Signed "signed"
251 %token AtEncode "@encode"
255 %token AtImplementation "@implementation"
256 %token AtImplementation_ ";@implementation"
257 %token AtImport "@import"
259 %token AtSelector "@selector"
260 %token <identifier_> Yes "YES"
261 %token <identifier_> No "NO"
264 %token <false_> False "false"
265 %token <null_> Null "null"
266 %token <true_> True "true"
268 // ES3/ES5/WIE/JSC Reserved
269 %token <word_> Auto "auto"
270 %token <word_> Break "break"
271 %token <word_> Case "case"
272 %token <word_> Catch "catch"
273 %token <word_> Continue "continue"
274 %token <word_> Default "default"
275 %token <word_> Delete "delete"
276 %token <word_> Do "do"
277 %token <word_> Else "else"
278 %token <word_> Finally "finally"
279 %token <word_> For "for"
280 %token <word_> Function "function"
281 %token <word_> Function_ ";function"
282 %token <word_> If "if"
283 %token <word_> In "in"
284 %token <word_> In_ "!in"
285 %token <word_> InstanceOf "instanceof"
286 %token <word_> New "new"
287 %token <word_> Return "return"
288 %token <word_> Switch "switch"
289 %token <this_> This "this"
290 %token <word_> Throw "throw"
291 %token <word_> Try "try"
292 %token <word_> TypeOf "typeof"
293 %token <word_> Var "var"
294 %token <word_> Void "void"
295 %token <word_> While "while"
296 %token <word_> With "with"
298 // ES3/IE6 Future, ES5/JSC Reserved
299 %token <word_> Debugger "debugger"
301 // ES3/ES5/IE6 Future, JSC Reserved
302 %token <word_> Const "const"
304 // ES3/ES5/IE6/JSC Future
305 %token <word_> Class "class"
306 %token <word_> Enum "enum"
307 %token <word_> Export "export"
308 %token <word_> Extends "extends"
309 %token <word_> Import "import"
310 %token <word_> Super "super"
312 // ES3 Future, ES5 Strict Future
313 %token <identifier_> Implements "implements"
314 %token <identifier_> Interface "interface"
315 %token <identifier_> Package "package"
316 %token <identifier_> Private "private"
317 %token <identifier_> Protected "protected"
318 %token <identifier_> Public "public"
319 %token <identifier_> Static "static"
322 %token <identifier_> Abstract "abstract"
323 %token <identifier_> Boolean "boolean"
324 %token <identifier_> Byte "byte"
325 %token <identifier_> Char "char"
326 %token <identifier_> Double "double"
327 %token <identifier_> Final "final"
328 %token <identifier_> Float "float"
329 %token <identifier_> Goto "goto"
330 %token <identifier_> Int "int"
331 %token <identifier_> Long "long"
332 %token <identifier_> Native "native"
333 %token <identifier_> Short "short"
334 %token <identifier_> Synchronized "synchronized"
335 %token <identifier_> Throws "throws"
336 %token <identifier_> Transient "transient"
337 %token <identifier_> Volatile "volatile"
340 %token <identifier_> Let "let"
341 %token <identifier_> Yield "yield"
344 %token <identifier_> Each "each"
345 %token <identifier_> Of "of"
349 %token <identifier_> Namespace "namespace"
350 %token <identifier_> XML "xml"
355 %token <identifier_> Identifier_
356 %token <number_> NumericLiteral
357 %token <string_> StringLiteral
358 %token <literal_> RegularExpressionLiteral
360 %type <expression_> AdditiveExpression
361 %type <argument_> ArgumentList_
362 %type <argument_> ArgumentList
363 %type <argument_> ArgumentListOpt
364 %type <argument_> Arguments
365 %type <expression_> ArrayComprehension
366 %type <expression_> ArrayInitialiser
367 %type <literal_> ArrayLiteral
368 %type <expression_> ArrowFunction
369 %type <functionParameter_> ArrowParameters
370 %type <expression_> AssignmentExpression
371 %type <identifier_> Binding
372 %type <identifier_> BindingIdentifier
373 %type <expression_> BitwiseANDExpression
374 %type <statement_> Block_
375 %type <statement_> Block
376 %type <boolean_> BooleanLiteral
377 %type <declaration_> BindingElement
378 %type <expression_> BitwiseORExpression
379 %type <expression_> BitwiseXORExpression
380 %type <statement_> BreakStatement
381 %type <statement_> BreakableStatement
382 %type <expression_> CallExpression_
383 %type <expression_> CallExpression
384 %type <clause_> CaseBlock
385 %type <clause_> CaseClause
386 %type <clause_> CaseClausesOpt
387 %type <catch_> CatchOpt
388 %type <expression_> Comprehension
389 %type <comprehension_> ComprehensionFor
390 %type <comprehension_> ComprehensionIf
391 %type <comprehension_> ComprehensionTail
392 %type <expression_> ConditionalExpression
393 %type <statement_> ContinueStatement
394 %type <statement_> ConciseBody
395 %type <statement_> DebuggerStatement
396 %type <statement_> Declaration__
397 %type <statement_> Declaration_
398 %type <statement_> Declaration
399 %type <clause_> DefaultClause
400 %type <expression_> Element
401 %type <expression_> ElementOpt
402 %type <element_> ElementList
403 %type <element_> ElementListOpt
404 %type <statement_> ElseStatementOpt
405 %type <statement_> EmptyStatement
406 %type <expression_> EqualityExpression
407 %type <compound_> Expression_
408 %type <compound_> Expression
409 %type <expression_> ExpressionOpt
410 %type <statement_> ExpressionStatement
411 %type <finally_> FinallyOpt
412 %type <for_> ForStatementInitialiser
413 %type <forin_> ForInStatementInitialiser
414 %type <declaration_> FormalParameter
415 %type <functionParameter_> FormalParameterList_
416 %type <functionParameter_> FormalParameterList
417 %type <functionParameter_> FormalParameterListOpt
418 %type <statement_> FunctionBody
419 %type <statement_> FunctionDeclaration
420 %type <expression_> FunctionExpression
421 %type <identifier_> Identifier
422 %type <identifier_> IdentifierOpt
423 %type <identifier_> IdentifierType
424 %type <word_> IdentifierName
425 %type <statement_> IfStatement
426 %type <expression_> Initialiser
427 %type <expression_> InitialiserOpt
428 %type <statement_> IterationStatement
429 %type <statement_> LabelledStatement
430 %type <expression_> LeftHandSideExpression
431 %type <statement_> LetStatement
432 %type <statement_> LexicalDeclaration
433 %type <literal_> Literal
434 %type <literal_> ValueLiteral
435 %type <expression_> LogicalANDExpression
436 %type <expression_> LogicalORExpression
437 %type <member_> MemberAccess
438 %type <expression_> MemberExpression_
439 %type <expression_> MemberExpression
440 %type <module_> Module
441 %type <expression_> MultiplicativeExpression
442 %type <expression_> NewExpression
443 %type <null_> NullLiteral
444 %type <literal_> ObjectLiteral
445 %type <compound_> Parenthetical
446 %type <compound_> ParentheticalOpt
447 %type <expression_> PostfixExpression
448 %type <expression_> PrimaryExpression
449 %type <statement_> Program
450 %type <statement_> ProgramBody
451 %type <statement_> ProgramBodyOpt
452 %type <propertyName_> PropertyName_
453 %type <propertyName_> PropertyName
454 %type <property_> PropertyDefinition
455 %type <property_> PropertyDefinitionList_
456 %type <property_> PropertyDefinitionList
457 %type <property_> PropertyDefinitionListOpt
458 %type <expression_> RelationalExpression
459 %type <statement_> ReturnStatement
460 %type <rubyProc_> RubyProcExpression
461 %type <functionParameter_> RubyProcParameterList_
462 %type <functionParameter_> RubyProcParameterList
463 %type <functionParameter_> RubyProcParameters
464 %type <functionParameter_> RubyProcParametersOpt
465 %type <expression_> ShiftExpression
466 %type <declaration_> SingleNameBinding
467 %type <statement_> Statement__
468 %type <statement_> Statement_
469 %type <statement_> Statement
470 %type <statement_> StatementList
471 %type <statement_> StatementListOpt
472 %type <statement_> StatementListItem
473 %type <statement_> SwitchStatement
474 %type <statement_> ThrowStatement
475 %type <statement_> TryStatement
476 %type <expression_> UnaryExpression_
477 %type <expression_> UnaryExpression
478 %type <declaration_> VariableDeclaration
479 %type <declarations_> VariableDeclarationList_
480 %type <declarations_> VariableDeclarationList
481 %type <statement_> VariableStatement
482 %type <statement_> WithStatement
484 %type <word_> WordOpt
485 %type <expression_> Variable
488 %type <typedIdentifier_> ArrayedType
489 %type <expression_> EncodedType
490 %type <modifier_> FunctionedType
491 %type <specifier_> IntegerType
492 %type <specifier_> IntegerTypeOpt
493 %type <typedIdentifier_> PrefixedType
494 %type <specifier_> PrimitiveType
495 %type <typedIdentifier_> TypeParenthetical
496 %type <typedIdentifier_> TypeSignifier
497 %type <typedIdentifier_> SuffixedType
498 %type <modifier_> TypeQualifierLeft
499 %type <typedIdentifier_> TypeQualifierRight
500 %type <typedIdentifier_> TypedIdentifier
501 %type <typedParameter_> TypedParameterList_
502 %type <typedParameter_> TypedParameterList
503 %type <typedParameter_> TypedParameterListOpt
507 %type <expression_> BoxableExpression
508 %type <statement_> CategoryStatement
509 %type <expression_> ClassExpression
510 %type <field_> ClassFieldListOpt
511 %type <field_> ClassFields
512 %type <statement_> ClassStatement
513 %type <expression_> ClassSuperOpt
514 %type <message_> ClassMessageDeclaration
515 %type <message_> ClassMessageDeclarationListOpt
516 %type <className_> ClassName
517 %type <className_> ClassNameOpt
518 %type <protocol_> ClassProtocolListOpt
519 %type <protocol_> ClassProtocols
520 %type <protocol_> ClassProtocolsOpt
521 %type <expression_> MessageExpression
522 %type <messageParameter_> MessageParameter
523 %type <messageParameter_> MessageParameters
524 %type <messageParameter_> MessageParameterList
525 %type <messageParameter_> MessageParameterListOpt
526 %type <bool_> MessageScope
527 %type <typedIdentifier_> ModifiedType
528 %type <argument_> SelectorCall_
529 %type <argument_> SelectorCall
530 %type <selector_> SelectorExpression_
531 %type <selector_> SelectorExpression
532 %type <selector_> SelectorExpressionOpt
533 %type <argument_> SelectorList
534 %type <word_> SelectorWordOpt
535 %type <expression_> TypeOpt
536 %type <argument_> VariadicCall
540 %type <propertyIdentifier_> PropertyIdentifier_
541 %type <selector_> PropertySelector_
542 %type <selector_> PropertySelector
543 %type <identifier_> QualifiedIdentifier_
544 %type <identifier_> QualifiedIdentifier
545 %type <identifier_> WildcardIdentifier
546 %type <identifier_> XMLComment
547 %type <identifier_> XMLCDATA
548 %type <identifier_> XMLElement
549 %type <identifier_> XMLElementContent
550 %type <identifier_> XMLMarkup
551 %type <identifier_> XMLPI
553 %type <attribute_> AttributeIdentifier
554 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
555 %type <expression_> PropertyIdentifier
556 %type <expression_> XMLListInitialiser
557 %type <expression_> XMLInitialiser
560 /* Token Priorities {{{ */
572 /* Lexer State {{{ */
574 : { driver.in_.push(true); }
578 : { driver.in_.push(false); }
582 : { driver.in_.pop(); }
586 : { driver.SetCondition(CYDriver::RegExpCondition); }
590 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
594 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
597 LexNoAtImplementation :
599 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
604 : LexNoBrace LexNoFunction LexNoAtImplementation
607 /* Virtual Tokens {{{ */
618 /* 7.6 Identifier Names and Identifiers {{{ */
629 : Identifier { $$ = $1; }
630 | "auto" { $$ = $1; }
631 | "break" NewLineOpt { $$ = $1; }
632 | "case" { $$ = $1; }
633 | "catch" { $$ = $1; }
634 | "class" { $$ = $1; }
635 | "const" { $$ = $1; }
636 | "continue" NewLineOpt { $$ = $1; }
637 | "debugger" { $$ = $1; }
638 | "default" { $$ = $1; }
639 | "delete" { $$ = $1; }
641 | "else" { $$ = $1; }
642 | "enum" { $$ = $1; }
643 | "export" { $$ = $1; }
644 | "extends" { $$ = $1; }
645 | "false" { $$ = $1; }
646 | "finally" { $$ = $1; }
647 /* XXX: | "for" { $$ = $1; } */
648 | "function" { $$ = $1; }
650 | "import" { $$ = $1; }
651 /* XXX: | "in" { $$ = $1; } */
653 /* XXX: | "instanceof" { $$ = $1; } */
655 // XXX: as it currently is not an Identifier
659 | "null" { $$ = $1; }
660 | "return" NewLineOpt { $$ = $1; }
661 | "super" { $$ = $1; }
662 | "switch" { $$ = $1; }
663 | "this" { $$ = $1; }
664 | "throw" NewLineOpt { $$ = $1; }
665 | "true" { $$ = $1; }
667 | "typeof" { $$ = $1; }
669 | "void" { $$ = $1; }
670 | "while" { $$ = $1; }
671 | "with" { $$ = $1; }
680 : Identifier_ { $$ = $1; }
682 | "implements" { $$ = $1; }
683 | "interface" { $$ = $1; }
684 | "package" { $$ = $1; }
685 | "private" { $$ = $1; }
686 | "protected" { $$ = $1; }
687 | "public" { $$ = $1; }
688 | "static" { $$ = $1; }
690 | "abstract" { $$ = $1; }
691 | "boolean" { $$ = $1; }
692 | "byte" { $$ = $1; }
693 | "double" { $$ = $1; }
694 | "final" { $$ = $1; }
695 | "float" { $$ = $1; }
696 | "goto" { $$ = $1; }
697 | "native" { $$ = $1; }
698 | "synchronized" { $$ = $1; }
699 | "throws" { $$ = $1; }
700 | "transient" { $$ = $1; }
702 // XXX: currently I only have this as Word
703 // | "let" { $$ = $1; }
705 | "yield" { $$ = $1; }
707 | "each" { $$ = $1; }
713 | "char" { $$ = $1; }
715 | "long" { $$ = $1; }
716 | "short" { $$ = $1; }
717 | "volatile" { $$ = $1; }
719 | "typedef" { $$ = $1; }
720 | "unsigned" { $$ = $1; }
721 | "signed" { $$ = $1; }
730 : Identifier { $$ = $1; }
735 /* 7.8 Literals {{{ */
737 : NullLiteral { $$ = $1; }
738 | ValueLiteral { $$ = $1; }
742 : BooleanLiteral { $$ = $1; }
743 | NumericLiteral { $$ = $1; }
744 | StringLiteral { $$ = $1; }
745 | RegularExpressionLiteral { $$ = $1; }
748 /* 7.8.1 Null Literals {{{ */
750 : "null" { $$ = $1; }
753 /* 7.8.2 Boolean Literals {{{ */
755 : "true" { $$ = $1; }
756 | "false" { $$ = $1; }
760 /* 7.9 Automatic Semicolon Insertion {{{ */
762 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
767 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
772 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
776 /* 11.1 Primary Expressions {{{ */
778 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
782 : Parenthetical { $$ = $1; }
787 : Identifier { $$ = CYNew CYVariable($1); }
791 : "this" { $$ = $1; }
792 | Variable { $$ = $1; }
793 | Literal { $$ = $1; }
794 | ArrayInitialiser { $$ = $1; }
795 | ObjectLiteral { $$ = $1; }
796 | Parenthetical { $$ = $1; }
797 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
800 /* 11.1.4 Array Initializer {{{ */
802 : ArrayLiteral { $$ = $1; }
803 | ArrayComprehension { $$ = $1; }
806 /* 11.1.4.1 Array Literal {{{ */
808 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
812 : AssignmentExpression { $$ = $1; }
816 : Element { $$ = $1; }
817 | LexSetRegExp { $$ = NULL; }
821 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
822 | Element { $$ = CYNew CYElement($1, NULL); }
826 : ElementList { $$ = $1; }
827 | LexSetRegExp { $$ = NULL; }
830 /* 11.1.4.2 Array Comprehension {{{ */
832 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
836 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
841 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
842 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
846 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
850 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
853 /* 11.1.5 Object Initialiser {{{ */
855 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
858 PropertyDefinitionList_
859 : "," PropertyDefinitionList { $$ = $2; }
860 | "," LexSetRegExp { $$ = NULL; }
864 PropertyDefinitionList
865 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
868 PropertyDefinitionListOpt
869 : PropertyDefinitionList { $$ = $1; }
870 | LexSetRegExp { $$ = NULL; }
874 // XXX: this should be IdentifierName
875 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
876 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
881 : IdentifierName { $$ = $1; }
882 | StringLiteral { $$ = $1; }
883 | NumericLiteral { $$ = $1; }
887 : LexSetRegExp PropertyName_ { $$ = $2; }
891 /* 11.2 Left-Hand-Side Expressions {{{ */
893 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
894 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
895 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
899 : MemberExpression { $$ = $1; }
900 //| "super" { $$ = $1; }
904 : LexSetRegExp PrimaryExpression { $$ = $2; }
905 | LexSetRegExp FunctionExpression { $$ = $2; }
906 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
907 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
911 : MemberExpression { $$ = $1; }
912 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
921 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
922 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
926 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
930 : "," ArgumentList { $$ = $2; }
935 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
939 : ArgumentList { $$ = $1; }
940 | LexSetRegExp { $$ = NULL; }
943 LeftHandSideExpression
944 : NewExpression { $$ = $1; }
945 | CallExpression { $$ = $1; }
948 /* 11.3 Postfix Expressions {{{ */
950 : %prec "" LeftHandSideExpression { $$ = $1; }
951 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
952 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
955 /* 11.4 Unary Operators {{{ */
957 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
958 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
959 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
960 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
961 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
962 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
963 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
964 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
965 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
966 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
967 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
971 : PostfixExpression { $$ = $1; }
972 | LexSetRegExp UnaryExpression_ { $$ = $2; }
975 /* 11.5 Multiplicative Operators {{{ */
976 MultiplicativeExpression
977 : UnaryExpression { $$ = $1; }
978 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
979 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
980 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
983 /* 11.6 Additive Operators {{{ */
985 : MultiplicativeExpression { $$ = $1; }
986 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
987 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
990 /* 11.7 Bitwise Shift Operators {{{ */
992 : AdditiveExpression { $$ = $1; }
993 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
994 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
995 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
998 /* 11.8 Relational Operators {{{ */
1000 : ShiftExpression { $$ = $1; }
1001 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1002 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1003 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1004 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1005 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1006 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1009 /* 11.9 Equality Operators {{{ */
1011 : RelationalExpression { $$ = $1; }
1012 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1013 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1014 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1015 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1018 /* 11.10 Binary Bitwise Operators {{{ */
1019 BitwiseANDExpression
1020 : EqualityExpression { $$ = $1; }
1021 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1024 BitwiseXORExpression
1025 : BitwiseANDExpression { $$ = $1; }
1026 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1030 : BitwiseXORExpression { $$ = $1; }
1031 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1034 /* 11.11 Binary Logical Operators {{{ */
1035 LogicalANDExpression
1036 : BitwiseORExpression { $$ = $1; }
1037 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1041 : LogicalANDExpression { $$ = $1; }
1042 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1045 /* 11.12 Conditional Operator ( ? : ) {{{ */
1046 ConditionalExpression
1047 : LogicalORExpression { $$ = $1; }
1048 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1049 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1052 /* 11.13 Assignment Operators {{{ */
1053 AssignmentExpression
1054 : ConditionalExpression { $$ = $1; }
1055 | ArrowFunction { $$ = $1; }
1056 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1057 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1058 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1059 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1060 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1061 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1062 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1063 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1064 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1065 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1066 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1067 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1070 /* 11.14 Comma Operator {{{ */
1072 : "," Expression { $$ = $2; }
1077 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1081 : Expression { $$ = $1; }
1082 | LexSetRegExp { $$ = NULL; }
1086 /* 12 Statements {{{ */
1088 : Block { $$ = $1; }
1089 | VariableStatement { $$ = $1; }
1090 | EmptyStatement { $$ = $1; }
1091 | IfStatement { $$ = $1; }
1092 | BreakableStatement { $$ = $1; }
1093 | ContinueStatement { $$ = $1; }
1094 | BreakStatement { $$ = $1; }
1095 | ReturnStatement { $$ = $1; }
1096 | WithStatement { $$ = $1; }
1097 | LabelledStatement { $$ = $1; }
1098 | ThrowStatement { $$ = $1; }
1099 | TryStatement { $$ = $1; }
1100 | DebuggerStatement { $$ = $1; }
1104 : LexSetRegExp Statement__ { $$ = $2; }
1105 | ExpressionStatement { $$ = $1; }
1109 : LexSetStatement Statement_ { $$ = $2; }
1113 : FunctionDeclaration { $$ = $1; }
1114 | LexicalDeclaration { $$ = $1; }
1118 : LexSetRegExp Declaration__ { $$ = $2; }
1122 : LexSetStatement Declaration_ { $$ = $2; }
1126 : IterationStatement { $$ = $1; }
1127 | SwitchStatement { $$ = $1; }
1130 /* 12.1 Block {{{ */
1132 : BRACE StatementListOpt "}" { $$ = $2; }
1136 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1140 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1144 : StatementList { $$ = $1; }
1145 | LexSetStatement LexSetRegExp { $$ = NULL; }
1149 : Statement { $$ = $1; }
1150 | Declaration { $$ = $1; }
1154 /* 12.2 Declarations {{{ */
1156 : Identifier { $$ = $1; }
1163 // XXX: BindingPattern
1165 /* 12.2.1 Let and Const Declarations {{{ */
1167 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1175 /* 12.2.2 Variable Statement {{{ */
1177 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1180 VariableDeclarationList_
1181 : "," VariableDeclarationList { $$ = $2; }
1185 VariableDeclarationList
1186 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1190 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1191 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1195 : "=" AssignmentExpression { $$ = $2; }
1199 : Initialiser { $$ = $1; }
1203 /* 12.2.4 Destructuring Binding Patterns {{{ */
1207 : SingleNameBinding { $$ = $1; }
1211 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1215 /* 12.3 Empty Statement {{{ */
1217 : ";" { $$ = CYNew CYEmpty(); }
1220 /* 12.4 Expression Statement {{{ */
1222 : Expression Terminator { $$ = CYNew CYExpress($1); }
1225 /* 12.5 The if Statement {{{ */
1227 : "else" Statement { $$ = $2; }
1228 | %prec "if" { $$ = NULL; }
1232 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1236 /* 12.6.1 The do-while Statement {{{ */
1238 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1241 /* 12.6.2 The while Statement {{{ */
1243 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1246 /* 12.6.3 The for Statement {{{ */
1248 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1251 ForStatementInitialiser
1252 : ExpressionOpt { $$ = $1; }
1253 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1256 /* 12.6.4 The for-in and for-of Statements {{{ */
1258 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1259 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1262 ForInStatementInitialiser
1263 : LeftHandSideExpression { $$ = $1; }
1264 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1268 /* 12.7 The continue Statement {{{ */
1270 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1271 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1274 /* 12.8 The break Statement {{{ */
1276 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1277 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1280 /* 12.9 The return Statement {{{ */
1282 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1283 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1286 /* 12.10 The with Statement {{{ */
1288 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1292 /* 12.11 The switch Statement {{{ */
1294 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1298 : BRACE CaseClausesOpt "}" { $$ = $2; }
1302 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1306 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1307 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1312 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1315 /* 12.12 Labelled Statements {{{ */
1317 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1320 /* 12.13 The throw Statement {{{ */
1322 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1323 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1326 /* 12.14 The try Statement {{{ */
1328 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1332 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1337 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1341 /* 12.14 The debugger Statement {{{ */
1343 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1347 /* 13.1 Function Definitions {{{ */
1349 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1353 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1356 FormalParameterList_
1357 : "," FormalParameterList { $$ = $2; }
1362 // XXX: : FunctionRestParameter { $$ = $1; }
1363 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1366 FormalParameterListOpt
1367 : FormalParameterList
1371 /* XXX: FunctionRestParameter
1372 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1376 : BindingElement { $$ = $1; }
1380 : StatementListOpt { $$ = $1; }
1383 /* 13.2 Arrow Function Definitions {{{ */
1385 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1389 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1390 //| ParentheticalOpt { $$ = $1; }
1394 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1395 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1398 /* 14 Program {{{ */
1400 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1404 : StatementList { $$ = $1; }
1408 : ProgramBody { $$ = $1; }
1409 | LexSetStatement LexSetRegExp { $$ = NULL; }
1414 /* Cycript (C): Type Encoding {{{ */
1416 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1420 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1421 | TypeParenthetical { $$ = $1; }
1425 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1426 | TypeSignifier { $$ = $1; }
1427 | { $$ = CYNew CYTypedIdentifier(); }
1431 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1435 : ArrayedType { $$ = $1; }
1436 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1437 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1438 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1442 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1447 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1448 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1452 : PrefixedType { $$ = $1; }
1453 | SuffixedType { $$ = $1; }
1454 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1455 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1459 : "int" { $$ = CYNew CYTypeVariable("int"); }
1460 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1461 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1462 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1463 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1467 : IntegerType { $$ = $1; }
1468 | { $$ = CYNew CYTypeVariable("int"); }
1472 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1473 | IntegerType { $$ = $1; }
1474 | "void" { $$ = CYNew CYTypeVoid(); }
1475 | "char" { $$ = CYNew CYTypeVariable("char"); }
1476 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1477 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1481 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1485 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1489 : "@encode" "(" EncodedType ")" { $$ = $3; }
1495 /* Cycript (Objective-C): @class Declaration {{{ */
1497 /* XXX: why the hell did I choose MemberExpression? */
1498 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1503 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1504 | LexSetRegExp { $$ = NULL; }
1508 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1512 : "+" { $$ = false; }
1513 | "-" { $$ = true; }
1517 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1522 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1525 MessageParameterList
1526 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1529 MessageParameterListOpt
1530 : MessageParameterList { $$ = $1; }
1535 : MessageParameterList { $$ = $1; }
1536 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1539 ClassMessageDeclaration
1540 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1543 ClassMessageDeclarationListOpt
1544 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1545 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1550 : Identifier { $$ = $1; }
1551 | "(" AssignmentExpression ")" { $$ = $2; }
1555 : ClassName { $$ = $1; }
1559 // XXX: this should be AssignmentExpressionNoRight
1561 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1565 : "," ClassProtocols { $$ = $2; }
1569 ClassProtocolListOpt
1570 : "<" ClassProtocols ">" { $$ = $2; }
1575 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1579 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1587 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1591 : ClassExpression { $$ = $1; }
1595 : ClassStatement { $$ = $1; }
1596 | CategoryStatement { $$ = $1; }
1599 /* Cycript (Objective-C): Send Message {{{ */
1601 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1606 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1607 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1611 : SelectorCall { $$ = $1; }
1612 | VariadicCall { $$ = $1; }
1616 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1620 : SelectorCall { $$ = $1; }
1621 | Word { $$ = CYNew CYArgument($1, NULL); }
1625 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1626 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1630 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1634 : SelectorExpression_ { $$ = $1; }
1635 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1638 SelectorExpressionOpt
1639 : SelectorExpression_ { $$ = $1; }
1644 : MessageExpression { $$ = $1; }
1645 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1650 /* Cycript: @import Directive {{{ */
1652 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1653 | Word { $$ = CYNew CYModule($1); }
1657 : "@import" Module { $$ = CYNew CYImport($2); }
1662 /* Cycript (Objective-C): Boxed Expressions {{{ */
1664 : NullLiteral { $$ = $1; }
1665 | BooleanLiteral { $$ = $1; }
1666 | NumericLiteral { $$ = $1; }
1667 | StringLiteral { $$ = $1; }
1668 | ArrayLiteral { $$ = $1; }
1669 | ObjectLiteral { $$ = $1; }
1670 | Parenthetical { $$ = $1; }
1671 | "YES" { $$ = CYNew CYTrue(); }
1672 | "NO" { $$ = CYNew CYFalse(); }
1676 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1679 /* Cycript (Objective-C): Block Expressions {{{ */
1681 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1682 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1686 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1689 /* Cycript (Objective-C): Instance Literals {{{ */
1691 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1697 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1698 LeftHandSideExpression
1699 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1703 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1707 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1708 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1709 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1712 /* Cycript (C): auto Compatibility {{{ */
1717 /* Cycript (C): Lambda Expressions {{{ */
1719 : "," TypedParameterList { $$ = $2; }
1724 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1727 TypedParameterListOpt
1728 : TypedParameterList { $$ = $1; }
1733 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1736 /* Cycript (C): Type Definitions {{{ */
1738 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1743 /* YUI: Documentation Comments {{{ */
1745 : Comment { $$ = $1; }
1750 /* Lexer State {{{ */
1752 : { driver.PushCondition(CYDriver::RegExpCondition); }
1756 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1760 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1764 : { driver.PopCondition(); }
1768 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1772 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1775 /* Virtual Tokens {{{ */
1782 /* 8.1 Context Keywords {{{ */
1784 : "namespace" { $$ = $1; }
1785 | "xml" { $$ = $1; }
1788 /* 8.3 XML Initialiser Input Elements {{{ */
1790 : XMLComment { $$ = $1; }
1791 | XMLCDATA { $$ = $1; }
1792 | XMLPI { $$ = $1; }
1796 /* 11.1 Primary Expressions {{{ */
1798 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1799 | XMLInitialiser { $$ = $1; }
1800 | XMLListInitialiser { $$ = $1; }
1804 : AttributeIdentifier { $$ = $1; }
1805 | QualifiedIdentifier { $$ = $1; }
1806 | WildcardIdentifier { $$ = $1; }
1809 /* 11.1.1 Attribute Identifiers {{{ */
1811 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1815 : PropertySelector { $$ = $1; }
1816 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1820 : Identifier { $$ = CYNew CYSelector($1); }
1821 | WildcardIdentifier { $$ = $1; }
1824 /* 11.1.2 Qualified Identifiers {{{ */
1825 QualifiedIdentifier_
1826 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1827 | QualifiedIdentifier { $$ = $1; }
1831 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1834 /* 11.1.3 Wildcard Identifiers {{{ */
1836 : "*" { $$ = CYNew CYWildcard(); }
1839 /* 11.1.4 XML Initialiser {{{ */
1841 : XMLMarkup { $$ = $1; }
1842 | XMLElement { $$ = $1; }
1846 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1847 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1851 : LexPushXMLTag XMLTagName XMLAttributes
1855 : BRACE LexPushRegExp Expression LexPop "}"
1864 : XMLAttributes_ XMLAttribute
1869 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1870 | XMLAttributes_ XMLWhitespaceOpt
1879 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1883 : XMLExpression XMLElementContentOpt
1884 | XMLMarkup XMLElementContentOpt
1885 | XMLText XMLElementContentOpt
1886 | XMLElement XMLElementContentOpt
1889 XMLElementContentOpt
1894 /* 11.1.5 XMLList Initialiser {{{ */
1896 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1900 /* 11.2 Left-Hand-Side Expressions {{{ */
1902 : Identifier { $$ = $1; }
1903 | PropertyIdentifier { $$ = $1; }
1907 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1908 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1909 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1912 /* 12.1 The default xml namespace Statement {{{ */
1913 /* XXX: DefaultXMLNamespaceStatement
1914 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1918 : DefaultXMLNamespaceStatement { $$ = $1; }
1923 /* JavaScript 1.7: Array Comprehensions {{{ */
1925 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1929 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1930 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1933 /* JavaScript 1.7: for each {{{ */
1935 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1938 /* JavaScript 1.7: let Statements {{{ */
1940 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1948 /* JavaScript FTW: Ruby Blocks {{{ */
1949 RubyProcParameterList_
1950 : "," RubyProcParameterList { $$ = $2; }
1954 RubyProcParameterList
1955 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1960 : "|" RubyProcParameterList "|" { $$ = $2; }
1961 | "||" { $$ = NULL; }
1964 RubyProcParametersOpt
1965 : RubyProcParameters
1970 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1974 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1978 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }