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 { CYBoolean *boolean_; }
49 %union { CYClause *clause_; }
50 %union { cy::Syntax::Catch *catch_; }
51 %union { CYClassTail *classTail_; }
52 %union { CYComprehension *comprehension_; }
53 %union { CYDeclaration *declaration_; }
54 %union { CYDeclarations *declarations_; }
55 %union { CYElement *element_; }
56 %union { CYExpression *expression_; }
57 %union { CYFalse *false_; }
58 %union { CYVariable *variable_; }
59 %union { CYFinally *finally_; }
60 %union { CYForInitializer *for_; }
61 %union { CYForInInitializer *forin_; }
62 %union { CYFunctionParameter *functionParameter_; }
63 %union { CYIdentifier *identifier_; }
64 %union { CYInfix *infix_; }
65 %union { CYLiteral *literal_; }
66 %union { CYMethod *method_; }
67 %union { CYModule *module_; }
68 %union { CYNull *null_; }
69 %union { CYNumber *number_; }
70 %union { CYParenthetical *parenthetical_; }
71 %union { CYProperty *property_; }
72 %union { CYPropertyName *propertyName_; }
73 %union { CYRubyProc *rubyProc_; }
74 %union { CYSpan *span_; }
75 %union { CYStatement *statement_; }
76 %union { CYString *string_; }
77 %union { CYTarget *target_; }
78 %union { CYThis *this_; }
79 %union { CYTrue *true_; }
80 %union { CYWord *word_; }
83 %union { CYTypeModifier *modifier_; }
84 %union { CYTypeSpecifier *specifier_; }
85 %union { CYTypedIdentifier *typedIdentifier_; }
86 %union { CYTypedParameter *typedParameter_; }
90 %union { CYMessage *message_; }
91 %union { CYMessageParameter *messageParameter_; }
92 %union { CYImplementationField *implementationField_; }
93 %union { CYProtocol *protocol_; }
94 %union { CYSelectorPart *selector_; }
98 %union { CYAttribute *attribute_; }
99 %union { CYPropertyIdentifier *propertyIdentifier_; }
100 %union { CYSelector *selector_; }
106 cy::parser::semantic_type semantic_;
107 hi::Value highlight_;
110 int cylex(YYSTYPE *, CYLocation *, void *);
116 typedef cy::parser::token tk;
119 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
120 if (driver.mark_ == CYMarkIgnore);
121 else if (driver.mark_ == CYMarkScript) {
122 driver.mark_ = CYMarkIgnore;
123 return cy::parser::token::MarkScript;
124 } else if (driver.mark_ == CYMarkModule) {
125 driver.mark_ = CYMarkIgnore;
126 return cy::parser::token::MarkModule;
130 if (driver.newline_ == CYDriver::NewLineHere)
131 driver.newline_ = CYDriver::NewLineLast;
132 else if (driver.newline_ == CYDriver::NewLineLast)
133 driver.newline_ = CYDriver::NewLineNone;
136 int token(cylex(&data, location, driver.scanner_));
137 *semantic = data.semantic_;
141 case tk::OpenBracket:
143 driver.in_.push(false);
147 if (driver.in_.top())
152 case tk::CloseBracket:
159 if (driver.yield_.top())
160 token = tk::_yield__;
164 driver.newline_ = CYDriver::NewLineHere;
170 driver.next_ = false;
174 #define CYLEX() do if (yyla.empty()) { \
175 YYCDEBUG << "Mapping a token: "; \
176 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
177 YY_SYMBOL_PRINT("Next token is", yyla); \
180 #define CYMAP(to, from) do { \
182 if (yyla.type == yytranslate_(token::from)) \
183 yyla.type = yytranslate_(token::to); \
186 #define CYLIN(from) do { \
188 if (yyla.type == yytranslate_(token::from) && driver.newline_ == CYDriver::NewLineLast) \
189 yyla.type = yytranslate_(token::from ## _); \
192 #define CYERR(location, message) do { \
193 error(location, message); \
197 #define CYEOK() do { \
199 driver.errors_.pop_back(); \
202 #define CYNOT(location) \
203 CYERR(location, "unimplemented feature")
205 #define CYMPT(location) do { \
206 if (!yyla.empty() && yyla.type_get() != yyeof_) \
207 CYERR(location, "unexpected lookahead"); \
217 @$.begin.filename = @$.end.filename = &driver.filename_;
223 %define api.location.type { CYLocation }
230 %param { CYDriver &driver }
232 /* Token Declarations {{{ */
238 %token XMLAttributeValue
240 %token XMLTagCharacters
246 %token LeftRight "<>"
247 %token LeftSlashRight "</>"
249 %token SlashRight "/>"
250 %token LeftSlash "</"
252 %token ColonColon "::"
253 %token PeriodPeriod ".."
256 @begin E4X ObjectiveC
262 %token AmpersandAmpersand "&&"
263 %token AmpersandEqual "&="
265 %token CarrotEqual "^="
267 %token EqualEqual "=="
268 %token EqualEqualEqual "==="
269 %token EqualRight "=>"
270 %token EqualRight_ "\n=>"
271 %token Exclamation "!"
272 %token ExclamationEqual "!="
273 %token ExclamationEqualEqual "!=="
275 %token HyphenEqual "-="
276 %token HyphenHyphen "--"
277 %token HyphenHyphen_ "\n--"
278 %token HyphenRight "->"
280 %token LeftEqual "<="
282 %token LeftLeftEqual "<<="
284 %token PercentEqual "%="
286 %token PeriodPeriodPeriod "..."
288 %token PipeEqual "|="
291 %token PlusEqual "+="
293 %token PlusPlus_ "\n++"
295 %token RightEqual ">="
296 %token RightRight ">>"
297 %token RightRightEqual ">>="
298 %token RightRightRight ">>>"
299 %token RightRightRightEqual ">>>="
301 %token SlashEqual "/="
303 %token StarEqual "*="
315 %token CloseParen ")"
318 %token OpenBrace_ "\n{"
319 %token OpenBrace__ ";{"
320 %token OpenBrace_let "let {"
321 %token CloseBrace "}"
323 %token OpenBracket "["
324 %token OpenBracket_let "let ["
325 %token CloseBracket "]"
327 %token At_error_ "@error"
330 %token At_class_ "@class"
334 %token _typedef_ "typedef"
335 %token _unsigned_ "unsigned"
336 %token _signed_ "signed"
337 %token _extern_ "extern"
341 %token At_encode_ "@encode"
345 %token At_implementation_ "@implementation"
346 %token At_import_ "@import"
347 %token At_end_ "@end"
348 %token At_selector_ "@selector"
349 %token At_null_ "@null"
350 %token At_YES_ "@YES"
352 %token At_true_ "@true"
353 %token At_false_ "@false"
358 %token _false_ "false"
362 %token _break_ "break"
364 %token _catch_ "catch"
365 %token _class_ "class"
366 %token _class__ ";class"
367 %token _const_ "const"
368 %token _continue_ "continue"
369 %token _debugger_ "debugger"
370 %token _default_ "default"
371 %token _delete_ "delete"
375 %token _export_ "export"
376 %token _extends_ "extends"
377 %token _finally_ "finally"
379 %token _function_ "function"
380 %token _function__ ";function"
382 %token _import_ "import"
385 %token _Infinity_ "Infinity"
386 %token _instanceof_ "instanceof"
388 %token _return_ "return"
389 %token _super_ "super"
390 %token _switch_ "switch"
391 %token _target_ "target"
393 %token _throw_ "throw"
395 %token _typeof_ "typeof"
398 %token _while_ "while"
401 %token _abstract_ "abstract"
402 %token _await_ "await"
403 %token _boolean_ "boolean"
406 %token _constructor_ "constructor"
407 %token _double_ "double"
409 %token _final_ "final"
410 %token _float_ "float"
414 %token _implements_ "implements"
416 %token _interface_ "interface"
420 %token _native_ "native"
421 %token _package_ "package"
422 %token _private_ "private"
423 %token _protected_ "protected"
424 %token _prototype_ "prototype"
425 %token _public_ "public"
427 %token _short_ "short"
428 %token _static_ "static"
429 %token _synchronized_ "synchronized"
430 %token _throws_ "throws"
431 %token _transient_ "transient"
432 %token _volatile_ "volatile"
433 %token _yield_ "yield"
434 %token _yield__ "!yield"
436 %token _undefined_ "undefined"
453 %token _namespace_ "namespace"
460 %token <identifier_> Identifier_
461 %token <number_> NumericLiteral
462 %token <string_> StringLiteral
463 %token <literal_> RegularExpressionLiteral_
465 %token <string_> NoSubstitutionTemplate
466 %token <string_> TemplateHead
467 %token <string_> TemplateMiddle
468 %token <string_> TemplateTail
470 %type <target_> AccessExpression
471 %type <expression_> AdditiveExpression
472 %type <argument_> ArgumentList_
473 %type <argument_> ArgumentList
474 %type <argument_> ArgumentListOpt
475 %type <argument_> Arguments
476 %type <target_> ArrayComprehension
477 %type <literal_> ArrayLiteral
478 %type <expression_> ArrowFunction
479 %type <functionParameter_> ArrowParameters
480 %type <expression_> AssignmentExpression
481 %type <expression_> AssignmentExpressionOpt
482 %type <identifier_> BindingIdentifier
483 %type <identifier_> BindingIdentifierOpt
484 %type <declarations_> BindingList_
485 %type <declarations_> BindingList
486 %type <expression_> BitwiseANDExpression
487 %type <statement_> Block
488 %type <statement_> BlockStatement
489 %type <boolean_> BooleanLiteral
490 %type <declaration_> BindingElement
491 %type <expression_> BitwiseORExpression
492 %type <expression_> BitwiseXORExpression
493 %type <statement_> BreakStatement
494 %type <statement_> BreakableStatement
495 %type <expression_> CallExpression_
496 %type <target_> CallExpression
497 %type <clause_> CaseBlock
498 %type <clause_> CaseClause
499 %type <clause_> CaseClausesOpt
501 %type <identifier_> CatchParameter
502 %type <statement_> ClassDeclaration
503 %type <target_> ClassExpression
504 %type <classTail_> ClassHeritage
505 %type <classTail_> ClassHeritageOpt
506 %type <classTail_> ClassTail
507 %type <target_> Comprehension
508 %type <comprehension_> ComprehensionFor
509 %type <comprehension_> ComprehensionIf
510 %type <comprehension_> ComprehensionTail
511 %type <propertyName_> ComputedPropertyName
512 %type <expression_> ConditionalExpression
513 %type <statement_> ContinueStatement
514 %type <statement_> ConciseBody
515 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
516 %type <statement_> DebuggerStatement
517 %type <statement_> Declaration__
518 %type <statement_> Declaration_
519 %type <statement_> Declaration
520 %type <clause_> DefaultClause
521 %type <element_> ElementList
522 %type <element_> ElementListOpt
523 %type <statement_> ElseStatementOpt
524 %type <for_> EmptyStatement
525 %type <expression_> EqualityExpression
526 %type <expression_> Expression
527 %type <expression_> ExpressionOpt
528 %type <for_> ExpressionStatement_
529 %type <statement_> ExpressionStatement
530 %type <finally_> Finally
531 %type <declaration_> ForBinding
532 %type <forin_> ForDeclaration
533 %type <forin_> ForInStatementInitializer
534 %type <for_> ForStatementInitializer
535 %type <declaration_> FormalParameter
536 %type <functionParameter_> FormalParameterList_
537 %type <functionParameter_> FormalParameterList
538 %type <functionParameter_> FormalParameters
539 %type <statement_> FunctionBody
540 %type <statement_> FunctionDeclaration
541 %type <target_> FunctionExpression
542 %type <statement_> FunctionStatementList
543 %type <statement_> GeneratorBody
544 %type <statement_> GeneratorDeclaration
545 %type <target_> GeneratorExpression
546 %type <method_> GeneratorMethod
547 %type <statement_> HoistableDeclaration
548 %type <identifier_> Identifier
549 %type <identifier_> IdentifierType
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 <declaration_> 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 <declaration_> 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 <declaration_> 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 <declaration_> VariableDeclaration
617 %type <declarations_> VariableDeclarationList_
618 %type <declarations_> 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 <typedIdentifier_> SuffixedType
634 %type <typedIdentifier_> TypeSignifier
635 %type <modifier_> TypeQualifierLeft
636 %type <typedIdentifier_> TypeQualifierRight
637 %type <typedIdentifier_> TypedIdentifier
638 %type <typedParameter_> TypedParameterList_
639 %type <typedParameter_> TypedParameterList
640 %type <typedParameter_> TypedParameterListOpt
644 %type <expression_> AssignmentExpressionClassic
645 %type <expression_> BoxableExpression
646 %type <statement_> CategoryStatement
647 %type <expression_> ClassSuperOpt
648 %type <expression_> ConditionalExpressionClassic
649 %type <implementationField_> ImplementationFieldListOpt
650 %type <implementationField_> ImplementationFields
651 %type <message_> ClassMessageDeclaration
652 %type <message_> ClassMessageDeclarationListOpt
653 %type <protocol_> ClassProtocolListOpt
654 %type <protocol_> ClassProtocols
655 %type <protocol_> ClassProtocolsOpt
656 %type <statement_> ImplementationStatement
657 %type <target_> MessageExpression
658 %type <messageParameter_> MessageParameter
659 %type <messageParameter_> MessageParameters
660 %type <messageParameter_> MessageParameterList
661 %type <messageParameter_> MessageParameterListOpt
662 %type <bool_> MessageScope
663 %type <argument_> SelectorCall_
664 %type <argument_> SelectorCall
665 %type <selector_> SelectorExpression_
666 %type <selector_> SelectorExpression
667 %type <selector_> SelectorExpressionOpt
668 %type <argument_> SelectorList
669 %type <word_> SelectorWordOpt
670 %type <typedIdentifier_> TypeOpt
671 %type <argument_> VariadicCall
675 %type <propertyIdentifier_> PropertyIdentifier_
676 %type <selector_> PropertySelector_
677 %type <selector_> PropertySelector
678 %type <identifier_> QualifiedIdentifier_
679 %type <identifier_> QualifiedIdentifier
680 %type <identifier_> WildcardIdentifier
681 %type <identifier_> XMLComment
682 %type <identifier_> XMLCDATA
683 %type <identifier_> XMLElement
684 %type <identifier_> XMLElementContent
685 %type <identifier_> XMLMarkup
686 %type <identifier_> XMLPI
688 %type <attribute_> AttributeIdentifier
689 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
690 %type <expression_> PropertyIdentifier
691 %type <expression_> XMLListInitialiser
692 %type <expression_> XMLInitialiser
695 /* Token Priorities {{{ */
711 /* Lexer State {{{ */
712 LexPushInOn: { driver.in_.push(true); };
713 LexPushInOff: { driver.in_.push(false); };
714 LexPopIn: { driver.in_.pop(); };
716 LexPushReturnOn: { driver.return_.push(true); };
717 LexPopReturn: { driver.return_.pop(); };
719 LexPushSuperOn: { driver.super_.push(true); };
720 LexPushSuperOff: { driver.super_.push(false); };
721 LexPopSuper: { driver.super_.pop(); };
723 LexPushYieldOn: { driver.yield_.push(true); };
724 LexPushYieldOff: { driver.yield_.push(false); };
725 LexPopYield: { driver.yield_.pop(); };
728 : { CYMAP(_of__, _of_); }
736 : { CYMPT(@$); driver.next_ = true; }
740 : { CYMAP(YieldStar, Star); }
744 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
748 : { CYMAP(_class__, _class_); }
752 : { CYMAP(_function__, _function_); }
756 : LexNoBrace LexNoClass LexNoFunction
759 /* Virtual Tokens {{{ */
770 /* 11.6 Names and Keywords {{{ */
773 | "for" { $$ = CYNew CYWord("for"); }
774 | "in" { $$ = CYNew CYWord("in"); }
775 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
784 : Identifier { $$ = $1; }
785 | "auto" { $$ = CYNew CYWord("auto"); }
786 | "break" { $$ = CYNew CYWord("break"); }
787 | "case" { $$ = CYNew CYWord("case"); }
788 | "catch" { $$ = CYNew CYWord("catch"); }
789 | "class" { $$ = CYNew CYWord("class"); }
790 | ";class" { $$ = CYNew CYWord("class"); }
791 | "const" { $$ = CYNew CYWord("const"); }
792 | "continue" { $$ = CYNew CYWord("continue"); }
793 | "debugger" { $$ = CYNew CYWord("debugger"); }
794 | "default" { $$ = CYNew CYWord("default"); }
795 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
796 | "do" { $$ = CYNew CYWord("do"); }
797 | "else" { $$ = CYNew CYWord("else"); }
798 | "enum" { $$ = CYNew CYWord("enum"); }
799 | "export" { $$ = CYNew CYWord("export"); }
800 | "extends" { $$ = CYNew CYWord("extends"); }
801 | "false" { $$ = CYNew CYWord("false"); }
802 | "finally" { $$ = CYNew CYWord("finally"); }
803 | "function" { $$ = CYNew CYWord("function"); }
804 | "if" { $$ = CYNew CYWord("if"); }
805 | "import" { $$ = CYNew CYWord("import"); }
806 | "!in" { $$ = CYNew CYWord("in"); }
807 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
808 | "null" { $$ = CYNew CYWord("null"); }
809 | "return" { $$ = CYNew CYWord("return"); }
810 | "super" { $$ = CYNew CYWord("super"); }
811 | "switch" { $$ = CYNew CYWord("switch"); }
812 | "this" { $$ = CYNew CYWord("this"); }
813 | "throw" { $$ = CYNew CYWord("throw"); }
814 | "true" { $$ = CYNew CYWord("true"); }
815 | "try" { $$ = CYNew CYWord("try"); }
816 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
817 | "var" { $$ = CYNew CYWord("var"); }
818 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
819 | "while" { $$ = CYNew CYWord("while"); }
820 | "with" { $$ = CYNew CYWord("with"); }
821 | "yield" { $$ = CYNew CYIdentifier("yield"); }
823 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
833 /* 11.8.1 Null Literals {{{ */
835 : "null" { $$ = CYNew CYNull(); }
838 /* 11.8.2 Boolean Literals {{{ */
840 : "true" { $$ = CYNew CYTrue(); }
841 | "false" { $$ = CYNew CYFalse(); }
844 /* 11.8.5 Regular Expression Literals {{{ */
845 RegularExpressionSlash
846 : "/" { $$ = false; }
847 | "/=" { $$ = true; }
850 RegularExpressionLiteral
851 : RegularExpressionSlash { CYMPT(@$); driver.SetRegEx($1); } RegularExpressionLiteral_ { $$ = $3; }
855 /* 11.9 Automatic Semicolon Insertion {{{ */
857 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
867 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) CYERR(@1, "required semi-colon"); else CYEOK(); } StrictSemi
872 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
876 /* 12.1 Identifiers {{{ */
878 : Identifier { $$ = CYNew CYVariable($1); }
879 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
883 : Identifier { $$ = $1; }
884 | "yield" { $$ = CYNew CYIdentifier("yield"); }
888 : BindingIdentifier { $$ = $1; }
893 : Identifier { $$ = $1; }
894 | "yield" { $$ = CYNew CYIdentifier("yield"); }
898 : Identifier_ { $$ = $1; }
899 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
900 | "await" { $$ = CYNew CYIdentifier("await"); }
901 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
902 | "byte" { $$ = CYNew CYIdentifier("byte"); }
903 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
904 | "double" { $$ = CYNew CYIdentifier("double"); }
905 | "each" { $$ = CYNew CYIdentifier("each"); }
906 | "eval" { $$ = CYNew CYIdentifier("eval"); }
907 | "final" { $$ = CYNew CYIdentifier("final"); }
908 | "float" { $$ = CYNew CYIdentifier("float"); }
909 | "from" { $$ = CYNew CYIdentifier("from"); }
910 | "get" { $$ = CYNew CYIdentifier("get"); }
911 | "goto" { $$ = CYNew CYIdentifier("goto"); }
912 | "implements" { $$ = CYNew CYIdentifier("implements"); }
913 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
914 | "interface" { $$ = CYNew CYIdentifier("interface"); }
915 | "let" { $$ = CYNew CYIdentifier("let"); }
916 | "!let" LexBind { $$ = CYNew CYIdentifier("let"); }
917 | "native" { $$ = CYNew CYIdentifier("native"); }
918 | "!of" { $$ = CYNew CYIdentifier("of"); }
919 | "package" { $$ = CYNew CYIdentifier("package"); }
920 | "private" { $$ = CYNew CYIdentifier("private"); }
921 | "protected" { $$ = CYNew CYIdentifier("protected"); }
922 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
923 | "public" { $$ = CYNew CYIdentifier("public"); }
924 | "set" { $$ = CYNew CYIdentifier("set"); }
925 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
926 | "target" { $$ = CYNew CYIdentifier("target"); }
927 | "throws" { $$ = CYNew CYIdentifier("throws"); }
928 | "transient" { $$ = CYNew CYIdentifier("transient"); }
929 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
931 | "bool" { $$ = CYNew CYIdentifier("bool"); }
932 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
933 | "id" { $$ = CYNew CYIdentifier("id"); }
934 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
940 | "char" { $$ = CYNew CYIdentifier("char"); }
941 | "int" { $$ = CYNew CYIdentifier("int"); }
942 | "long" { $$ = CYNew CYIdentifier("long"); }
943 | "short" { $$ = CYNew CYIdentifier("short"); }
944 | "static" { $$ = CYNew CYIdentifier("static"); }
945 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
947 | "extern" { $$ = CYNew CYIdentifier("extern"); }
948 | "signed" { $$ = CYNew CYIdentifier("signed"); }
949 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
950 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
953 | "nil" { $$ = CYNew CYIdentifier("nil"); }
954 | "NO" { $$ = CYNew CYIdentifier("NO"); }
955 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
956 | "YES" { $$ = CYNew CYIdentifier("YES"); }
960 /* 12.2 Primary Expression {{{ */
962 : "this" { $$ = CYNew CYThis(); }
963 | IdentifierReference { $$ = $1; }
964 | Literal { $$ = $1; }
965 | ArrayLiteral { $$ = $1; }
966 | ObjectLiteral { $$ = $1; }
967 | FunctionExpression { $$ = $1; }
968 | ClassExpression { $$ = $1; }
969 | GeneratorExpression { $$ = $1; }
970 | RegularExpressionLiteral { $$ = $1; }
971 | TemplateLiteral { $$ = $1; }
972 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
973 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
976 CoverParenthesizedExpressionAndArrowParameterList
977 : "(" Expression ")" { $$ = CYNew CYParenthetical($2); }
978 | "(" LexSetRegExp ")" { $$ = NULL; }
979 | "(" LexSetRegExp "..." BindingIdentifier ")" { CYNOT(@$); }
980 | "(" Expression "," LexSetRegExp "..." BindingIdentifier ")" { CYNOT(@$); }
983 /* 12.2.4 Literals {{{ */
985 : NullLiteral { $$ = $1; }
986 | BooleanLiteral { $$ = $1; }
987 | NumericLiteral { $$ = $1; }
988 | StringLiteral { $$ = $1; }
991 /* 12.2.5 Array Initializer {{{ */
993 : "[" ElementListOpt "]" { $$ = CYNew CYArray($2); }
997 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
998 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
999 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
1003 : ElementList { $$ = $1; }
1004 | LexSetRegExp { $$ = NULL; }
1007 /* 12.2.6 Object Initializer {{{ */
1009 : BRACE PropertyDefinitionListOpt "}" { $$ = CYNew CYObject($2); }
1012 PropertyDefinitionList_
1013 : "," PropertyDefinitionListOpt { $$ = $2; }
1017 PropertyDefinitionList
1018 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
1021 PropertyDefinitionListOpt
1022 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
1023 | LexSetRegExp { $$ = NULL; }
1027 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
1028 | CoverInitializedName { CYNOT(@$); }
1029 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
1030 | MethodDefinition { $$ = $1; }
1034 : LiteralPropertyName { $$ = $1; }
1035 | ComputedPropertyName { $$ = $1; }
1039 : IdentifierName { $$ = $1; }
1040 | StringLiteral { $$ = $1; }
1041 | NumericLiteral { $$ = $1; }
1044 ComputedPropertyName
1045 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
1048 CoverInitializedName
1049 : IdentifierReference Initializer
1053 : "=" AssignmentExpression { $$ = $2; }
1057 : Initializer { $$ = $1; }
1061 /* 12.2.9 Template Literals {{{ */
1063 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
1064 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
1068 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
1069 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
1073 /* 12.3 Left-Hand-Side Expressions {{{ */
1075 : "[" Expression "]" { $$ = CYNew CYDirectMember(NULL, $2); }
1076 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1077 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1078 | TemplateLiteral { CYNOT(@$); }
1082 : LexSetRegExp PrimaryExpression { $$ = $2; }
1083 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1084 | SuperProperty { $$ = $1; }
1085 | MetaProperty { CYNOT(@$); }
1086 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1090 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
1091 | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
1099 : LexSetRegExp "new" LexSetRegExp "." "target"
1103 : MemberExpression { $$ = $1; }
1104 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1108 : MemberExpression { $$ = $1; }
1109 | CallExpression { $$ = $1; }
1113 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1114 | SuperCall { $$ = $1; }
1115 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1119 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
1123 : "(" ArgumentListOpt ")" { $$ = $2; }
1127 : "," ArgumentList { $$ = $2; }
1132 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1133 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1137 : ArgumentList { $$ = $1; }
1138 | LexSetRegExp { $$ = NULL; }
1142 : NewExpression { $$ = $1; }
1143 | CallExpression { $$ = $1; }
1146 LeftHandSideExpression
1147 : AccessExpression LexCrement { $$ = $1; }
1148 | LexSetRegExp IndirectExpression { $$ = $2; }
1151 /* 12.4 Postfix Expressions {{{ */
1153 : { CYLIN(PlusPlus); CYLIN(HyphenHyphen); }
1157 : AccessExpression LexCrement { $$ = $1; }
1158 | AccessExpression LexCrement "++" { $$ = CYNew CYPostIncrement($1); }
1159 | AccessExpression LexCrement "--" { $$ = CYNew CYPostDecrement($1); }
1162 /* 12.5 Unary Operators {{{ */
1164 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1165 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1166 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1167 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1168 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1169 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1170 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1171 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1172 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1173 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1174 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1178 : PostfixExpression LexOpenBrace { $$ = $1; }
1179 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1182 /* 12.6 Multiplicative Operators {{{ */
1183 MultiplicativeExpression
1184 : UnaryExpression { $$ = $1; }
1185 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1186 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1187 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1190 /* 12.7 Additive Operators {{{ */
1192 : MultiplicativeExpression { $$ = $1; }
1193 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1194 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1197 /* 12.8 Bitwise Shift Operators {{{ */
1199 : AdditiveExpression { $$ = $1; }
1200 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1201 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1202 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1205 /* 12.9 Relational Operators {{{ */
1206 RelationalExpression
1207 : ShiftExpression { $$ = $1; }
1208 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1209 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1210 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1211 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1212 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1213 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1216 /* 12.10 Equality Operators {{{ */
1218 : RelationalExpression { $$ = $1; }
1219 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1220 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1221 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1222 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1225 /* 12.11 Binary Bitwise Operators {{{ */
1226 BitwiseANDExpression
1227 : EqualityExpression { $$ = $1; }
1228 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1231 BitwiseXORExpression
1232 : BitwiseANDExpression { $$ = $1; }
1233 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1237 : BitwiseXORExpression { $$ = $1; }
1238 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1241 /* 12.12 Binary Logical Operators {{{ */
1242 LogicalANDExpression
1243 : BitwiseORExpression { $$ = $1; }
1244 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1248 : LogicalANDExpression { $$ = $1; }
1249 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1252 /* 12.13 Conditional Operator ( ? : ) {{{ */
1254 ConditionalExpressionClassic
1255 : LogicalORExpression { $$ = $1; }
1256 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
1260 ConditionalExpression
1261 : LogicalORExpression { $$ = $1; }
1262 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1265 /* 12.14 Assignment Operators {{{ */
1266 LeftHandSideAssignment
1267 : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
1268 | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
1269 | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
1270 | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
1271 | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
1272 | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
1273 | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
1274 | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
1275 | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
1276 | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
1277 | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
1278 | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
1282 AssignmentExpressionClassic
1283 : ConditionalExpressionClassic { $$ = $1; }
1284 | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
1288 AssignmentExpression
1289 : ConditionalExpression { $$ = $1; }
1290 | LexSetRegExp YieldExpression { $$ = $2; }
1291 | ArrowFunction { $$ = $1; }
1292 | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
1295 AssignmentExpressionOpt
1296 : AssignmentExpression { $$ = $1; }
1297 | LexSetRegExp { $$ = NULL; }
1300 /* 12.15 Comma Operator ( , ) {{{ */
1302 : AssignmentExpression { $$ = $1; }
1303 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1307 : Expression { $$ = $1; }
1308 | LexSetRegExp { $$ = NULL; }
1312 /* 13 Statements and Declarations {{{ */
1314 : BlockStatement { $$ = $1; }
1315 | VariableStatement { $$ = $1; }
1316 | EmptyStatement { $$ = $1; }
1317 | IfStatement { $$ = $1; }
1318 | BreakableStatement { $$ = $1; }
1319 | ContinueStatement { $$ = $1; }
1320 | BreakStatement { $$ = $1; }
1321 | ReturnStatement { $$ = $1; }
1322 | WithStatement { $$ = $1; }
1323 | LabelledStatement { $$ = $1; }
1324 | ThrowStatement { $$ = $1; }
1325 | TryStatement { $$ = $1; }
1326 | DebuggerStatement { $$ = $1; }
1330 : LexSetRegExp Statement__ { $$ = $2; }
1331 | ExpressionStatement { $$ = $1; }
1335 : LexSetStatement LexLet Statement_ { $$ = $3; }
1339 : HoistableDeclaration { $$ = $1; }
1340 | ClassDeclaration { $$ = $1; }
1344 : LexLet LexSetRegExp Declaration__ { $$ = $3; }
1345 | LexicalDeclaration { $$ = $1; }
1349 : LexSetStatement Declaration_ { $$ = $2; }
1352 HoistableDeclaration
1353 : FunctionDeclaration { $$ = $1; }
1354 | GeneratorDeclaration { $$ = $1; }
1358 : IterationStatement { $$ = $1; }
1359 | SwitchStatement { $$ = $1; }
1362 /* 13.2 Block {{{ */
1364 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1368 : BRACE StatementListOpt "}" { $$ = $2; }
1372 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1376 : StatementList { $$ = $1; }
1377 | LexSetStatement LexLet LexSetRegExp { $$ = NULL; }
1381 : Statement { $$ = $1; }
1382 | Declaration { $$ = $1; }
1385 /* 13.3 Let and Const Declarations {{{ */
1387 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1391 : LexicalDeclaration_ Terminator { $$ = $1; }
1395 : { CYMAP(_let__, _let_); }
1399 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); } LexOf
1403 : LexLet LexSetRegExp "!let" LexBind { $$ = false; }
1404 | LexLet LexSetRegExp "const" { $$ = true; }
1408 : "," LexBind BindingList { $$ = $3; }
1413 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1417 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1418 | BindingPattern Initializer { CYNOT(@1); }
1421 /* 13.3.2 Variable Statement {{{ */
1423 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1427 : VariableStatement_ Terminator { $$ = $1; }
1430 VariableDeclarationList_
1431 : "," VariableDeclarationList { $$ = $2; }
1435 VariableDeclarationList
1436 : LexBind VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($2, $3); }
1440 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1441 | BindingPattern Initializer { CYNOT(@1); }
1444 /* 13.3.3 Destructuring Binding Patterns {{{ */
1446 : ObjectBindingPattern
1447 | ArrayBindingPattern
1450 ObjectBindingPattern
1451 : "let {" BindingPropertyListOpt "}"
1455 : "let [" { CYNOT(@$); }
1458 BindingPropertyList_
1459 : "," BindingPropertyListOpt
1464 : BindingProperty BindingPropertyList_
1467 BindingPropertyListOpt
1468 : BindingPropertyList
1474 | PropertyName ":" BindingElement
1478 : LexBind SingleNameBinding { $$ = $2; }
1479 | LexBind BindingPattern InitializerOpt { CYNOT(@$); }
1483 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1487 : "..." BindingIdentifier
1490 /* 13.4 Empty Statement {{{ */
1492 : ";" { $$ = CYNew CYEmpty(); }
1495 /* 13.5 Expression Statement {{{ */
1496 ExpressionStatement_
1497 : Expression { $$ = CYNew CYExpress($1); }
1500 : ExpressionStatement_ Terminator { $$ = $1; }
1503 /* 13.6 The if Statement {{{ */
1505 : "else" Statement { $$ = $2; }
1506 | %prec "if" { $$ = NULL; }
1510 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1513 /* 13.7 Iteration Statements {{{ */
1515 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1516 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1517 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1518 | "for" "(" LexPushInOn LexLet LexSetRegExp Var_ LexBind BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($8, $9), $12, $14); }
1519 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1520 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1523 ForStatementInitializer
1524 : LexLet LexSetRegExp EmptyStatement { $$ = $3; }
1525 | LexLet ExpressionStatement_ ";" { $$ = $2; }
1526 | LexLet LexSetRegExp VariableStatement_ ";" { $$ = $3; }
1527 | LexicalDeclaration_ ";" { $$ = $1; }
1530 ForInStatementInitializer
1531 : LexLet AccessExpression LexCrement { $$ = $2; }
1532 | LexLet LexSetRegExp IndirectExpression { $$ = $3; }
1533 | LexLet LexSetRegExp Var_ LexBind ForBinding { $$ = CYNew CYForVariable($5); }
1534 | ForDeclaration { $$ = $1; }
1538 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1542 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1543 | BindingPattern { CYNOT(@1); }
1546 /* 13.8 The continue Statement {{{ */
1548 : "continue" LexNewLine
1552 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1553 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1556 /* 13.9 The break Statement {{{ */
1558 : "break" LexNewLine
1562 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1563 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1566 /* 13.10 The return Statement {{{ */
1568 : "return" { if (!driver.return_.top()) CYERR(@1, "invalid return"); } LexNewLine
1572 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1573 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1576 /* 13.11 The with Statement {{{ */
1578 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1581 /* 13.12 The switch Statement {{{ */
1583 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1587 : BRACE CaseClausesOpt "}" { $$ = $2; }
1591 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1595 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1596 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1600 // XXX: the standard makes certain you can only have one of these
1602 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1605 /* 13.13 Labelled Statements {{{ */
1607 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1611 : Statement { $$ = $1; }
1612 | LexSetStatement LexLet LexSetRegExp FunctionDeclaration { $$ = $4; }
1615 /* 13.14 The throw Statement {{{ */
1617 : "throw" LexNewLine
1621 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1622 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1625 /* 13.15 The try Statement {{{ */
1627 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1628 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1629 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1633 : "catch" "(" LexBind CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($4, $6); }
1637 : "finally" Block { $$ = CYNew CYFinally($2); }
1641 : BindingIdentifier { $$ = $1; }
1642 | BindingPattern { CYNOT(@$); }
1645 /* 13.16 The debugger Statement {{{ */
1647 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1651 /* 14.1 Function Definitions {{{ */
1653 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1657 : "function" BindingIdentifierOpt "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionExpression($2, $4, $8); }
1660 StrictFormalParameters
1661 : FormalParameters { $$ = $1; }
1665 : LexBind { $$ = NULL; }
1666 | FormalParameterList
1669 FormalParameterList_
1670 : "," FormalParameterList { $$ = $2; }
1675 : LexBind FunctionRestParameter { CYNOT(@$); }
1676 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1679 FunctionRestParameter
1680 : BindingRestElement
1684 : BindingElement { $$ = $1; }
1688 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1691 FunctionStatementList
1692 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1695 /* 14.2 Arrow Function Definitions {{{ */
1697 : { CYLIN(EqualRight); }
1701 : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); }
1705 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1706 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1710 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1711 | LexSetRegExp ";{" FunctionBody "}" { $$ = $3; }
1714 /* 14.3 Method Definitions {{{ */
1716 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1717 | GeneratorMethod { $$ = $1; }
1718 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1719 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1722 PropertySetParameterList
1723 : FormalParameter { $$ = $1; }
1726 /* 14.4 Generator Function Definitions {{{ */
1728 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1731 GeneratorDeclaration
1732 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1736 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1740 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1744 : "!yield" LexNewLine LexNoStar
1748 : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1749 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1750 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1753 /* 14.5 Class Definitions {{{ */
1755 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1759 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1763 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1767 : "extends" AccessExpression { $$ = CYNew CYClassTail($2); }
1771 : ClassHeritage { $$ = $1; }
1772 | { $$ = CYNew CYClassTail(NULL); }
1785 : ClassElementListOpt ClassElement
1794 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1795 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1800 /* 15.1 Scripts {{{ */
1802 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1806 : StatementList { $$ = $1; }
1810 : ScriptBody { $$ = $1; }
1811 | LexSetStatement LexLet LexSetRegExp { $$ = NULL; }
1814 /* 15.2 Modules {{{ */
1829 : ModuleItemListOpt ModuleItem
1838 : LexSetStatement LexLet LexSetRegExp ImportDeclaration
1839 | LexSetStatement LexLet LexSetRegExp ExportDeclaration
1843 /* 15.2.2 Imports {{{ */
1845 : "import" ImportClause FromClause Terminator
1846 | "import" ModuleSpecifier Terminator
1850 : ImportedDefaultBinding
1853 | ImportedDefaultBinding "," NameSpaceImport
1854 | ImportedDefaultBinding "," NamedImports
1857 ImportedDefaultBinding
1862 : "*" "as" ImportedBinding
1866 : BRACE ImportsListOpt "}"
1870 : "from" ModuleSpecifier
1874 : "," ImportsListOpt
1879 : ImportSpecifier ImportsList_
1889 | IdentifierName "as" ImportedBinding
1900 /* 15.2.3 Exports {{{ */
1902 : "*" FromClause Terminator
1903 | ExportClause FromClause Terminator
1904 | ExportClause Terminator
1906 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1907 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1908 | "default" LexSetStatement AssignmentExpression Terminator
1912 : "export" LexSetStatement LexLet LexSetRegExp ExportDeclaration_
1913 | "export" Declaration
1917 : ";{" ExportsListOpt "}"
1921 : "," ExportsListOpt
1926 : ExportSpecifier ExportsList_
1936 | IdentifierName "as" IdentifierName
1941 /* Cycript (C): Type Encoding {{{ */
1943 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1944 | "(" "*" TypeQualifierRight ")" { $$ = $3; }
1948 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1949 | "(" "^" TypeQualifierRight ")" "(" TypedParameterListOpt ")" { $$ = $3; $$->modifier_ = CYNew CYTypeBlockWith($6, $$->modifier_); }
1950 | TypeSignifier "(" TypedParameterListOpt ")" { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1951 | "(" TypedParameterListOpt ")" { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($2, $$->modifier_); }
1952 | TypeSignifier { $$ = $1; }
1953 | { $$ = CYNew CYTypedIdentifier(@$); }
1957 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1962 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1963 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1967 : PrefixedType { $$ = $1; }
1968 | SuffixedType { $$ = $1; }
1969 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1970 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1974 : "int" { $$ = CYNew CYTypeVariable("int"); }
1975 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1976 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1977 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1978 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1982 : IntegerType { $$ = $1; }
1983 | { $$ = CYNew CYTypeVariable("int"); }
1987 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1988 | IntegerType { $$ = $1; }
1989 | "void" { $$ = CYNew CYTypeVoid(); }
1990 | "char" { $$ = CYNew CYTypeVariable("char"); }
1991 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1992 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1996 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
2000 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
2006 /* Cycript (Objective-C): @class Declaration {{{ */
2008 /* XXX: why the hell did I choose MemberExpression? */
2009 : ":" LexSetRegExp MemberExpression { $$ = $3; }
2013 ImplementationFieldListOpt
2014 : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
2015 | LexSetRegExp { $$ = NULL; }
2018 ImplementationFields
2019 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
2023 : "+" { $$ = false; }
2024 | "-" { $$ = true; }
2028 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
2029 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2033 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
2036 MessageParameterList
2037 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
2040 MessageParameterListOpt
2041 : MessageParameterList { $$ = $1; }
2046 : MessageParameterList { $$ = $1; }
2047 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
2050 ClassMessageDeclaration
2051 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
2054 ClassMessageDeclarationListOpt
2055 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
2059 // XXX: this should be AssignmentExpressionNoRight
2061 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
2065 : "," ClassProtocols { $$ = $2; }
2069 ClassProtocolListOpt
2070 : "<" ClassProtocols ">" { $$ = $2; }
2074 ImplementationStatement
2075 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
2083 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
2087 : ImplementationStatement { $$ = $1; }
2088 | CategoryStatement { $$ = $1; }
2091 /* Cycript (Objective-C): Send Message {{{ */
2093 : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
2098 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
2099 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2103 : SelectorCall { $$ = $1; }
2104 | VariadicCall { $$ = $1; }
2108 : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
2112 : SelectorCall { $$ = $1; }
2113 | Word { $$ = CYNew CYArgument($1, NULL); }
2117 : "[" AssignmentExpressionClassic { driver.contexts_.push_back($2); } SelectorList "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($2, $4); }
2118 | "[" LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" { $$ = CYNew CYSendSuper($5); }
2122 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2126 : SelectorExpression_ { $$ = $1; }
2127 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2130 SelectorExpressionOpt
2131 : SelectorExpression_ { $$ = $1; }
2136 : MessageExpression { $$ = $1; }
2137 | "@selector" "(" SelectorExpression ")" { $$ = CYNew CYSelector($3); }
2142 /* Cycript: @import Directive {{{ */
2144 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2145 | Word { $$ = CYNew CYModule($1); }
2149 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2154 /* Cycript (Objective-C): Boxed Expressions {{{ */
2156 : NullLiteral { $$ = $1; }
2157 | BooleanLiteral { $$ = $1; }
2158 | NumericLiteral { $$ = $1; }
2159 | StringLiteral { $$ = $1; }
2160 | ArrayLiteral { $$ = $1; }
2161 | ObjectLiteral { $$ = $1; }
2162 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2163 | "YES" { $$ = CYNew CYTrue(); }
2164 | "NO" { $$ = CYNew CYFalse(); }
2168 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2169 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2170 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2171 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2172 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2173 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2176 /* Cycript (Objective-C): Block Expressions {{{ */
2178 : "^" TypedIdentifier { if ($2->identifier_ != NULL) CYERR($2->location_, "unexpected identifier"); } BRACE FunctionBody "}" { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $5); else CYERR($2->location_, "expected parameters"); }
2181 /* Cycript (Objective-C): Instance Literals {{{ */
2183 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2189 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2191 : IndirectExpression { $$ = $1; }
2195 : "*" UnaryExpression { $$ = CYNew CYIndirect($2); }
2199 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2203 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2204 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2205 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2208 /* Cycript (C): auto Compatibility {{{ */
2213 /* Cycript (C): Lambda Expressions {{{ */
2215 : "," TypedParameterList { $$ = $2; }
2220 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2223 TypedParameterListOpt
2224 : TypedParameterList { $$ = $1; }
2229 : "[" LexSetRegExp "&" LexSetRegExp "]" "(" TypedParameterListOpt ")" "->" TypedIdentifier BRACE FunctionBody "}" { $$ = CYNew CYLambda($10, $7, $12); }
2232 /* Cycript (C): Type Definitions {{{ */
2234 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2237 /* Cycript (C): extern "C" {{{ */
2239 : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) CYERR(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) CYERR($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
2246 /* Lexer State {{{ */
2248 : { driver.PushCondition(CYDriver::RegExpCondition); }
2252 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2256 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2260 : { driver.PopCondition(); }
2264 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2268 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2271 /* Virtual Tokens {{{ */
2278 /* 8.1 Context Keywords {{{ */
2280 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2281 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2284 /* 8.3 XML Initializer Input Elements {{{ */
2286 : XMLComment { $$ = $1; }
2287 | XMLCDATA { $$ = $1; }
2288 | XMLPI { $$ = $1; }
2292 /* 11.1 Primary Expressions {{{ */
2294 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2295 | XMLInitialiser { $$ = $1; }
2296 | XMLListInitialiser { $$ = $1; }
2300 : AttributeIdentifier { $$ = $1; }
2301 | QualifiedIdentifier { $$ = $1; }
2302 | WildcardIdentifier { $$ = $1; }
2305 /* 11.1.1 Attribute Identifiers {{{ */
2307 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2311 : PropertySelector { $$ = $1; }
2312 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2316 : Identifier { $$ = CYNew CYSelector($1); }
2317 | WildcardIdentifier { $$ = $1; }
2320 /* 11.1.2 Qualified Identifiers {{{ */
2321 QualifiedIdentifier_
2322 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2323 | QualifiedIdentifier { $$ = $1; }
2327 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2330 /* 11.1.3 Wildcard Identifiers {{{ */
2332 : "*" { $$ = CYNew CYWildcard(); }
2335 /* 11.1.4 XML Initializer {{{ */
2337 : XMLMarkup { $$ = $1; }
2338 | XMLElement { $$ = $1; }
2342 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2343 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2347 : LexPushXMLTag XMLTagName XMLAttributes
2351 : BRACE LexPushRegExp Expression LexPop "}"
2360 : XMLAttributes_ XMLAttribute
2365 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2366 | XMLAttributes_ XMLWhitespaceOpt
2375 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2379 : XMLExpression XMLElementContentOpt
2380 | XMLMarkup XMLElementContentOpt
2381 | XMLText XMLElementContentOpt
2382 | XMLElement XMLElementContentOpt
2385 XMLElementContentOpt
2390 /* 11.1.5 XMLList Initializer {{{ */
2392 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2396 /* 11.2 Left-Hand-Side Expressions {{{ */
2398 : Identifier { $$ = $1; }
2399 | PropertyIdentifier { $$ = $1; }
2403 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2404 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2405 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2408 /* 12.1 The default xml namespace Statement {{{ */
2409 /* XXX: DefaultXMLNamespaceStatement
2410 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2414 : DefaultXMLNamespaceStatement { $$ = $1; }
2419 /* JavaScript FTL: Array Comprehensions {{{ */
2421 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2425 : "for" "each" "(" LexPushInOn LexBind ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($6, $9); }
2428 /* JavaScript FTL: for each {{{ */
2430 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2434 /* JavaScript FTW: Array Comprehensions {{{ */
2436 : ArrayComprehension
2440 : "[" Comprehension "]" { $$ = $2; }
2444 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2449 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2450 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2454 : "for" "(" LexPushInOn LexBind ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($5, $8); }
2455 | "for" "(" LexPushInOn LexBind ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2459 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2462 /* JavaScript FTW: Coalesce Operator {{{ */
2463 ConditionalExpression
2464 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2467 /* JavaScript FTW: Named Arguments {{{ */
2469 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2472 /* JavaScript FTW: Ruby Blocks {{{ */
2473 RubyProcParameterList_
2474 : "," RubyProcParameterList { $$ = $2; }
2478 RubyProcParameterList
2479 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2484 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2485 | LexSetRegExp "||" { $$ = NULL; }
2488 RubyProcParametersOpt
2489 : RubyProcParameters { $$ = $1; }
2490 | LexSetRegExp { $$ = NULL; }
2494 : { CYLIN(OpenBrace); }
2498 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2502 : BRACE RubyProcParameters StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2506 : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); }
2512 bool CYDriver::Parse(CYMark mark) {
2514 CYLocal<CYPool> local(&pool_);
2515 cy::parser parser(*this);
2517 parser.set_debug_level(debug_);
2519 return parser.parse() != 0;
2522 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2526 CYDriver::Error error;
2527 error.warning_ = true;
2528 error.location_ = location;
2529 error.message_ = message;
2530 errors_.push_back(error);
2533 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2534 CYDriver::Error error;
2535 error.warning_ = false;
2536 error.location_ = location;
2537 error.message_ = message;
2538 driver.errors_.push_back(error);