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 ___proto___ "__proto__"
423 %token _prototype_ "prototype"
424 %token _public_ "public"
426 %token _short_ "short"
427 %token _static_ "static"
428 %token _synchronized_ "synchronized"
429 %token _throws_ "throws"
430 %token _transient_ "transient"
431 %token _volatile_ "volatile"
432 %token _yield_ "yield"
433 %token _yield__ "!yield"
435 %token _undefined_ "undefined"
451 %token _namespace_ "namespace"
456 %token YieldStar "yield *"
458 %token <identifier_> Identifier_
459 %token <number_> NumericLiteral
460 %token <string_> StringLiteral
461 %token <literal_> RegularExpressionLiteral_
463 %token <string_> NoSubstitutionTemplate
464 %token <string_> TemplateHead
465 %token <string_> TemplateMiddle
466 %token <string_> TemplateTail
468 %type <target_> AccessExpression
469 %type <expression_> AdditiveExpression
470 %type <argument_> ArgumentList_
471 %type <argument_> ArgumentList
472 %type <argument_> ArgumentListOpt
473 %type <argument_> Arguments
474 %type <target_> ArrayComprehension
475 %type <literal_> ArrayLiteral
476 %type <expression_> ArrowFunction
477 %type <functionParameter_> ArrowParameters
478 %type <expression_> AssignmentExpression
479 %type <expression_> AssignmentExpressionOpt
480 %type <identifier_> BindingIdentifier
481 %type <identifier_> BindingIdentifierOpt
482 %type <bindings_> BindingList_
483 %type <bindings_> BindingList
484 %type <expression_> BitwiseANDExpression
485 %type <statement_> Block
486 %type <statement_> BlockStatement
487 %type <boolean_> BooleanLiteral
488 %type <binding_> BindingElement
489 %type <expression_> BitwiseORExpression
490 %type <expression_> BitwiseXORExpression
491 %type <statement_> BreakStatement
492 %type <statement_> BreakableStatement
493 %type <expression_> CallExpression_
494 %type <target_> CallExpression
495 %type <clause_> CaseBlock
496 %type <clause_> CaseClause
497 %type <clause_> CaseClausesOpt
499 %type <identifier_> CatchParameter
500 %type <statement_> ClassDeclaration
501 %type <target_> ClassExpression
502 %type <classTail_> ClassHeritage
503 %type <classTail_> ClassHeritageOpt
504 %type <classTail_> ClassTail
505 %type <target_> Comprehension
506 %type <comprehension_> ComprehensionFor
507 %type <comprehension_> ComprehensionIf
508 %type <comprehension_> ComprehensionTail
509 %type <propertyName_> ComputedPropertyName
510 %type <expression_> ConditionalExpression
511 %type <statement_> ContinueStatement
512 %type <statement_> ConciseBody
513 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
514 %type <statement_> DebuggerStatement
515 %type <statement_> Declaration_
516 %type <statement_> Declaration
517 %type <clause_> DefaultClause
518 %type <element_> ElementList
519 %type <element_> ElementListOpt
520 %type <statement_> ElseStatementOpt
521 %type <for_> EmptyStatement
522 %type <expression_> EqualityExpression
523 %type <expression_> Expression
524 %type <expression_> ExpressionOpt
525 %type <for_> ExpressionStatement_
526 %type <statement_> ExpressionStatement
527 %type <finally_> Finally
528 %type <binding_> ForBinding
529 %type <forin_> ForDeclaration
530 %type <forin_> ForInStatementInitializer
531 %type <for_> ForStatementInitializer
532 %type <binding_> FormalParameter
533 %type <functionParameter_> FormalParameterList_
534 %type <functionParameter_> FormalParameterList
535 %type <functionParameter_> FormalParameters
536 %type <statement_> FunctionBody
537 %type <statement_> FunctionDeclaration
538 %type <target_> FunctionExpression
539 %type <statement_> FunctionStatementList
540 %type <statement_> GeneratorBody
541 %type <statement_> GeneratorDeclaration
542 %type <target_> GeneratorExpression
543 %type <method_> GeneratorMethod
544 %type <statement_> HoistableDeclaration
545 %type <identifier_> Identifier
546 %type <identifier_> IdentifierNoOf
547 %type <identifier_> IdentifierType
548 %type <identifier_> IdentifierTypeNoOf
549 %type <identifier_> IdentifierTypeOpt
550 %type <word_> IdentifierName
551 %type <variable_> IdentifierReference
552 %type <statement_> IfStatement
553 %type <target_> IndirectExpression
554 %type <expression_> Initializer
555 %type <expression_> InitializerOpt
556 %type <statement_> IterationStatement
557 %type <identifier_> LabelIdentifier
558 %type <statement_> LabelledItem
559 %type <statement_> LabelledStatement
560 %type <assignment_> LeftHandSideAssignment
561 %type <target_> LeftHandSideExpression
562 %type <bool_> LetOrConst
563 %type <binding_> LexicalBinding
564 %type <for_> LexicalDeclaration_
565 %type <statement_> LexicalDeclaration
566 %type <literal_> Literal
567 %type <propertyName_> LiteralPropertyName
568 %type <expression_> LogicalANDExpression
569 %type <expression_> LogicalORExpression
570 %type <access_> MemberAccess
571 %type <target_> MemberExpression
572 %type <method_> MethodDefinition
573 %type <module_> ModulePath
574 %type <expression_> MultiplicativeExpression
575 %type <target_> NewExpression
576 %type <null_> NullLiteral
577 %type <literal_> ObjectLiteral
578 %type <expression_> PostfixExpression
579 %type <target_> PrimaryExpression
580 %type <propertyName_> PropertyName
581 %type <property_> PropertyDefinition
582 %type <property_> PropertyDefinitionList_
583 %type <property_> PropertyDefinitionList
584 %type <property_> PropertyDefinitionListOpt
585 %type <functionParameter_> PropertySetParameterList
586 %type <literal_> RegularExpressionLiteral
587 %type <bool_> RegularExpressionSlash
588 %type <expression_> RelationalExpression
589 %type <statement_> ReturnStatement
590 %type <rubyProc_> RubyProcExpression
591 %type <functionParameter_> RubyProcParameterList_
592 %type <functionParameter_> RubyProcParameterList
593 %type <functionParameter_> RubyProcParameters
594 %type <functionParameter_> RubyProcParametersOpt
595 %type <statement_> Script
596 %type <statement_> ScriptBody
597 %type <statement_> ScriptBodyOpt
598 %type <expression_> ShiftExpression
599 %type <binding_> SingleNameBinding
600 %type <statement_> Statement__
601 %type <statement_> Statement_
602 %type <statement_> Statement
603 %type <statement_> StatementList
604 %type <statement_> StatementListOpt
605 %type <statement_> StatementListItem
606 %type <functionParameter_> StrictFormalParameters
607 %type <target_> SuperCall
608 %type <target_> SuperProperty
609 %type <statement_> SwitchStatement
610 %type <target_> TemplateLiteral
611 %type <span_> TemplateSpans
612 %type <statement_> ThrowStatement
613 %type <statement_> TryStatement
614 %type <expression_> UnaryExpression_
615 %type <expression_> UnaryExpression
616 %type <binding_> VariableDeclaration
617 %type <bindings_> VariableDeclarationList_
618 %type <bindings_> VariableDeclarationList
619 %type <for_> VariableStatement_
620 %type <statement_> VariableStatement
621 %type <statement_> WithStatement
624 %type <word_> WordOpt
626 %type <expression_> YieldExpression
629 %type <specifier_> IntegerType
630 %type <specifier_> IntegerTypeOpt
631 %type <typedIdentifier_> PrefixedType
632 %type <specifier_> PrimitiveType
633 %type <structField_> StructFieldListOpt
634 %type <typedIdentifier_> SuffixedType
635 %type <typedIdentifier_> TypeSignifier
636 %type <modifier_> TypeQualifierLeft
637 %type <typedIdentifier_> TypeQualifierRight
638 %type <typedIdentifier_> TypedIdentifierMaybe
639 %type <typedIdentifier_> TypedIdentifierNo
640 %type <typedIdentifier_> TypedIdentifierYes
641 %type <typedParameter_> TypedParameterList_
642 %type <typedParameter_> TypedParameterList
643 %type <typedParameter_> TypedParameterListOpt
647 %type <expression_> AssignmentExpressionClassic
648 %type <expression_> BoxableExpression
649 %type <statement_> CategoryStatement
650 %type <expression_> ClassSuperOpt
651 %type <expression_> ConditionalExpressionClassic
652 %type <message_> ClassMessageDeclaration
653 %type <message_> ClassMessageDeclarationListOpt
654 %type <protocol_> ClassProtocolListOpt
655 %type <protocol_> ClassProtocols
656 %type <protocol_> ClassProtocolsOpt
657 %type <implementationField_> ImplementationFieldListOpt
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 : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
734 : { 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::__); }
738 : { CYMAP(YieldStar, Star); }
742 : { CYMAP(OpenBrace_, OpenBrace); }
746 : { CYMAP(_class__, _class_); }
750 : { CYMAP(_function__, _function_); }
754 : LexNoBrace LexNoClass LexNoFunction
757 /* Virtual Tokens {{{ */
763 /* 11.6 Names and Keywords {{{ */
765 : Word[pass] { $$ = $pass; }
766 | "for" { $$ = CYNew CYWord("for"); }
767 | "in" { $$ = CYNew CYWord("in"); }
768 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
772 : IdentifierNoOf[pass] { $$ = $pass; }
773 | "break" { $$ = CYNew CYWord("break"); }
774 | "case" { $$ = CYNew CYWord("case"); }
775 | "catch" { $$ = CYNew CYWord("catch"); }
776 | "class" LexOf { $$ = CYNew CYWord("class"); }
777 | ";class" { $$ = CYNew CYWord("class"); }
778 | "const" { $$ = CYNew CYWord("const"); }
779 | "continue" { $$ = CYNew CYWord("continue"); }
780 | "debugger" { $$ = CYNew CYWord("debugger"); }
781 | "default" { $$ = CYNew CYWord("default"); }
782 | "delete" { $$ = CYNew CYWord("delete"); }
783 | "do" { $$ = CYNew CYWord("do"); }
784 | "else" { $$ = CYNew CYWord("else"); }
785 | "enum" { $$ = CYNew CYWord("enum"); }
786 | "export" { $$ = CYNew CYWord("export"); }
787 | "extends" { $$ = CYNew CYWord("extends"); }
788 | "false" { $$ = CYNew CYWord("false"); }
789 | "finally" { $$ = CYNew CYWord("finally"); }
790 | "function" LexOf { $$ = CYNew CYWord("function"); }
791 | "if" { $$ = CYNew CYWord("if"); }
792 | "import" { $$ = CYNew CYWord("import"); }
793 | "!in" { $$ = CYNew CYWord("in"); }
794 | "!of" { $$ = CYNew CYWord("of"); }
795 | "new" { $$ = CYNew CYWord("new"); }
796 | "null" { $$ = CYNew CYWord("null"); }
797 | "return" { $$ = CYNew CYWord("return"); }
798 | "super" { $$ = CYNew CYWord("super"); }
799 | "switch" { $$ = CYNew CYWord("switch"); }
800 | "this" { $$ = CYNew CYWord("this"); }
801 | "throw" { $$ = CYNew CYWord("throw"); }
802 | "true" { $$ = CYNew CYWord("true"); }
803 | "try" { $$ = CYNew CYWord("try"); }
804 | "typeof" { $$ = CYNew CYWord("typeof"); }
805 | "var" { $$ = CYNew CYWord("var"); }
806 | "void" { $$ = CYNew CYWord("void"); }
807 | "while" { $$ = CYNew CYWord("while"); }
808 | "with" { $$ = CYNew CYWord("with"); }
809 | "yield" { $$ = CYNew CYIdentifier("yield"); }
814 : Word[pass] { $$ = $pass; }
819 /* 11.8.1 Null Literals {{{ */
821 : "null" { $$ = CYNew CYNull(); }
824 /* 11.8.2 Boolean Literals {{{ */
826 : "true" { $$ = CYNew CYTrue(); }
827 | "false" { $$ = CYNew CYFalse(); }
830 /* 11.8.5 Regular Expression Literals {{{ */
831 RegularExpressionSlash
832 : "/" { $$ = false; }
833 | "/=" { $$ = true; }
836 RegularExpressionLiteral
837 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
841 /* 11.9 Automatic Semicolon Insertion {{{ */
843 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
851 : LexNewLineOrNot "\n"
856 : LexNewLineOrNot "\n" StrictSemi
857 | NewLineNot LexOf Terminator
862 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) 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 : LexOf IdentifierNoOf[pass] { $$ = $pass; }
879 | LexOf "!of" { $$ = CYNew CYIdentifier("of"); }
880 | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); }
884 : BindingIdentifier[pass] { $$ = $pass; }
885 | LexOf { $$ = NULL; }
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 LexOf { $$ = CYNew CYIdentifier("let"); }
913 | "native" { $$ = CYNew CYIdentifier("native"); }
914 | "package" { $$ = CYNew CYIdentifier("package"); }
915 | "private" { $$ = CYNew CYIdentifier("private"); }
916 | "protected" { $$ = CYNew CYIdentifier("protected"); }
917 | "__proto__" { $$ = CYNew CYIdentifier("__proto__"); }
918 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
919 | "public" { $$ = CYNew CYIdentifier("public"); }
920 | "set" { $$ = CYNew CYIdentifier("set"); }
921 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
922 | "target" { $$ = CYNew CYIdentifier("target"); }
923 | "throws" { $$ = CYNew CYIdentifier("throws"); }
924 | "transient" { $$ = CYNew CYIdentifier("transient"); }
925 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
927 | "bool" { $$ = CYNew CYIdentifier("bool"); }
928 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
929 | "id" { $$ = CYNew CYIdentifier("id"); }
930 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
935 : IdentifierTypeNoOf[pass] { $$ = $pass; }
936 | "of" { $$ = CYNew CYIdentifier("of"); }
940 : IdentifierType[pass] { $$ = $pass; }
946 | "char" { $$ = CYNew CYIdentifier("char"); }
947 | "int" { $$ = CYNew CYIdentifier("int"); }
948 | "long" { $$ = CYNew CYIdentifier("long"); }
949 | "short" { $$ = CYNew CYIdentifier("short"); }
950 | "static" { $$ = CYNew CYIdentifier("static"); }
951 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
953 | "signed" { $$ = CYNew CYIdentifier("signed"); }
954 | "struct" { $$ = CYNew CYIdentifier("struct"); }
955 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
958 | "nil" { $$ = CYNew CYIdentifier("nil"); }
959 | "NO" { $$ = CYNew CYIdentifier("NO"); }
960 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
961 | "YES" { $$ = CYNew CYIdentifier("YES"); }
966 : IdentifierNoOf[pass] { $$ = $pass; }
967 | "of" { $$ = CYNew CYIdentifier("of"); }
968 | "!of" { $$ = CYNew CYIdentifier("of"); }
971 /* 12.2 Primary Expression {{{ */
973 : "this" { $$ = CYNew CYThis(); }
974 | IdentifierReference[pass] { $$ = $pass; }
975 | Literal[pass] { $$ = $pass; }
976 | ArrayLiteral[pass] { $$ = $pass; }
977 | ObjectLiteral[pass] { $$ = $pass; }
978 | FunctionExpression[pass] { $$ = $pass; }
979 | ClassExpression[pass] { $$ = $pass; }
980 | GeneratorExpression[pass] { $$ = $pass; }
981 | RegularExpressionLiteral[pass] { $$ = $pass; }
982 | TemplateLiteral[pass] { $$ = $pass; }
983 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
984 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
987 CoverParenthesizedExpressionAndArrowParameterList
988 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
989 | "(" LexOf ")" { $$ = NULL; }
990 | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
991 | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
994 /* 12.2.4 Literals {{{ */
996 : NullLiteral[pass] { $$ = $pass; }
997 | BooleanLiteral[pass] { $$ = $pass; }
998 | NumericLiteral[pass] { $$ = $pass; }
999 | StringLiteral[pass] { $$ = $pass; }
1002 /* 12.2.5 Array Initializer {{{ */
1004 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
1008 : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); }
1009 | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
1010 | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); }
1014 : ElementList[pass] { $$ = $pass; }
1015 | LexOf { $$ = NULL; }
1018 /* 12.2.6 Object Initializer {{{ */
1020 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
1023 PropertyDefinitionList_
1024 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1028 PropertyDefinitionList
1029 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1032 PropertyDefinitionListOpt
1033 : PropertyDefinitionList[properties] { $$ = $properties; }
1038 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1039 | CoverInitializedName[name] { CYNOT(@$); }
1040 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1041 | MethodDefinition[pass] { $$ = $pass; }
1045 : LiteralPropertyName[pass] { $$ = $pass; }
1046 | ComputedPropertyName[pass] { $$ = $pass; }
1050 : IdentifierName[pass] { $$ = $pass; }
1051 | StringLiteral[pass] { $$ = $pass; }
1052 | NumericLiteral[pass] { $$ = $pass; }
1055 ComputedPropertyName
1056 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1059 CoverInitializedName
1060 : IdentifierReference Initializer
1064 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1068 : Initializer[pass] { $$ = $pass; }
1072 /* 12.2.9 Template Literals {{{ */
1074 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1075 | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1079 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1080 | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); }
1084 /* 12.3 Left-Hand-Side Expressions {{{ */
1086 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1087 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1088 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1089 | TemplateLiteral { CYNOT(@$); }
1093 : PrimaryExpression[pass] { $$ = $pass; }
1094 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1095 | SuperProperty[pass] { $$ = $pass; }
1096 | MetaProperty { CYNOT(@$); }
1097 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1101 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1102 | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1110 : "new" "." "target"
1114 : MemberExpression[pass] { $$ = $pass; }
1115 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1119 : MemberExpression[pass] { $$ = $pass; }
1120 | CallExpression[pass] { $$ = $pass; }
1124 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1125 | SuperCall[pass] { $$ = $pass; }
1126 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1130 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1134 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1138 : "," ArgumentList[arguments] { $$ = $arguments; }
1143 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1144 | LexOf "..." AssignmentExpression { CYNOT(@$); }
1148 : ArgumentList[pass] { $$ = $pass; }
1149 | LexOf { $$ = NULL; }
1153 : NewExpression[pass] { $$ = $pass; }
1154 | CallExpression[pass] { $$ = $pass; }
1157 LeftHandSideExpression
1158 : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
1159 | IndirectExpression[pass] { $$ = $pass; }
1162 /* 12.4 Postfix Expressions {{{ */
1164 : AccessExpression[lhs] LexNewLineOrOpt { $$ = $lhs; }
1165 | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); }
1166 | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); }
1169 /* 12.5 Unary Operators {{{ */
1171 : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); }
1172 | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
1173 | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
1174 | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1175 | "--" 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] { $$ = $expression; }
1184 | PostfixExpression[expression] "\n" { $$ = $expression; }
1185 | UnaryExpression_[pass] { $$ = $pass; }
1188 /* 12.6 Multiplicative Operators {{{ */
1189 MultiplicativeExpression
1190 : UnaryExpression[pass] { $$ = $pass; }
1191 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1192 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1193 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1196 /* 12.7 Additive Operators {{{ */
1198 : MultiplicativeExpression[pass] { $$ = $pass; }
1199 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1200 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1203 /* 12.8 Bitwise Shift Operators {{{ */
1205 : AdditiveExpression[pass] { $$ = $pass; }
1206 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1207 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1208 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1211 /* 12.9 Relational Operators {{{ */
1212 RelationalExpression
1213 : ShiftExpression[pass] { $$ = $pass; }
1214 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1215 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1216 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1217 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1218 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1219 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1222 /* 12.10 Equality Operators {{{ */
1224 : RelationalExpression[pass] { $$ = $pass; }
1225 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1226 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1227 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1228 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1231 /* 12.11 Binary Bitwise Operators {{{ */
1232 BitwiseANDExpression
1233 : EqualityExpression[pass] { $$ = $pass; }
1234 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1237 BitwiseXORExpression
1238 : BitwiseANDExpression[pass] { $$ = $pass; }
1239 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1243 : BitwiseXORExpression[pass] { $$ = $pass; }
1244 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1247 /* 12.12 Binary Logical Operators {{{ */
1248 LogicalANDExpression
1249 : BitwiseORExpression[pass] { $$ = $pass; }
1250 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1254 : LogicalANDExpression[pass] { $$ = $pass; }
1255 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1258 /* 12.13 Conditional Operator ( ? : ) {{{ */
1260 ConditionalExpressionClassic
1261 : LogicalORExpression[pass] { $$ = $pass; }
1262 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1266 ConditionalExpression
1267 : LogicalORExpression[pass] { $$ = $pass; }
1268 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1271 /* 12.14 Assignment Operators {{{ */
1272 LeftHandSideAssignment
1273 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1274 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1275 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1276 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1277 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1278 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1279 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1280 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1281 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1282 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1283 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1284 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1288 AssignmentExpressionClassic
1289 : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; }
1290 | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1294 AssignmentExpression
1295 : LexOf ConditionalExpression[pass] { $$ = $pass; }
1296 | LexOf YieldExpression[pass] { $$ = $pass; }
1297 | ArrowFunction[pass] { $$ = $pass; }
1298 | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1301 AssignmentExpressionOpt
1302 : AssignmentExpression[pass] { $$ = $pass; }
1303 | LexOf { $$ = NULL; }
1306 /* 12.15 Comma Operator ( , ) {{{ */
1308 : AssignmentExpression[pass] { $$ = $pass; }
1309 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1313 : Expression[pass] { $$ = $pass; }
1314 | LexOf { $$ = NULL; }
1318 /* 13 Statements and Declarations {{{ */
1320 : BlockStatement[pass] { $$ = $pass; }
1321 | VariableStatement[pass] { $$ = $pass; }
1322 | EmptyStatement[pass] { $$ = $pass; }
1323 | IfStatement[pass] { $$ = $pass; }
1324 | BreakableStatement[pass] { $$ = $pass; }
1325 | ContinueStatement[pass] { $$ = $pass; }
1326 | BreakStatement[pass] { $$ = $pass; }
1327 | ReturnStatement[pass] { $$ = $pass; }
1328 | WithStatement[pass] { $$ = $pass; }
1329 | LabelledStatement[pass] { $$ = $pass; }
1330 | ThrowStatement[pass] { $$ = $pass; }
1331 | TryStatement[pass] { $$ = $pass; }
1332 | DebuggerStatement[pass] { $$ = $pass; }
1336 : LexOf Statement__[pass] { $$ = $pass; }
1337 | ExpressionStatement[pass] { $$ = $pass; }
1341 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1345 : HoistableDeclaration[pass] { $$ = $pass; }
1346 | ClassDeclaration[pass] { $$ = $pass; }
1350 : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; }
1351 | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; }
1354 HoistableDeclaration
1355 : FunctionDeclaration[pass] { $$ = $pass; }
1356 | GeneratorDeclaration[pass] { $$ = $pass; }
1360 : IterationStatement[pass] { $$ = $pass; }
1361 | SwitchStatement[pass] { $$ = $pass; }
1364 /* 13.2 Block {{{ */
1366 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1370 : "{" StatementListOpt[code] "}" { $$ = $code; }
1374 : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; }
1378 : StatementList[pass] { $$ = $pass; }
1379 | LexSetStatement LexLet LexOf { $$ = NULL; }
1383 : Statement[pass] { $$ = $pass; }
1384 | Declaration[pass] { $$ = $pass; }
1387 /* 13.3 Let and Const Declarations {{{ */
1389 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1393 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1397 : { CYMAP(_let__, _let_); }
1401 : { CYMAP(_of__, _of_); }
1405 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); }
1409 : LexLet LexOf "!let" LexBind LexOf { $$ = false; }
1410 | LexLet LexOf "const" { $$ = true; }
1414 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1419 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1423 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1424 | LexOf BindingPattern Initializer { CYNOT(@$); }
1427 /* 13.3.2 Variable Statement {{{ */
1429 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1433 : VariableStatement_[statement] Terminator { $$ = $statement; }
1436 VariableDeclarationList_
1437 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1441 VariableDeclarationList
1442 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1446 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1447 | LexOf BindingPattern Initializer { CYNOT(@$); }
1450 /* 13.3.3 Destructuring Binding Patterns {{{ */
1452 : ObjectBindingPattern
1453 | ArrayBindingPattern
1456 ObjectBindingPattern
1457 : "let {" BindingPropertyListOpt "}"
1461 : "let [" BindingElementListOpt "]"
1464 BindingPropertyList_
1465 : "," BindingPropertyListOpt
1470 : BindingProperty BindingPropertyList_
1473 BindingPropertyListOpt
1474 : BindingPropertyList
1479 : BindingElementOpt[element] "," BindingElementListOpt[next]
1480 | BindingRestElement[element]
1481 | BindingElement[element]
1484 BindingElementListOpt
1485 : BindingElementList[pass]
1491 | LexOf PropertyName ":" BindingElement
1495 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1496 | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1500 : BindingElement[pass]
1505 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1509 : LexBind LexOf "..." BindingIdentifier
1512 /* 13.4 Empty Statement {{{ */
1514 : ";" { $$ = CYNew CYEmpty(); }
1517 /* 13.5 Expression Statement {{{ */
1518 ExpressionStatement_
1519 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1522 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1525 /* 13.6 The if Statement {{{ */
1527 : "else" Statement[false] { $$ = $false; }
1528 | %prec "if" { $$ = NULL; }
1532 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1535 /* 13.7 Iteration Statements {{{ */
1537 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1538 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1539 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1540 | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1541 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1542 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1545 ForStatementInitializer
1546 : LexLet LexOf EmptyStatement[pass] { $$ = $pass; }
1547 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1548 | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; }
1549 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1552 ForInStatementInitializer
1553 : LexLet LexOf AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
1554 | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
1555 | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1556 | ForDeclaration[pass] { $$ = $pass; }
1560 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1564 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1565 | LexOf BindingPattern { CYNOT(@$); }
1568 /* 13.8 The continue Statement {{{ */
1570 : "continue" TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1571 | "continue" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1574 /* 13.9 The break Statement {{{ */
1576 : "break" TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1577 | "break" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1580 /* 13.10 The return Statement {{{ */
1582 : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
1586 : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1587 | Return NewLineNot Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1590 /* 13.11 The with Statement {{{ */
1592 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1595 /* 13.12 The switch Statement {{{ */
1597 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1601 : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1605 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1609 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1610 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1614 // XXX: the standard makes certain you can only have one of these
1616 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1619 /* 13.13 Labelled Statements {{{ */
1621 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1625 : Statement[pass] { $$ = $pass; }
1626 | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; }
1629 /* 13.14 The throw Statement {{{ */
1631 : "throw"[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); }
1632 | "throw" NewLineNot Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1635 /* 13.15 The try Statement {{{ */
1637 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1638 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1639 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1643 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1647 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1651 : BindingIdentifier[pass] { $$ = $pass; }
1652 | LexOf BindingPattern { CYNOT(@$); }
1655 /* 13.16 The debugger Statement {{{ */
1657 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1661 /* 14.1 Function Definitions {{{ */
1663 : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1667 : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1670 StrictFormalParameters
1671 : FormalParameters[pass] { $$ = $pass; }
1675 : LexBind LexOf { $$ = NULL; }
1676 | FormalParameterList
1679 FormalParameterList_
1680 : "," FormalParameterList[parameters] { $$ = $parameters; }
1685 : FunctionRestParameter { CYNOT(@$); }
1686 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1689 FunctionRestParameter
1690 : BindingRestElement
1694 : BindingElement[pass] { $$ = $pass; }
1698 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1701 FunctionStatementList
1702 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1705 /* 14.2 Arrow Function Definitions {{{ */
1707 : ArrowParameters[parameters] LexNewLineOrOpt "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1711 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1712 | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1716 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1717 | LexOf ";{" FunctionBody[code] "}" { $$ = $code; }
1720 /* 14.3 Method Definitions {{{ */
1722 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1723 | GeneratorMethod[pass] { $$ = $pass; }
1724 | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1725 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1728 PropertySetParameterList
1729 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1732 /* 14.4 Generator Function Definitions {{{ */
1734 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1737 GeneratorDeclaration
1738 : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1742 : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1746 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1750 : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1751 | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1752 | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1753 | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1756 /* 14.5 Class Definitions {{{ */
1758 : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1762 : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1766 : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1770 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1774 : ClassHeritage[pass] { $$ = $pass; }
1775 | { $$ = CYNew CYClassTail(NULL); }
1788 : ClassElementListOpt ClassElement
1797 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1798 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1803 /* 15.1 Scripts {{{ */
1805 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1809 : StatementList[pass] { $$ = $pass; }
1813 : ScriptBody[pass] { $$ = $pass; }
1814 | LexSetStatement LexLet LexOf { $$ = NULL; }
1817 /* 15.2 Modules {{{ */
1832 : ModuleItemListOpt ModuleItem
1841 : LexSetStatement LexLet LexOf ImportDeclaration
1842 | LexSetStatement LexLet LexOf ExportDeclaration
1846 /* 15.2.2 Imports {{{ */
1848 : "import" ImportClause FromClause Terminator
1849 | "import" LexOf ModuleSpecifier Terminator
1853 : ImportedDefaultBinding
1854 | LexOf NameSpaceImport
1855 | LexOf NamedImports
1856 | ImportedDefaultBinding "," NameSpaceImport
1857 | ImportedDefaultBinding "," NamedImports
1860 ImportedDefaultBinding
1865 : "*" "as" ImportedBinding
1869 : "{" ImportsListOpt "}"
1873 : "from" ModuleSpecifier
1877 : "," ImportsListOpt
1882 : ImportSpecifier ImportsList_
1892 | LexOf IdentifierName "as" ImportedBinding
1903 /* 15.2.3 Exports {{{ */
1905 : "*" FromClause Terminator
1906 | ExportClause FromClause Terminator
1907 | ExportClause Terminator
1909 | "default" LexSetStatement LexOf HoistableDeclaration
1910 | "default" LexSetStatement LexOf ClassDeclaration
1911 | "default" LexSetStatement AssignmentExpression Terminator
1915 : "export" LexSetStatement LexLet LexOf ExportDeclaration_
1916 | "export" Declaration
1920 : ";{" ExportsListOpt "}"
1924 : "," ExportsListOpt
1929 : ExportSpecifier ExportsList_
1939 | IdentifierName "as" IdentifierName
1944 /* Cycript (C): Type Encoding {{{ */
1946 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
1947 | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
1951 : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
1952 | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
1953 | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1954 | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1955 | TypeSignifier[pass] { $$ = $pass; }
1956 | { $$ = CYNew CYTypedIdentifier(@$); }
1960 : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1965 | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
1966 | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
1970 : PrefixedType[pass] { $$ = $pass; }
1971 | SuffixedType[pass] { $$ = $pass; }
1972 | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1973 | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1977 : "int" { $$ = CYNew CYTypeVariable("int"); }
1978 | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); }
1979 | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); }
1980 | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); }
1981 | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); }
1985 : IntegerType[pass] { $$ = $pass; }
1986 | { $$ = CYNew CYTypeVariable("int"); }
1990 : TypedIdentifierMaybe[typed] ";" StructFieldListOpt[next] { $$ = CYNew CYTypeStructField($typed, $next); }
1995 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
1996 | IntegerType[pass] { $$ = $pass; }
1997 | "void" { $$ = CYNew CYTypeVoid(); }
1998 | "char" { $$ = CYNew CYTypeVariable("char"); }
1999 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
2000 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
2001 | "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" { $$ = CYNew CYTypeStruct($name, $fields); }
2004 TypedIdentifierMaybe
2005 : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2009 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; }
2013 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; }
2017 : "@encode" "(" TypedIdentifierMaybe[typed] ")" { $$ = CYNew CYEncodedType($typed); }
2023 /* Cycript (Objective-C): @class Declaration {{{ */
2025 /* XXX: why the hell did I choose MemberExpression? */
2026 : ":" MemberExpression[extends] { $$ = $extends; }
2030 ImplementationFieldListOpt
2031 : TypedIdentifierMaybe[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2036 : "+" { $$ = false; }
2037 | "-" { $$ = true; }
2041 : "(" TypedIdentifierNo[type] ")" { $$ = $type; }
2042 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2046 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2049 MessageParameterList
2050 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2053 MessageParameterListOpt
2054 : MessageParameterList[pass] { $$ = $pass; }
2059 : MessageParameterList[pass] { $$ = $pass; }
2060 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2063 ClassMessageDeclaration
2064 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2067 ClassMessageDeclarationListOpt
2068 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2072 // XXX: this should be AssignmentExpressionNoRight
2074 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2078 : "," ClassProtocols[protocols] { $$ = $protocols; }
2082 ClassProtocolListOpt
2083 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2087 ImplementationStatement
2088 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] "{" ImplementationFieldListOpt[fields] "}" ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2096 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2100 : ImplementationStatement[pass] { $$ = $pass; }
2101 | CategoryStatement[pass] { $$ = $pass; }
2104 /* Cycript (Objective-C): Send Message {{{ */
2106 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2111 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2112 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2116 : SelectorCall[pass] { $$ = $pass; }
2117 | VariadicCall[pass] { $$ = $pass; }
2121 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2125 : SelectorCall[pass] { $$ = $pass; }
2126 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2130 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2131 | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2135 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2139 : SelectorExpression_[pass] { $$ = $pass; }
2140 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2143 SelectorExpressionOpt
2144 : SelectorExpression_[pass] { $$ = $pass; }
2149 : MessageExpression[pass] { $$ = $pass; }
2150 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2155 /* Cycript: @import Directive {{{ */
2157 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2158 | Word[part] { $$ = CYNew CYModule($part); }
2162 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2167 /* Cycript (Objective-C): Boxed Expressions {{{ */
2169 : NullLiteral[pass] { $$ = $pass; }
2170 | BooleanLiteral[pass] { $$ = $pass; }
2171 | NumericLiteral[pass] { $$ = $pass; }
2172 | StringLiteral[pass] { $$ = $pass; }
2173 | ArrayLiteral[pass] { $$ = $pass; }
2174 | ObjectLiteral[pass] { $$ = $pass; }
2175 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2176 | "YES" { $$ = CYNew CYTrue(); }
2177 | "NO" { $$ = CYNew CYFalse(); }
2181 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2182 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2183 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2184 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2185 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2186 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2189 /* Cycript (Objective-C): Block Expressions {{{ */
2191 : "^" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2194 /* Cycript (Objective-C): Instance Literals {{{ */
2196 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2202 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2204 : IndirectExpression[pass] { $$ = $pass; }
2208 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2212 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2216 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2217 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2218 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2221 /* Cycript (C): Lambda Expressions {{{ */
2223 : "," TypedParameterList[parameters] { $$ = $parameters; }
2228 : TypedIdentifierMaybe[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
2231 TypedParameterListOpt
2232 : TypedParameterList[pass] { $$ = $pass; }
2237 : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifierMaybe[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2240 /* Cycript (C): Type Definitions {{{ */
2242 : "typedef" NewLineOpt { $$ = CYNew CYIdentifier("typedef"); }
2246 : "typedef" NewLineNot TypedIdentifierYes[typed] Terminator { $$ = CYNew CYTypeDefinition($typed); }
2250 : "(" LexOf "typedef" NewLineOpt TypedIdentifierNo[typed] ")" { $$ = CYNew CYTypeExpression($typed); }
2253 /* Cycript (C): extern "C" {{{ */
2255 : "extern" NewLineOpt { $$ = CYNew CYIdentifier("extern"); }
2259 : "extern" NewLineNot StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifierYes[typed] Terminator { $$ = CYNew CYExternal($abi, $typed); }
2266 /* Lexer State {{{ */
2268 : { driver.PushCondition(CYDriver::RegExpCondition); }
2272 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2276 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2280 : { driver.PopCondition(); }
2284 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2288 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2291 /* Virtual Tokens {{{ */
2298 /* 8.1 Context Keywords {{{ */
2300 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2301 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2304 /* 8.3 XML Initializer Input Elements {{{ */
2306 : XMLComment { $$ = $1; }
2307 | XMLCDATA { $$ = $1; }
2308 | XMLPI { $$ = $1; }
2312 /* 11.1 Primary Expressions {{{ */
2314 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2315 | XMLInitilizer { $$ = $1; }
2316 | XMLListInitilizer { $$ = $1; }
2320 : AttributeIdentifier { $$ = $1; }
2321 | QualifiedIdentifier { $$ = $1; }
2322 | WildcardIdentifier { $$ = $1; }
2325 /* 11.1.1 Attribute Identifiers {{{ */
2327 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2331 : PropertySelector { $$ = $1; }
2332 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2336 : Identifier { $$ = CYNew CYSelector($1); }
2337 | WildcardIdentifier { $$ = $1; }
2340 /* 11.1.2 Qualified Identifiers {{{ */
2341 QualifiedIdentifier_
2342 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2343 | QualifiedIdentifier { $$ = $1; }
2347 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2350 /* 11.1.3 Wildcard Identifiers {{{ */
2352 : "*" { $$ = CYNew CYWildcard(); }
2355 /* 11.1.4 XML Initializer {{{ */
2357 : XMLMarkup { $$ = $1; }
2358 | XMLElement { $$ = $1; }
2362 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2363 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2367 : LexPushXMLTag XMLTagName XMLAttributes
2371 : "{" LexPushRegExp Expression LexPop "}"
2380 : XMLAttributes_ XMLAttribute
2385 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2386 | XMLAttributes_ XMLWhitespaceOpt
2395 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2399 : XMLExpression XMLElementContentOpt
2400 | XMLMarkup XMLElementContentOpt
2401 | XMLText XMLElementContentOpt
2402 | XMLElement XMLElementContentOpt
2405 XMLElementContentOpt
2410 /* 11.1.5 XMLList Initializer {{{ */
2412 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2416 /* 11.2 Left-Hand-Side Expressions {{{ */
2418 : Identifier { $$ = $1; }
2419 | PropertyIdentifier { $$ = $1; }
2423 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2424 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2425 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2428 /* 12.1 The default xml namespace Statement {{{ */
2429 /* XXX: DefaultXMLNamespaceStatement
2430 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2434 : DefaultXMLNamespaceStatement { $$ = $1; }
2439 /* JavaScript FTL: Array Comprehensions {{{ */
2441 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2445 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2448 /* JavaScript FTL: for each {{{ */
2450 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2454 /* JavaScript FTW: Array Comprehensions {{{ */
2456 : ArrayComprehension
2460 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2464 : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2469 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2470 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2474 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2475 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2479 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2482 /* JavaScript FTW: Coalesce Operator {{{ */
2483 ConditionalExpression
2484 : LogicalORExpression[test] "?" LexPushInOff LexOf ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); }
2487 /* JavaScript FTW: Named Arguments {{{ */
2489 : LexOf Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2492 /* JavaScript FTW: Ruby Blocks {{{ */
2493 RubyProcParameterList_
2494 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2498 RubyProcParameterList
2499 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2500 | LexOf { $$ = NULL; }
2504 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2505 | "||" { $$ = NULL; }
2508 RubyProcParametersOpt
2509 : RubyProcParameters[pass] { $$ = $pass; }
2514 : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2518 : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2522 : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLineOrOpt { $$ = CYNew CYRubyBlock($lhs, $rhs); }
2528 bool CYDriver::Parse(CYMark mark) {
2530 CYLocal<CYPool> local(&pool_);
2531 cy::parser parser(*this);
2533 parser.set_debug_level(debug_);
2535 return parser.parse() != 0;
2538 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2542 CYDriver::Error error;
2543 error.warning_ = true;
2544 error.location_ = location;
2545 error.message_ = message;
2546 errors_.push_back(error);
2549 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2550 CYDriver::Error error;
2551 error.warning_ = false;
2552 error.location_ = location;
2553 error.message_ = message;
2554 driver.errors_.push_back(error);