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 *);
116 typedef cy::parser::token tk;
119 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
120 if (driver.mark_ == CYMarkIgnore);
121 else if (driver.mark_ == CYMarkScript) {
122 driver.mark_ = CYMarkIgnore;
123 return cy::parser::token::MarkScript;
124 } else if (driver.mark_ == CYMarkModule) {
125 driver.mark_ = CYMarkIgnore;
126 return cy::parser::token::MarkModule;
130 if (driver.newline_ == CYDriver::NewLineHere)
131 driver.newline_ = CYDriver::NewLineLast;
132 else if (driver.newline_ == CYDriver::NewLineLast)
133 driver.newline_ = CYDriver::NewLineNone;
136 int token(cylex(&data, location, driver.scanner_));
137 *semantic = data.semantic_;
141 case tk::OpenBracket:
143 driver.in_.push(false);
147 if (driver.in_.top())
152 case tk::CloseBracket:
159 if (driver.yield_.top())
160 token = tk::_yield__;
164 driver.newline_ = CYDriver::NewLineHere;
170 driver.next_ = false;
174 #define CYLEX() do if (yyla.empty()) { \
175 YYCDEBUG << "Mapping a token: "; \
176 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
177 YY_SYMBOL_PRINT("Next token is", yyla); \
180 #define CYMAP(to, from) do { \
182 if (yyla.type == yytranslate_(token::from)) \
183 yyla.type = yytranslate_(token::to); \
186 #define CYLIN(from) do { \
188 if (yyla.type == yytranslate_(token::from) && driver.newline_ == CYDriver::NewLineLast) \
189 yyla.type = yytranslate_(token::from ## _); \
192 #define CYERR(location, message) do { \
193 error(location, message); \
197 #define CYEOK() do { \
199 driver.errors_.pop_back(); \
202 #define CYNOT(location) \
203 CYERR(location, "unimplemented feature")
205 #define CYMPT(location) do { \
206 if (!yyla.empty() && yyla.type_get() != yyeof_) \
207 CYERR(location, "unexpected lookahead"); \
217 @$.begin.filename = @$.end.filename = &driver.filename_;
223 %define api.location.type { CYLocation }
230 %param { CYDriver &driver }
232 /* Token Declarations {{{ */
238 %token XMLAttributeValue
240 %token XMLTagCharacters
246 %token LeftRight "<>"
247 %token LeftSlashRight "</>"
249 %token SlashRight "/>"
250 %token LeftSlash "</"
252 %token ColonColon "::"
253 %token PeriodPeriod ".."
256 @begin E4X ObjectiveC
262 %token AmpersandAmpersand "&&"
263 %token AmpersandEqual "&="
265 %token CarrotEqual "^="
267 %token EqualEqual "=="
268 %token EqualEqualEqual "==="
269 %token EqualRight "=>"
270 %token EqualRight_ "\n=>"
271 %token Exclamation "!"
272 %token ExclamationEqual "!="
273 %token ExclamationEqualEqual "!=="
275 %token HyphenEqual "-="
276 %token HyphenHyphen "--"
277 %token HyphenHyphen_ "\n--"
278 %token HyphenRight "->"
280 %token LeftEqual "<="
282 %token LeftLeftEqual "<<="
284 %token PercentEqual "%="
286 %token PeriodPeriodPeriod "..."
288 %token PipeEqual "|="
291 %token PlusEqual "+="
293 %token PlusPlus_ "\n++"
295 %token RightEqual ">="
296 %token RightRight ">>"
297 %token RightRightEqual ">>="
298 %token RightRightRight ">>>"
299 %token RightRightRightEqual ">>>="
301 %token SlashEqual "/="
303 %token StarEqual "*="
315 %token CloseParen ")"
318 %token OpenBrace_ "\n{"
319 %token OpenBrace__ ";{"
320 %token OpenBrace_let "let {"
321 %token CloseBrace "}"
323 %token OpenBracket "["
324 %token OpenBracket_let "let ["
325 %token CloseBracket "]"
327 %token At_error_ "@error"
330 %token At_class_ "@class"
334 %token _typedef_ "typedef"
335 %token _unsigned_ "unsigned"
336 %token _signed_ "signed"
337 %token _extern_ "extern"
341 %token At_encode_ "@encode"
345 %token At_implementation_ "@implementation"
346 %token At_import_ "@import"
347 %token At_end_ "@end"
348 %token At_selector_ "@selector"
349 %token At_null_ "@null"
350 %token At_YES_ "@YES"
352 %token At_true_ "@true"
353 %token At_false_ "@false"
358 %token _false_ "false"
362 %token _break_ "break"
364 %token _catch_ "catch"
365 %token _class_ "class"
366 %token _class__ ";class"
367 %token _const_ "const"
368 %token _continue_ "continue"
369 %token _debugger_ "debugger"
370 %token _default_ "default"
371 %token _delete_ "delete"
375 %token _export_ "export"
376 %token _extends_ "extends"
377 %token _finally_ "finally"
379 %token _function_ "function"
380 %token _function__ ";function"
382 %token _import_ "import"
385 %token _Infinity_ "Infinity"
386 %token _instanceof_ "instanceof"
388 %token _return_ "return"
389 %token _super_ "super"
390 %token _switch_ "switch"
391 %token _target_ "target"
393 %token _throw_ "throw"
395 %token _typeof_ "typeof"
398 %token _while_ "while"
401 %token _abstract_ "abstract"
402 %token _await_ "await"
403 %token _boolean_ "boolean"
406 %token _constructor_ "constructor"
407 %token _double_ "double"
409 %token _final_ "final"
410 %token _float_ "float"
414 %token _implements_ "implements"
416 %token _interface_ "interface"
420 %token _native_ "native"
421 %token _package_ "package"
422 %token _private_ "private"
423 %token _protected_ "protected"
424 %token _prototype_ "prototype"
425 %token _public_ "public"
427 %token _short_ "short"
428 %token _static_ "static"
429 %token _synchronized_ "synchronized"
430 %token _throws_ "throws"
431 %token _transient_ "transient"
432 %token _volatile_ "volatile"
433 %token _yield_ "yield"
434 %token _yield__ "!yield"
436 %token _undefined_ "undefined"
453 %token _namespace_ "namespace"
460 %token <identifier_> Identifier_
461 %token <number_> NumericLiteral
462 %token <string_> StringLiteral
463 %token <literal_> RegularExpressionLiteral_
465 %token <string_> NoSubstitutionTemplate
466 %token <string_> TemplateHead
467 %token <string_> TemplateMiddle
468 %token <string_> TemplateTail
470 %type <target_> AccessExpression
471 %type <expression_> AdditiveExpression
472 %type <argument_> ArgumentList_
473 %type <argument_> ArgumentList
474 %type <argument_> ArgumentListOpt
475 %type <argument_> Arguments
476 %type <target_> ArrayComprehension
477 %type <literal_> ArrayLiteral
478 %type <expression_> ArrowFunction
479 %type <functionParameter_> ArrowParameters
480 %type <expression_> AssignmentExpression
481 %type <expression_> AssignmentExpressionOpt
482 %type <identifier_> BindingIdentifier
483 %type <identifier_> BindingIdentifierOpt
484 %type <bindings_> BindingList_
485 %type <bindings_> BindingList
486 %type <expression_> BitwiseANDExpression
487 %type <statement_> Block
488 %type <statement_> BlockStatement
489 %type <boolean_> BooleanLiteral
490 %type <binding_> BindingElement
491 %type <expression_> BitwiseORExpression
492 %type <expression_> BitwiseXORExpression
493 %type <statement_> BreakStatement
494 %type <statement_> BreakableStatement
495 %type <expression_> CallExpression_
496 %type <target_> CallExpression
497 %type <clause_> CaseBlock
498 %type <clause_> CaseClause
499 %type <clause_> CaseClausesOpt
501 %type <identifier_> CatchParameter
502 %type <statement_> ClassDeclaration
503 %type <target_> ClassExpression
504 %type <classTail_> ClassHeritage
505 %type <classTail_> ClassHeritageOpt
506 %type <classTail_> ClassTail
507 %type <target_> Comprehension
508 %type <comprehension_> ComprehensionFor
509 %type <comprehension_> ComprehensionIf
510 %type <comprehension_> ComprehensionTail
511 %type <propertyName_> ComputedPropertyName
512 %type <expression_> ConditionalExpression
513 %type <statement_> ContinueStatement
514 %type <statement_> ConciseBody
515 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
516 %type <statement_> DebuggerStatement
517 %type <statement_> Declaration__
518 %type <statement_> Declaration_
519 %type <statement_> Declaration
520 %type <clause_> DefaultClause
521 %type <element_> ElementList
522 %type <element_> ElementListOpt
523 %type <statement_> ElseStatementOpt
524 %type <for_> EmptyStatement
525 %type <expression_> EqualityExpression
526 %type <expression_> Expression
527 %type <expression_> ExpressionOpt
528 %type <for_> ExpressionStatement_
529 %type <statement_> ExpressionStatement
530 %type <finally_> Finally
531 %type <binding_> ForBinding
532 %type <forin_> ForDeclaration
533 %type <forin_> ForInStatementInitializer
534 %type <for_> ForStatementInitializer
535 %type <binding_> FormalParameter
536 %type <functionParameter_> FormalParameterList_
537 %type <functionParameter_> FormalParameterList
538 %type <functionParameter_> FormalParameters
539 %type <statement_> FunctionBody
540 %type <statement_> FunctionDeclaration
541 %type <target_> FunctionExpression
542 %type <statement_> FunctionStatementList
543 %type <statement_> GeneratorBody
544 %type <statement_> GeneratorDeclaration
545 %type <target_> GeneratorExpression
546 %type <method_> GeneratorMethod
547 %type <statement_> HoistableDeclaration
548 %type <identifier_> Identifier
549 %type <identifier_> IdentifierNoOf
550 %type <identifier_> IdentifierType
551 %type <identifier_> IdentifierTypeNoOf
552 %type <word_> IdentifierName
553 %type <variable_> IdentifierReference
554 %type <statement_> IfStatement
555 %type <target_> IndirectExpression
556 %type <expression_> Initializer
557 %type <expression_> InitializerOpt
558 %type <statement_> IterationStatement
559 %type <identifier_> LabelIdentifier
560 %type <statement_> LabelledItem
561 %type <statement_> LabelledStatement
562 %type <assignment_> LeftHandSideAssignment
563 %type <target_> LeftHandSideExpression
564 %type <bool_> LetOrConst
565 %type <binding_> LexicalBinding
566 %type <for_> LexicalDeclaration_
567 %type <statement_> LexicalDeclaration
568 %type <literal_> Literal
569 %type <propertyName_> LiteralPropertyName
570 %type <expression_> LogicalANDExpression
571 %type <expression_> LogicalORExpression
572 %type <access_> MemberAccess
573 %type <target_> MemberExpression
574 %type <method_> MethodDefinition
575 %type <module_> ModulePath
576 %type <expression_> MultiplicativeExpression
577 %type <target_> NewExpression
578 %type <null_> NullLiteral
579 %type <literal_> ObjectLiteral
580 %type <expression_> PostfixExpression
581 %type <target_> PrimaryExpression
582 %type <propertyName_> PropertyName
583 %type <property_> PropertyDefinition
584 %type <property_> PropertyDefinitionList_
585 %type <property_> PropertyDefinitionList
586 %type <property_> PropertyDefinitionListOpt
587 %type <functionParameter_> PropertySetParameterList
588 %type <literal_> RegularExpressionLiteral
589 %type <bool_> RegularExpressionSlash
590 %type <expression_> RelationalExpression
591 %type <statement_> ReturnStatement
592 %type <rubyProc_> RubyProcExpression
593 %type <functionParameter_> RubyProcParameterList_
594 %type <functionParameter_> RubyProcParameterList
595 %type <functionParameter_> RubyProcParameters
596 %type <functionParameter_> RubyProcParametersOpt
597 %type <statement_> Script
598 %type <statement_> ScriptBody
599 %type <statement_> ScriptBodyOpt
600 %type <expression_> ShiftExpression
601 %type <binding_> SingleNameBinding
602 %type <statement_> Statement__
603 %type <statement_> Statement_
604 %type <statement_> Statement
605 %type <statement_> StatementList
606 %type <statement_> StatementListOpt
607 %type <statement_> StatementListItem
608 %type <functionParameter_> StrictFormalParameters
609 %type <target_> SuperCall
610 %type <target_> SuperProperty
611 %type <statement_> SwitchStatement
612 %type <target_> TemplateLiteral
613 %type <span_> TemplateSpans
614 %type <statement_> ThrowStatement
615 %type <statement_> TryStatement
616 %type <expression_> UnaryExpression_
617 %type <expression_> UnaryExpression
618 %type <binding_> VariableDeclaration
619 %type <bindings_> VariableDeclarationList_
620 %type <bindings_> VariableDeclarationList
621 %type <for_> VariableStatement_
622 %type <statement_> VariableStatement
623 %type <statement_> WithStatement
626 %type <word_> WordOpt
628 %type <expression_> YieldExpression
631 %type <specifier_> IntegerType
632 %type <specifier_> IntegerTypeOpt
633 %type <typedIdentifier_> PrefixedType
634 %type <specifier_> PrimitiveType
635 %type <typedIdentifier_> SuffixedType
636 %type <typedIdentifier_> TypeSignifier
637 %type <modifier_> TypeQualifierLeft
638 %type <typedIdentifier_> TypeQualifierRight
639 %type <typedIdentifier_> TypedIdentifier
640 %type <typedParameter_> TypedParameterList_
641 %type <typedParameter_> TypedParameterList
642 %type <typedParameter_> TypedParameterListOpt
646 %type <expression_> AssignmentExpressionClassic
647 %type <expression_> BoxableExpression
648 %type <statement_> CategoryStatement
649 %type <expression_> ClassSuperOpt
650 %type <expression_> ConditionalExpressionClassic
651 %type <implementationField_> ImplementationFieldListOpt
652 %type <implementationField_> ImplementationFields
653 %type <message_> ClassMessageDeclaration
654 %type <message_> ClassMessageDeclarationListOpt
655 %type <protocol_> ClassProtocolListOpt
656 %type <protocol_> ClassProtocols
657 %type <protocol_> ClassProtocolsOpt
658 %type <statement_> ImplementationStatement
659 %type <target_> MessageExpression
660 %type <messageParameter_> MessageParameter
661 %type <messageParameter_> MessageParameters
662 %type <messageParameter_> MessageParameterList
663 %type <messageParameter_> MessageParameterListOpt
664 %type <bool_> MessageScope
665 %type <argument_> SelectorCall_
666 %type <argument_> SelectorCall
667 %type <selector_> SelectorExpression_
668 %type <selector_> SelectorExpression
669 %type <selector_> SelectorExpressionOpt
670 %type <argument_> SelectorList
671 %type <word_> SelectorWordOpt
672 %type <typedIdentifier_> TypeOpt
673 %type <argument_> VariadicCall
677 %type <propertyIdentifier_> PropertyIdentifier_
678 %type <selector_> PropertySelector_
679 %type <selector_> PropertySelector
680 %type <identifier_> QualifiedIdentifier_
681 %type <identifier_> QualifiedIdentifier
682 %type <identifier_> WildcardIdentifier
683 %type <identifier_> XMLComment
684 %type <identifier_> XMLCDATA
685 %type <identifier_> XMLElement
686 %type <identifier_> XMLElementContent
687 %type <identifier_> XMLMarkup
688 %type <identifier_> XMLPI
690 %type <attribute_> AttributeIdentifier
691 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
692 %type <expression_> PropertyIdentifier
693 %type <expression_> XMLListInitilizer
694 %type <expression_> XMLInitilizer
697 /* Token Priorities {{{ */
713 /* Lexer State {{{ */
714 LexPushInOn: { driver.in_.push(true); };
715 LexPushInOff: { driver.in_.push(false); };
716 LexPopIn: { driver.in_.pop(); };
718 LexPushReturnOn: { driver.return_.push(true); };
719 LexPopReturn: { driver.return_.pop(); };
721 LexPushSuperOn: { driver.super_.push(true); };
722 LexPushSuperOff: { driver.super_.push(false); };
723 LexPopSuper: { driver.super_.pop(); };
725 LexPushYieldOn: { driver.yield_.push(true); };
726 LexPushYieldOff: { driver.yield_.push(false); };
727 LexPopYield: { driver.yield_.pop(); };
730 : { CYMPT(@$); driver.next_ = true; }
734 : { CYMAP(YieldStar, Star); }
738 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
742 : { CYMAP(_class__, _class_); }
746 : { CYMAP(_function__, _function_); }
750 : LexNoBrace LexNoClass LexNoFunction
753 /* Virtual Tokens {{{ */
764 /* 11.6 Names and Keywords {{{ */
766 : Word[pass] { $$ = $pass; }
767 | "for" { $$ = CYNew CYWord("for"); }
768 | "in" { $$ = CYNew CYWord("in"); }
769 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
778 : IdentifierNoOf[pass] { $$ = $pass; }
779 | "auto" { $$ = CYNew CYWord("auto"); }
780 | "break" { $$ = CYNew CYWord("break"); }
781 | "case" { $$ = CYNew CYWord("case"); }
782 | "catch" { $$ = CYNew CYWord("catch"); }
783 | "class" LexOf { $$ = CYNew CYWord("class"); }
784 | ";class" { $$ = CYNew CYWord("class"); }
785 | "const" { $$ = CYNew CYWord("const"); }
786 | "continue" { $$ = CYNew CYWord("continue"); }
787 | "debugger" { $$ = CYNew CYWord("debugger"); }
788 | "default" { $$ = CYNew CYWord("default"); }
789 | "delete" { $$ = CYNew CYWord("delete"); }
790 | "do" { $$ = CYNew CYWord("do"); }
791 | "else" { $$ = CYNew CYWord("else"); }
792 | "enum" { $$ = CYNew CYWord("enum"); }
793 | "export" { $$ = CYNew CYWord("export"); }
794 | "extends" { $$ = CYNew CYWord("extends"); }
795 | "false" { $$ = CYNew CYWord("false"); }
796 | "finally" { $$ = CYNew CYWord("finally"); }
797 | "function" LexOf { $$ = CYNew CYWord("function"); }
798 | "if" { $$ = CYNew CYWord("if"); }
799 | "import" { $$ = CYNew CYWord("import"); }
800 | "!in" { $$ = CYNew CYWord("in"); }
801 | "!of" { $$ = CYNew CYWord("of"); }
802 | "new" { $$ = CYNew CYWord("new"); }
803 | "null" { $$ = CYNew CYWord("null"); }
804 | "return" { $$ = CYNew CYWord("return"); }
805 | "super" { $$ = CYNew CYWord("super"); }
806 | "switch" { $$ = CYNew CYWord("switch"); }
807 | "this" { $$ = CYNew CYWord("this"); }
808 | "throw" { $$ = CYNew CYWord("throw"); }
809 | "true" { $$ = CYNew CYWord("true"); }
810 | "try" { $$ = CYNew CYWord("try"); }
811 | "typeof" { $$ = CYNew CYWord("typeof"); }
812 | "var" { $$ = CYNew CYWord("var"); }
813 | "void" { $$ = CYNew CYWord("void"); }
814 | "while" { $$ = CYNew CYWord("while"); }
815 | "with" { $$ = CYNew CYWord("with"); }
816 | "yield" { $$ = CYNew CYIdentifier("yield"); }
818 | Yield NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
823 : Word[pass] { $$ = $pass; }
828 /* 11.8.1 Null Literals {{{ */
830 : "null" { $$ = CYNew CYNull(); }
833 /* 11.8.2 Boolean Literals {{{ */
835 : "true" { $$ = CYNew CYTrue(); }
836 | "false" { $$ = CYNew CYFalse(); }
839 /* 11.8.5 Regular Expression Literals {{{ */
840 RegularExpressionSlash
841 : "/" { $$ = false; }
842 | "/=" { $$ = true; }
845 RegularExpressionLiteral
846 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
850 /* 11.9 Automatic Semicolon Insertion {{{ */
852 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
862 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
867 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
871 /* 12.1 Identifiers {{{ */
873 : Identifier[pass] { $$ = CYNew CYVariable($pass); }
874 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
878 : IdentifierNoOf[pass] { $$ = $pass; }
879 | "!of" { $$ = CYNew CYIdentifier("of"); }
880 | "yield" { $$ = CYNew CYIdentifier("yield"); }
884 : BindingIdentifier[pass] { $$ = $pass; }
889 : Identifier[pass] { $$ = $pass; }
890 | "yield" { $$ = CYNew CYIdentifier("yield"); }
894 : Identifier_[pass] { $$ = $pass; }
895 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
896 | "await" { $$ = CYNew CYIdentifier("await"); }
897 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
898 | "byte" { $$ = CYNew CYIdentifier("byte"); }
899 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
900 | "double" { $$ = CYNew CYIdentifier("double"); }
901 | "each" { $$ = CYNew CYIdentifier("each"); }
902 | "eval" { $$ = CYNew CYIdentifier("eval"); }
903 | "final" { $$ = CYNew CYIdentifier("final"); }
904 | "float" { $$ = CYNew CYIdentifier("float"); }
905 | "from" { $$ = CYNew CYIdentifier("from"); }
906 | "get" { $$ = CYNew CYIdentifier("get"); }
907 | "goto" { $$ = CYNew CYIdentifier("goto"); }
908 | "implements" { $$ = CYNew CYIdentifier("implements"); }
909 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
910 | "interface" { $$ = CYNew CYIdentifier("interface"); }
911 | "let" { $$ = CYNew CYIdentifier("let"); }
912 | "!let" LexBind { $$ = CYNew CYIdentifier("let"); }
913 | "native" { $$ = CYNew CYIdentifier("native"); }
914 | "package" { $$ = CYNew CYIdentifier("package"); }
915 | "private" { $$ = CYNew CYIdentifier("private"); }
916 | "protected" { $$ = CYNew CYIdentifier("protected"); }
917 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
918 | "public" { $$ = CYNew CYIdentifier("public"); }
919 | "set" { $$ = CYNew CYIdentifier("set"); }
920 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
921 | "target" { $$ = CYNew CYIdentifier("target"); }
922 | "throws" { $$ = CYNew CYIdentifier("throws"); }
923 | "transient" { $$ = CYNew CYIdentifier("transient"); }
924 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
926 | "bool" { $$ = CYNew CYIdentifier("bool"); }
927 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
928 | "id" { $$ = CYNew CYIdentifier("id"); }
929 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
934 : IdentifierTypeNoOf[pass] { $$ = $pass; }
935 | "of" { $$ = CYNew CYIdentifier("of"); }
940 | "char" { $$ = CYNew CYIdentifier("char"); }
941 | "int" { $$ = CYNew CYIdentifier("int"); }
942 | "long" { $$ = CYNew CYIdentifier("long"); }
943 | "short" { $$ = CYNew CYIdentifier("short"); }
944 | "static" { $$ = CYNew CYIdentifier("static"); }
945 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
947 | "extern" { $$ = CYNew CYIdentifier("extern"); }
948 | "signed" { $$ = CYNew CYIdentifier("signed"); }
949 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
950 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
953 | "nil" { $$ = CYNew CYIdentifier("nil"); }
954 | "NO" { $$ = CYNew CYIdentifier("NO"); }
955 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
956 | "YES" { $$ = CYNew CYIdentifier("YES"); }
961 : IdentifierNoOf[pass] { $$ = $pass; }
962 | "of" { $$ = CYNew CYIdentifier("of"); }
965 /* 12.2 Primary Expression {{{ */
967 : "this" { $$ = CYNew CYThis(); }
968 | IdentifierReference[pass] { $$ = $pass; }
969 | Literal[pass] { $$ = $pass; }
970 | ArrayLiteral[pass] { $$ = $pass; }
971 | ObjectLiteral[pass] { $$ = $pass; }
972 | FunctionExpression[pass] { $$ = $pass; }
973 | ClassExpression[pass] { $$ = $pass; }
974 | GeneratorExpression[pass] { $$ = $pass; }
975 | RegularExpressionLiteral[pass] { $$ = $pass; }
976 | TemplateLiteral[pass] { $$ = $pass; }
977 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
978 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
981 CoverParenthesizedExpressionAndArrowParameterList
982 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
983 | "(" ")" { $$ = NULL; }
984 | "(" "..." BindingIdentifier ")" { CYNOT(@$); }
985 | "(" Expression "," "..." BindingIdentifier ")" { CYNOT(@$); }
988 /* 12.2.4 Literals {{{ */
990 : NullLiteral[pass] { $$ = $pass; }
991 | BooleanLiteral[pass] { $$ = $pass; }
992 | NumericLiteral[pass] { $$ = $pass; }
993 | StringLiteral[pass] { $$ = $pass; }
996 /* 12.2.5 Array Initializer {{{ */
998 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
1002 : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); }
1003 | "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
1004 | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); }
1008 : ElementList[pass] { $$ = $pass; }
1012 /* 12.2.6 Object Initializer {{{ */
1014 : BRACE PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
1017 PropertyDefinitionList_
1018 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1022 PropertyDefinitionList
1023 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1026 PropertyDefinitionListOpt
1027 : PropertyDefinitionList[properties] { $$ = $properties; }
1032 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1033 | CoverInitializedName[name] { CYNOT(@$); }
1034 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1035 | MethodDefinition[pass] { $$ = $pass; }
1039 : LiteralPropertyName[pass] { $$ = $pass; }
1040 | ComputedPropertyName[pass] { $$ = $pass; }
1044 : IdentifierName[pass] { $$ = $pass; }
1045 | StringLiteral[pass] { $$ = $pass; }
1046 | NumericLiteral[pass] { $$ = $pass; }
1049 ComputedPropertyName
1050 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1053 CoverInitializedName
1054 : IdentifierReference Initializer
1058 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1062 : Initializer[pass] { $$ = $pass; }
1066 /* 12.2.9 Template Literals {{{ */
1068 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1069 | TemplateHead[string] TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1073 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1074 | Expression[value] TemplateTail[string] { $$ = CYNew CYSpan($value, $string, NULL); }
1078 /* 12.3 Left-Hand-Side Expressions {{{ */
1080 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1081 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1082 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1083 | TemplateLiteral { CYNOT(@$); }
1087 : PrimaryExpression[pass] { $$ = $pass; }
1088 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1089 | SuperProperty[pass] { $$ = $pass; }
1090 | MetaProperty { CYNOT(@$); }
1091 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1095 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1096 | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1104 : "new" "." "target"
1108 : MemberExpression[pass] { $$ = $pass; }
1109 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1113 : MemberExpression[pass] { $$ = $pass; }
1114 | CallExpression[pass] { $$ = $pass; }
1118 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1119 | SuperCall[pass] { $$ = $pass; }
1120 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1124 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1128 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1132 : "," ArgumentList[arguments] { $$ = $arguments; }
1137 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1138 | "..." AssignmentExpression { CYNOT(@$); }
1142 : ArgumentList[pass] { $$ = $pass; }
1147 : NewExpression[pass] { $$ = $pass; }
1148 | CallExpression[pass] { $$ = $pass; }
1151 LeftHandSideExpression
1152 : AccessExpression[pass] LexCrement { $$ = $pass; }
1153 | IndirectExpression[pass] { $$ = $pass; }
1156 /* 12.4 Postfix Expressions {{{ */
1158 : { CYLIN(PlusPlus); CYLIN(HyphenHyphen); }
1162 : AccessExpression[lhs] LexCrement { $$ = $lhs; }
1163 | AccessExpression[lhs] LexCrement "++" { $$ = CYNew CYPostIncrement($lhs); }
1164 | AccessExpression[lhs] LexCrement "--" { $$ = CYNew CYPostDecrement($lhs); }
1167 /* 12.5 Unary Operators {{{ */
1169 : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); }
1170 | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
1171 | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
1172 | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1173 | "\n++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1174 | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1175 | "\n--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1176 | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
1177 | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
1178 | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
1179 | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); }
1183 : PostfixExpression[expression] LexOpenBrace { $$ = $expression; }
1184 | UnaryExpression_[pass] { $$ = $pass; }
1187 /* 12.6 Multiplicative Operators {{{ */
1188 MultiplicativeExpression
1189 : UnaryExpression[pass] { $$ = $pass; }
1190 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1191 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1192 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1195 /* 12.7 Additive Operators {{{ */
1197 : MultiplicativeExpression[pass] { $$ = $pass; }
1198 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1199 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1202 /* 12.8 Bitwise Shift Operators {{{ */
1204 : AdditiveExpression[pass] { $$ = $pass; }
1205 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1206 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1207 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1210 /* 12.9 Relational Operators {{{ */
1211 RelationalExpression
1212 : ShiftExpression[pass] { $$ = $pass; }
1213 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1214 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1215 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1216 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1217 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1218 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1221 /* 12.10 Equality Operators {{{ */
1223 : RelationalExpression[pass] { $$ = $pass; }
1224 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1225 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1226 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1227 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1230 /* 12.11 Binary Bitwise Operators {{{ */
1231 BitwiseANDExpression
1232 : EqualityExpression[pass] { $$ = $pass; }
1233 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1236 BitwiseXORExpression
1237 : BitwiseANDExpression[pass] { $$ = $pass; }
1238 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1242 : BitwiseXORExpression[pass] { $$ = $pass; }
1243 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1246 /* 12.12 Binary Logical Operators {{{ */
1247 LogicalANDExpression
1248 : BitwiseORExpression[pass] { $$ = $pass; }
1249 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1253 : LogicalANDExpression[pass] { $$ = $pass; }
1254 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1257 /* 12.13 Conditional Operator ( ? : ) {{{ */
1259 ConditionalExpressionClassic
1260 : LogicalORExpression[pass] { $$ = $pass; }
1261 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1265 ConditionalExpression
1266 : LogicalORExpression[pass] { $$ = $pass; }
1267 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1270 /* 12.14 Assignment Operators {{{ */
1271 LeftHandSideAssignment
1272 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1273 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1274 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1275 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1276 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1277 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1278 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1279 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1280 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1281 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1282 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1283 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1287 AssignmentExpressionClassic
1288 : ConditionalExpressionClassic[pass] { $$ = $pass; }
1289 | LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1293 AssignmentExpression
1294 : ConditionalExpression[pass] { $$ = $pass; }
1295 | YieldExpression[pass] { $$ = $pass; }
1296 | ArrowFunction[pass] { $$ = $pass; }
1297 | LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1300 AssignmentExpressionOpt
1301 : AssignmentExpression[pass] { $$ = $pass; }
1305 /* 12.15 Comma Operator ( , ) {{{ */
1307 : AssignmentExpression[pass] { $$ = $pass; }
1308 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1312 : Expression[pass] { $$ = $pass; }
1317 /* 13 Statements and Declarations {{{ */
1319 : BlockStatement[pass] { $$ = $pass; }
1320 | VariableStatement[pass] { $$ = $pass; }
1321 | EmptyStatement[pass] { $$ = $pass; }
1322 | IfStatement[pass] { $$ = $pass; }
1323 | BreakableStatement[pass] { $$ = $pass; }
1324 | ContinueStatement[pass] { $$ = $pass; }
1325 | BreakStatement[pass] { $$ = $pass; }
1326 | ReturnStatement[pass] { $$ = $pass; }
1327 | WithStatement[pass] { $$ = $pass; }
1328 | LabelledStatement[pass] { $$ = $pass; }
1329 | ThrowStatement[pass] { $$ = $pass; }
1330 | TryStatement[pass] { $$ = $pass; }
1331 | DebuggerStatement[pass] { $$ = $pass; }
1335 : Statement__[pass] { $$ = $pass; }
1336 | ExpressionStatement[pass] { $$ = $pass; }
1340 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1344 : HoistableDeclaration[pass] { $$ = $pass; }
1345 | ClassDeclaration[pass] { $$ = $pass; }
1349 : LexLet Declaration__[pass] { $$ = $pass; }
1350 | LexicalDeclaration[pass] { $$ = $pass; }
1354 : LexSetStatement Declaration_[pass] { $$ = $pass; }
1357 HoistableDeclaration
1358 : FunctionDeclaration[pass] { $$ = $pass; }
1359 | GeneratorDeclaration[pass] { $$ = $pass; }
1363 : IterationStatement[pass] { $$ = $pass; }
1364 | SwitchStatement[pass] { $$ = $pass; }
1367 /* 13.2 Block {{{ */
1369 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1373 : BRACE StatementListOpt[code] "}" { $$ = $code; }
1377 : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; }
1381 : StatementList[pass] { $$ = $pass; }
1382 | LexSetStatement LexLet { $$ = NULL; }
1386 : Statement[pass] { $$ = $pass; }
1387 | Declaration[pass] { $$ = $pass; }
1390 /* 13.3 Let and Const Declarations {{{ */
1392 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1396 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1400 : { CYMAP(_let__, _let_); }
1404 : { CYMAP(_of__, _of_); }
1408 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); } LexOf
1412 : LexLet "!let" LexBind { $$ = false; }
1413 | LexLet "const" { $$ = true; }
1417 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1422 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1426 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1427 | BindingPattern Initializer { CYNOT(@$); }
1430 /* 13.3.2 Variable Statement {{{ */
1432 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1436 : VariableStatement_[statement] Terminator { $$ = $statement; }
1439 VariableDeclarationList_
1440 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1444 VariableDeclarationList
1445 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1449 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1450 | BindingPattern Initializer { CYNOT(@$); }
1453 /* 13.3.3 Destructuring Binding Patterns {{{ */
1455 : ObjectBindingPattern
1456 | ArrayBindingPattern
1459 ObjectBindingPattern
1460 : "let {" BindingPropertyListOpt "}"
1464 : "let [" { CYNOT(@$); }
1467 BindingPropertyList_
1468 : "," BindingPropertyListOpt
1473 : BindingProperty BindingPropertyList_
1476 BindingPropertyListOpt
1477 : BindingPropertyList
1483 | PropertyName ":" BindingElement
1487 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1488 | LexBind BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1492 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1496 : "..." BindingIdentifier
1499 /* 13.4 Empty Statement {{{ */
1501 : ";" { $$ = CYNew CYEmpty(); }
1504 /* 13.5 Expression Statement {{{ */
1505 ExpressionStatement_
1506 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1509 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1512 /* 13.6 The if Statement {{{ */
1514 : "else" Statement[false] { $$ = $false; }
1515 | %prec "if" { $$ = NULL; }
1519 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1522 /* 13.7 Iteration Statements {{{ */
1524 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1525 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1526 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1527 | "for" "(" LexPushInOn LexLet Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1528 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1529 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1532 ForStatementInitializer
1533 : LexLet EmptyStatement[pass] { $$ = $pass; }
1534 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1535 | LexLet VariableStatement_[initializer] ";" { $$ = $initializer; }
1536 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1539 ForInStatementInitializer
1540 : LexLet AccessExpression[pass] LexCrement { $$ = $pass; }
1541 | LexLet IndirectExpression[pass] { $$ = $pass; }
1542 | LexLet Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1543 | ForDeclaration[pass] { $$ = $pass; }
1547 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1551 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1552 | BindingPattern { CYNOT(@$); }
1555 /* 13.8 The continue Statement {{{ */
1557 : "continue" LexNewLine
1561 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1562 | Continue Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1565 /* 13.9 The break Statement {{{ */
1567 : "break" LexNewLine
1571 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1572 | Break Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1575 /* 13.10 The return Statement {{{ */
1577 : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); } LexNewLine
1581 : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1582 | Return Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1585 /* 13.11 The with Statement {{{ */
1587 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1590 /* 13.12 The switch Statement {{{ */
1592 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1596 : BRACE CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1600 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1604 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1605 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1609 // XXX: the standard makes certain you can only have one of these
1611 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1614 /* 13.13 Labelled Statements {{{ */
1616 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1620 : Statement[pass] { $$ = $pass; }
1621 | LexSetStatement LexLet FunctionDeclaration[pass] { $$ = $pass; }
1624 /* 13.14 The throw Statement {{{ */
1626 : "throw" LexNewLine
1630 : Throw[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); }
1631 | Throw Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1634 /* 13.15 The try Statement {{{ */
1636 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1637 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1638 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1642 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1646 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1650 : BindingIdentifier[pass] { $$ = $pass; }
1651 | BindingPattern { CYNOT(@$); }
1654 /* 13.16 The debugger Statement {{{ */
1656 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1660 /* 14.1 Function Definitions {{{ */
1662 : ";function" LexOf BindingIdentifier[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1666 : "function" LexOf BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1669 StrictFormalParameters
1670 : FormalParameters[pass] { $$ = $pass; }
1674 : LexBind { $$ = NULL; }
1675 | FormalParameterList
1678 FormalParameterList_
1679 : "," FormalParameterList[parameters] { $$ = $parameters; }
1684 : LexBind FunctionRestParameter { CYNOT(@$); }
1685 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1688 FunctionRestParameter
1689 : BindingRestElement
1693 : BindingElement[pass] { $$ = $pass; }
1697 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1700 FunctionStatementList
1701 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1704 /* 14.2 Arrow Function Definitions {{{ */
1706 : { CYLIN(EqualRight); }
1710 : ArrowParameters[parameters] LexEqualRight "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1714 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1715 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1719 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1720 | ";{" FunctionBody[code] "}" { $$ = $code; }
1723 /* 14.3 Method Definitions {{{ */
1725 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1726 | GeneratorMethod[pass] { $$ = $pass; }
1727 | "get" PropertyName[name] "(" ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1728 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" BRACE FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1731 PropertySetParameterList
1732 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1735 /* 14.4 Generator Function Definitions {{{ */
1737 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1740 GeneratorDeclaration
1741 : ";function" LexOf "*" LexOf BindingIdentifier[name] "(" FormalParameters[code] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1745 : "function" LexOf "*" LexOf BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" BRACE GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1749 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1753 : "!yield" LexNewLine LexNoStar
1757 : Yield NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1758 | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1759 | Yield YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1762 /* 14.5 Class Definitions {{{ */
1764 : ";class" LexOf BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1768 : "class" LexOf BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1772 : ClassHeritageOpt[tail] { driver.class_.push($tail); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1776 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1780 : ClassHeritage[pass] { $$ = $pass; }
1781 | { $$ = CYNew CYClassTail(NULL); }
1794 : ClassElementListOpt ClassElement
1803 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1804 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1809 /* 15.1 Scripts {{{ */
1811 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1815 : StatementList[pass] { $$ = $pass; }
1819 : ScriptBody[pass] { $$ = $pass; }
1820 | LexSetStatement LexLet { $$ = NULL; }
1823 /* 15.2 Modules {{{ */
1838 : ModuleItemListOpt ModuleItem
1847 : LexSetStatement LexLet ImportDeclaration
1848 | LexSetStatement LexLet ExportDeclaration
1852 /* 15.2.2 Imports {{{ */
1854 : "import" ImportClause FromClause Terminator
1855 | "import" ModuleSpecifier Terminator
1859 : ImportedDefaultBinding
1862 | ImportedDefaultBinding "," NameSpaceImport
1863 | ImportedDefaultBinding "," NamedImports
1866 ImportedDefaultBinding
1871 : "*" "as" ImportedBinding
1875 : BRACE ImportsListOpt "}"
1879 : "from" ModuleSpecifier
1883 : "," ImportsListOpt
1888 : ImportSpecifier ImportsList_
1898 | IdentifierName "as" ImportedBinding
1909 /* 15.2.3 Exports {{{ */
1911 : "*" FromClause Terminator
1912 | ExportClause FromClause Terminator
1913 | ExportClause Terminator
1915 | "default" LexSetStatement HoistableDeclaration
1916 | "default" LexSetStatement ClassDeclaration
1917 | "default" LexSetStatement AssignmentExpression Terminator
1921 : "export" LexSetStatement LexLet ExportDeclaration_
1922 | "export" Declaration
1926 : ";{" ExportsListOpt "}"
1930 : "," ExportsListOpt
1935 : ExportSpecifier ExportsList_
1945 | IdentifierName "as" IdentifierName
1950 /* Cycript (C): Type Encoding {{{ */
1952 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
1953 | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
1957 : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
1958 | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
1959 | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1960 | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1961 | TypeSignifier[pass] { $$ = $pass; }
1962 | { $$ = CYNew CYTypedIdentifier(@$); }
1966 : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1971 | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
1972 | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
1976 : PrefixedType[pass] { $$ = $pass; }
1977 | SuffixedType[pass] { $$ = $pass; }
1978 | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1979 | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1983 : "int" { $$ = CYNew CYTypeVariable("int"); }
1984 | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); }
1985 | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); }
1986 | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); }
1987 | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); }
1991 : IntegerType[pass] { $$ = $pass; }
1992 | { $$ = CYNew CYTypeVariable("int"); }
1996 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
1997 | IntegerType[pass] { $$ = $pass; }
1998 | "void" { $$ = CYNew CYTypeVoid(); }
1999 | "char" { $$ = CYNew CYTypeVariable("char"); }
2000 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
2001 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
2005 : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2009 : "@encode" "(" TypedIdentifier[typed] ")" { $$ = CYNew CYEncodedType($typed); }
2015 /* Cycript (Objective-C): @class Declaration {{{ */
2017 /* XXX: why the hell did I choose MemberExpression? */
2018 : ":" MemberExpression[extends] { $$ = $extends; }
2022 ImplementationFieldListOpt
2023 : TypedIdentifier[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2027 ImplementationFields
2028 : BRACE ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
2032 : "+" { $$ = false; }
2033 | "-" { $$ = true; }
2037 : "(" TypedIdentifier[type] ")" { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); $$ = $type; }
2038 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2042 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2045 MessageParameterList
2046 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2049 MessageParameterListOpt
2050 : MessageParameterList[pass] { $$ = $pass; }
2055 : MessageParameterList[pass] { $$ = $pass; }
2056 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2059 ClassMessageDeclaration
2060 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] BRACE LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2063 ClassMessageDeclarationListOpt
2064 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2068 // XXX: this should be AssignmentExpressionNoRight
2070 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2074 : "," ClassProtocols[protocols] { $$ = $protocols; }
2078 ClassProtocolListOpt
2079 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2083 ImplementationStatement
2084 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] ImplementationFields[fields] ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2092 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2096 : ImplementationStatement[pass] { $$ = $pass; }
2097 | CategoryStatement[pass] { $$ = $pass; }
2100 /* Cycript (Objective-C): Send Message {{{ */
2102 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2107 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2108 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2112 : SelectorCall[pass] { $$ = $pass; }
2113 | VariadicCall[pass] { $$ = $pass; }
2117 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2121 : SelectorCall[pass] { $$ = $pass; }
2122 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2126 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2127 | "[" "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2131 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2135 : SelectorExpression_[pass] { $$ = $pass; }
2136 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2139 SelectorExpressionOpt
2140 : SelectorExpression_[pass] { $$ = $pass; }
2145 : MessageExpression[pass] { $$ = $pass; }
2146 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2151 /* Cycript: @import Directive {{{ */
2153 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2154 | Word[part] { $$ = CYNew CYModule($part); }
2158 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2163 /* Cycript (Objective-C): Boxed Expressions {{{ */
2165 : NullLiteral[pass] { $$ = $pass; }
2166 | BooleanLiteral[pass] { $$ = $pass; }
2167 | NumericLiteral[pass] { $$ = $pass; }
2168 | StringLiteral[pass] { $$ = $pass; }
2169 | ArrayLiteral[pass] { $$ = $pass; }
2170 | ObjectLiteral[pass] { $$ = $pass; }
2171 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2172 | "YES" { $$ = CYNew CYTrue(); }
2173 | "NO" { $$ = CYNew CYFalse(); }
2177 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2178 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2179 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2180 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2181 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2182 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2185 /* Cycript (Objective-C): Block Expressions {{{ */
2187 : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } BRACE FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2190 /* Cycript (Objective-C): Instance Literals {{{ */
2192 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2198 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2200 : IndirectExpression[pass] { $$ = $pass; }
2204 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2208 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2212 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2213 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2214 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2217 /* Cycript (C): auto Compatibility {{{ */
2222 /* Cycript (C): Lambda Expressions {{{ */
2224 : "," TypedParameterList[parameters] { $$ = $parameters; }
2229 : TypedIdentifier[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
2232 TypedParameterListOpt
2233 : TypedParameterList[pass] { $$ = $pass; }
2238 : "[" "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] BRACE FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2241 /* Cycript (C): Type Definitions {{{ */
2243 : "typedef" TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); }
2246 /* Cycript (C): extern "C" {{{ */
2248 : "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); }
2255 /* Lexer State {{{ */
2257 : { driver.PushCondition(CYDriver::RegExpCondition); }
2261 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2265 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2269 : { driver.PopCondition(); }
2273 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2277 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2280 /* Virtual Tokens {{{ */
2287 /* 8.1 Context Keywords {{{ */
2289 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2290 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2293 /* 8.3 XML Initializer Input Elements {{{ */
2295 : XMLComment { $$ = $1; }
2296 | XMLCDATA { $$ = $1; }
2297 | XMLPI { $$ = $1; }
2301 /* 11.1 Primary Expressions {{{ */
2303 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2304 | XMLInitilizer { $$ = $1; }
2305 | XMLListInitilizer { $$ = $1; }
2309 : AttributeIdentifier { $$ = $1; }
2310 | QualifiedIdentifier { $$ = $1; }
2311 | WildcardIdentifier { $$ = $1; }
2314 /* 11.1.1 Attribute Identifiers {{{ */
2316 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2320 : PropertySelector { $$ = $1; }
2321 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2325 : Identifier { $$ = CYNew CYSelector($1); }
2326 | WildcardIdentifier { $$ = $1; }
2329 /* 11.1.2 Qualified Identifiers {{{ */
2330 QualifiedIdentifier_
2331 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2332 | QualifiedIdentifier { $$ = $1; }
2336 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2339 /* 11.1.3 Wildcard Identifiers {{{ */
2341 : "*" { $$ = CYNew CYWildcard(); }
2344 /* 11.1.4 XML Initializer {{{ */
2346 : XMLMarkup { $$ = $1; }
2347 | XMLElement { $$ = $1; }
2351 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2352 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2356 : LexPushXMLTag XMLTagName XMLAttributes
2360 : BRACE LexPushRegExp Expression LexPop "}"
2369 : XMLAttributes_ XMLAttribute
2374 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2375 | XMLAttributes_ XMLWhitespaceOpt
2384 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2388 : XMLExpression XMLElementContentOpt
2389 | XMLMarkup XMLElementContentOpt
2390 | XMLText XMLElementContentOpt
2391 | XMLElement XMLElementContentOpt
2394 XMLElementContentOpt
2399 /* 11.1.5 XMLList Initializer {{{ */
2401 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2405 /* 11.2 Left-Hand-Side Expressions {{{ */
2407 : Identifier { $$ = $1; }
2408 | PropertyIdentifier { $$ = $1; }
2412 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2413 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2414 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2417 /* 12.1 The default xml namespace Statement {{{ */
2418 /* XXX: DefaultXMLNamespaceStatement
2419 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2423 : DefaultXMLNamespaceStatement { $$ = $1; }
2428 /* JavaScript FTL: Array Comprehensions {{{ */
2430 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2434 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2437 /* JavaScript FTL: for each {{{ */
2439 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2443 /* JavaScript FTW: Array Comprehensions {{{ */
2445 : ArrayComprehension
2449 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2453 : ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2458 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2459 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2463 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2464 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2468 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2471 /* JavaScript FTW: Coalesce Operator {{{ */
2472 ConditionalExpression
2473 : LogicalORExpression[test] "?" LexPushInOff ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); }
2476 /* JavaScript FTW: Named Arguments {{{ */
2478 : Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2481 /* JavaScript FTW: Ruby Blocks {{{ */
2482 RubyProcParameterList_
2483 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2487 RubyProcParameterList
2488 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2493 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2494 | "||" { $$ = NULL; }
2497 RubyProcParametersOpt
2498 : RubyProcParameters[pass] { $$ = $pass; }
2503 : { CYLIN(OpenBrace); }
2507 : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2511 : BRACE RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2515 : PostfixExpression[lhs] LexOpenBrace RubyProcExpression[rhs] { $$ = CYNew CYRubyBlock($lhs, $rhs); }
2521 bool CYDriver::Parse(CYMark mark) {
2523 CYLocal<CYPool> local(&pool_);
2524 cy::parser parser(*this);
2526 parser.set_debug_level(debug_);
2528 return parser.parse() != 0;
2531 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2535 CYDriver::Error error;
2536 error.warning_ = true;
2537 error.location_ = location;
2538 error.message_ = message;
2539 errors_.push_back(error);
2542 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2543 CYDriver::Error error;
2544 error.warning_ = false;
2545 error.location_ = location;
2546 error.message_ = message;
2547 driver.errors_.push_back(error);