1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 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/>.
23 #define YYSTACKEXPANDABLE 1
30 #define CYNew new(driver.pool_)
33 #include "ObjectiveC/Syntax.hpp"
37 #include "E4X/Syntax.hpp"
40 #include "Highlight.hpp"
43 %union { bool bool_; }
45 %union { CYMember *access_; }
46 %union { CYArgument *argument_; }
47 %union { CYAssignment *assignment_; }
48 %union { CYBinding *binding_; }
49 %union { CYBindings *bindings_; }
50 %union { CYBoolean *boolean_; }
51 %union { CYClause *clause_; }
52 %union { cy::Syntax::Catch *catch_; }
53 %union { CYClassTail *classTail_; }
54 %union { CYComprehension *comprehension_; }
55 %union { CYElement *element_; }
56 %union { CYExpression *expression_; }
57 %union { CYFalse *false_; }
58 %union { CYVariable *variable_; }
59 %union { CYFinally *finally_; }
60 %union { CYForInitializer *for_; }
61 %union { CYForInInitializer *forin_; }
62 %union { CYFunctionParameter *functionParameter_; }
63 %union { CYIdentifier *identifier_; }
64 %union { CYInfix *infix_; }
65 %union { CYLiteral *literal_; }
66 %union { CYMethod *method_; }
67 %union { CYModule *module_; }
68 %union { CYNull *null_; }
69 %union { CYNumber *number_; }
70 %union { CYParenthetical *parenthetical_; }
71 %union { CYProperty *property_; }
72 %union { CYPropertyName *propertyName_; }
73 %union { CYRubyProc *rubyProc_; }
74 %union { CYSpan *span_; }
75 %union { CYStatement *statement_; }
76 %union { CYString *string_; }
77 %union { CYTarget *target_; }
78 %union { CYThis *this_; }
79 %union { CYTrue *true_; }
80 %union { CYWord *word_; }
83 %union { CYTypeModifier *modifier_; }
84 %union { CYTypeSpecifier *specifier_; }
85 %union { CYTypedIdentifier *typedIdentifier_; }
86 %union { CYTypedParameter *typedParameter_; }
90 %union { CYMessage *message_; }
91 %union { CYMessageParameter *messageParameter_; }
92 %union { CYImplementationField *implementationField_; }
93 %union { CYProtocol *protocol_; }
94 %union { CYSelectorPart *selector_; }
98 %union { CYAttribute *attribute_; }
99 %union { CYPropertyIdentifier *propertyIdentifier_; }
100 %union { CYSelector *selector_; }
106 cy::parser::semantic_type semantic_;
107 hi::Value highlight_;
110 int cylex(YYSTYPE *, CYLocation *, void *);
118 typedef cy::parser::token tk;
120 _finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
121 driver.newline_ = false;
124 int token(cylex(&data, location, driver.scanner_));
125 *semantic = data.semantic_;
129 case tk::OpenBracket:
131 driver.in_.push(false);
135 if (driver.in_.top())
140 case tk::CloseBracket:
147 if (driver.yield_.top())
148 token = tk::_yield__;
152 driver.newline_ = true;
160 #define yylex_(semantic, location, driver) ({ \
162 if (driver.hold_ == cy::parser::empty_symbol) \
163 type = yytranslate_(cylex_(semantic, location, driver)); \
165 type = driver.hold_; \
166 driver.hold_ = cy::parser::empty_symbol; \
170 #define CYLEX() do if (yyla.empty()) { \
171 YYCDEBUG << "Mapping a token: "; \
172 yyla.type = yylex_(&yyla.value, &yyla.location, driver); \
173 YY_SYMBOL_PRINT("Next token is", yyla); \
176 #define CYMAP(to, from) do { \
178 if (yyla.type == yytranslate_(token::from)) \
179 yyla.type = yytranslate_(token::to); \
182 #define CYERR(location, message) do { \
183 error(location, message); \
187 #define CYEOK() do { \
189 driver.errors_.pop_back(); \
192 #define CYNOT(location) \
193 CYERR(location, "unimplemented feature")
195 #define CYMPT(location) do { \
196 if (!yyla.empty() && yyla.type_get() != yyeof_) \
197 CYERR(location, "unexpected lookahead"); \
207 @$.begin.filename = @$.end.filename = &driver.filename_;
209 switch (driver.mark_) {
211 driver.hold_ = yytranslate_(token::MarkScript);
214 driver.hold_ = yytranslate_(token::MarkModule);
222 %define api.location.type { CYLocation }
229 %param { CYDriver &driver }
231 /* Token Declarations {{{ */
237 %token XMLAttributeValue
239 %token XMLTagCharacters
245 %token LeftRight "<>"
246 %token LeftSlashRight "</>"
248 %token SlashRight "/>"
249 %token LeftSlash "</"
251 %token ColonColon "::"
252 %token PeriodPeriod ".."
255 @begin E4X ObjectiveC
261 %token AmpersandAmpersand "&&"
262 %token AmpersandEqual "&="
264 %token CarrotEqual "^="
266 %token EqualEqual "=="
267 %token EqualEqualEqual "==="
268 %token EqualRight "=>"
269 %token Exclamation "!"
270 %token ExclamationEqual "!="
271 %token ExclamationEqualEqual "!=="
273 %token HyphenEqual "-="
274 %token HyphenHyphen "--"
275 %token HyphenRight "->"
277 %token LeftEqual "<="
279 %token LeftLeftEqual "<<="
281 %token PercentEqual "%="
283 %token PeriodPeriodPeriod "..."
285 %token PipeEqual "|="
288 %token PlusEqual "+="
291 %token RightEqual ">="
292 %token RightRight ">>"
293 %token RightRightEqual ">>="
294 %token RightRightRight ">>>"
295 %token RightRightRightEqual ">>>="
297 %token SlashEqual "/="
299 %token StarEqual "*="
311 %token CloseParen ")"
314 %token OpenBrace_ ";{"
315 %token OpenBrace_let "let {"
316 %token CloseBrace "}"
318 %token OpenBracket "["
319 %token OpenBracket_let "let ["
320 %token CloseBracket "]"
322 %token At_error_ "@error"
325 %token At_class_ "@class"
329 %token _typedef_ "typedef"
330 %token _unsigned_ "unsigned"
331 %token _signed_ "signed"
332 %token _extern_ "extern"
336 %token At_encode_ "@encode"
340 %token At_implementation_ "@implementation"
341 %token At_import_ "@import"
342 %token At_end_ "@end"
343 %token At_selector_ "@selector"
344 %token At_null_ "@null"
345 %token At_YES_ "@YES"
347 %token At_true_ "@true"
348 %token At_false_ "@false"
353 %token _false_ "false"
357 %token _break_ "break"
359 %token _catch_ "catch"
360 %token _class_ "class"
361 %token _class__ ";class"
362 %token _const_ "const"
363 %token _continue_ "continue"
364 %token _debugger_ "debugger"
365 %token _default_ "default"
366 %token _delete_ "delete"
370 %token _export_ "export"
371 %token _extends_ "extends"
372 %token _finally_ "finally"
374 %token _function_ "function"
375 %token _function__ ";function"
377 %token _import_ "import"
380 %token _Infinity_ "Infinity"
381 %token _instanceof_ "instanceof"
383 %token _return_ "return"
384 %token _super_ "super"
385 %token _switch_ "switch"
386 %token _target_ "target"
388 %token _throw_ "throw"
390 %token _typeof_ "typeof"
393 %token _while_ "while"
396 %token _abstract_ "abstract"
397 %token _await_ "await"
398 %token _boolean_ "boolean"
401 %token _constructor_ "constructor"
402 %token _double_ "double"
404 %token _final_ "final"
405 %token _float_ "float"
409 %token _implements_ "implements"
411 %token _interface_ "interface"
415 %token _native_ "native"
416 %token _package_ "package"
417 %token _private_ "private"
418 %token _protected_ "protected"
419 %token _prototype_ "prototype"
420 %token _public_ "public"
422 %token _short_ "short"
423 %token _static_ "static"
424 %token _synchronized_ "synchronized"
425 %token _throws_ "throws"
426 %token _transient_ "transient"
427 %token _volatile_ "volatile"
428 %token _yield_ "yield"
429 %token _yield__ "!yield"
431 %token _undefined_ "undefined"
447 %token _namespace_ "namespace"
454 %token <identifier_> Identifier_
455 %token <number_> NumericLiteral
456 %token <string_> StringLiteral
457 %token <literal_> RegularExpressionLiteral_
459 %token <string_> NoSubstitutionTemplate
460 %token <string_> TemplateHead
461 %token <string_> TemplateMiddle
462 %token <string_> TemplateTail
464 %type <target_> AccessExpression
465 %type <expression_> AdditiveExpression
466 %type <argument_> ArgumentList_
467 %type <argument_> ArgumentList
468 %type <argument_> ArgumentListOpt
469 %type <argument_> Arguments
470 %type <target_> ArrayComprehension
471 %type <literal_> ArrayLiteral
472 %type <expression_> ArrowFunction
473 %type <functionParameter_> ArrowParameters
474 %type <expression_> AssignmentExpression
475 %type <expression_> AssignmentExpressionOpt
476 %type <identifier_> BindingIdentifier
477 %type <identifier_> BindingIdentifierOpt
478 %type <bindings_> BindingList_
479 %type <bindings_> BindingList
480 %type <expression_> BitwiseANDExpression
481 %type <statement_> Block
482 %type <statement_> BlockStatement
483 %type <boolean_> BooleanLiteral
484 %type <binding_> BindingElement
485 %type <expression_> BitwiseORExpression
486 %type <expression_> BitwiseXORExpression
487 %type <statement_> BreakStatement
488 %type <statement_> BreakableStatement
489 %type <expression_> CallExpression_
490 %type <target_> CallExpression
491 %type <clause_> CaseBlock
492 %type <clause_> CaseClause
493 %type <clause_> CaseClausesOpt
495 %type <identifier_> CatchParameter
496 %type <statement_> ClassDeclaration
497 %type <target_> ClassExpression
498 %type <classTail_> ClassHeritage
499 %type <classTail_> ClassHeritageOpt
500 %type <classTail_> ClassTail
501 %type <target_> Comprehension
502 %type <comprehension_> ComprehensionFor
503 %type <comprehension_> ComprehensionIf
504 %type <comprehension_> ComprehensionTail
505 %type <propertyName_> ComputedPropertyName
506 %type <expression_> ConditionalExpression
507 %type <statement_> ContinueStatement
508 %type <statement_> ConciseBody
509 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
510 %type <statement_> DebuggerStatement
511 %type <statement_> Declaration_
512 %type <statement_> Declaration
513 %type <clause_> DefaultClause
514 %type <element_> ElementList
515 %type <element_> ElementListOpt
516 %type <statement_> ElseStatementOpt
517 %type <for_> EmptyStatement
518 %type <expression_> EqualityExpression
519 %type <expression_> Expression
520 %type <expression_> ExpressionOpt
521 %type <for_> ExpressionStatement_
522 %type <statement_> ExpressionStatement
523 %type <finally_> Finally
524 %type <binding_> ForBinding
525 %type <forin_> ForDeclaration
526 %type <forin_> ForInStatementInitializer
527 %type <for_> ForStatementInitializer
528 %type <binding_> FormalParameter
529 %type <functionParameter_> FormalParameterList_
530 %type <functionParameter_> FormalParameterList
531 %type <functionParameter_> FormalParameters
532 %type <statement_> FunctionBody
533 %type <statement_> FunctionDeclaration
534 %type <target_> FunctionExpression
535 %type <statement_> FunctionStatementList
536 %type <statement_> GeneratorBody
537 %type <statement_> GeneratorDeclaration
538 %type <target_> GeneratorExpression
539 %type <method_> GeneratorMethod
540 %type <statement_> HoistableDeclaration
541 %type <identifier_> Identifier
542 %type <identifier_> IdentifierNoOf
543 %type <identifier_> IdentifierType
544 %type <identifier_> IdentifierTypeNoOf
545 %type <word_> IdentifierName
546 %type <variable_> IdentifierReference
547 %type <statement_> IfStatement
548 %type <target_> IndirectExpression
549 %type <expression_> Initializer
550 %type <expression_> InitializerOpt
551 %type <statement_> IterationStatement
552 %type <identifier_> LabelIdentifier
553 %type <statement_> LabelledItem
554 %type <statement_> LabelledStatement
555 %type <assignment_> LeftHandSideAssignment
556 %type <target_> LeftHandSideExpression
557 %type <bool_> LetOrConst
558 %type <binding_> LexicalBinding
559 %type <for_> LexicalDeclaration_
560 %type <statement_> LexicalDeclaration
561 %type <literal_> Literal
562 %type <propertyName_> LiteralPropertyName
563 %type <expression_> LogicalANDExpression
564 %type <expression_> LogicalORExpression
565 %type <access_> MemberAccess
566 %type <target_> MemberExpression
567 %type <method_> MethodDefinition
568 %type <module_> ModulePath
569 %type <expression_> MultiplicativeExpression
570 %type <target_> NewExpression
571 %type <null_> NullLiteral
572 %type <literal_> ObjectLiteral
573 %type <expression_> PostfixExpression
574 %type <target_> PrimaryExpression
575 %type <propertyName_> PropertyName
576 %type <property_> PropertyDefinition
577 %type <property_> PropertyDefinitionList_
578 %type <property_> PropertyDefinitionList
579 %type <property_> PropertyDefinitionListOpt
580 %type <functionParameter_> PropertySetParameterList
581 %type <literal_> RegularExpressionLiteral
582 %type <bool_> RegularExpressionSlash
583 %type <expression_> RelationalExpression
584 %type <statement_> ReturnStatement
585 %type <rubyProc_> RubyProcExpression
586 %type <functionParameter_> RubyProcParameterList_
587 %type <functionParameter_> RubyProcParameterList
588 %type <functionParameter_> RubyProcParameters
589 %type <functionParameter_> RubyProcParametersOpt
590 %type <statement_> Script
591 %type <statement_> ScriptBody
592 %type <statement_> ScriptBodyOpt
593 %type <expression_> ShiftExpression
594 %type <binding_> SingleNameBinding
595 %type <statement_> Statement__
596 %type <statement_> Statement_
597 %type <statement_> Statement
598 %type <statement_> StatementList
599 %type <statement_> StatementListOpt
600 %type <statement_> StatementListItem
601 %type <functionParameter_> StrictFormalParameters
602 %type <target_> SuperCall
603 %type <target_> SuperProperty
604 %type <statement_> SwitchStatement
605 %type <target_> TemplateLiteral
606 %type <span_> TemplateSpans
607 %type <statement_> ThrowStatement
608 %type <statement_> TryStatement
609 %type <expression_> UnaryExpression_
610 %type <expression_> UnaryExpression
611 %type <binding_> VariableDeclaration
612 %type <bindings_> VariableDeclarationList_
613 %type <bindings_> VariableDeclarationList
614 %type <for_> VariableStatement_
615 %type <statement_> VariableStatement
616 %type <statement_> WithStatement
619 %type <word_> WordOpt
621 %type <expression_> YieldExpression
624 %type <specifier_> IntegerType
625 %type <specifier_> IntegerTypeOpt
626 %type <typedIdentifier_> PrefixedType
627 %type <specifier_> PrimitiveType
628 %type <typedIdentifier_> SuffixedType
629 %type <typedIdentifier_> TypeSignifier
630 %type <modifier_> TypeQualifierLeft
631 %type <typedIdentifier_> TypeQualifierRight
632 %type <typedIdentifier_> TypedIdentifier
633 %type <typedParameter_> TypedParameterList_
634 %type <typedParameter_> TypedParameterList
635 %type <typedParameter_> TypedParameterListOpt
639 %type <expression_> AssignmentExpressionClassic
640 %type <expression_> BoxableExpression
641 %type <statement_> CategoryStatement
642 %type <expression_> ClassSuperOpt
643 %type <expression_> ConditionalExpressionClassic
644 %type <implementationField_> ImplementationFieldListOpt
645 %type <implementationField_> ImplementationFields
646 %type <message_> ClassMessageDeclaration
647 %type <message_> ClassMessageDeclarationListOpt
648 %type <protocol_> ClassProtocolListOpt
649 %type <protocol_> ClassProtocols
650 %type <protocol_> ClassProtocolsOpt
651 %type <statement_> ImplementationStatement
652 %type <target_> MessageExpression
653 %type <messageParameter_> MessageParameter
654 %type <messageParameter_> MessageParameters
655 %type <messageParameter_> MessageParameterList
656 %type <messageParameter_> MessageParameterListOpt
657 %type <bool_> MessageScope
658 %type <argument_> SelectorCall_
659 %type <argument_> SelectorCall
660 %type <selector_> SelectorExpression_
661 %type <selector_> SelectorExpression
662 %type <selector_> SelectorExpressionOpt
663 %type <argument_> SelectorList
664 %type <word_> SelectorWordOpt
665 %type <typedIdentifier_> TypeOpt
666 %type <argument_> VariadicCall
670 %type <propertyIdentifier_> PropertyIdentifier_
671 %type <selector_> PropertySelector_
672 %type <selector_> PropertySelector
673 %type <identifier_> QualifiedIdentifier_
674 %type <identifier_> QualifiedIdentifier
675 %type <identifier_> WildcardIdentifier
676 %type <identifier_> XMLComment
677 %type <identifier_> XMLCDATA
678 %type <identifier_> XMLElement
679 %type <identifier_> XMLElementContent
680 %type <identifier_> XMLMarkup
681 %type <identifier_> XMLPI
683 %type <attribute_> AttributeIdentifier
684 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
685 %type <expression_> PropertyIdentifier
686 %type <expression_> XMLListInitilizer
687 %type <expression_> XMLInitilizer
690 /* Token Priorities {{{ */
706 /* Lexer State {{{ */
707 LexPushInOn: { driver.in_.push(true); };
708 LexPushInOff: { driver.in_.push(false); };
709 LexPopIn: { driver.in_.pop(); };
711 LexPushReturnOn: { driver.return_.push(true); };
712 LexPopReturn: { driver.return_.pop(); };
714 LexPushSuperOn: { driver.super_.push(true); };
715 LexPushSuperOff: { driver.super_.push(false); };
716 LexPopSuper: { driver.super_.pop(); };
718 LexPushYieldOn: { driver.yield_.push(true); };
719 LexPushYieldOff: { driver.yield_.push(false); };
720 LexPopYield: { driver.yield_.pop(); };
723 : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
727 : { CYMAP(YieldStar, Star); }
731 : { CYMAP(OpenBrace_, OpenBrace); }
735 : { CYMAP(_class__, _class_); }
739 : { CYMAP(_function__, _function_); }
743 : LexNoBrace LexNoClass LexNoFunction
746 /* Virtual Tokens {{{ */
752 /* 11.6 Names and Keywords {{{ */
754 : Word[pass] { $$ = $pass; }
755 | "for" { $$ = CYNew CYWord("for"); }
756 | "in" { $$ = CYNew CYWord("in"); }
757 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
761 : IdentifierNoOf[pass] { $$ = $pass; }
762 | "break" { $$ = CYNew CYWord("break"); }
763 | "case" { $$ = CYNew CYWord("case"); }
764 | "catch" { $$ = CYNew CYWord("catch"); }
765 | "class" LexOf { $$ = CYNew CYWord("class"); }
766 | ";class" { $$ = CYNew CYWord("class"); }
767 | "const" { $$ = CYNew CYWord("const"); }
768 | "continue" { $$ = CYNew CYWord("continue"); }
769 | "debugger" { $$ = CYNew CYWord("debugger"); }
770 | "default" { $$ = CYNew CYWord("default"); }
771 | "delete" { $$ = CYNew CYWord("delete"); }
772 | "do" { $$ = CYNew CYWord("do"); }
773 | "else" { $$ = CYNew CYWord("else"); }
774 | "enum" { $$ = CYNew CYWord("enum"); }
775 | "export" { $$ = CYNew CYWord("export"); }
776 | "extends" { $$ = CYNew CYWord("extends"); }
777 | "false" { $$ = CYNew CYWord("false"); }
778 | "finally" { $$ = CYNew CYWord("finally"); }
779 | "function" LexOf { $$ = CYNew CYWord("function"); }
780 | "if" { $$ = CYNew CYWord("if"); }
781 | "import" { $$ = CYNew CYWord("import"); }
782 | "!in" { $$ = CYNew CYWord("in"); }
783 | "!of" { $$ = CYNew CYWord("of"); }
784 | "new" { $$ = CYNew CYWord("new"); }
785 | "null" { $$ = CYNew CYWord("null"); }
786 | "return" { $$ = CYNew CYWord("return"); }
787 | "super" { $$ = CYNew CYWord("super"); }
788 | "switch" { $$ = CYNew CYWord("switch"); }
789 | "this" { $$ = CYNew CYWord("this"); }
790 | "throw" { $$ = CYNew CYWord("throw"); }
791 | "true" { $$ = CYNew CYWord("true"); }
792 | "try" { $$ = CYNew CYWord("try"); }
793 | "typeof" { $$ = CYNew CYWord("typeof"); }
794 | "var" { $$ = CYNew CYWord("var"); }
795 | "void" { $$ = CYNew CYWord("void"); }
796 | "while" { $$ = CYNew CYWord("while"); }
797 | "with" { $$ = CYNew CYWord("with"); }
798 | "yield" { $$ = CYNew CYIdentifier("yield"); }
803 : Word[pass] { $$ = $pass; }
808 /* 11.8.1 Null Literals {{{ */
810 : "null" { $$ = CYNew CYNull(); }
813 /* 11.8.2 Boolean Literals {{{ */
815 : "true" { $$ = CYNew CYTrue(); }
816 | "false" { $$ = CYNew CYFalse(); }
819 /* 11.8.5 Regular Expression Literals {{{ */
820 RegularExpressionSlash
821 : "/" { $$ = false; }
822 | "/=" { $$ = true; }
825 RegularExpressionLiteral
826 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
830 /* 11.9 Automatic Semicolon Insertion {{{ */
832 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
842 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
847 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
851 /* 12.1 Identifiers {{{ */
853 : Identifier[pass] { $$ = CYNew CYVariable($pass); }
854 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
858 : LexOf IdentifierNoOf[pass] { $$ = $pass; }
859 | LexOf "!of" { $$ = CYNew CYIdentifier("of"); }
860 | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); }
864 : BindingIdentifier[pass] { $$ = $pass; }
865 | LexOf { $$ = NULL; }
869 : Identifier[pass] { $$ = $pass; }
870 | "yield" { $$ = CYNew CYIdentifier("yield"); }
874 : Identifier_[pass] { $$ = $pass; }
875 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
876 | "await" { $$ = CYNew CYIdentifier("await"); }
877 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
878 | "byte" { $$ = CYNew CYIdentifier("byte"); }
879 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
880 | "double" { $$ = CYNew CYIdentifier("double"); }
881 | "each" { $$ = CYNew CYIdentifier("each"); }
882 | "eval" { $$ = CYNew CYIdentifier("eval"); }
883 | "final" { $$ = CYNew CYIdentifier("final"); }
884 | "float" { $$ = CYNew CYIdentifier("float"); }
885 | "from" { $$ = CYNew CYIdentifier("from"); }
886 | "get" { $$ = CYNew CYIdentifier("get"); }
887 | "goto" { $$ = CYNew CYIdentifier("goto"); }
888 | "implements" { $$ = CYNew CYIdentifier("implements"); }
889 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
890 | "interface" { $$ = CYNew CYIdentifier("interface"); }
891 | "let" { $$ = CYNew CYIdentifier("let"); }
892 | "!let" LexBind LexOf { $$ = CYNew CYIdentifier("let"); }
893 | "native" { $$ = CYNew CYIdentifier("native"); }
894 | "package" { $$ = CYNew CYIdentifier("package"); }
895 | "private" { $$ = CYNew CYIdentifier("private"); }
896 | "protected" { $$ = CYNew CYIdentifier("protected"); }
897 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
898 | "public" { $$ = CYNew CYIdentifier("public"); }
899 | "set" { $$ = CYNew CYIdentifier("set"); }
900 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
901 | "target" { $$ = CYNew CYIdentifier("target"); }
902 | "throws" { $$ = CYNew CYIdentifier("throws"); }
903 | "transient" { $$ = CYNew CYIdentifier("transient"); }
904 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
906 | "bool" { $$ = CYNew CYIdentifier("bool"); }
907 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
908 | "id" { $$ = CYNew CYIdentifier("id"); }
909 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
914 : IdentifierTypeNoOf[pass] { $$ = $pass; }
915 | "of" { $$ = CYNew CYIdentifier("of"); }
920 | "char" { $$ = CYNew CYIdentifier("char"); }
921 | "int" { $$ = CYNew CYIdentifier("int"); }
922 | "long" { $$ = CYNew CYIdentifier("long"); }
923 | "short" { $$ = CYNew CYIdentifier("short"); }
924 | "static" { $$ = CYNew CYIdentifier("static"); }
925 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
927 | "extern" { $$ = CYNew CYIdentifier("extern"); }
928 | "signed" { $$ = CYNew CYIdentifier("signed"); }
929 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
930 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
933 | "nil" { $$ = CYNew CYIdentifier("nil"); }
934 | "NO" { $$ = CYNew CYIdentifier("NO"); }
935 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
936 | "YES" { $$ = CYNew CYIdentifier("YES"); }
941 : IdentifierNoOf[pass] { $$ = $pass; }
942 | "of" { $$ = CYNew CYIdentifier("of"); }
943 | "!of" { $$ = CYNew CYIdentifier("of"); }
946 /* 12.2 Primary Expression {{{ */
948 : "this" { $$ = CYNew CYThis(); }
949 | IdentifierReference[pass] { $$ = $pass; }
950 | Literal[pass] { $$ = $pass; }
951 | ArrayLiteral[pass] { $$ = $pass; }
952 | ObjectLiteral[pass] { $$ = $pass; }
953 | FunctionExpression[pass] { $$ = $pass; }
954 | ClassExpression[pass] { $$ = $pass; }
955 | GeneratorExpression[pass] { $$ = $pass; }
956 | RegularExpressionLiteral[pass] { $$ = $pass; }
957 | TemplateLiteral[pass] { $$ = $pass; }
958 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
959 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
962 CoverParenthesizedExpressionAndArrowParameterList
963 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
964 | "(" LexOf ")" { $$ = NULL; }
965 | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
966 | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
969 /* 12.2.4 Literals {{{ */
971 : NullLiteral[pass] { $$ = $pass; }
972 | BooleanLiteral[pass] { $$ = $pass; }
973 | NumericLiteral[pass] { $$ = $pass; }
974 | StringLiteral[pass] { $$ = $pass; }
977 /* 12.2.5 Array Initializer {{{ */
979 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
983 : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); }
984 | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
985 | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); }
989 : ElementList[pass] { $$ = $pass; }
990 | LexOf { $$ = NULL; }
993 /* 12.2.6 Object Initializer {{{ */
995 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
998 PropertyDefinitionList_
999 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1003 PropertyDefinitionList
1004 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1007 PropertyDefinitionListOpt
1008 : PropertyDefinitionList[properties] { $$ = $properties; }
1013 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1014 | CoverInitializedName[name] { CYNOT(@$); }
1015 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1016 | MethodDefinition[pass] { $$ = $pass; }
1020 : LiteralPropertyName[pass] { $$ = $pass; }
1021 | ComputedPropertyName[pass] { $$ = $pass; }
1025 : IdentifierName[pass] { $$ = $pass; }
1026 | StringLiteral[pass] { $$ = $pass; }
1027 | NumericLiteral[pass] { $$ = $pass; }
1030 ComputedPropertyName
1031 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1034 CoverInitializedName
1035 : IdentifierReference Initializer
1039 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1043 : Initializer[pass] { $$ = $pass; }
1047 /* 12.2.9 Template Literals {{{ */
1049 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1050 | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1054 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1055 | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); }
1059 /* 12.3 Left-Hand-Side Expressions {{{ */
1061 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1062 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1063 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1064 | TemplateLiteral { CYNOT(@$); }
1068 : PrimaryExpression[pass] { $$ = $pass; }
1069 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1070 | SuperProperty[pass] { $$ = $pass; }
1071 | MetaProperty { CYNOT(@$); }
1072 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1076 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1077 | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1085 : "new" "." "target"
1089 : MemberExpression[pass] { $$ = $pass; }
1090 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1094 : MemberExpression[pass] { $$ = $pass; }
1095 | CallExpression[pass] { $$ = $pass; }
1099 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1100 | SuperCall[pass] { $$ = $pass; }
1101 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1105 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1109 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1113 : "," ArgumentList[arguments] { $$ = $arguments; }
1118 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1119 | LexOf "..." AssignmentExpression { CYNOT(@$); }
1123 : ArgumentList[pass] { $$ = $pass; }
1124 | LexOf { $$ = NULL; }
1128 : NewExpression[pass] { $$ = $pass; }
1129 | CallExpression[pass] { $$ = $pass; }
1132 LeftHandSideExpression
1133 : AccessExpression[pass] LexNewLine { $$ = $pass; }
1134 | IndirectExpression[pass] { $$ = $pass; }
1137 /* 12.4 Postfix Expressions {{{ */
1139 : AccessExpression[lhs] LexNewLine { $$ = $lhs; }
1140 | AccessExpression[lhs] LexNewLine "++" { $$ = CYNew CYPostIncrement($lhs); }
1141 | AccessExpression[lhs] LexNewLine "--" { $$ = CYNew CYPostDecrement($lhs); }
1144 /* 12.5 Unary Operators {{{ */
1146 : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); }
1147 | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
1148 | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
1149 | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1150 | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1151 | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
1152 | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
1153 | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
1154 | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); }
1158 : PostfixExpression[expression] { $$ = $expression; }
1159 | PostfixExpression[expression] "\n" { $$ = $expression; }
1160 | UnaryExpression_[pass] { $$ = $pass; }
1163 /* 12.6 Multiplicative Operators {{{ */
1164 MultiplicativeExpression
1165 : UnaryExpression[pass] { $$ = $pass; }
1166 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1167 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1168 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1171 /* 12.7 Additive Operators {{{ */
1173 : MultiplicativeExpression[pass] { $$ = $pass; }
1174 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1175 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1178 /* 12.8 Bitwise Shift Operators {{{ */
1180 : AdditiveExpression[pass] { $$ = $pass; }
1181 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1182 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1183 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1186 /* 12.9 Relational Operators {{{ */
1187 RelationalExpression
1188 : ShiftExpression[pass] { $$ = $pass; }
1189 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1190 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1191 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1192 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1193 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1194 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1197 /* 12.10 Equality Operators {{{ */
1199 : RelationalExpression[pass] { $$ = $pass; }
1200 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1201 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1202 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1203 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1206 /* 12.11 Binary Bitwise Operators {{{ */
1207 BitwiseANDExpression
1208 : EqualityExpression[pass] { $$ = $pass; }
1209 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1212 BitwiseXORExpression
1213 : BitwiseANDExpression[pass] { $$ = $pass; }
1214 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1218 : BitwiseXORExpression[pass] { $$ = $pass; }
1219 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1222 /* 12.12 Binary Logical Operators {{{ */
1223 LogicalANDExpression
1224 : BitwiseORExpression[pass] { $$ = $pass; }
1225 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1229 : LogicalANDExpression[pass] { $$ = $pass; }
1230 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1233 /* 12.13 Conditional Operator ( ? : ) {{{ */
1235 ConditionalExpressionClassic
1236 : LogicalORExpression[pass] { $$ = $pass; }
1237 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1241 ConditionalExpression
1242 : LogicalORExpression[pass] { $$ = $pass; }
1243 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1246 /* 12.14 Assignment Operators {{{ */
1247 LeftHandSideAssignment
1248 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1249 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1250 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1251 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1252 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1253 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1254 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1255 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1256 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1257 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1258 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1259 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1263 AssignmentExpressionClassic
1264 : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; }
1265 | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1269 AssignmentExpression
1270 : LexOf ConditionalExpression[pass] { $$ = $pass; }
1271 | LexOf YieldExpression[pass] { $$ = $pass; }
1272 | ArrowFunction[pass] { $$ = $pass; }
1273 | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1276 AssignmentExpressionOpt
1277 : AssignmentExpression[pass] { $$ = $pass; }
1278 | LexOf { $$ = NULL; }
1281 /* 12.15 Comma Operator ( , ) {{{ */
1283 : AssignmentExpression[pass] { $$ = $pass; }
1284 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1288 : Expression[pass] { $$ = $pass; }
1289 | LexOf { $$ = NULL; }
1293 /* 13 Statements and Declarations {{{ */
1295 : BlockStatement[pass] { $$ = $pass; }
1296 | VariableStatement[pass] { $$ = $pass; }
1297 | EmptyStatement[pass] { $$ = $pass; }
1298 | IfStatement[pass] { $$ = $pass; }
1299 | BreakableStatement[pass] { $$ = $pass; }
1300 | ContinueStatement[pass] { $$ = $pass; }
1301 | BreakStatement[pass] { $$ = $pass; }
1302 | ReturnStatement[pass] { $$ = $pass; }
1303 | WithStatement[pass] { $$ = $pass; }
1304 | LabelledStatement[pass] { $$ = $pass; }
1305 | ThrowStatement[pass] { $$ = $pass; }
1306 | TryStatement[pass] { $$ = $pass; }
1307 | DebuggerStatement[pass] { $$ = $pass; }
1311 : LexOf Statement__[pass] { $$ = $pass; }
1312 | ExpressionStatement[pass] { $$ = $pass; }
1316 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1320 : HoistableDeclaration[pass] { $$ = $pass; }
1321 | ClassDeclaration[pass] { $$ = $pass; }
1325 : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; }
1326 | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; }
1329 HoistableDeclaration
1330 : FunctionDeclaration[pass] { $$ = $pass; }
1331 | GeneratorDeclaration[pass] { $$ = $pass; }
1335 : IterationStatement[pass] { $$ = $pass; }
1336 | SwitchStatement[pass] { $$ = $pass; }
1339 /* 13.2 Block {{{ */
1341 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1345 : "{" StatementListOpt[code] "}" { $$ = $code; }
1349 : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; }
1353 : StatementList[pass] { $$ = $pass; }
1354 | LexSetStatement LexLet LexOf { $$ = NULL; }
1358 : Statement[pass] { $$ = $pass; }
1359 | Declaration[pass] { $$ = $pass; }
1362 /* 13.3 Let and Const Declarations {{{ */
1364 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1368 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1372 : { CYMAP(_let__, _let_); }
1376 : { CYMAP(_of__, _of_); }
1380 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); }
1384 : LexLet LexOf "!let" LexBind LexOf { $$ = false; }
1385 | LexLet LexOf "const" { $$ = true; }
1389 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1394 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1398 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1399 | LexOf BindingPattern Initializer { CYNOT(@$); }
1402 /* 13.3.2 Variable Statement {{{ */
1404 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1408 : VariableStatement_[statement] Terminator { $$ = $statement; }
1411 VariableDeclarationList_
1412 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1416 VariableDeclarationList
1417 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1421 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1422 | LexOf BindingPattern Initializer { CYNOT(@$); }
1425 /* 13.3.3 Destructuring Binding Patterns {{{ */
1427 : ObjectBindingPattern
1428 | ArrayBindingPattern
1431 ObjectBindingPattern
1432 : "let {" BindingPropertyListOpt "}"
1436 : "let [" BindingElementListOpt "]"
1439 BindingPropertyList_
1440 : "," BindingPropertyListOpt
1445 : BindingProperty BindingPropertyList_
1448 BindingPropertyListOpt
1449 : BindingPropertyList
1454 : BindingElementOpt[element] "," BindingElementListOpt[next]
1455 | BindingRestElement[element]
1456 | BindingElement[element]
1459 BindingElementListOpt
1460 : BindingElementList[pass]
1466 | LexOf PropertyName ":" BindingElement
1470 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1471 | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1475 : BindingElement[pass]
1480 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1484 : LexBind LexOf "..." BindingIdentifier
1487 /* 13.4 Empty Statement {{{ */
1489 : ";" { $$ = CYNew CYEmpty(); }
1492 /* 13.5 Expression Statement {{{ */
1493 ExpressionStatement_
1494 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1497 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1500 /* 13.6 The if Statement {{{ */
1502 : "else" Statement[false] { $$ = $false; }
1503 | %prec "if" { $$ = NULL; }
1507 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1510 /* 13.7 Iteration Statements {{{ */
1512 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1513 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1514 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1515 | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1516 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1517 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1520 ForStatementInitializer
1521 : LexLet LexOf EmptyStatement[pass] { $$ = $pass; }
1522 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1523 | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; }
1524 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1527 ForInStatementInitializer
1528 : LexLet LexOf AccessExpression[pass] LexNewLine { $$ = $pass; }
1529 | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
1530 | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1531 | ForDeclaration[pass] { $$ = $pass; }
1535 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1539 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1540 | LexOf BindingPattern { CYNOT(@$); }
1543 /* 13.8 The continue Statement {{{ */
1545 : "continue" LexNewLine TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1546 | "continue" LexNewLine Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1549 /* 13.9 The break Statement {{{ */
1551 : "break" LexNewLine TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1552 | "break" LexNewLine Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1555 /* 13.10 The return Statement {{{ */
1557 : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
1561 : Return LexNewLine LexOf TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1562 | Return LexNewLine Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1565 /* 13.11 The with Statement {{{ */
1567 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1570 /* 13.12 The switch Statement {{{ */
1572 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1576 : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1580 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1584 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1585 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1589 // XXX: the standard makes certain you can only have one of these
1591 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1594 /* 13.13 Labelled Statements {{{ */
1596 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1600 : Statement[pass] { $$ = $pass; }
1601 | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; }
1604 /* 13.14 The throw Statement {{{ */
1606 : "throw"[throw] LexNewLine LexOf TerminatorSoft { CYERR(@throw, "throw without exception"); }
1607 | "throw" LexNewLine Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1610 /* 13.15 The try Statement {{{ */
1612 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1613 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1614 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1618 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1622 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1626 : BindingIdentifier[pass] { $$ = $pass; }
1627 | LexOf BindingPattern { CYNOT(@$); }
1630 /* 13.16 The debugger Statement {{{ */
1632 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1636 /* 14.1 Function Definitions {{{ */
1638 : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1642 : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1645 StrictFormalParameters
1646 : FormalParameters[pass] { $$ = $pass; }
1650 : LexBind LexOf { $$ = NULL; }
1651 | FormalParameterList
1654 FormalParameterList_
1655 : "," FormalParameterList[parameters] { $$ = $parameters; }
1660 : FunctionRestParameter { CYNOT(@$); }
1661 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1664 FunctionRestParameter
1665 : BindingRestElement
1669 : BindingElement[pass] { $$ = $pass; }
1673 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1676 FunctionStatementList
1677 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1680 /* 14.2 Arrow Function Definitions {{{ */
1682 : ArrowParameters[parameters] LexNewLine "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1686 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1687 | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1691 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1692 | LexOf ";{" FunctionBody[code] "}" { $$ = $code; }
1695 /* 14.3 Method Definitions {{{ */
1697 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1698 | GeneratorMethod[pass] { $$ = $pass; }
1699 | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1700 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1703 PropertySetParameterList
1704 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1707 /* 14.4 Generator Function Definitions {{{ */
1709 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1712 GeneratorDeclaration
1713 : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1717 : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1721 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1725 : "!yield" LexNewLine LexNoStar
1729 : Yield LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1730 | Yield LexOf "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1731 | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1732 | Yield LexOf YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1735 /* 14.5 Class Definitions {{{ */
1737 : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1741 : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1745 : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1749 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1753 : ClassHeritage[pass] { $$ = $pass; }
1754 | { $$ = CYNew CYClassTail(NULL); }
1767 : ClassElementListOpt ClassElement
1776 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1777 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1782 /* 15.1 Scripts {{{ */
1784 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1788 : StatementList[pass] { $$ = $pass; }
1792 : ScriptBody[pass] { $$ = $pass; }
1793 | LexSetStatement LexLet LexOf { $$ = NULL; }
1796 /* 15.2 Modules {{{ */
1811 : ModuleItemListOpt ModuleItem
1820 : LexSetStatement LexLet LexOf ImportDeclaration
1821 | LexSetStatement LexLet LexOf ExportDeclaration
1825 /* 15.2.2 Imports {{{ */
1827 : "import" ImportClause FromClause Terminator
1828 | "import" LexOf ModuleSpecifier Terminator
1832 : ImportedDefaultBinding
1833 | LexOf NameSpaceImport
1834 | LexOf NamedImports
1835 | ImportedDefaultBinding "," NameSpaceImport
1836 | ImportedDefaultBinding "," NamedImports
1839 ImportedDefaultBinding
1844 : "*" "as" ImportedBinding
1848 : "{" ImportsListOpt "}"
1852 : "from" ModuleSpecifier
1856 : "," ImportsListOpt
1861 : ImportSpecifier ImportsList_
1871 | LexOf IdentifierName "as" ImportedBinding
1882 /* 15.2.3 Exports {{{ */
1884 : "*" FromClause Terminator
1885 | ExportClause FromClause Terminator
1886 | ExportClause Terminator
1888 | "default" LexSetStatement LexOf HoistableDeclaration
1889 | "default" LexSetStatement LexOf ClassDeclaration
1890 | "default" LexSetStatement AssignmentExpression Terminator
1894 : "export" LexSetStatement LexLet LexOf ExportDeclaration_
1895 | "export" Declaration
1899 : ";{" ExportsListOpt "}"
1903 : "," ExportsListOpt
1908 : ExportSpecifier ExportsList_
1918 | IdentifierName "as" IdentifierName
1923 /* Cycript (C): Type Encoding {{{ */
1925 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
1926 | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
1930 : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
1931 | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
1932 | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1933 | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1934 | TypeSignifier[pass] { $$ = $pass; }
1935 | { $$ = CYNew CYTypedIdentifier(@$); }
1939 : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1944 | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
1945 | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
1949 : PrefixedType[pass] { $$ = $pass; }
1950 | SuffixedType[pass] { $$ = $pass; }
1951 | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1952 | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1956 : "int" { $$ = CYNew CYTypeVariable("int"); }
1957 | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); }
1958 | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); }
1959 | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); }
1960 | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); }
1964 : IntegerType[pass] { $$ = $pass; }
1965 | { $$ = CYNew CYTypeVariable("int"); }
1969 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
1970 | IntegerType[pass] { $$ = $pass; }
1971 | "void" { $$ = CYNew CYTypeVoid(); }
1972 | "char" { $$ = CYNew CYTypeVariable("char"); }
1973 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1974 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1978 : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
1982 : "@encode" "(" TypedIdentifier[typed] ")" { $$ = CYNew CYEncodedType($typed); }
1988 /* Cycript (Objective-C): @class Declaration {{{ */
1990 /* XXX: why the hell did I choose MemberExpression? */
1991 : ":" MemberExpression[extends] { $$ = $extends; }
1995 ImplementationFieldListOpt
1996 : TypedIdentifier[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2000 ImplementationFields
2001 : "{" ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
2005 : "+" { $$ = false; }
2006 | "-" { $$ = true; }
2010 : "(" TypedIdentifier[type] ")" { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); $$ = $type; }
2011 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2015 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2018 MessageParameterList
2019 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2022 MessageParameterListOpt
2023 : MessageParameterList[pass] { $$ = $pass; }
2028 : MessageParameterList[pass] { $$ = $pass; }
2029 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2032 ClassMessageDeclaration
2033 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2036 ClassMessageDeclarationListOpt
2037 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2041 // XXX: this should be AssignmentExpressionNoRight
2043 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2047 : "," ClassProtocols[protocols] { $$ = $protocols; }
2051 ClassProtocolListOpt
2052 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2056 ImplementationStatement
2057 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] ImplementationFields[fields] ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2065 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2069 : ImplementationStatement[pass] { $$ = $pass; }
2070 | CategoryStatement[pass] { $$ = $pass; }
2073 /* Cycript (Objective-C): Send Message {{{ */
2075 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2080 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2081 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2085 : SelectorCall[pass] { $$ = $pass; }
2086 | VariadicCall[pass] { $$ = $pass; }
2090 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2094 : SelectorCall[pass] { $$ = $pass; }
2095 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2099 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2100 | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2104 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2108 : SelectorExpression_[pass] { $$ = $pass; }
2109 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2112 SelectorExpressionOpt
2113 : SelectorExpression_[pass] { $$ = $pass; }
2118 : MessageExpression[pass] { $$ = $pass; }
2119 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2124 /* Cycript: @import Directive {{{ */
2126 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2127 | Word[part] { $$ = CYNew CYModule($part); }
2131 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2136 /* Cycript (Objective-C): Boxed Expressions {{{ */
2138 : NullLiteral[pass] { $$ = $pass; }
2139 | BooleanLiteral[pass] { $$ = $pass; }
2140 | NumericLiteral[pass] { $$ = $pass; }
2141 | StringLiteral[pass] { $$ = $pass; }
2142 | ArrayLiteral[pass] { $$ = $pass; }
2143 | ObjectLiteral[pass] { $$ = $pass; }
2144 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2145 | "YES" { $$ = CYNew CYTrue(); }
2146 | "NO" { $$ = CYNew CYFalse(); }
2150 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2151 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2152 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2153 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2154 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2155 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2158 /* Cycript (Objective-C): Block Expressions {{{ */
2160 : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2163 /* Cycript (Objective-C): Instance Literals {{{ */
2165 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2171 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2173 : IndirectExpression[pass] { $$ = $pass; }
2177 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2181 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2185 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2186 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2187 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2190 /* Cycript (C): Lambda Expressions {{{ */
2192 : "," TypedParameterList[parameters] { $$ = $parameters; }
2197 : TypedIdentifier[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
2200 TypedParameterListOpt
2201 : TypedParameterList[pass] { $$ = $pass; }
2206 : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2209 /* Cycript (C): Type Definitions {{{ */
2211 : "typedef" TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); }
2214 /* Cycript (C): extern "C" {{{ */
2216 : "extern" StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($abi, $typed); }
2223 /* Lexer State {{{ */
2225 : { driver.PushCondition(CYDriver::RegExpCondition); }
2229 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2233 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2237 : { driver.PopCondition(); }
2241 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2245 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2248 /* Virtual Tokens {{{ */
2255 /* 8.1 Context Keywords {{{ */
2257 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2258 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2261 /* 8.3 XML Initializer Input Elements {{{ */
2263 : XMLComment { $$ = $1; }
2264 | XMLCDATA { $$ = $1; }
2265 | XMLPI { $$ = $1; }
2269 /* 11.1 Primary Expressions {{{ */
2271 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2272 | XMLInitilizer { $$ = $1; }
2273 | XMLListInitilizer { $$ = $1; }
2277 : AttributeIdentifier { $$ = $1; }
2278 | QualifiedIdentifier { $$ = $1; }
2279 | WildcardIdentifier { $$ = $1; }
2282 /* 11.1.1 Attribute Identifiers {{{ */
2284 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2288 : PropertySelector { $$ = $1; }
2289 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2293 : Identifier { $$ = CYNew CYSelector($1); }
2294 | WildcardIdentifier { $$ = $1; }
2297 /* 11.1.2 Qualified Identifiers {{{ */
2298 QualifiedIdentifier_
2299 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2300 | QualifiedIdentifier { $$ = $1; }
2304 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2307 /* 11.1.3 Wildcard Identifiers {{{ */
2309 : "*" { $$ = CYNew CYWildcard(); }
2312 /* 11.1.4 XML Initializer {{{ */
2314 : XMLMarkup { $$ = $1; }
2315 | XMLElement { $$ = $1; }
2319 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2320 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2324 : LexPushXMLTag XMLTagName XMLAttributes
2328 : "{" LexPushRegExp Expression LexPop "}"
2337 : XMLAttributes_ XMLAttribute
2342 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2343 | XMLAttributes_ XMLWhitespaceOpt
2352 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2356 : XMLExpression XMLElementContentOpt
2357 | XMLMarkup XMLElementContentOpt
2358 | XMLText XMLElementContentOpt
2359 | XMLElement XMLElementContentOpt
2362 XMLElementContentOpt
2367 /* 11.1.5 XMLList Initializer {{{ */
2369 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2373 /* 11.2 Left-Hand-Side Expressions {{{ */
2375 : Identifier { $$ = $1; }
2376 | PropertyIdentifier { $$ = $1; }
2380 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2381 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2382 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2385 /* 12.1 The default xml namespace Statement {{{ */
2386 /* XXX: DefaultXMLNamespaceStatement
2387 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2391 : DefaultXMLNamespaceStatement { $$ = $1; }
2396 /* JavaScript FTL: Array Comprehensions {{{ */
2398 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2402 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2405 /* JavaScript FTL: for each {{{ */
2407 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2411 /* JavaScript FTW: Array Comprehensions {{{ */
2413 : ArrayComprehension
2417 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2421 : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2426 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2427 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2431 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2432 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2436 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2439 /* JavaScript FTW: Coalesce Operator {{{ */
2440 ConditionalExpression
2441 : LogicalORExpression[test] "?" LexPushInOff LexOf ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); }
2444 /* JavaScript FTW: Named Arguments {{{ */
2446 : LexOf Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2449 /* JavaScript FTW: Ruby Blocks {{{ */
2450 RubyProcParameterList_
2451 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2455 RubyProcParameterList
2456 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2457 | LexOf { $$ = NULL; }
2461 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2462 | "||" { $$ = NULL; }
2465 RubyProcParametersOpt
2466 : RubyProcParameters[pass] { $$ = $pass; }
2471 : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2475 : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2479 : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLine { $$ = CYNew CYRubyBlock($lhs, $rhs); }
2485 bool CYDriver::Parse(CYMark mark) {
2487 CYLocal<CYPool> local(&pool_);
2488 cy::parser parser(*this);
2490 parser.set_debug_level(debug_);
2492 return parser.parse() != 0;
2495 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2499 CYDriver::Error error;
2500 error.warning_ = true;
2501 error.location_ = location;
2502 error.message_ = message;
2503 errors_.push_back(error);
2506 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2507 CYDriver::Error error;
2508 error.warning_ = false;
2509 error.location_ = location;
2510 error.message_ = message;
2511 driver.errors_.push_back(error);