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 { CYTypeStructField *structField_; }
84 %union { CYTypeModifier *modifier_; }
85 %union { CYTypeSpecifier *specifier_; }
86 %union { CYTypedIdentifier *typedIdentifier_; }
87 %union { CYTypedParameter *typedParameter_; }
91 %union { CYImplementationField *implementationField_; }
92 %union { CYMessage *message_; }
93 %union { CYMessageParameter *messageParameter_; }
94 %union { CYProtocol *protocol_; }
95 %union { CYSelectorPart *selector_; }
99 %union { CYAttribute *attribute_; }
100 %union { CYPropertyIdentifier *propertyIdentifier_; }
101 %union { CYSelector *selector_; }
107 cy::parser::semantic_type semantic_;
108 hi::Value highlight_;
111 int cylex(YYSTYPE *, CYLocation *, void *);
119 typedef cy::parser::token tk;
121 _finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
122 driver.newline_ = false;
125 int token(cylex(&data, location, driver.scanner_));
126 *semantic = data.semantic_;
130 case tk::OpenBracket:
132 driver.in_.push(false);
136 if (driver.in_.top())
141 case tk::CloseBracket:
148 if (driver.yield_.top())
149 token = tk::_yield__;
153 driver.newline_ = true;
161 #define yylex_(semantic, location, driver) ({ \
163 if (driver.hold_ == cy::parser::empty_symbol) \
164 type = yytranslate_(cylex_(semantic, location, driver)); \
166 type = driver.hold_; \
167 driver.hold_ = cy::parser::empty_symbol; \
171 #define CYLEX() do if (yyla.empty()) { \
172 YYCDEBUG << "Mapping a token: "; \
173 yyla.type = yylex_(&yyla.value, &yyla.location, driver); \
174 YY_SYMBOL_PRINT("Next token is", yyla); \
177 #define CYMAP(to, from) do { \
179 if (yyla.type == yytranslate_(token::from)) \
180 yyla.type = yytranslate_(token::to); \
183 #define CYERR(location, message) do { \
184 error(location, message); \
188 #define CYEOK() do { \
190 driver.errors_.pop_back(); \
193 #define CYNOT(location) \
194 CYERR(location, "unimplemented feature")
196 #define CYMPT(location) do { \
197 if (!yyla.empty() && yyla.type_get() != yyeof_) \
198 CYERR(location, "unexpected lookahead"); \
208 @$.begin.filename = @$.end.filename = &driver.filename_;
210 switch (driver.mark_) {
212 driver.hold_ = yytranslate_(token::MarkScript);
215 driver.hold_ = yytranslate_(token::MarkModule);
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 Exclamation "!"
271 %token ExclamationEqual "!="
272 %token ExclamationEqualEqual "!=="
274 %token HyphenEqual "-="
275 %token HyphenHyphen "--"
276 %token HyphenRight "->"
278 %token LeftEqual "<="
280 %token LeftLeftEqual "<<="
282 %token PercentEqual "%="
284 %token PeriodPeriodPeriod "..."
286 %token PipeEqual "|="
289 %token PlusEqual "+="
292 %token RightEqual ">="
293 %token RightRight ">>"
294 %token RightRightEqual ">>="
295 %token RightRightRight ">>>"
296 %token RightRightRightEqual ">>>="
298 %token SlashEqual "/="
300 %token StarEqual "*="
313 %token CloseParen ")"
316 %token OpenBrace_ ";{"
317 %token OpenBrace_let "let {"
318 %token CloseBrace "}"
320 %token OpenBracket "["
321 %token OpenBracket_let "let ["
322 %token CloseBracket "]"
324 %token At_error_ "@error"
327 %token At_class_ "@class"
331 %token _typedef_ "typedef"
332 %token _unsigned_ "unsigned"
333 %token _signed_ "signed"
334 %token _struct_ "struct"
335 %token _extern_ "extern"
339 %token At_encode_ "@encode"
343 %token At_implementation_ "@implementation"
344 %token At_import_ "@import"
345 %token At_end_ "@end"
346 %token At_selector_ "@selector"
347 %token At_null_ "@null"
348 %token At_YES_ "@YES"
350 %token At_true_ "@true"
351 %token At_false_ "@false"
356 %token _false_ "false"
360 %token _break_ "break"
362 %token _catch_ "catch"
363 %token _class_ "class"
364 %token _class__ ";class"
365 %token _const_ "const"
366 %token _continue_ "continue"
367 %token _debugger_ "debugger"
368 %token _default_ "default"
369 %token _delete_ "delete"
373 %token _export_ "export"
374 %token _extends_ "extends"
375 %token _finally_ "finally"
377 %token _function_ "function"
378 %token _function__ ";function"
380 %token _import_ "import"
383 %token _Infinity_ "Infinity"
384 %token _instanceof_ "instanceof"
386 %token _return_ "return"
387 %token _super_ "super"
388 %token _switch_ "switch"
389 %token _target_ "target"
391 %token _throw_ "throw"
393 %token _typeof_ "typeof"
396 %token _while_ "while"
399 %token _abstract_ "abstract"
400 %token _await_ "await"
401 %token _boolean_ "boolean"
404 %token _constructor_ "constructor"
405 %token _double_ "double"
407 %token _final_ "final"
408 %token _float_ "float"
412 %token _implements_ "implements"
414 %token _interface_ "interface"
418 %token _native_ "native"
419 %token _package_ "package"
420 %token _private_ "private"
421 %token _protected_ "protected"
422 %token _prototype_ "prototype"
423 %token _public_ "public"
425 %token _short_ "short"
426 %token _static_ "static"
427 %token _synchronized_ "synchronized"
428 %token _throws_ "throws"
429 %token _transient_ "transient"
430 %token _volatile_ "volatile"
431 %token _yield_ "yield"
432 %token _yield__ "!yield"
434 %token _undefined_ "undefined"
450 %token _namespace_ "namespace"
455 %token YieldStar "yield *"
457 %token <identifier_> Identifier_
458 %token <number_> NumericLiteral
459 %token <string_> StringLiteral
460 %token <literal_> RegularExpressionLiteral_
462 %token <string_> NoSubstitutionTemplate
463 %token <string_> TemplateHead
464 %token <string_> TemplateMiddle
465 %token <string_> TemplateTail
467 %type <target_> AccessExpression
468 %type <expression_> AdditiveExpression
469 %type <argument_> ArgumentList_
470 %type <argument_> ArgumentList
471 %type <argument_> ArgumentListOpt
472 %type <argument_> Arguments
473 %type <target_> ArrayComprehension
474 %type <literal_> ArrayLiteral
475 %type <expression_> ArrowFunction
476 %type <functionParameter_> ArrowParameters
477 %type <expression_> AssignmentExpression
478 %type <expression_> AssignmentExpressionOpt
479 %type <identifier_> BindingIdentifier
480 %type <identifier_> BindingIdentifierOpt
481 %type <bindings_> BindingList_
482 %type <bindings_> BindingList
483 %type <expression_> BitwiseANDExpression
484 %type <statement_> Block
485 %type <statement_> BlockStatement
486 %type <boolean_> BooleanLiteral
487 %type <binding_> BindingElement
488 %type <expression_> BitwiseORExpression
489 %type <expression_> BitwiseXORExpression
490 %type <statement_> BreakStatement
491 %type <statement_> BreakableStatement
492 %type <expression_> CallExpression_
493 %type <target_> CallExpression
494 %type <clause_> CaseBlock
495 %type <clause_> CaseClause
496 %type <clause_> CaseClausesOpt
498 %type <identifier_> CatchParameter
499 %type <statement_> ClassDeclaration
500 %type <target_> ClassExpression
501 %type <classTail_> ClassHeritage
502 %type <classTail_> ClassHeritageOpt
503 %type <classTail_> ClassTail
504 %type <target_> Comprehension
505 %type <comprehension_> ComprehensionFor
506 %type <comprehension_> ComprehensionIf
507 %type <comprehension_> ComprehensionTail
508 %type <propertyName_> ComputedPropertyName
509 %type <expression_> ConditionalExpression
510 %type <statement_> ContinueStatement
511 %type <statement_> ConciseBody
512 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
513 %type <statement_> DebuggerStatement
514 %type <statement_> Declaration_
515 %type <statement_> Declaration
516 %type <clause_> DefaultClause
517 %type <element_> ElementList
518 %type <element_> ElementListOpt
519 %type <statement_> ElseStatementOpt
520 %type <for_> EmptyStatement
521 %type <expression_> EqualityExpression
522 %type <expression_> Expression
523 %type <expression_> ExpressionOpt
524 %type <for_> ExpressionStatement_
525 %type <statement_> ExpressionStatement
526 %type <finally_> Finally
527 %type <binding_> ForBinding
528 %type <forin_> ForDeclaration
529 %type <forin_> ForInStatementInitializer
530 %type <for_> ForStatementInitializer
531 %type <binding_> FormalParameter
532 %type <functionParameter_> FormalParameterList_
533 %type <functionParameter_> FormalParameterList
534 %type <functionParameter_> FormalParameters
535 %type <statement_> FunctionBody
536 %type <statement_> FunctionDeclaration
537 %type <target_> FunctionExpression
538 %type <statement_> FunctionStatementList
539 %type <statement_> GeneratorBody
540 %type <statement_> GeneratorDeclaration
541 %type <target_> GeneratorExpression
542 %type <method_> GeneratorMethod
543 %type <statement_> HoistableDeclaration
544 %type <identifier_> Identifier
545 %type <identifier_> IdentifierNoOf
546 %type <identifier_> IdentifierType
547 %type <identifier_> IdentifierTypeNoOf
548 %type <identifier_> IdentifierTypeOpt
549 %type <word_> IdentifierName
550 %type <variable_> IdentifierReference
551 %type <statement_> IfStatement
552 %type <target_> IndirectExpression
553 %type <expression_> Initializer
554 %type <expression_> InitializerOpt
555 %type <statement_> IterationStatement
556 %type <identifier_> LabelIdentifier
557 %type <statement_> LabelledItem
558 %type <statement_> LabelledStatement
559 %type <assignment_> LeftHandSideAssignment
560 %type <target_> LeftHandSideExpression
561 %type <bool_> LetOrConst
562 %type <binding_> LexicalBinding
563 %type <for_> LexicalDeclaration_
564 %type <statement_> LexicalDeclaration
565 %type <literal_> Literal
566 %type <propertyName_> LiteralPropertyName
567 %type <expression_> LogicalANDExpression
568 %type <expression_> LogicalORExpression
569 %type <access_> MemberAccess
570 %type <target_> MemberExpression
571 %type <method_> MethodDefinition
572 %type <module_> ModulePath
573 %type <expression_> MultiplicativeExpression
574 %type <target_> NewExpression
575 %type <null_> NullLiteral
576 %type <literal_> ObjectLiteral
577 %type <expression_> PostfixExpression
578 %type <target_> PrimaryExpression
579 %type <propertyName_> PropertyName
580 %type <property_> PropertyDefinition
581 %type <property_> PropertyDefinitionList_
582 %type <property_> PropertyDefinitionList
583 %type <property_> PropertyDefinitionListOpt
584 %type <functionParameter_> PropertySetParameterList
585 %type <literal_> RegularExpressionLiteral
586 %type <bool_> RegularExpressionSlash
587 %type <expression_> RelationalExpression
588 %type <statement_> ReturnStatement
589 %type <rubyProc_> RubyProcExpression
590 %type <functionParameter_> RubyProcParameterList_
591 %type <functionParameter_> RubyProcParameterList
592 %type <functionParameter_> RubyProcParameters
593 %type <functionParameter_> RubyProcParametersOpt
594 %type <statement_> Script
595 %type <statement_> ScriptBody
596 %type <statement_> ScriptBodyOpt
597 %type <expression_> ShiftExpression
598 %type <binding_> SingleNameBinding
599 %type <statement_> Statement__
600 %type <statement_> Statement_
601 %type <statement_> Statement
602 %type <statement_> StatementList
603 %type <statement_> StatementListOpt
604 %type <statement_> StatementListItem
605 %type <functionParameter_> StrictFormalParameters
606 %type <target_> SuperCall
607 %type <target_> SuperProperty
608 %type <statement_> SwitchStatement
609 %type <target_> TemplateLiteral
610 %type <span_> TemplateSpans
611 %type <statement_> ThrowStatement
612 %type <statement_> TryStatement
613 %type <expression_> UnaryExpression_
614 %type <expression_> UnaryExpression
615 %type <binding_> VariableDeclaration
616 %type <bindings_> VariableDeclarationList_
617 %type <bindings_> VariableDeclarationList
618 %type <for_> VariableStatement_
619 %type <statement_> VariableStatement
620 %type <statement_> WithStatement
623 %type <word_> WordOpt
625 %type <expression_> YieldExpression
628 %type <specifier_> IntegerType
629 %type <specifier_> IntegerTypeOpt
630 %type <typedIdentifier_> PrefixedType
631 %type <specifier_> PrimitiveType
632 %type <structField_> StructFieldListOpt
633 %type <typedIdentifier_> SuffixedType
634 %type <typedIdentifier_> TypeSignifier
635 %type <modifier_> TypeQualifierLeft
636 %type <typedIdentifier_> TypeQualifierRight
637 %type <typedIdentifier_> TypedIdentifierMaybe
638 %type <typedIdentifier_> TypedIdentifierNo
639 %type <typedIdentifier_> TypedIdentifierYes
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 <message_> ClassMessageDeclaration
652 %type <message_> ClassMessageDeclarationListOpt
653 %type <protocol_> ClassProtocolListOpt
654 %type <protocol_> ClassProtocols
655 %type <protocol_> ClassProtocolsOpt
656 %type <implementationField_> ImplementationFieldListOpt
657 %type <statement_> ImplementationStatement
658 %type <target_> MessageExpression
659 %type <messageParameter_> MessageParameter
660 %type <messageParameter_> MessageParameters
661 %type <messageParameter_> MessageParameterList
662 %type <messageParameter_> MessageParameterListOpt
663 %type <bool_> MessageScope
664 %type <argument_> SelectorCall_
665 %type <argument_> SelectorCall
666 %type <selector_> SelectorExpression_
667 %type <selector_> SelectorExpression
668 %type <selector_> SelectorExpressionOpt
669 %type <argument_> SelectorList
670 %type <word_> SelectorWordOpt
671 %type <typedIdentifier_> TypeOpt
672 %type <argument_> VariadicCall
676 %type <propertyIdentifier_> PropertyIdentifier_
677 %type <selector_> PropertySelector_
678 %type <selector_> PropertySelector
679 %type <identifier_> QualifiedIdentifier_
680 %type <identifier_> QualifiedIdentifier
681 %type <identifier_> WildcardIdentifier
682 %type <identifier_> XMLComment
683 %type <identifier_> XMLCDATA
684 %type <identifier_> XMLElement
685 %type <identifier_> XMLElementContent
686 %type <identifier_> XMLMarkup
687 %type <identifier_> XMLPI
689 %type <attribute_> AttributeIdentifier
690 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
691 %type <expression_> PropertyIdentifier
692 %type <expression_> XMLListInitilizer
693 %type <expression_> XMLInitilizer
696 /* Token Priorities {{{ */
712 /* Lexer State {{{ */
713 LexPushInOn: { driver.in_.push(true); };
714 LexPushInOff: { driver.in_.push(false); };
715 LexPopIn: { driver.in_.pop(); };
717 LexPushReturnOn: { driver.return_.push(true); };
718 LexPopReturn: { driver.return_.pop(); };
720 LexPushSuperOn: { driver.super_.push(true); };
721 LexPushSuperOff: { driver.super_.push(false); };
722 LexPopSuper: { driver.super_.pop(); };
724 LexPushYieldOn: { driver.yield_.push(true); };
725 LexPushYieldOff: { driver.yield_.push(false); };
726 LexPopYield: { driver.yield_.pop(); };
729 : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
733 : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); driver.hold_ = yyla.type; yyla.type = yytranslate_(driver.newline_ ? cy::parser::token::NewLine : cy::parser::token::__); }
737 : { CYMAP(YieldStar, Star); }
741 : { CYMAP(OpenBrace_, OpenBrace); }
745 : { CYMAP(_class__, _class_); }
749 : { CYMAP(_function__, _function_); }
753 : LexNoBrace LexNoClass LexNoFunction
756 /* Virtual Tokens {{{ */
762 /* 11.6 Names and Keywords {{{ */
764 : Word[pass] { $$ = $pass; }
765 | "for" { $$ = CYNew CYWord("for"); }
766 | "in" { $$ = CYNew CYWord("in"); }
767 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
771 : IdentifierNoOf[pass] { $$ = $pass; }
772 | "break" { $$ = CYNew CYWord("break"); }
773 | "case" { $$ = CYNew CYWord("case"); }
774 | "catch" { $$ = CYNew CYWord("catch"); }
775 | "class" LexOf { $$ = CYNew CYWord("class"); }
776 | ";class" { $$ = CYNew CYWord("class"); }
777 | "const" { $$ = CYNew CYWord("const"); }
778 | "continue" { $$ = CYNew CYWord("continue"); }
779 | "debugger" { $$ = CYNew CYWord("debugger"); }
780 | "default" { $$ = CYNew CYWord("default"); }
781 | "delete" { $$ = CYNew CYWord("delete"); }
782 | "do" { $$ = CYNew CYWord("do"); }
783 | "else" { $$ = CYNew CYWord("else"); }
784 | "enum" { $$ = CYNew CYWord("enum"); }
785 | "export" { $$ = CYNew CYWord("export"); }
786 | "extends" { $$ = CYNew CYWord("extends"); }
787 | "false" { $$ = CYNew CYWord("false"); }
788 | "finally" { $$ = CYNew CYWord("finally"); }
789 | "function" LexOf { $$ = CYNew CYWord("function"); }
790 | "if" { $$ = CYNew CYWord("if"); }
791 | "import" { $$ = CYNew CYWord("import"); }
792 | "!in" { $$ = CYNew CYWord("in"); }
793 | "!of" { $$ = CYNew CYWord("of"); }
794 | "new" { $$ = CYNew CYWord("new"); }
795 | "null" { $$ = CYNew CYWord("null"); }
796 | "return" { $$ = CYNew CYWord("return"); }
797 | "super" { $$ = CYNew CYWord("super"); }
798 | "switch" { $$ = CYNew CYWord("switch"); }
799 | "this" { $$ = CYNew CYWord("this"); }
800 | "throw" { $$ = CYNew CYWord("throw"); }
801 | "true" { $$ = CYNew CYWord("true"); }
802 | "try" { $$ = CYNew CYWord("try"); }
803 | "typeof" { $$ = CYNew CYWord("typeof"); }
804 | "var" { $$ = CYNew CYWord("var"); }
805 | "void" { $$ = CYNew CYWord("void"); }
806 | "while" { $$ = CYNew CYWord("while"); }
807 | "with" { $$ = CYNew CYWord("with"); }
808 | "yield" { $$ = CYNew CYIdentifier("yield"); }
813 : Word[pass] { $$ = $pass; }
818 /* 11.8.1 Null Literals {{{ */
820 : "null" { $$ = CYNew CYNull(); }
823 /* 11.8.2 Boolean Literals {{{ */
825 : "true" { $$ = CYNew CYTrue(); }
826 | "false" { $$ = CYNew CYFalse(); }
829 /* 11.8.5 Regular Expression Literals {{{ */
830 RegularExpressionSlash
831 : "/" { $$ = false; }
832 | "/=" { $$ = true; }
835 RegularExpressionLiteral
836 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
840 /* 11.9 Automatic Semicolon Insertion {{{ */
842 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
850 : LexNewLineOrNot "\n"
855 : LexNewLineOrNot "\n" StrictSemi
856 | NewLineNot LexOf Terminator
861 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
866 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
870 /* 12.1 Identifiers {{{ */
872 : Identifier[pass] { $$ = CYNew CYVariable($pass); }
873 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
877 : LexOf IdentifierNoOf[pass] { $$ = $pass; }
878 | LexOf "!of" { $$ = CYNew CYIdentifier("of"); }
879 | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); }
883 : BindingIdentifier[pass] { $$ = $pass; }
884 | LexOf { $$ = NULL; }
888 : Identifier[pass] { $$ = $pass; }
889 | "yield" { $$ = CYNew CYIdentifier("yield"); }
893 : Identifier_[pass] { $$ = $pass; }
894 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
895 | "await" { $$ = CYNew CYIdentifier("await"); }
896 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
897 | "byte" { $$ = CYNew CYIdentifier("byte"); }
898 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
899 | "double" { $$ = CYNew CYIdentifier("double"); }
900 | "each" { $$ = CYNew CYIdentifier("each"); }
901 | "eval" { $$ = CYNew CYIdentifier("eval"); }
902 | "final" { $$ = CYNew CYIdentifier("final"); }
903 | "float" { $$ = CYNew CYIdentifier("float"); }
904 | "from" { $$ = CYNew CYIdentifier("from"); }
905 | "get" { $$ = CYNew CYIdentifier("get"); }
906 | "goto" { $$ = CYNew CYIdentifier("goto"); }
907 | "implements" { $$ = CYNew CYIdentifier("implements"); }
908 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
909 | "interface" { $$ = CYNew CYIdentifier("interface"); }
910 | "let" { $$ = CYNew CYIdentifier("let"); }
911 | "!let" LexBind LexOf { $$ = CYNew CYIdentifier("let"); }
912 | "native" { $$ = CYNew CYIdentifier("native"); }
913 | "package" { $$ = CYNew CYIdentifier("package"); }
914 | "private" { $$ = CYNew CYIdentifier("private"); }
915 | "protected" { $$ = CYNew CYIdentifier("protected"); }
916 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
917 | "public" { $$ = CYNew CYIdentifier("public"); }
918 | "set" { $$ = CYNew CYIdentifier("set"); }
919 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
920 | "target" { $$ = CYNew CYIdentifier("target"); }
921 | "throws" { $$ = CYNew CYIdentifier("throws"); }
922 | "transient" { $$ = CYNew CYIdentifier("transient"); }
923 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
925 | "bool" { $$ = CYNew CYIdentifier("bool"); }
926 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
927 | "id" { $$ = CYNew CYIdentifier("id"); }
928 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
933 : IdentifierTypeNoOf[pass] { $$ = $pass; }
934 | "of" { $$ = CYNew CYIdentifier("of"); }
938 : IdentifierType[pass] { $$ = $pass; }
944 | "char" { $$ = CYNew CYIdentifier("char"); }
945 | "int" { $$ = CYNew CYIdentifier("int"); }
946 | "long" { $$ = CYNew CYIdentifier("long"); }
947 | "short" { $$ = CYNew CYIdentifier("short"); }
948 | "static" { $$ = CYNew CYIdentifier("static"); }
949 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
951 | "signed" { $$ = CYNew CYIdentifier("signed"); }
952 | "struct" { $$ = CYNew CYIdentifier("struct"); }
953 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
956 | "nil" { $$ = CYNew CYIdentifier("nil"); }
957 | "NO" { $$ = CYNew CYIdentifier("NO"); }
958 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
959 | "YES" { $$ = CYNew CYIdentifier("YES"); }
964 : IdentifierNoOf[pass] { $$ = $pass; }
965 | "of" { $$ = CYNew CYIdentifier("of"); }
966 | "!of" { $$ = CYNew CYIdentifier("of"); }
969 /* 12.2 Primary Expression {{{ */
971 : "this" { $$ = CYNew CYThis(); }
972 | IdentifierReference[pass] { $$ = $pass; }
973 | Literal[pass] { $$ = $pass; }
974 | ArrayLiteral[pass] { $$ = $pass; }
975 | ObjectLiteral[pass] { $$ = $pass; }
976 | FunctionExpression[pass] { $$ = $pass; }
977 | ClassExpression[pass] { $$ = $pass; }
978 | GeneratorExpression[pass] { $$ = $pass; }
979 | RegularExpressionLiteral[pass] { $$ = $pass; }
980 | TemplateLiteral[pass] { $$ = $pass; }
981 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
982 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
985 CoverParenthesizedExpressionAndArrowParameterList
986 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
987 | "(" LexOf ")" { $$ = NULL; }
988 | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
989 | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
992 /* 12.2.4 Literals {{{ */
994 : NullLiteral[pass] { $$ = $pass; }
995 | BooleanLiteral[pass] { $$ = $pass; }
996 | NumericLiteral[pass] { $$ = $pass; }
997 | StringLiteral[pass] { $$ = $pass; }
1000 /* 12.2.5 Array Initializer {{{ */
1002 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
1006 : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); }
1007 | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
1008 | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); }
1012 : ElementList[pass] { $$ = $pass; }
1013 | LexOf { $$ = NULL; }
1016 /* 12.2.6 Object Initializer {{{ */
1018 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
1021 PropertyDefinitionList_
1022 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1026 PropertyDefinitionList
1027 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1030 PropertyDefinitionListOpt
1031 : PropertyDefinitionList[properties] { $$ = $properties; }
1036 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1037 | CoverInitializedName[name] { CYNOT(@$); }
1038 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1039 | MethodDefinition[pass] { $$ = $pass; }
1043 : LiteralPropertyName[pass] { $$ = $pass; }
1044 | ComputedPropertyName[pass] { $$ = $pass; }
1048 : IdentifierName[pass] { $$ = $pass; }
1049 | StringLiteral[pass] { $$ = $pass; }
1050 | NumericLiteral[pass] { $$ = $pass; }
1053 ComputedPropertyName
1054 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1057 CoverInitializedName
1058 : IdentifierReference Initializer
1062 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1066 : Initializer[pass] { $$ = $pass; }
1070 /* 12.2.9 Template Literals {{{ */
1072 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1073 | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1077 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1078 | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); }
1082 /* 12.3 Left-Hand-Side Expressions {{{ */
1084 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1085 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1086 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1087 | TemplateLiteral { CYNOT(@$); }
1091 : PrimaryExpression[pass] { $$ = $pass; }
1092 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1093 | SuperProperty[pass] { $$ = $pass; }
1094 | MetaProperty { CYNOT(@$); }
1095 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1099 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1100 | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1108 : "new" "." "target"
1112 : MemberExpression[pass] { $$ = $pass; }
1113 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1117 : MemberExpression[pass] { $$ = $pass; }
1118 | CallExpression[pass] { $$ = $pass; }
1122 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1123 | SuperCall[pass] { $$ = $pass; }
1124 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1128 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1132 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1136 : "," ArgumentList[arguments] { $$ = $arguments; }
1141 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1142 | LexOf "..." AssignmentExpression { CYNOT(@$); }
1146 : ArgumentList[pass] { $$ = $pass; }
1147 | LexOf { $$ = NULL; }
1151 : NewExpression[pass] { $$ = $pass; }
1152 | CallExpression[pass] { $$ = $pass; }
1155 LeftHandSideExpression
1156 : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
1157 | IndirectExpression[pass] { $$ = $pass; }
1160 /* 12.4 Postfix Expressions {{{ */
1162 : AccessExpression[lhs] LexNewLineOrOpt { $$ = $lhs; }
1163 | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); }
1164 | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = 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 | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1174 | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
1175 | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
1176 | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
1177 | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); }
1181 : PostfixExpression[expression] { $$ = $expression; }
1182 | PostfixExpression[expression] "\n" { $$ = $expression; }
1183 | UnaryExpression_[pass] { $$ = $pass; }
1186 /* 12.6 Multiplicative Operators {{{ */
1187 MultiplicativeExpression
1188 : UnaryExpression[pass] { $$ = $pass; }
1189 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1190 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1191 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1194 /* 12.7 Additive Operators {{{ */
1196 : MultiplicativeExpression[pass] { $$ = $pass; }
1197 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1198 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1201 /* 12.8 Bitwise Shift Operators {{{ */
1203 : AdditiveExpression[pass] { $$ = $pass; }
1204 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1205 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1206 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1209 /* 12.9 Relational Operators {{{ */
1210 RelationalExpression
1211 : ShiftExpression[pass] { $$ = $pass; }
1212 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1213 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1214 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1215 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1216 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1217 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1220 /* 12.10 Equality Operators {{{ */
1222 : RelationalExpression[pass] { $$ = $pass; }
1223 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1224 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1225 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1226 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1229 /* 12.11 Binary Bitwise Operators {{{ */
1230 BitwiseANDExpression
1231 : EqualityExpression[pass] { $$ = $pass; }
1232 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1235 BitwiseXORExpression
1236 : BitwiseANDExpression[pass] { $$ = $pass; }
1237 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1241 : BitwiseXORExpression[pass] { $$ = $pass; }
1242 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1245 /* 12.12 Binary Logical Operators {{{ */
1246 LogicalANDExpression
1247 : BitwiseORExpression[pass] { $$ = $pass; }
1248 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1252 : LogicalANDExpression[pass] { $$ = $pass; }
1253 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1256 /* 12.13 Conditional Operator ( ? : ) {{{ */
1258 ConditionalExpressionClassic
1259 : LogicalORExpression[pass] { $$ = $pass; }
1260 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1264 ConditionalExpression
1265 : LogicalORExpression[pass] { $$ = $pass; }
1266 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1269 /* 12.14 Assignment Operators {{{ */
1270 LeftHandSideAssignment
1271 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1272 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1273 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1274 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1275 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1276 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1277 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1278 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1279 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1280 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1281 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1282 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1286 AssignmentExpressionClassic
1287 : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; }
1288 | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1292 AssignmentExpression
1293 : LexOf ConditionalExpression[pass] { $$ = $pass; }
1294 | LexOf YieldExpression[pass] { $$ = $pass; }
1295 | ArrowFunction[pass] { $$ = $pass; }
1296 | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1299 AssignmentExpressionOpt
1300 : AssignmentExpression[pass] { $$ = $pass; }
1301 | LexOf { $$ = NULL; }
1304 /* 12.15 Comma Operator ( , ) {{{ */
1306 : AssignmentExpression[pass] { $$ = $pass; }
1307 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1311 : Expression[pass] { $$ = $pass; }
1312 | LexOf { $$ = NULL; }
1316 /* 13 Statements and Declarations {{{ */
1318 : BlockStatement[pass] { $$ = $pass; }
1319 | VariableStatement[pass] { $$ = $pass; }
1320 | EmptyStatement[pass] { $$ = $pass; }
1321 | IfStatement[pass] { $$ = $pass; }
1322 | BreakableStatement[pass] { $$ = $pass; }
1323 | ContinueStatement[pass] { $$ = $pass; }
1324 | BreakStatement[pass] { $$ = $pass; }
1325 | ReturnStatement[pass] { $$ = $pass; }
1326 | WithStatement[pass] { $$ = $pass; }
1327 | LabelledStatement[pass] { $$ = $pass; }
1328 | ThrowStatement[pass] { $$ = $pass; }
1329 | TryStatement[pass] { $$ = $pass; }
1330 | DebuggerStatement[pass] { $$ = $pass; }
1334 : LexOf Statement__[pass] { $$ = $pass; }
1335 | ExpressionStatement[pass] { $$ = $pass; }
1339 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1343 : HoistableDeclaration[pass] { $$ = $pass; }
1344 | ClassDeclaration[pass] { $$ = $pass; }
1348 : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; }
1349 | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; }
1352 HoistableDeclaration
1353 : FunctionDeclaration[pass] { $$ = $pass; }
1354 | GeneratorDeclaration[pass] { $$ = $pass; }
1358 : IterationStatement[pass] { $$ = $pass; }
1359 | SwitchStatement[pass] { $$ = $pass; }
1362 /* 13.2 Block {{{ */
1364 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1368 : "{" StatementListOpt[code] "}" { $$ = $code; }
1372 : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; }
1376 : StatementList[pass] { $$ = $pass; }
1377 | LexSetStatement LexLet LexOf { $$ = NULL; }
1381 : Statement[pass] { $$ = $pass; }
1382 | Declaration[pass] { $$ = $pass; }
1385 /* 13.3 Let and Const Declarations {{{ */
1387 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1391 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1395 : { CYMAP(_let__, _let_); }
1399 : { CYMAP(_of__, _of_); }
1403 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); }
1407 : LexLet LexOf "!let" LexBind LexOf { $$ = false; }
1408 | LexLet LexOf "const" { $$ = true; }
1412 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1417 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1421 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1422 | LexOf BindingPattern Initializer { CYNOT(@$); }
1425 /* 13.3.2 Variable Statement {{{ */
1427 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1431 : VariableStatement_[statement] Terminator { $$ = $statement; }
1434 VariableDeclarationList_
1435 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1439 VariableDeclarationList
1440 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1444 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1445 | LexOf BindingPattern Initializer { CYNOT(@$); }
1448 /* 13.3.3 Destructuring Binding Patterns {{{ */
1450 : ObjectBindingPattern
1451 | ArrayBindingPattern
1454 ObjectBindingPattern
1455 : "let {" BindingPropertyListOpt "}"
1459 : "let [" BindingElementListOpt "]"
1462 BindingPropertyList_
1463 : "," BindingPropertyListOpt
1468 : BindingProperty BindingPropertyList_
1471 BindingPropertyListOpt
1472 : BindingPropertyList
1477 : BindingElementOpt[element] "," BindingElementListOpt[next]
1478 | BindingRestElement[element]
1479 | BindingElement[element]
1482 BindingElementListOpt
1483 : BindingElementList[pass]
1489 | LexOf PropertyName ":" BindingElement
1493 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1494 | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1498 : BindingElement[pass]
1503 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1507 : LexBind LexOf "..." BindingIdentifier
1510 /* 13.4 Empty Statement {{{ */
1512 : ";" { $$ = CYNew CYEmpty(); }
1515 /* 13.5 Expression Statement {{{ */
1516 ExpressionStatement_
1517 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1520 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1523 /* 13.6 The if Statement {{{ */
1525 : "else" Statement[false] { $$ = $false; }
1526 | %prec "if" { $$ = NULL; }
1530 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1533 /* 13.7 Iteration Statements {{{ */
1535 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1536 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1537 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1538 | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1539 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1540 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1543 ForStatementInitializer
1544 : LexLet LexOf EmptyStatement[pass] { $$ = $pass; }
1545 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1546 | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; }
1547 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1550 ForInStatementInitializer
1551 : LexLet LexOf AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
1552 | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
1553 | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1554 | ForDeclaration[pass] { $$ = $pass; }
1558 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1562 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1563 | LexOf BindingPattern { CYNOT(@$); }
1566 /* 13.8 The continue Statement {{{ */
1568 : "continue" TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1569 | "continue" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1572 /* 13.9 The break Statement {{{ */
1574 : "break" TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1575 | "break" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1578 /* 13.10 The return Statement {{{ */
1580 : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
1584 : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1585 | Return NewLineNot Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1588 /* 13.11 The with Statement {{{ */
1590 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1593 /* 13.12 The switch Statement {{{ */
1595 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1599 : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1603 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1607 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1608 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1612 // XXX: the standard makes certain you can only have one of these
1614 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1617 /* 13.13 Labelled Statements {{{ */
1619 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1623 : Statement[pass] { $$ = $pass; }
1624 | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; }
1627 /* 13.14 The throw Statement {{{ */
1629 : "throw"[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); }
1630 | "throw" NewLineNot Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1633 /* 13.15 The try Statement {{{ */
1635 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1636 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1637 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1641 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1645 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1649 : BindingIdentifier[pass] { $$ = $pass; }
1650 | LexOf BindingPattern { CYNOT(@$); }
1653 /* 13.16 The debugger Statement {{{ */
1655 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1659 /* 14.1 Function Definitions {{{ */
1661 : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1665 : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1668 StrictFormalParameters
1669 : FormalParameters[pass] { $$ = $pass; }
1673 : LexBind LexOf { $$ = NULL; }
1674 | FormalParameterList
1677 FormalParameterList_
1678 : "," FormalParameterList[parameters] { $$ = $parameters; }
1683 : FunctionRestParameter { CYNOT(@$); }
1684 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1687 FunctionRestParameter
1688 : BindingRestElement
1692 : BindingElement[pass] { $$ = $pass; }
1696 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1699 FunctionStatementList
1700 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1703 /* 14.2 Arrow Function Definitions {{{ */
1705 : ArrowParameters[parameters] LexNewLineOrOpt "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1709 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1710 | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1714 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1715 | LexOf ";{" FunctionBody[code] "}" { $$ = $code; }
1718 /* 14.3 Method Definitions {{{ */
1720 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1721 | GeneratorMethod[pass] { $$ = $pass; }
1722 | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1723 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1726 PropertySetParameterList
1727 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1730 /* 14.4 Generator Function Definitions {{{ */
1732 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1735 GeneratorDeclaration
1736 : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1740 : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1744 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1748 : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1749 | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1750 | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1751 | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1754 /* 14.5 Class Definitions {{{ */
1756 : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1760 : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1764 : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1768 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1772 : ClassHeritage[pass] { $$ = $pass; }
1773 | { $$ = CYNew CYClassTail(NULL); }
1786 : ClassElementListOpt ClassElement
1795 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1796 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1801 /* 15.1 Scripts {{{ */
1803 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1807 : StatementList[pass] { $$ = $pass; }
1811 : ScriptBody[pass] { $$ = $pass; }
1812 | LexSetStatement LexLet LexOf { $$ = NULL; }
1815 /* 15.2 Modules {{{ */
1830 : ModuleItemListOpt ModuleItem
1839 : LexSetStatement LexLet LexOf ImportDeclaration
1840 | LexSetStatement LexLet LexOf ExportDeclaration
1844 /* 15.2.2 Imports {{{ */
1846 : "import" ImportClause FromClause Terminator
1847 | "import" LexOf ModuleSpecifier Terminator
1851 : ImportedDefaultBinding
1852 | LexOf NameSpaceImport
1853 | LexOf NamedImports
1854 | ImportedDefaultBinding "," NameSpaceImport
1855 | ImportedDefaultBinding "," NamedImports
1858 ImportedDefaultBinding
1863 : "*" "as" ImportedBinding
1867 : "{" ImportsListOpt "}"
1871 : "from" ModuleSpecifier
1875 : "," ImportsListOpt
1880 : ImportSpecifier ImportsList_
1890 | LexOf IdentifierName "as" ImportedBinding
1901 /* 15.2.3 Exports {{{ */
1903 : "*" FromClause Terminator
1904 | ExportClause FromClause Terminator
1905 | ExportClause Terminator
1907 | "default" LexSetStatement LexOf HoistableDeclaration
1908 | "default" LexSetStatement LexOf ClassDeclaration
1909 | "default" LexSetStatement AssignmentExpression Terminator
1913 : "export" LexSetStatement LexLet LexOf ExportDeclaration_
1914 | "export" Declaration
1918 : ";{" ExportsListOpt "}"
1922 : "," ExportsListOpt
1927 : ExportSpecifier ExportsList_
1937 | IdentifierName "as" IdentifierName
1942 /* Cycript (C): Type Encoding {{{ */
1944 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
1945 | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
1949 : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
1950 | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
1951 | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1952 | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1953 | TypeSignifier[pass] { $$ = $pass; }
1954 | { $$ = CYNew CYTypedIdentifier(@$); }
1958 : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1963 | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
1964 | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
1968 : PrefixedType[pass] { $$ = $pass; }
1969 | SuffixedType[pass] { $$ = $pass; }
1970 | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1971 | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1975 : "int" { $$ = CYNew CYTypeVariable("int"); }
1976 | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); }
1977 | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); }
1978 | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); }
1979 | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); }
1983 : IntegerType[pass] { $$ = $pass; }
1984 | { $$ = CYNew CYTypeVariable("int"); }
1988 : TypedIdentifierMaybe[typed] ";" StructFieldListOpt[next] { $$ = CYNew CYTypeStructField($typed, $next); }
1993 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
1994 | IntegerType[pass] { $$ = $pass; }
1995 | "void" { $$ = CYNew CYTypeVoid(); }
1996 | "char" { $$ = CYNew CYTypeVariable("char"); }
1997 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1998 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1999 | "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" { $$ = CYNew CYTypeStruct($name, $fields); }
2002 TypedIdentifierMaybe
2003 : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2007 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; }
2011 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; }
2015 : "@encode" "(" TypedIdentifierMaybe[typed] ")" { $$ = CYNew CYEncodedType($typed); }
2021 /* Cycript (Objective-C): @class Declaration {{{ */
2023 /* XXX: why the hell did I choose MemberExpression? */
2024 : ":" MemberExpression[extends] { $$ = $extends; }
2028 ImplementationFieldListOpt
2029 : TypedIdentifierMaybe[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2034 : "+" { $$ = false; }
2035 | "-" { $$ = true; }
2039 : "(" TypedIdentifierNo[type] ")" { $$ = $type; }
2040 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2044 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2047 MessageParameterList
2048 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2051 MessageParameterListOpt
2052 : MessageParameterList[pass] { $$ = $pass; }
2057 : MessageParameterList[pass] { $$ = $pass; }
2058 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2061 ClassMessageDeclaration
2062 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2065 ClassMessageDeclarationListOpt
2066 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2070 // XXX: this should be AssignmentExpressionNoRight
2072 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2076 : "," ClassProtocols[protocols] { $$ = $protocols; }
2080 ClassProtocolListOpt
2081 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2085 ImplementationStatement
2086 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] "{" ImplementationFieldListOpt[fields] "}" ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2094 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2098 : ImplementationStatement[pass] { $$ = $pass; }
2099 | CategoryStatement[pass] { $$ = $pass; }
2102 /* Cycript (Objective-C): Send Message {{{ */
2104 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2109 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2110 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2114 : SelectorCall[pass] { $$ = $pass; }
2115 | VariadicCall[pass] { $$ = $pass; }
2119 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2123 : SelectorCall[pass] { $$ = $pass; }
2124 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2128 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2129 | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2133 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2137 : SelectorExpression_[pass] { $$ = $pass; }
2138 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2141 SelectorExpressionOpt
2142 : SelectorExpression_[pass] { $$ = $pass; }
2147 : MessageExpression[pass] { $$ = $pass; }
2148 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2153 /* Cycript: @import Directive {{{ */
2155 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2156 | Word[part] { $$ = CYNew CYModule($part); }
2160 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2165 /* Cycript (Objective-C): Boxed Expressions {{{ */
2167 : NullLiteral[pass] { $$ = $pass; }
2168 | BooleanLiteral[pass] { $$ = $pass; }
2169 | NumericLiteral[pass] { $$ = $pass; }
2170 | StringLiteral[pass] { $$ = $pass; }
2171 | ArrayLiteral[pass] { $$ = $pass; }
2172 | ObjectLiteral[pass] { $$ = $pass; }
2173 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2174 | "YES" { $$ = CYNew CYTrue(); }
2175 | "NO" { $$ = CYNew CYFalse(); }
2179 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2180 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2181 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2182 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2183 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2184 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2187 /* Cycript (Objective-C): Block Expressions {{{ */
2189 : "^" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2192 /* Cycript (Objective-C): Instance Literals {{{ */
2194 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2200 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2202 : IndirectExpression[pass] { $$ = $pass; }
2206 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2210 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2214 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2215 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2216 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2219 /* Cycript (C): Lambda Expressions {{{ */
2221 : "," TypedParameterList[parameters] { $$ = $parameters; }
2226 : TypedIdentifierMaybe[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
2229 TypedParameterListOpt
2230 : TypedParameterList[pass] { $$ = $pass; }
2235 : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifierMaybe[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2238 /* Cycript (C): Type Definitions {{{ */
2240 : "typedef" NewLineOpt { $$ = CYNew CYIdentifier("typedef"); }
2244 : "typedef" NewLineNot TypedIdentifierYes[typed] Terminator { $$ = CYNew CYTypeDefinition($typed); }
2248 : "(" LexOf "typedef" NewLineOpt TypedIdentifierNo[typed] ")" { $$ = CYNew CYTypeExpression($typed); }
2251 /* Cycript (C): extern "C" {{{ */
2253 : "extern" NewLineOpt { $$ = CYNew CYIdentifier("extern"); }
2257 : "extern" NewLineNot StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifierYes[typed] Terminator { $$ = CYNew CYExternal($abi, $typed); }
2264 /* Lexer State {{{ */
2266 : { driver.PushCondition(CYDriver::RegExpCondition); }
2270 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2274 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2278 : { driver.PopCondition(); }
2282 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2286 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2289 /* Virtual Tokens {{{ */
2296 /* 8.1 Context Keywords {{{ */
2298 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2299 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2302 /* 8.3 XML Initializer Input Elements {{{ */
2304 : XMLComment { $$ = $1; }
2305 | XMLCDATA { $$ = $1; }
2306 | XMLPI { $$ = $1; }
2310 /* 11.1 Primary Expressions {{{ */
2312 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2313 | XMLInitilizer { $$ = $1; }
2314 | XMLListInitilizer { $$ = $1; }
2318 : AttributeIdentifier { $$ = $1; }
2319 | QualifiedIdentifier { $$ = $1; }
2320 | WildcardIdentifier { $$ = $1; }
2323 /* 11.1.1 Attribute Identifiers {{{ */
2325 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2329 : PropertySelector { $$ = $1; }
2330 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2334 : Identifier { $$ = CYNew CYSelector($1); }
2335 | WildcardIdentifier { $$ = $1; }
2338 /* 11.1.2 Qualified Identifiers {{{ */
2339 QualifiedIdentifier_
2340 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2341 | QualifiedIdentifier { $$ = $1; }
2345 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2348 /* 11.1.3 Wildcard Identifiers {{{ */
2350 : "*" { $$ = CYNew CYWildcard(); }
2353 /* 11.1.4 XML Initializer {{{ */
2355 : XMLMarkup { $$ = $1; }
2356 | XMLElement { $$ = $1; }
2360 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2361 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2365 : LexPushXMLTag XMLTagName XMLAttributes
2369 : "{" LexPushRegExp Expression LexPop "}"
2378 : XMLAttributes_ XMLAttribute
2383 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2384 | XMLAttributes_ XMLWhitespaceOpt
2393 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2397 : XMLExpression XMLElementContentOpt
2398 | XMLMarkup XMLElementContentOpt
2399 | XMLText XMLElementContentOpt
2400 | XMLElement XMLElementContentOpt
2403 XMLElementContentOpt
2408 /* 11.1.5 XMLList Initializer {{{ */
2410 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2414 /* 11.2 Left-Hand-Side Expressions {{{ */
2416 : Identifier { $$ = $1; }
2417 | PropertyIdentifier { $$ = $1; }
2421 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2422 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2423 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2426 /* 12.1 The default xml namespace Statement {{{ */
2427 /* XXX: DefaultXMLNamespaceStatement
2428 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2432 : DefaultXMLNamespaceStatement { $$ = $1; }
2437 /* JavaScript FTL: Array Comprehensions {{{ */
2439 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2443 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2446 /* JavaScript FTL: for each {{{ */
2448 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2452 /* JavaScript FTW: Array Comprehensions {{{ */
2454 : ArrayComprehension
2458 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2462 : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2467 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2468 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2472 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2473 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2477 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2480 /* JavaScript FTW: Coalesce Operator {{{ */
2481 ConditionalExpression
2482 : LogicalORExpression[test] "?" LexPushInOff LexOf ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); }
2485 /* JavaScript FTW: Named Arguments {{{ */
2487 : LexOf Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2490 /* JavaScript FTW: Ruby Blocks {{{ */
2491 RubyProcParameterList_
2492 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2496 RubyProcParameterList
2497 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2498 | LexOf { $$ = NULL; }
2502 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2503 | "||" { $$ = NULL; }
2506 RubyProcParametersOpt
2507 : RubyProcParameters[pass] { $$ = $pass; }
2512 : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2516 : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2520 : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLineOrOpt { $$ = CYNew CYRubyBlock($lhs, $rhs); }
2526 bool CYDriver::Parse(CYMark mark) {
2528 CYLocal<CYPool> local(&pool_);
2529 cy::parser parser(*this);
2531 parser.set_debug_level(debug_);
2533 return parser.parse() != 0;
2536 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2540 CYDriver::Error error;
2541 error.warning_ = true;
2542 error.location_ = location;
2543 error.message_ = message;
2544 errors_.push_back(error);
2547 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2548 CYDriver::Error error;
2549 error.warning_ = false;
2550 error.location_ = location;
2551 error.message_ = message;
2552 driver.errors_.push_back(error);