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 if (driver.in_.top())
146 if (driver.yield_.top())
147 token = tk::_yield__;
150 case tk::HyphenHyphen:
151 if (driver.newline_ == CYDriver::NewLineLast)
152 token = tk::HyphenHyphen_;
156 driver.newline_ = CYDriver::NewLineHere;
162 if (driver.newline_ == CYDriver::NewLineLast)
163 token = tk::PlusPlus_;
167 driver.next_ = false;
171 #define CYLEX() do if (yyla.empty()) { \
172 YYCDEBUG << "Mapping a token: "; \
173 yyla.type = yytranslate_(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 CYLIN(from) do { \
185 if (yyla.type == yytranslate_(token::from) && driver.newline_ == CYDriver::NewLineLast) \
186 yyla.type = yytranslate_(token::from ## _); \
189 #define CYERR(location, message) do { \
190 error(location, message); \
194 #define CYNOT(location) \
195 CYERR(location, "unimplemented feature")
204 @$.begin.filename = @$.end.filename = &driver.filename_;
210 %define api.location.type { CYLocation }
217 %param { CYDriver &driver }
219 /* Token Declarations {{{ */
225 %token XMLAttributeValue
227 %token XMLTagCharacters
233 %token LeftRight "<>"
234 %token LeftSlashRight "</>"
236 %token SlashRight "/>"
237 %token LeftSlash "</"
239 %token ColonColon "::"
240 %token PeriodPeriod ".."
243 @begin E4X ObjectiveC
249 %token AmpersandAmpersand "&&"
250 %token AmpersandEqual "&="
252 %token CarrotEqual "^="
254 %token EqualEqual "=="
255 %token EqualEqualEqual "==="
256 %token EqualRight "=>"
257 %token EqualRight_ "\n=>"
258 %token Exclamation "!"
259 %token ExclamationEqual "!="
260 %token ExclamationEqualEqual "!=="
262 %token HyphenEqual "-="
263 %token HyphenHyphen "--"
264 %token HyphenHyphen_ "\n--"
265 %token HyphenRight "->"
267 %token LeftEqual "<="
269 %token LeftLeftEqual "<<="
271 %token PercentEqual "%="
273 %token PeriodPeriodPeriod "..."
275 %token PipeEqual "|="
278 %token PlusEqual "+="
280 %token PlusPlus_ "\n++"
282 %token RightEqual ">="
283 %token RightRight ">>"
284 %token RightRightEqual ">>="
285 %token RightRightRight ">>>"
286 %token RightRightRightEqual ">>>="
288 %token SlashEqual "/="
290 %token StarEqual "*="
302 %token CloseParen ")"
305 %token OpenBrace_ "\n{"
306 %token OpenBrace__ ";{"
307 %token CloseBrace "}"
309 %token OpenBracket "["
310 %token CloseBracket "]"
312 %token At_error_ "@error"
315 %token At_class_ "@class"
319 %token _typedef_ "typedef"
320 %token _unsigned_ "unsigned"
321 %token _signed_ "signed"
322 %token _extern_ "extern"
326 %token At_encode_ "@encode"
330 %token At_implementation_ "@implementation"
331 %token At_import_ "@import"
332 %token At_end_ "@end"
333 %token At_selector_ "@selector"
334 %token At_null_ "@null"
335 %token At_YES_ "@YES"
337 %token At_true_ "@true"
338 %token At_false_ "@false"
343 %token _false_ "false"
347 %token _break_ "break"
349 %token _catch_ "catch"
350 %token _class_ "class"
351 %token _class__ ";class"
352 %token _const_ "const"
353 %token _continue_ "continue"
354 %token _debugger_ "debugger"
355 %token _default_ "default"
356 %token _delete_ "delete"
360 %token _export_ "export"
361 %token _extends_ "extends"
362 %token _finally_ "finally"
364 %token _function_ "function"
365 %token _function__ ";function"
367 %token _import_ "import"
370 %token _Infinity_ "Infinity"
371 %token _instanceof_ "instanceof"
373 %token _return_ "return"
374 %token _super_ "super"
375 %token _switch_ "switch"
376 %token _target_ "target"
378 %token _throw_ "throw"
380 %token _typeof_ "typeof"
383 %token _while_ "while"
386 %token _abstract_ "abstract"
387 %token _await_ "await"
388 %token _boolean_ "boolean"
391 %token _constructor_ "constructor"
392 %token _double_ "double"
394 %token _final_ "final"
395 %token _float_ "float"
399 %token _implements_ "implements"
401 %token _interface_ "interface"
404 %token _native_ "native"
405 %token _package_ "package"
406 %token _private_ "private"
407 %token _protected_ "protected"
408 %token _prototype_ "prototype"
409 %token _public_ "public"
411 %token _short_ "short"
412 %token _static_ "static"
413 %token _synchronized_ "synchronized"
414 %token _throws_ "throws"
415 %token _transient_ "transient"
416 %token _volatile_ "volatile"
417 %token _yield_ "yield"
418 %token _yield__ "!yield"
420 %token _undefined_ "undefined"
436 %token _namespace_ "namespace"
443 %token <identifier_> Identifier_
444 %token <number_> NumericLiteral
445 %token <string_> StringLiteral
446 %token <literal_> RegularExpressionLiteral
448 %token <string_> NoSubstitutionTemplate
449 %token <string_> TemplateHead
450 %token <string_> TemplateMiddle
451 %token <string_> TemplateTail
453 %type <expression_> AdditiveExpression
454 %type <argument_> ArgumentList_
455 %type <argument_> ArgumentList
456 %type <argument_> ArgumentListOpt
457 %type <argument_> Arguments
458 %type <target_> ArrayComprehension
459 %type <literal_> ArrayLiteral
460 %type <expression_> ArrowFunction
461 %type <functionParameter_> ArrowParameters
462 %type <expression_> AssignmentExpression
463 %type <expression_> AssignmentExpressionOpt
464 %type <identifier_> BindingIdentifier
465 %type <identifier_> BindingIdentifierOpt
466 %type <declarations_> BindingList_
467 %type <declarations_> BindingList
468 %type <expression_> BitwiseANDExpression
469 %type <statement_> Block
470 %type <statement_> BlockStatement
471 %type <boolean_> BooleanLiteral
472 %type <declaration_> BindingElement
473 %type <expression_> BitwiseORExpression
474 %type <expression_> BitwiseXORExpression
475 %type <statement_> BreakStatement
476 %type <statement_> BreakableStatement
477 %type <expression_> CallExpression_
478 %type <target_> CallExpression
479 %type <clause_> CaseBlock
480 %type <clause_> CaseClause
481 %type <clause_> CaseClausesOpt
483 %type <identifier_> CatchParameter
484 %type <statement_> ClassDeclaration
485 %type <target_> ClassExpression
486 %type <classTail_> ClassHeritage
487 %type <classTail_> ClassHeritageOpt
488 %type <classTail_> ClassTail
489 %type <target_> Comprehension
490 %type <comprehension_> ComprehensionFor
491 %type <comprehension_> ComprehensionIf
492 %type <comprehension_> ComprehensionTail
493 %type <propertyName_> ComputedPropertyName
494 %type <expression_> ConditionalExpression
495 %type <statement_> ContinueStatement
496 %type <statement_> ConciseBody
497 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
498 %type <statement_> DebuggerStatement
499 %type <statement_> Declaration__
500 %type <statement_> Declaration_
501 %type <statement_> Declaration
502 %type <clause_> DefaultClause
503 %type <element_> ElementList
504 %type <element_> ElementListOpt
505 %type <statement_> ElseStatementOpt
506 %type <for_> EmptyStatement
507 %type <expression_> EqualityExpression
508 %type <expression_> Expression
509 %type <expression_> ExpressionOpt
510 %type <for_> ExpressionStatement_
511 %type <statement_> ExpressionStatement
512 %type <finally_> Finally
513 %type <declaration_> ForBinding
514 %type <forin_> ForDeclaration
515 %type <forin_> ForInStatementInitializer
516 %type <for_> ForStatementInitializer
517 %type <declaration_> FormalParameter
518 %type <functionParameter_> FormalParameterList_
519 %type <functionParameter_> FormalParameterList
520 %type <functionParameter_> FormalParameters
521 %type <statement_> FunctionBody
522 %type <statement_> FunctionDeclaration
523 %type <target_> FunctionExpression
524 %type <statement_> FunctionStatementList
525 %type <statement_> GeneratorBody
526 %type <statement_> GeneratorDeclaration
527 %type <target_> GeneratorExpression
528 %type <method_> GeneratorMethod
529 %type <statement_> HoistableDeclaration
530 %type <identifier_> Identifier
531 %type <identifier_> IdentifierType
532 %type <word_> IdentifierName
533 %type <variable_> IdentifierReference
534 %type <statement_> IfStatement
535 %type <expression_> Initializer
536 %type <expression_> InitializerOpt
537 %type <statement_> IterationStatement
538 %type <identifier_> LabelIdentifier
539 %type <statement_> LabelledItem
540 %type <statement_> LabelledStatement
541 %type <assignment_> LeftHandSideAssignment
542 %type <target_> LeftHandSideExpression
543 %type <bool_> LetOrConst
544 %type <declaration_> LexicalBinding
545 %type <for_> LexicalDeclaration_
546 %type <statement_> LexicalDeclaration
547 %type <literal_> Literal
548 %type <propertyName_> LiteralPropertyName
549 %type <expression_> LogicalANDExpression
550 %type <expression_> LogicalORExpression
551 %type <access_> MemberAccess
552 %type <target_> MemberExpression
553 %type <method_> MethodDefinition
554 %type <module_> ModulePath
555 %type <expression_> MultiplicativeExpression
556 %type <target_> NewExpression
557 %type <null_> NullLiteral
558 %type <literal_> ObjectLiteral
559 %type <expression_> PostfixExpression
560 %type <target_> PrimaryExpression
561 %type <propertyName_> PropertyName
562 %type <property_> PropertyDefinition
563 %type <property_> PropertyDefinitionList_
564 %type <property_> PropertyDefinitionList
565 %type <property_> PropertyDefinitionListOpt
566 %type <declaration_> PropertySetParameterList
567 %type <expression_> RelationalExpression
568 %type <statement_> ReturnStatement
569 %type <rubyProc_> RubyProcExpression
570 %type <functionParameter_> RubyProcParameterList_
571 %type <functionParameter_> RubyProcParameterList
572 %type <functionParameter_> RubyProcParameters
573 %type <functionParameter_> RubyProcParametersOpt
574 %type <statement_> Script
575 %type <statement_> ScriptBody
576 %type <statement_> ScriptBodyOpt
577 %type <expression_> ShiftExpression
578 %type <declaration_> SingleNameBinding
579 %type <statement_> Statement__
580 %type <statement_> Statement_
581 %type <statement_> Statement
582 %type <statement_> StatementList
583 %type <statement_> StatementListOpt
584 %type <statement_> StatementListItem
585 %type <functionParameter_> StrictFormalParameters
586 %type <target_> SuperCall
587 %type <target_> SuperProperty
588 %type <statement_> SwitchStatement
589 %type <target_> TemplateLiteral
590 %type <span_> TemplateSpans
591 %type <statement_> ThrowStatement
592 %type <statement_> TryStatement
593 %type <expression_> UnaryExpression_
594 %type <expression_> UnaryExpression
595 %type <declaration_> VariableDeclaration
596 %type <declarations_> VariableDeclarationList_
597 %type <declarations_> VariableDeclarationList
598 %type <for_> VariableStatement_
599 %type <statement_> VariableStatement
600 %type <statement_> WithStatement
603 %type <word_> WordOpt
605 %type <expression_> YieldExpression
608 %type <specifier_> IntegerType
609 %type <specifier_> IntegerTypeOpt
610 %type <typedIdentifier_> PrefixedType
611 %type <specifier_> PrimitiveType
612 %type <typedIdentifier_> SuffixedType
613 %type <typedIdentifier_> TypeSignifier
614 %type <modifier_> TypeQualifierLeft
615 %type <typedIdentifier_> TypeQualifierRight
616 %type <typedIdentifier_> TypedIdentifier
617 %type <typedParameter_> TypedParameterList_
618 %type <typedParameter_> TypedParameterList
619 %type <typedParameter_> TypedParameterListOpt
623 %type <expression_> AssignmentExpressionClassic
624 %type <expression_> BoxableExpression
625 %type <statement_> CategoryStatement
626 %type <expression_> ClassSuperOpt
627 %type <expression_> ConditionalExpressionClassic
628 %type <implementationField_> ImplementationFieldListOpt
629 %type <implementationField_> ImplementationFields
630 %type <message_> ClassMessageDeclaration
631 %type <message_> ClassMessageDeclarationListOpt
632 %type <protocol_> ClassProtocolListOpt
633 %type <protocol_> ClassProtocols
634 %type <protocol_> ClassProtocolsOpt
635 %type <statement_> ImplementationStatement
636 %type <target_> MessageExpression
637 %type <messageParameter_> MessageParameter
638 %type <messageParameter_> MessageParameters
639 %type <messageParameter_> MessageParameterList
640 %type <messageParameter_> MessageParameterListOpt
641 %type <bool_> MessageScope
642 %type <argument_> SelectorCall_
643 %type <argument_> SelectorCall
644 %type <selector_> SelectorExpression_
645 %type <selector_> SelectorExpression
646 %type <selector_> SelectorExpressionOpt
647 %type <argument_> SelectorList
648 %type <word_> SelectorWordOpt
649 %type <typedIdentifier_> TypeOpt
650 %type <argument_> VariadicCall
654 %type <propertyIdentifier_> PropertyIdentifier_
655 %type <selector_> PropertySelector_
656 %type <selector_> PropertySelector
657 %type <identifier_> QualifiedIdentifier_
658 %type <identifier_> QualifiedIdentifier
659 %type <identifier_> WildcardIdentifier
660 %type <identifier_> XMLComment
661 %type <identifier_> XMLCDATA
662 %type <identifier_> XMLElement
663 %type <identifier_> XMLElementContent
664 %type <identifier_> XMLMarkup
665 %type <identifier_> XMLPI
667 %type <attribute_> AttributeIdentifier
668 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
669 %type <expression_> PropertyIdentifier
670 %type <expression_> XMLListInitialiser
671 %type <expression_> XMLInitialiser
674 /* Token Priorities {{{ */
693 /* Lexer State {{{ */
694 LexPushInOn: { driver.in_.push(true); };
695 LexPushInOff: { driver.in_.push(false); };
696 LexPopIn: { driver.in_.pop(); };
698 LexPushReturnOn: { driver.return_.push(true); };
699 LexPopReturn: { driver.return_.pop(); };
701 LexPushSuperOn: { driver.super_.push(true); };
702 LexPushSuperOff: { driver.super_.push(false); };
703 LexPopSuper: { driver.super_.pop(); };
705 LexPushYieldOn: { driver.yield_.push(true); };
706 LexPushYieldOff: { driver.yield_.push(false); };
707 LexPopYield: { driver.yield_.pop(); };
710 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
714 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
718 : { CYMAP(YieldStar, Star); }
722 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
726 : { CYMAP(_class__, _class_); }
730 : { CYMAP(_function__, _function_); }
734 : LexNoBrace LexNoClass LexNoFunction
737 /* Virtual Tokens {{{ */
748 /* 11.6 Names and Keywords {{{ */
751 | "for" { $$ = CYNew CYWord("for"); }
752 | "in" { $$ = CYNew CYWord("in"); }
753 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
762 : Identifier { $$ = $1; }
763 | "auto" { $$ = CYNew CYWord("auto"); }
764 | "break" { $$ = CYNew CYWord("break"); }
765 | "case" { $$ = CYNew CYWord("case"); }
766 | "catch" { $$ = CYNew CYWord("catch"); }
767 | "class" { $$ = CYNew CYWord("class"); }
768 | ";class" { $$ = CYNew CYWord("class"); }
769 | "const" { $$ = CYNew CYWord("const"); }
770 | "continue" { $$ = CYNew CYWord("continue"); }
771 | "debugger" { $$ = CYNew CYWord("debugger"); }
772 | "default" { $$ = CYNew CYWord("default"); }
773 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
774 | "do" { $$ = CYNew CYWord("do"); }
775 | "else" { $$ = CYNew CYWord("else"); }
776 | "enum" { $$ = CYNew CYWord("enum"); }
777 | "export" { $$ = CYNew CYWord("export"); }
778 | "extends" { $$ = CYNew CYWord("extends"); }
779 | "false" { $$ = CYNew CYWord("false"); }
780 | "finally" { $$ = CYNew CYWord("finally"); }
781 | "function" { $$ = CYNew CYWord("function"); }
782 | "if" { $$ = CYNew CYWord("if"); }
783 | "import" { $$ = CYNew CYWord("import"); }
784 | "!in" { $$ = CYNew CYWord("in"); }
785 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
786 | "null" { $$ = CYNew CYWord("null"); }
787 | "return" { $$ = CYNew CYWord("return"); }
788 | "super" { $$ = CYNew CYWord("super"); }
789 | "switch" { $$ = CYNew CYWord("switch"); }
790 | "this" { $$ = CYNew CYWord("this"); }
791 | "throw" { $$ = CYNew CYWord("throw"); }
792 | "true" { $$ = CYNew CYWord("true"); }
793 | "try" { $$ = CYNew CYWord("try"); }
794 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
795 | "var" { $$ = CYNew CYWord("var"); }
796 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
797 | "while" { $$ = CYNew CYWord("while"); }
798 | "with" { $$ = CYNew CYWord("with"); }
799 | "yield" { $$ = CYNew CYIdentifier("yield"); }
801 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
803 // XXX: should be Identifier
804 | "let" { $$ = CYNew CYIdentifier("let"); }
814 /* 11.8.1 Null Literals {{{ */
816 : "null" { $$ = CYNew CYNull(); }
819 /* 11.8.2 Boolean Literals {{{ */
821 : "true" { $$ = CYNew CYTrue(); }
822 | "false" { $$ = CYNew CYFalse(); }
826 /* 11.9 Automatic Semicolon Insertion {{{ */
828 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
838 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && driver.newline_ == CYDriver::NewLineNone) { CYERR(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
843 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
847 /* 12.1 Identifiers {{{ */
849 : Identifier { $$ = CYNew CYVariable($1); }
850 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
854 : Identifier { $$ = $1; }
855 | "yield" { $$ = CYNew CYIdentifier("yield"); }
859 : BindingIdentifier { $$ = $1; }
864 : Identifier { $$ = $1; }
865 | "yield" { $$ = CYNew CYIdentifier("yield"); }
869 : Identifier_ { $$ = $1; }
870 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
871 | "await" { $$ = CYNew CYIdentifier("await"); }
872 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
873 | "byte" { $$ = CYNew CYIdentifier("byte"); }
874 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
875 | "double" { $$ = CYNew CYIdentifier("double"); }
876 | "each" { $$ = CYNew CYIdentifier("each"); }
877 | "eval" { $$ = CYNew CYIdentifier("eval"); }
878 | "final" { $$ = CYNew CYIdentifier("final"); }
879 | "float" { $$ = CYNew CYIdentifier("float"); }
880 | "from" { $$ = CYNew CYIdentifier("from"); }
881 | "get" { $$ = CYNew CYIdentifier("get"); }
882 | "goto" { $$ = CYNew CYIdentifier("goto"); }
883 | "implements" { $$ = CYNew CYIdentifier("implements"); }
884 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
885 | "interface" { $$ = CYNew CYIdentifier("interface"); }
886 | "native" { $$ = CYNew CYIdentifier("native"); }
887 | "of" { $$ = CYNew CYIdentifier("of"); }
888 | "package" { $$ = CYNew CYIdentifier("package"); }
889 | "private" { $$ = CYNew CYIdentifier("private"); }
890 | "protected" { $$ = CYNew CYIdentifier("protected"); }
891 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
892 | "public" { $$ = CYNew CYIdentifier("public"); }
893 | "set" { $$ = CYNew CYIdentifier("set"); }
894 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
895 | "target" { $$ = CYNew CYIdentifier("target"); }
896 | "throws" { $$ = CYNew CYIdentifier("throws"); }
897 | "transient" { $$ = CYNew CYIdentifier("transient"); }
898 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
900 | "bool" { $$ = CYNew CYIdentifier("bool"); }
901 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
902 | "id" { $$ = CYNew CYIdentifier("id"); }
903 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
909 | "char" { $$ = CYNew CYIdentifier("char"); }
910 | "int" { $$ = CYNew CYIdentifier("int"); }
911 | "long" { $$ = CYNew CYIdentifier("long"); }
912 | "short" { $$ = CYNew CYIdentifier("short"); }
913 | "static" { $$ = CYNew CYIdentifier("static"); }
914 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
916 | "extern" { $$ = CYNew CYIdentifier("extern"); }
917 | "signed" { $$ = CYNew CYIdentifier("signed"); }
918 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
919 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
922 | "nil" { $$ = CYNew CYIdentifier("nil"); }
923 | "NO" { $$ = CYNew CYIdentifier("NO"); }
924 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
925 | "YES" { $$ = CYNew CYIdentifier("YES"); }
929 /* 12.2 Primary Expression {{{ */
931 : "this" { $$ = CYNew CYThis(); }
932 | IdentifierReference { $$ = $1; }
933 | Literal { $$ = $1; }
934 | ArrayLiteral { $$ = $1; }
935 | ObjectLiteral { $$ = $1; }
936 | FunctionExpression { $$ = $1; }
937 | ClassExpression { $$ = $1; }
938 | GeneratorExpression { $$ = $1; }
939 | RegularExpressionLiteral { $$ = $1; }
940 | TemplateLiteral { $$ = $1; }
941 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
942 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
945 CoverParenthesizedExpressionAndArrowParameterList
946 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
947 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
948 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
949 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
952 /* 12.2.4 Literals {{{ */
954 : NullLiteral { $$ = $1; }
955 | BooleanLiteral { $$ = $1; }
956 | NumericLiteral { $$ = $1; }
957 | StringLiteral { $$ = $1; }
960 /* 12.2.5 Array Initializer {{{ */
962 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
966 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
967 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
968 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
972 : ElementList { $$ = $1; }
973 | LexSetRegExp { $$ = NULL; }
976 /* 12.2.6 Object Initializer {{{ */
978 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
981 PropertyDefinitionList_
982 : "," PropertyDefinitionListOpt { $$ = $2; }
986 PropertyDefinitionList
987 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
990 PropertyDefinitionListOpt
991 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
992 | LexSetRegExp { $$ = NULL; }
996 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
997 | CoverInitializedName { CYNOT(@$); }
998 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
999 | MethodDefinition { $$ = $1; }
1003 : LiteralPropertyName { $$ = $1; }
1004 | ComputedPropertyName { $$ = $1; }
1008 : IdentifierName { $$ = $1; }
1009 | StringLiteral { $$ = $1; }
1010 | NumericLiteral { $$ = $1; }
1013 ComputedPropertyName
1014 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
1017 CoverInitializedName
1018 : IdentifierReference Initializer
1022 : "=" AssignmentExpression { $$ = $2; }
1026 : Initializer { $$ = $1; }
1030 /* 12.2.9 Template Literals {{{ */
1032 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
1033 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
1037 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
1038 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
1042 /* 12.3 Left-Hand-Side Expressions {{{ */
1044 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
1045 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1046 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1047 | TemplateLiteral { CYNOT(@$); }
1051 : LexSetRegExp PrimaryExpression { $$ = $2; }
1052 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1053 | SuperProperty { $$ = $1; }
1054 | MetaProperty { CYNOT(@$); }
1055 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1059 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
1060 | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
1068 : LexSetRegExp "new" LexSetRegExp "." "target"
1072 : MemberExpression { $$ = $1; }
1073 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1077 : MemberExpression { $$ = $1; }
1078 | CallExpression { $$ = $1; }
1082 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1083 | SuperCall { $$ = $1; }
1084 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1088 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
1092 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1096 : "," ArgumentList { $$ = $2; }
1101 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1102 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1106 : ArgumentList { $$ = $1; }
1107 | LexSetRegExp { $$ = NULL; }
1110 LeftHandSideExpression
1111 : NewExpression { $$ = $1; }
1112 | CallExpression { $$ = $1; }
1115 /* 12.4 Postfix Expressions {{{ */
1117 : %prec "" LeftHandSideExpression { $$ = $1; }
1118 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1119 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1122 /* 12.5 Unary Operators {{{ */
1124 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1125 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1126 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1127 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1128 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1129 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1130 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1131 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1132 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1133 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1134 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1138 : %prec "" PostfixExpression LexOpenBrace { $$ = $1; }
1139 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1142 /* 12.6 Multiplicative Operators {{{ */
1143 MultiplicativeExpression
1144 : UnaryExpression { $$ = $1; }
1145 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1146 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1147 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1150 /* 12.7 Additive Operators {{{ */
1152 : MultiplicativeExpression { $$ = $1; }
1153 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1154 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1157 /* 12.8 Bitwise Shift Operators {{{ */
1159 : AdditiveExpression { $$ = $1; }
1160 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1161 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1162 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1165 /* 12.9 Relational Operators {{{ */
1166 RelationalExpression
1167 : ShiftExpression { $$ = $1; }
1168 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1169 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1170 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1171 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1172 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1173 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1176 /* 12.10 Equality Operators {{{ */
1178 : RelationalExpression { $$ = $1; }
1179 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1180 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1181 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1182 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1185 /* 12.11 Binary Bitwise Operators {{{ */
1186 BitwiseANDExpression
1187 : EqualityExpression { $$ = $1; }
1188 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1191 BitwiseXORExpression
1192 : BitwiseANDExpression { $$ = $1; }
1193 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1197 : BitwiseXORExpression { $$ = $1; }
1198 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1201 /* 12.12 Binary Logical Operators {{{ */
1202 LogicalANDExpression
1203 : BitwiseORExpression { $$ = $1; }
1204 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1208 : LogicalANDExpression { $$ = $1; }
1209 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1212 /* 12.13 Conditional Operator ( ? : ) {{{ */
1214 ConditionalExpressionClassic
1215 : LogicalORExpression { $$ = $1; }
1216 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
1220 ConditionalExpression
1221 : LogicalORExpression { $$ = $1; }
1222 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1225 /* 12.14 Assignment Operators {{{ */
1226 LeftHandSideAssignment
1227 : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
1228 | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
1229 | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
1230 | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
1231 | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
1232 | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
1233 | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
1234 | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
1235 | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
1236 | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
1237 | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
1238 | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
1242 AssignmentExpressionClassic
1243 : ConditionalExpressionClassic { $$ = $1; }
1244 | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
1248 AssignmentExpression
1249 : ConditionalExpression { $$ = $1; }
1250 | LexSetRegExp YieldExpression { $$ = $2; }
1251 | ArrowFunction { $$ = $1; }
1252 | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
1255 AssignmentExpressionOpt
1256 : AssignmentExpression { $$ = $1; }
1257 | LexSetRegExp { $$ = NULL; }
1260 /* 12.15 Comma Operator ( , ) {{{ */
1262 : AssignmentExpression { $$ = $1; }
1263 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1267 : Expression { $$ = $1; }
1268 | LexSetRegExp { $$ = NULL; }
1272 /* 13 Statements and Declarations {{{ */
1274 : BlockStatement { $$ = $1; }
1275 | VariableStatement { $$ = $1; }
1276 | EmptyStatement { $$ = $1; }
1277 | IfStatement { $$ = $1; }
1278 | BreakableStatement { $$ = $1; }
1279 | ContinueStatement { $$ = $1; }
1280 | BreakStatement { $$ = $1; }
1281 | ReturnStatement { $$ = $1; }
1282 | WithStatement { $$ = $1; }
1283 | LabelledStatement { $$ = $1; }
1284 | ThrowStatement { $$ = $1; }
1285 | TryStatement { $$ = $1; }
1286 | DebuggerStatement { $$ = $1; }
1290 : LexSetRegExp Statement__ { $$ = $2; }
1291 | ExpressionStatement { $$ = $1; }
1295 : LexSetStatement Statement_ { $$ = $2; }
1299 : HoistableDeclaration { $$ = $1; }
1300 | ClassDeclaration { $$ = $1; }
1301 | LexicalDeclaration { $$ = $1; }
1305 : LexSetRegExp Declaration__ { $$ = $2; }
1309 : LexSetStatement Declaration_ { $$ = $2; }
1312 HoistableDeclaration
1313 : FunctionDeclaration { $$ = $1; }
1314 | GeneratorDeclaration { $$ = $1; }
1318 : IterationStatement { $$ = $1; }
1319 | SwitchStatement { $$ = $1; }
1322 /* 13.2 Block {{{ */
1324 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1328 : BRACE StatementListOpt "}" { $$ = $2; }
1332 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1336 : StatementList { $$ = $1; }
1337 | LexSetStatement LexSetRegExp { $$ = NULL; }
1341 : Statement { $$ = $1; }
1342 | Declaration { $$ = $1; }
1345 /* 13.3 Let and Const Declarations {{{ */
1347 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1351 : LexicalDeclaration_ Terminator { $$ = $1; }
1355 : "let" { $$ = false; }
1356 | "const" { $$ = true; }
1360 : "," BindingList { $$ = $2; }
1365 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1369 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1370 | BindingPattern Initializer { CYNOT(@1); }
1373 /* 13.3.2 Variable Statement {{{ */
1375 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1379 : VariableStatement_ Terminator { $$ = $1; }
1382 VariableDeclarationList_
1383 : "," VariableDeclarationList { $$ = $2; }
1387 VariableDeclarationList
1388 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1392 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1393 | BindingPattern Initializer { CYNOT(@1); }
1396 /* 13.3.3 Destructuring Binding Patterns {{{ */
1398 : ObjectBindingPattern
1399 | ArrayBindingPattern
1402 ObjectBindingPattern
1403 : BRACE BindingPropertyListOpt "}"
1407 : "[" { CYNOT(@$); }
1410 BindingPropertyList_
1411 : "," BindingPropertyListOpt
1416 : BindingProperty BindingPropertyList_
1419 BindingPropertyListOpt
1420 : BindingPropertyList
1426 | PropertyName ":" BindingElement
1430 : SingleNameBinding { $$ = $1; }
1431 | BindingPattern InitializerOpt { CYNOT(@$); }
1435 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1439 : "..." BindingIdentifier
1442 /* 13.4 Empty Statement {{{ */
1444 : ";" { $$ = CYNew CYEmpty(); }
1447 /* 13.5 Expression Statement {{{ */
1448 ExpressionStatement_
1449 : Expression { $$ = CYNew CYExpress($1); }
1452 : ExpressionStatement_ Terminator { $$ = $1; }
1455 /* 13.6 The if Statement {{{ */
1457 : "else" Statement { $$ = $2; }
1458 | %prec "if" { $$ = NULL; }
1462 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1465 /* 13.7 Iteration Statements {{{ */
1467 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1468 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1469 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1470 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1471 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1472 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1475 ForStatementInitializer
1476 : LexSetRegExp EmptyStatement { $$ = $2; }
1477 | ExpressionStatement_ ";" { $$ = $1; }
1478 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1479 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1482 ForInStatementInitializer
1483 : LeftHandSideExpression { $$ = $1; }
1484 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1485 | LexSetRegExp ForDeclaration { $$ = $2; }
1489 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1493 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1494 | BindingPattern { CYNOT(@1); }
1497 /* 13.8 The continue Statement {{{ */
1499 : "continue" LexNewLine
1503 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1504 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1507 /* 13.9 The break Statement {{{ */
1509 : "break" LexNewLine
1513 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1514 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1517 /* 13.10 The return Statement {{{ */
1519 : "return" { if (!driver.return_.top()) CYERR(@1, "invalid return"); } LexNewLine
1523 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1524 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1527 /* 13.11 The with Statement {{{ */
1529 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1532 /* 13.12 The switch Statement {{{ */
1534 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1538 : BRACE CaseClausesOpt "}" { $$ = $2; }
1542 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1546 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1547 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1551 // XXX: the standard makes certain you can only have one of these
1553 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1556 /* 13.13 Labelled Statements {{{ */
1558 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1562 : Statement { $$ = $1; }
1563 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1566 /* 13.14 The throw Statement {{{ */
1568 : "throw" LexNewLine
1572 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1573 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1576 /* 13.15 The try Statement {{{ */
1578 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1579 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1580 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1584 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1588 : "finally" Block { $$ = CYNew CYFinally($2); }
1592 : BindingIdentifier { $$ = $1; }
1593 | BindingPattern { CYNOT(@$); }
1596 /* 13.16 The debugger Statement {{{ */
1598 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1602 /* 14.1 Function Definitions {{{ */
1604 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1608 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1611 StrictFormalParameters
1612 : FormalParameters { $$ = $1; }
1617 | FormalParameterList
1620 FormalParameterList_
1621 : "," FormalParameterList { $$ = $2; }
1626 : FunctionRestParameter { CYNOT(@$); }
1627 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1630 FunctionRestParameter
1631 : BindingRestElement
1635 : BindingElement { $$ = $1; }
1639 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1642 FunctionStatementList
1643 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1646 /* 14.2 Arrow Function Definitions {{{ */
1648 : { CYLIN(EqualRight); }
1652 : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); }
1656 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1657 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1661 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1662 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1665 /* 14.3 Method Definitions {{{ */
1667 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1668 | GeneratorMethod { $$ = $1; }
1669 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1670 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1673 PropertySetParameterList
1674 : FormalParameter { $$ = $1; }
1677 /* 14.4 Generator Function Definitions {{{ */
1679 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1682 GeneratorDeclaration
1683 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1687 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1691 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1695 : "!yield" LexNewLine LexNoStar
1699 : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1700 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1701 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1704 /* 14.5 Class Definitions {{{ */
1706 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1710 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1714 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1718 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1722 : ClassHeritage { $$ = $1; }
1723 | { $$ = CYNew CYClassTail(NULL); }
1736 : ClassElementListOpt ClassElement
1745 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1746 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1751 /* 15.1 Scripts {{{ */
1753 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1757 : StatementList { $$ = $1; }
1761 : ScriptBody { $$ = $1; }
1762 | LexSetStatement LexSetRegExp { $$ = NULL; }
1765 /* 15.2 Modules {{{ */
1780 : ModuleItemListOpt ModuleItem
1789 : LexSetStatement LexSetRegExp ImportDeclaration
1790 | LexSetStatement LexSetRegExp ExportDeclaration
1794 /* 15.2.2 Imports {{{ */
1796 : "import" ImportClause FromClause Terminator
1797 | "import" ModuleSpecifier Terminator
1801 : ImportedDefaultBinding
1804 | ImportedDefaultBinding "," NameSpaceImport
1805 | ImportedDefaultBinding "," NamedImports
1808 ImportedDefaultBinding
1813 : "*" "as" ImportedBinding
1817 : BRACE ImportsListOpt "}"
1821 : "from" ModuleSpecifier
1825 : "," ImportsListOpt
1830 : ImportSpecifier ImportsList_
1840 | IdentifierName "as" ImportedBinding
1851 /* 15.2.3 Exports {{{ */
1853 : "*" FromClause Terminator
1854 | ExportClause FromClause Terminator
1855 | ExportClause Terminator
1857 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1858 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1859 | "default" LexSetStatement AssignmentExpression Terminator
1863 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1864 | "export" Declaration
1868 : ";{" ExportsListOpt "}"
1872 : "," ExportsListOpt
1877 : ExportSpecifier ExportsList_
1887 | IdentifierName "as" IdentifierName
1892 /* Cycript (C): Type Encoding {{{ */
1894 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1895 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1899 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1900 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1901 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1902 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1903 | TypeSignifier { $$ = $1; }
1904 | { $$ = CYNew CYTypedIdentifier(@$); }
1908 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1913 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1914 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1918 : PrefixedType { $$ = $1; }
1919 | SuffixedType { $$ = $1; }
1920 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1921 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1925 : "int" { $$ = CYNew CYTypeVariable("int"); }
1926 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1927 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1928 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1929 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1933 : IntegerType { $$ = $1; }
1934 | { $$ = CYNew CYTypeVariable("int"); }
1938 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1939 | IntegerType { $$ = $1; }
1940 | "void" { $$ = CYNew CYTypeVoid(); }
1941 | "char" { $$ = CYNew CYTypeVariable("char"); }
1942 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1943 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1947 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1951 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1957 /* Cycript (Objective-C): @class Declaration {{{ */
1959 /* XXX: why the hell did I choose MemberExpression? */
1960 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1964 ImplementationFieldListOpt
1965 : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
1966 | LexSetRegExp { $$ = NULL; }
1969 ImplementationFields
1970 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1974 : "+" { $$ = false; }
1975 | "-" { $$ = true; }
1979 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1980 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1984 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1987 MessageParameterList
1988 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1991 MessageParameterListOpt
1992 : MessageParameterList { $$ = $1; }
1997 : MessageParameterList { $$ = $1; }
1998 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
2001 ClassMessageDeclaration
2002 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
2005 ClassMessageDeclarationListOpt
2006 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
2010 // XXX: this should be AssignmentExpressionNoRight
2012 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
2016 : "," ClassProtocols { $$ = $2; }
2020 ClassProtocolListOpt
2021 : "<" ClassProtocols ">" { $$ = $2; }
2025 ImplementationStatement
2026 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
2034 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
2038 : ImplementationStatement { $$ = $1; }
2039 | CategoryStatement { $$ = $1; }
2042 /* Cycript (Objective-C): Send Message {{{ */
2044 : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
2049 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
2050 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2054 : SelectorCall { $$ = $1; }
2055 | VariadicCall { $$ = $1; }
2059 : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
2063 : SelectorCall { $$ = $1; }
2064 | Word { $$ = CYNew CYArgument($1, NULL); }
2068 : "[" LexPushInOff AssignmentExpressionClassic { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2069 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2073 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2077 : SelectorExpression_ { $$ = $1; }
2078 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2081 SelectorExpressionOpt
2082 : SelectorExpression_ { $$ = $1; }
2087 : MessageExpression { $$ = $1; }
2088 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2093 /* Cycript: @import Directive {{{ */
2095 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2096 | Word { $$ = CYNew CYModule($1); }
2100 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2105 /* Cycript (Objective-C): Boxed Expressions {{{ */
2107 : NullLiteral { $$ = $1; }
2108 | BooleanLiteral { $$ = $1; }
2109 | NumericLiteral { $$ = $1; }
2110 | StringLiteral { $$ = $1; }
2111 | ArrayLiteral { $$ = $1; }
2112 | ObjectLiteral { $$ = $1; }
2113 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2114 | "YES" { $$ = CYNew CYTrue(); }
2115 | "NO" { $$ = CYNew CYFalse(); }
2119 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2120 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2121 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2122 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2123 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2124 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2127 /* Cycript (Objective-C): Block Expressions {{{ */
2129 : "^" TypedIdentifier { if ($2->identifier_ != NULL) CYERR($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else CYERR($2->location_, "expected parameters"); }
2132 /* Cycript (Objective-C): Instance Literals {{{ */
2134 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2140 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2141 LeftHandSideExpression
2142 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2146 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2150 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2151 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2152 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2155 /* Cycript (C): auto Compatibility {{{ */
2160 /* Cycript (C): Lambda Expressions {{{ */
2162 : "," TypedParameterList { $$ = $2; }
2167 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2170 TypedParameterListOpt
2171 : TypedParameterList { $$ = $1; }
2176 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2179 /* Cycript (C): Type Definitions {{{ */
2181 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2184 /* Cycript (C): extern "C" {{{ */
2186 : "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); }
2193 /* Lexer State {{{ */
2195 : { driver.PushCondition(CYDriver::RegExpCondition); }
2199 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2203 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2207 : { driver.PopCondition(); }
2211 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2215 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2218 /* Virtual Tokens {{{ */
2225 /* 8.1 Context Keywords {{{ */
2227 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2228 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2231 /* 8.3 XML Initializer Input Elements {{{ */
2233 : XMLComment { $$ = $1; }
2234 | XMLCDATA { $$ = $1; }
2235 | XMLPI { $$ = $1; }
2239 /* 11.1 Primary Expressions {{{ */
2241 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2242 | XMLInitialiser { $$ = $1; }
2243 | XMLListInitialiser { $$ = $1; }
2247 : AttributeIdentifier { $$ = $1; }
2248 | QualifiedIdentifier { $$ = $1; }
2249 | WildcardIdentifier { $$ = $1; }
2252 /* 11.1.1 Attribute Identifiers {{{ */
2254 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2258 : PropertySelector { $$ = $1; }
2259 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2263 : Identifier { $$ = CYNew CYSelector($1); }
2264 | WildcardIdentifier { $$ = $1; }
2267 /* 11.1.2 Qualified Identifiers {{{ */
2268 QualifiedIdentifier_
2269 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2270 | QualifiedIdentifier { $$ = $1; }
2274 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2277 /* 11.1.3 Wildcard Identifiers {{{ */
2279 : "*" { $$ = CYNew CYWildcard(); }
2282 /* 11.1.4 XML Initializer {{{ */
2284 : XMLMarkup { $$ = $1; }
2285 | XMLElement { $$ = $1; }
2289 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2290 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2294 : LexPushXMLTag XMLTagName XMLAttributes
2298 : BRACE LexPushRegExp Expression LexPop "}"
2307 : XMLAttributes_ XMLAttribute
2312 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2313 | XMLAttributes_ XMLWhitespaceOpt
2322 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2326 : XMLExpression XMLElementContentOpt
2327 | XMLMarkup XMLElementContentOpt
2328 | XMLText XMLElementContentOpt
2329 | XMLElement XMLElementContentOpt
2332 XMLElementContentOpt
2337 /* 11.1.5 XMLList Initializer {{{ */
2339 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2343 /* 11.2 Left-Hand-Side Expressions {{{ */
2345 : Identifier { $$ = $1; }
2346 | PropertyIdentifier { $$ = $1; }
2350 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2351 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2352 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2355 /* 12.1 The default xml namespace Statement {{{ */
2356 /* XXX: DefaultXMLNamespaceStatement
2357 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2361 : DefaultXMLNamespaceStatement { $$ = $1; }
2366 /* JavaScript FTL: Array Comprehensions {{{ */
2368 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2372 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2375 /* JavaScript FTL: for each {{{ */
2377 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2381 /* JavaScript FTW: Array Comprehensions {{{ */
2383 : ArrayComprehension
2387 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2391 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2396 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2397 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2401 : "for" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2402 | "for" "(" LexPushInOn ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2406 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2409 /* JavaScript FTW: Coalesce Operator {{{ */
2410 ConditionalExpression
2411 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2414 /* JavaScript FTW: Named Arguments {{{ */
2416 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2419 /* JavaScript FTW: Ruby Blocks {{{ */
2420 RubyProcParameterList_
2421 : "," RubyProcParameterList { $$ = $2; }
2425 RubyProcParameterList
2426 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2431 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2432 | LexSetRegExp "||" { $$ = NULL; }
2435 RubyProcParametersOpt
2436 : RubyProcParameters { $$ = $1; }
2437 | LexSetRegExp { $$ = NULL; }
2441 : { CYLIN(OpenBrace); }
2445 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2449 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2453 : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); }
2459 bool CYDriver::Parse(CYMark mark) {
2461 CYLocal<CYPool> local(&pool_);
2462 cy::parser parser(*this);
2464 parser.set_debug_level(debug_);
2466 return parser.parse() != 0;
2469 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2473 CYDriver::Error error;
2474 error.warning_ = true;
2475 error.location_ = location;
2476 error.message_ = message;
2477 errors_.push_back(error);
2480 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2481 CYDriver::Error error;
2482 error.warning_ = false;
2483 error.location_ = location;
2484 error.message_ = message;
2485 driver.errors_.push_back(error);