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.return_.top())
147 token = tk::_return__;
151 if (driver.yield_.top())
152 token = tk::_yield__;
156 if (driver.newline_ == CYDriver::NewLineLast)
157 token = tk::EqualRight_;
160 case tk::HyphenHyphen:
161 if (driver.newline_ == CYDriver::NewLineLast)
162 token = tk::HyphenHyphen_;
166 driver.newline_ = CYDriver::NewLineHere;
172 if (driver.newline_ == CYDriver::NewLineLast)
173 token = tk::OpenBrace_;
177 if (driver.newline_ == CYDriver::NewLineLast)
178 token = tk::PlusPlus_;
182 driver.next_ = false;
186 #define CYLEX() do if (yyla.empty()) { \
187 YYCDEBUG << "Mapping a token: "; \
188 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
189 YY_SYMBOL_PRINT("Next token is", yyla); \
192 #define CYMAP(to, from) do { \
194 if (yyla.type == yytranslate_(token::from)) \
195 yyla.type = yytranslate_(token::to); \
198 #define CYERR(location, message) do { \
199 error(location, message); \
203 #define CYNOT(location) \
204 CYERR(location, "unimplemented feature")
213 @$.begin.filename = @$.end.filename = &driver.filename_;
219 %define api.location.type { CYLocation }
226 %param { CYDriver &driver }
228 /* Token Declarations {{{ */
234 %token XMLAttributeValue
236 %token XMLTagCharacters
242 %token LeftRight "<>"
243 %token LeftSlashRight "</>"
245 %token SlashRight "/>"
246 %token LeftSlash "</"
248 %token ColonColon "::"
249 %token PeriodPeriod ".."
252 @begin E4X ObjectiveC
258 %token AmpersandAmpersand "&&"
259 %token AmpersandEqual "&="
261 %token CarrotEqual "^="
263 %token EqualEqual "=="
264 %token EqualEqualEqual "==="
265 %token EqualRight "=>"
266 %token EqualRight_ "\n=>"
267 %token Exclamation "!"
268 %token ExclamationEqual "!="
269 %token ExclamationEqualEqual "!=="
271 %token HyphenEqual "-="
272 %token HyphenHyphen "--"
273 %token HyphenHyphen_ "\n--"
274 %token HyphenRight "->"
276 %token LeftEqual "<="
278 %token LeftLeftEqual "<<="
280 %token PercentEqual "%="
282 %token PeriodPeriodPeriod "..."
284 %token PipeEqual "|="
287 %token PlusEqual "+="
289 %token PlusPlus_ "\n++"
291 %token RightEqual ">="
292 %token RightRight ">>"
293 %token RightRightEqual ">>="
294 %token RightRightRight ">>>"
295 %token RightRightRightEqual ">>>="
297 %token SlashEqual "/="
299 %token StarEqual "*="
311 %token CloseParen ")"
314 %token OpenBrace_ "\n{"
315 %token OpenBrace__ ";{"
316 %token CloseBrace "}"
318 %token OpenBracket "["
319 %token CloseBracket "]"
321 %token At_error_ "@error"
324 %token At_class_ "@class"
328 %token _typedef_ "typedef"
329 %token _unsigned_ "unsigned"
330 %token _signed_ "signed"
331 %token _extern_ "extern"
335 %token At_encode_ "@encode"
339 %token At_implementation_ "@implementation"
340 %token At_import_ "@import"
341 %token At_end_ "@end"
342 %token At_selector_ "@selector"
343 %token At_null_ "@null"
344 %token At_YES_ "@YES"
346 %token At_true_ "@true"
347 %token At_false_ "@false"
352 %token _false_ "false"
356 %token _break_ "break"
358 %token _catch_ "catch"
359 %token _class_ "class"
360 %token _class__ ";class"
361 %token _const_ "const"
362 %token _continue_ "continue"
363 %token _debugger_ "debugger"
364 %token _default_ "default"
365 %token _delete_ "delete"
369 %token _export_ "export"
370 %token _extends_ "extends"
371 %token _finally_ "finally"
373 %token _function_ "function"
374 %token _function__ ";function"
376 %token _import_ "import"
379 %token _Infinity_ "Infinity"
380 %token _instanceof_ "instanceof"
382 %token _return_ "return"
383 %token _return__ "!return"
384 %token _super_ "super"
385 %token _switch_ "switch"
386 %token _target_ "target"
388 %token _throw_ "throw"
390 %token _typeof_ "typeof"
393 %token _while_ "while"
396 %token _abstract_ "abstract"
397 %token _await_ "await"
398 %token _boolean_ "boolean"
401 %token _constructor_ "constructor"
402 %token _double_ "double"
404 %token _final_ "final"
405 %token _float_ "float"
409 %token _implements_ "implements"
411 %token _interface_ "interface"
414 %token _native_ "native"
415 %token _package_ "package"
416 %token _private_ "private"
417 %token _protected_ "protected"
418 %token _prototype_ "prototype"
419 %token _public_ "public"
421 %token _short_ "short"
422 %token _static_ "static"
423 %token _synchronized_ "synchronized"
424 %token _throws_ "throws"
425 %token _transient_ "transient"
426 %token _volatile_ "volatile"
427 %token _yield_ "yield"
428 %token _yield__ "!yield"
430 %token _undefined_ "undefined"
446 %token _namespace_ "namespace"
453 %token <identifier_> Identifier_
454 %token <number_> NumericLiteral
455 %token <string_> StringLiteral
456 %token <literal_> RegularExpressionLiteral
458 %token <string_> NoSubstitutionTemplate
459 %token <string_> TemplateHead
460 %token <string_> TemplateMiddle
461 %token <string_> TemplateTail
463 %type <expression_> AdditiveExpression
464 %type <argument_> ArgumentList_
465 %type <argument_> ArgumentList
466 %type <argument_> ArgumentListOpt
467 %type <argument_> Arguments
468 %type <target_> ArrayComprehension
469 %type <literal_> ArrayLiteral
470 %type <expression_> ArrowFunction
471 %type <functionParameter_> ArrowParameters
472 %type <expression_> AssignmentExpression
473 %type <expression_> AssignmentExpressionOpt
474 %type <identifier_> BindingIdentifier
475 %type <identifier_> BindingIdentifierOpt
476 %type <declarations_> BindingList_
477 %type <declarations_> BindingList
478 %type <expression_> BitwiseANDExpression
479 %type <statement_> Block
480 %type <statement_> BlockStatement
481 %type <boolean_> BooleanLiteral
482 %type <declaration_> BindingElement
483 %type <expression_> BitwiseORExpression
484 %type <expression_> BitwiseXORExpression
485 %type <statement_> BreakStatement
486 %type <statement_> BreakableStatement
487 %type <expression_> CallExpression_
488 %type <target_> CallExpression
489 %type <clause_> CaseBlock
490 %type <clause_> CaseClause
491 %type <clause_> CaseClausesOpt
493 %type <identifier_> CatchParameter
494 %type <statement_> ClassDeclaration
495 %type <target_> ClassExpression
496 %type <classTail_> ClassHeritage
497 %type <classTail_> ClassHeritageOpt
498 %type <classTail_> ClassTail
499 %type <target_> Comprehension
500 %type <comprehension_> ComprehensionFor
501 %type <comprehension_> ComprehensionIf
502 %type <comprehension_> ComprehensionTail
503 %type <propertyName_> ComputedPropertyName
504 %type <expression_> ConditionalExpression
505 %type <statement_> ContinueStatement
506 %type <statement_> ConciseBody
507 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
508 %type <statement_> DebuggerStatement
509 %type <statement_> Declaration__
510 %type <statement_> Declaration_
511 %type <statement_> Declaration
512 %type <clause_> DefaultClause
513 %type <element_> ElementList
514 %type <element_> ElementListOpt
515 %type <statement_> ElseStatementOpt
516 %type <for_> EmptyStatement
517 %type <expression_> EqualityExpression
518 %type <expression_> Expression
519 %type <expression_> ExpressionOpt
520 %type <for_> ExpressionStatement_
521 %type <statement_> ExpressionStatement
522 %type <finally_> Finally
523 %type <declaration_> ForBinding
524 %type <forin_> ForDeclaration
525 %type <forin_> ForInStatementInitializer
526 %type <for_> ForStatementInitializer
527 %type <declaration_> FormalParameter
528 %type <functionParameter_> FormalParameterList_
529 %type <functionParameter_> FormalParameterList
530 %type <functionParameter_> FormalParameters
531 %type <statement_> FunctionBody
532 %type <statement_> FunctionDeclaration
533 %type <target_> FunctionExpression
534 %type <statement_> FunctionStatementList
535 %type <statement_> GeneratorBody
536 %type <statement_> GeneratorDeclaration
537 %type <target_> GeneratorExpression
538 %type <method_> GeneratorMethod
539 %type <statement_> HoistableDeclaration
540 %type <identifier_> Identifier
541 %type <identifier_> IdentifierType
542 %type <word_> IdentifierName
543 %type <variable_> IdentifierReference
544 %type <statement_> IfStatement
545 %type <expression_> Initializer
546 %type <expression_> InitializerOpt
547 %type <statement_> IterationStatement
548 %type <identifier_> LabelIdentifier
549 %type <statement_> LabelledItem
550 %type <statement_> LabelledStatement
551 %type <assignment_> LeftHandSideAssignment
552 %type <target_> LeftHandSideExpression
553 %type <bool_> LetOrConst
554 %type <declaration_> LexicalBinding
555 %type <for_> LexicalDeclaration_
556 %type <statement_> LexicalDeclaration
557 %type <literal_> Literal
558 %type <propertyName_> LiteralPropertyName
559 %type <expression_> LogicalANDExpression
560 %type <expression_> LogicalORExpression
561 %type <access_> MemberAccess
562 %type <target_> MemberExpression
563 %type <method_> MethodDefinition
564 %type <module_> ModulePath
565 %type <expression_> MultiplicativeExpression
566 %type <target_> NewExpression
567 %type <null_> NullLiteral
568 %type <literal_> ObjectLiteral
569 %type <expression_> PostfixExpression
570 %type <target_> PrimaryExpression
571 %type <propertyName_> PropertyName
572 %type <property_> PropertyDefinition
573 %type <property_> PropertyDefinitionList_
574 %type <property_> PropertyDefinitionList
575 %type <property_> PropertyDefinitionListOpt
576 %type <declaration_> PropertySetParameterList
577 %type <expression_> RelationalExpression
578 %type <statement_> ReturnStatement
579 %type <rubyProc_> RubyProcExpression
580 %type <functionParameter_> RubyProcParameterList_
581 %type <functionParameter_> RubyProcParameterList
582 %type <functionParameter_> RubyProcParameters
583 %type <functionParameter_> RubyProcParametersOpt
584 %type <statement_> Script
585 %type <statement_> ScriptBody
586 %type <statement_> ScriptBodyOpt
587 %type <expression_> ShiftExpression
588 %type <declaration_> SingleNameBinding
589 %type <statement_> Statement__
590 %type <statement_> Statement_
591 %type <statement_> Statement
592 %type <statement_> StatementList
593 %type <statement_> StatementListOpt
594 %type <statement_> StatementListItem
595 %type <functionParameter_> StrictFormalParameters
596 %type <target_> SuperCall
597 %type <target_> SuperProperty
598 %type <statement_> SwitchStatement
599 %type <target_> TemplateLiteral
600 %type <span_> TemplateSpans
601 %type <statement_> ThrowStatement
602 %type <statement_> TryStatement
603 %type <expression_> UnaryExpression_
604 %type <expression_> UnaryExpression
605 %type <declaration_> VariableDeclaration
606 %type <declarations_> VariableDeclarationList_
607 %type <declarations_> VariableDeclarationList
608 %type <for_> VariableStatement_
609 %type <statement_> VariableStatement
610 %type <statement_> WithStatement
613 %type <word_> WordOpt
615 %type <expression_> YieldExpression
618 %type <specifier_> IntegerType
619 %type <specifier_> IntegerTypeOpt
620 %type <typedIdentifier_> PrefixedType
621 %type <specifier_> PrimitiveType
622 %type <typedIdentifier_> SuffixedType
623 %type <typedIdentifier_> TypeSignifier
624 %type <modifier_> TypeQualifierLeft
625 %type <typedIdentifier_> TypeQualifierRight
626 %type <typedIdentifier_> TypedIdentifier
627 %type <typedParameter_> TypedParameterList_
628 %type <typedParameter_> TypedParameterList
629 %type <typedParameter_> TypedParameterListOpt
633 %type <expression_> AssignmentExpressionClassic
634 %type <expression_> BoxableExpression
635 %type <statement_> CategoryStatement
636 %type <expression_> ClassSuperOpt
637 %type <expression_> ConditionalExpressionClassic
638 %type <implementationField_> ImplementationFieldListOpt
639 %type <implementationField_> ImplementationFields
640 %type <message_> ClassMessageDeclaration
641 %type <message_> ClassMessageDeclarationListOpt
642 %type <protocol_> ClassProtocolListOpt
643 %type <protocol_> ClassProtocols
644 %type <protocol_> ClassProtocolsOpt
645 %type <statement_> ImplementationStatement
646 %type <target_> MessageExpression
647 %type <messageParameter_> MessageParameter
648 %type <messageParameter_> MessageParameters
649 %type <messageParameter_> MessageParameterList
650 %type <messageParameter_> MessageParameterListOpt
651 %type <bool_> MessageScope
652 %type <argument_> SelectorCall_
653 %type <argument_> SelectorCall
654 %type <selector_> SelectorExpression_
655 %type <selector_> SelectorExpression
656 %type <selector_> SelectorExpressionOpt
657 %type <argument_> SelectorList
658 %type <word_> SelectorWordOpt
659 %type <typedIdentifier_> TypeOpt
660 %type <argument_> VariadicCall
664 %type <propertyIdentifier_> PropertyIdentifier_
665 %type <selector_> PropertySelector_
666 %type <selector_> PropertySelector
667 %type <identifier_> QualifiedIdentifier_
668 %type <identifier_> QualifiedIdentifier
669 %type <identifier_> WildcardIdentifier
670 %type <identifier_> XMLComment
671 %type <identifier_> XMLCDATA
672 %type <identifier_> XMLElement
673 %type <identifier_> XMLElementContent
674 %type <identifier_> XMLMarkup
675 %type <identifier_> XMLPI
677 %type <attribute_> AttributeIdentifier
678 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
679 %type <expression_> PropertyIdentifier
680 %type <expression_> XMLListInitialiser
681 %type <expression_> XMLInitialiser
684 /* Token Priorities {{{ */
703 /* Lexer State {{{ */
704 LexPushInOn: { driver.in_.push(true); };
705 LexPushInOff: { driver.in_.push(false); };
706 LexPopIn: { driver.in_.pop(); };
708 LexPushReturnOn: { driver.return_.push(true); };
709 LexPopReturn: { driver.return_.pop(); };
711 LexPushSuperOn: { driver.super_.push(true); };
712 LexPushSuperOff: { driver.super_.push(false); };
713 LexPopSuper: { driver.super_.pop(); };
715 LexPushYieldOn: { driver.yield_.push(true); };
716 LexPushYieldOff: { driver.yield_.push(false); };
717 LexPopYield: { driver.yield_.pop(); };
720 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
724 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
728 : { CYMAP(YieldStar, Star); }
732 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
736 : { CYMAP(_class__, _class_); }
740 : { CYMAP(_function__, _function_); }
744 : LexNoBrace LexNoClass LexNoFunction
747 /* Virtual Tokens {{{ */
758 /* 11.6 Names and Keywords {{{ */
761 | "for" { $$ = CYNew CYWord("for"); }
762 | "in" { $$ = CYNew CYWord("in"); }
763 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
772 : Identifier { $$ = $1; }
773 | "auto" { $$ = CYNew CYWord("auto"); }
774 | "break" { $$ = CYNew CYWord("break"); }
775 | "case" { $$ = CYNew CYWord("case"); }
776 | "catch" { $$ = CYNew CYWord("catch"); }
777 | "class" { $$ = CYNew CYWord("class"); }
778 | ";class" { $$ = CYNew CYWord("class"); }
779 | "const" { $$ = CYNew CYWord("const"); }
780 | "continue" { $$ = CYNew CYWord("continue"); }
781 | "debugger" { $$ = CYNew CYWord("debugger"); }
782 | "default" { $$ = CYNew CYWord("default"); }
783 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
784 | "do" { $$ = CYNew CYWord("do"); }
785 | "else" { $$ = CYNew CYWord("else"); }
786 | "enum" { $$ = CYNew CYWord("enum"); }
787 | "export" { $$ = CYNew CYWord("export"); }
788 | "extends" { $$ = CYNew CYWord("extends"); }
789 | "false" { $$ = CYNew CYWord("false"); }
790 | "finally" { $$ = CYNew CYWord("finally"); }
791 | "function" { $$ = CYNew CYWord("function"); }
792 | "if" { $$ = CYNew CYWord("if"); }
793 | "import" { $$ = CYNew CYWord("import"); }
794 | "!in" { $$ = CYNew CYWord("in"); }
795 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
796 | "null" { $$ = CYNew CYWord("null"); }
797 | "return" { $$ = CYNew CYWord("return"); }
798 | "!return" { $$ = CYNew CYWord("return"); }
799 | "super" { $$ = CYNew CYWord("super"); }
800 | "switch" { $$ = CYNew CYWord("switch"); }
801 | "this" { $$ = CYNew CYWord("this"); }
802 | "throw" { $$ = CYNew CYWord("throw"); }
803 | "true" { $$ = CYNew CYWord("true"); }
804 | "try" { $$ = CYNew CYWord("try"); }
805 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
806 | "var" { $$ = CYNew CYWord("var"); }
807 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
808 | "while" { $$ = CYNew CYWord("while"); }
809 | "with" { $$ = CYNew CYWord("with"); }
810 | "yield" { $$ = CYNew CYIdentifier("yield"); }
812 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
814 // XXX: should be Identifier
815 | "let" { $$ = CYNew CYIdentifier("let"); }
825 /* 11.8.1 Null Literals {{{ */
827 : "null" { $$ = CYNew CYNull(); }
830 /* 11.8.2 Boolean Literals {{{ */
832 : "true" { $$ = CYNew CYTrue(); }
833 | "false" { $$ = CYNew CYFalse(); }
837 /* 11.9 Automatic Semicolon Insertion {{{ */
839 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
849 | 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
854 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
858 /* 12.1 Identifiers {{{ */
860 : Identifier { $$ = CYNew CYVariable($1); }
861 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
865 : Identifier { $$ = $1; }
866 | "yield" { $$ = CYNew CYIdentifier("yield"); }
870 : BindingIdentifier { $$ = $1; }
875 : Identifier { $$ = $1; }
876 | "yield" { $$ = CYNew CYIdentifier("yield"); }
880 : Identifier_ { $$ = $1; }
881 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
882 | "await" { $$ = CYNew CYIdentifier("await"); }
883 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
884 | "byte" { $$ = CYNew CYIdentifier("byte"); }
885 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
886 | "double" { $$ = CYNew CYIdentifier("double"); }
887 | "each" { $$ = CYNew CYIdentifier("each"); }
888 | "eval" { $$ = CYNew CYIdentifier("eval"); }
889 | "final" { $$ = CYNew CYIdentifier("final"); }
890 | "float" { $$ = CYNew CYIdentifier("float"); }
891 | "from" { $$ = CYNew CYIdentifier("from"); }
892 | "get" { $$ = CYNew CYIdentifier("get"); }
893 | "goto" { $$ = CYNew CYIdentifier("goto"); }
894 | "implements" { $$ = CYNew CYIdentifier("implements"); }
895 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
896 | "interface" { $$ = CYNew CYIdentifier("interface"); }
897 | "native" { $$ = CYNew CYIdentifier("native"); }
898 | "of" { $$ = CYNew CYIdentifier("of"); }
899 | "package" { $$ = CYNew CYIdentifier("package"); }
900 | "private" { $$ = CYNew CYIdentifier("private"); }
901 | "protected" { $$ = CYNew CYIdentifier("protected"); }
902 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
903 | "public" { $$ = CYNew CYIdentifier("public"); }
904 | "set" { $$ = CYNew CYIdentifier("set"); }
905 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
906 | "target" { $$ = CYNew CYIdentifier("target"); }
907 | "throws" { $$ = CYNew CYIdentifier("throws"); }
908 | "transient" { $$ = CYNew CYIdentifier("transient"); }
909 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
911 | "bool" { $$ = CYNew CYIdentifier("bool"); }
912 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
913 | "id" { $$ = CYNew CYIdentifier("id"); }
914 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
920 | "char" { $$ = CYNew CYIdentifier("char"); }
921 | "int" { $$ = CYNew CYIdentifier("int"); }
922 | "long" { $$ = CYNew CYIdentifier("long"); }
923 | "short" { $$ = CYNew CYIdentifier("short"); }
924 | "static" { $$ = CYNew CYIdentifier("static"); }
925 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
927 | "extern" { $$ = CYNew CYIdentifier("extern"); }
928 | "signed" { $$ = CYNew CYIdentifier("signed"); }
929 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
930 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
933 | "nil" { $$ = CYNew CYIdentifier("nil"); }
934 | "NO" { $$ = CYNew CYIdentifier("NO"); }
935 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
936 | "YES" { $$ = CYNew CYIdentifier("YES"); }
940 /* 12.2 Primary Expression {{{ */
942 : "this" { $$ = CYNew CYThis(); }
943 | IdentifierReference { $$ = $1; }
944 | Literal { $$ = $1; }
945 | ArrayLiteral { $$ = $1; }
946 | ObjectLiteral { $$ = $1; }
947 | FunctionExpression { $$ = $1; }
948 | ClassExpression { $$ = $1; }
949 | GeneratorExpression { $$ = $1; }
950 | RegularExpressionLiteral { $$ = $1; }
951 | TemplateLiteral { $$ = $1; }
952 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
953 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
956 CoverParenthesizedExpressionAndArrowParameterList
957 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
958 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
959 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
960 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
963 /* 12.2.4 Literals {{{ */
965 : NullLiteral { $$ = $1; }
966 | BooleanLiteral { $$ = $1; }
967 | NumericLiteral { $$ = $1; }
968 | StringLiteral { $$ = $1; }
971 /* 12.2.5 Array Initializer {{{ */
973 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
977 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
978 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
979 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
983 : ElementList { $$ = $1; }
984 | LexSetRegExp { $$ = NULL; }
987 /* 12.2.6 Object Initializer {{{ */
989 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
992 PropertyDefinitionList_
993 : "," PropertyDefinitionListOpt { $$ = $2; }
997 PropertyDefinitionList
998 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
1001 PropertyDefinitionListOpt
1002 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
1003 | LexSetRegExp { $$ = NULL; }
1007 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
1008 | CoverInitializedName { CYNOT(@$); }
1009 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
1010 | MethodDefinition { $$ = $1; }
1014 : LiteralPropertyName { $$ = $1; }
1015 | ComputedPropertyName { $$ = $1; }
1019 : IdentifierName { $$ = $1; }
1020 | StringLiteral { $$ = $1; }
1021 | NumericLiteral { $$ = $1; }
1024 ComputedPropertyName
1025 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
1028 CoverInitializedName
1029 : IdentifierReference Initializer
1033 : "=" AssignmentExpression { $$ = $2; }
1037 : Initializer { $$ = $1; }
1041 /* 12.2.9 Template Literals {{{ */
1043 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
1044 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
1048 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
1049 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
1053 /* 12.3 Left-Hand-Side Expressions {{{ */
1055 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
1056 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1057 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1058 | TemplateLiteral { CYNOT(@$); }
1062 : LexSetRegExp PrimaryExpression { $$ = $2; }
1063 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1064 | SuperProperty { $$ = $1; }
1065 | MetaProperty { CYNOT(@$); }
1066 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1070 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
1071 | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
1079 : LexSetRegExp "new" LexSetRegExp "." "target"
1083 : MemberExpression { $$ = $1; }
1084 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1088 : MemberExpression { $$ = $1; }
1089 | CallExpression { $$ = $1; }
1093 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1094 | SuperCall { $$ = $1; }
1095 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1099 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
1103 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1107 : "," ArgumentList { $$ = $2; }
1112 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1113 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1117 : ArgumentList { $$ = $1; }
1118 | LexSetRegExp { $$ = NULL; }
1121 LeftHandSideExpression
1122 : NewExpression { $$ = $1; }
1123 | CallExpression { $$ = $1; }
1126 /* 12.4 Postfix Expressions {{{ */
1128 : %prec "" LeftHandSideExpression { $$ = $1; }
1129 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1130 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1133 /* 12.5 Unary Operators {{{ */
1135 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1136 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1137 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1138 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1139 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1140 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1141 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1142 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1143 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1144 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1145 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1149 : %prec "" PostfixExpression { $$ = $1; }
1150 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1153 /* 12.6 Multiplicative Operators {{{ */
1154 MultiplicativeExpression
1155 : UnaryExpression { $$ = $1; }
1156 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1157 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1158 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1161 /* 12.7 Additive Operators {{{ */
1163 : MultiplicativeExpression { $$ = $1; }
1164 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1165 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1168 /* 12.8 Bitwise Shift Operators {{{ */
1170 : AdditiveExpression { $$ = $1; }
1171 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1172 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1173 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1176 /* 12.9 Relational Operators {{{ */
1177 RelationalExpression
1178 : ShiftExpression { $$ = $1; }
1179 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1180 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1181 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1182 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1183 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1184 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1187 /* 12.10 Equality Operators {{{ */
1189 : RelationalExpression { $$ = $1; }
1190 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1191 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1192 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1193 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1196 /* 12.11 Binary Bitwise Operators {{{ */
1197 BitwiseANDExpression
1198 : EqualityExpression { $$ = $1; }
1199 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1202 BitwiseXORExpression
1203 : BitwiseANDExpression { $$ = $1; }
1204 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1208 : BitwiseXORExpression { $$ = $1; }
1209 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1212 /* 12.12 Binary Logical Operators {{{ */
1213 LogicalANDExpression
1214 : BitwiseORExpression { $$ = $1; }
1215 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1219 : LogicalANDExpression { $$ = $1; }
1220 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1223 /* 12.13 Conditional Operator ( ? : ) {{{ */
1225 ConditionalExpressionClassic
1226 : LogicalORExpression { $$ = $1; }
1227 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
1231 ConditionalExpression
1232 : LogicalORExpression { $$ = $1; }
1233 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1236 /* 12.14 Assignment Operators {{{ */
1237 LeftHandSideAssignment
1238 : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
1239 | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
1240 | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
1241 | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
1242 | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
1243 | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
1244 | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
1245 | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
1246 | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
1247 | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
1248 | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
1249 | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
1253 AssignmentExpressionClassic
1254 : ConditionalExpressionClassic { $$ = $1; }
1255 | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
1259 AssignmentExpression
1260 : ConditionalExpression { $$ = $1; }
1261 | LexSetRegExp YieldExpression { $$ = $2; }
1262 | ArrowFunction { $$ = $1; }
1263 | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
1266 AssignmentExpressionOpt
1267 : AssignmentExpression { $$ = $1; }
1268 | LexSetRegExp { $$ = NULL; }
1271 /* 12.15 Comma Operator ( , ) {{{ */
1273 : AssignmentExpression { $$ = $1; }
1274 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1278 : Expression { $$ = $1; }
1279 | LexSetRegExp { $$ = NULL; }
1283 /* 13 Statements and Declarations {{{ */
1285 : BlockStatement { $$ = $1; }
1286 | VariableStatement { $$ = $1; }
1287 | EmptyStatement { $$ = $1; }
1288 | IfStatement { $$ = $1; }
1289 | BreakableStatement { $$ = $1; }
1290 | ContinueStatement { $$ = $1; }
1291 | BreakStatement { $$ = $1; }
1292 | ReturnStatement { $$ = $1; }
1293 | WithStatement { $$ = $1; }
1294 | LabelledStatement { $$ = $1; }
1295 | ThrowStatement { $$ = $1; }
1296 | TryStatement { $$ = $1; }
1297 | DebuggerStatement { $$ = $1; }
1301 : LexSetRegExp Statement__ { $$ = $2; }
1302 | ExpressionStatement { $$ = $1; }
1306 : LexSetStatement Statement_ { $$ = $2; }
1310 : HoistableDeclaration { $$ = $1; }
1311 | ClassDeclaration { $$ = $1; }
1312 | LexicalDeclaration { $$ = $1; }
1316 : LexSetRegExp Declaration__ { $$ = $2; }
1320 : LexSetStatement Declaration_ { $$ = $2; }
1323 HoistableDeclaration
1324 : FunctionDeclaration { $$ = $1; }
1325 | GeneratorDeclaration { $$ = $1; }
1329 : IterationStatement { $$ = $1; }
1330 | SwitchStatement { $$ = $1; }
1333 /* 13.2 Block {{{ */
1335 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1339 : BRACE StatementListOpt "}" { $$ = $2; }
1343 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1347 : StatementList { $$ = $1; }
1348 | LexSetStatement LexSetRegExp { $$ = NULL; }
1352 : Statement { $$ = $1; }
1353 | Declaration { $$ = $1; }
1356 /* 13.3 Let and Const Declarations {{{ */
1358 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1362 : LexicalDeclaration_ Terminator { $$ = $1; }
1366 : "let" { $$ = false; }
1367 | "const" { $$ = true; }
1371 : "," BindingList { $$ = $2; }
1376 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1380 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1381 | BindingPattern Initializer { CYNOT(@1); }
1384 /* 13.3.2 Variable Statement {{{ */
1386 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1390 : VariableStatement_ Terminator { $$ = $1; }
1393 VariableDeclarationList_
1394 : "," VariableDeclarationList { $$ = $2; }
1398 VariableDeclarationList
1399 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1403 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1404 | BindingPattern Initializer { CYNOT(@1); }
1407 /* 13.3.3 Destructuring Binding Patterns {{{ */
1409 : ObjectBindingPattern
1410 | ArrayBindingPattern
1413 ObjectBindingPattern
1414 : BRACE BindingPropertyListOpt "}"
1418 : "[" { CYNOT(@$); }
1421 BindingPropertyList_
1422 : "," BindingPropertyListOpt
1427 : BindingProperty BindingPropertyList_
1430 BindingPropertyListOpt
1431 : BindingPropertyList
1437 | PropertyName ":" BindingElement
1441 : SingleNameBinding { $$ = $1; }
1442 | BindingPattern InitializerOpt { CYNOT(@$); }
1446 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1450 : "..." BindingIdentifier
1453 /* 13.4 Empty Statement {{{ */
1455 : ";" { $$ = CYNew CYEmpty(); }
1458 /* 13.5 Expression Statement {{{ */
1459 ExpressionStatement_
1460 : Expression { $$ = CYNew CYExpress($1); }
1463 : ExpressionStatement_ Terminator { $$ = $1; }
1466 /* 13.6 The if Statement {{{ */
1468 : "else" Statement { $$ = $2; }
1469 | %prec "if" { $$ = NULL; }
1473 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1476 /* 13.7 Iteration Statements {{{ */
1478 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1479 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1480 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1481 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1482 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1483 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1486 ForStatementInitializer
1487 : LexSetRegExp EmptyStatement { $$ = $2; }
1488 | ExpressionStatement_ ";" { $$ = $1; }
1489 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1490 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1493 ForInStatementInitializer
1494 : LeftHandSideExpression { $$ = $1; }
1495 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1496 | LexSetRegExp ForDeclaration { $$ = $2; }
1500 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1504 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1505 | BindingPattern { CYNOT(@1); }
1508 /* 13.8 The continue Statement {{{ */
1510 : "continue" LexNewLine
1514 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1515 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1518 /* 13.9 The break Statement {{{ */
1520 : "break" LexNewLine
1524 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1525 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1528 /* 13.10 The return Statement {{{ */
1530 : "!return" LexNewLine
1534 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1535 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1538 /* 13.11 The with Statement {{{ */
1540 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1543 /* 13.12 The switch Statement {{{ */
1545 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1549 : BRACE CaseClausesOpt "}" { $$ = $2; }
1553 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1557 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1558 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1562 // XXX: the standard makes certain you can only have one of these
1564 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1567 /* 13.13 Labelled Statements {{{ */
1569 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1573 : Statement { $$ = $1; }
1574 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1577 /* 13.14 The throw Statement {{{ */
1579 : "throw" LexNewLine
1583 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1584 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1587 /* 13.15 The try Statement {{{ */
1589 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1590 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1591 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1595 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1599 : "finally" Block { $$ = CYNew CYFinally($2); }
1603 : BindingIdentifier { $$ = $1; }
1604 | BindingPattern { CYNOT(@$); }
1607 /* 13.16 The debugger Statement {{{ */
1609 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1613 /* 14.1 Function Definitions {{{ */
1615 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1619 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1622 StrictFormalParameters
1623 : FormalParameters { $$ = $1; }
1628 | FormalParameterList
1631 FormalParameterList_
1632 : "," FormalParameterList { $$ = $2; }
1637 : FunctionRestParameter { CYNOT(@$); }
1638 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1641 FunctionRestParameter
1642 : BindingRestElement
1646 : BindingElement { $$ = $1; }
1650 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1653 FunctionStatementList
1654 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1657 /* 14.2 Arrow Function Definitions {{{ */
1659 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1663 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1664 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1668 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1669 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1672 /* 14.3 Method Definitions {{{ */
1674 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1675 | GeneratorMethod { $$ = $1; }
1676 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1677 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1680 PropertySetParameterList
1681 : FormalParameter { $$ = $1; }
1684 /* 14.4 Generator Function Definitions {{{ */
1686 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1689 GeneratorDeclaration
1690 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1694 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1698 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1702 : "!yield" LexNewLine LexNoStar
1706 : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1707 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1708 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1711 /* 14.5 Class Definitions {{{ */
1713 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1717 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1721 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1725 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1729 : ClassHeritage { $$ = $1; }
1730 | { $$ = CYNew CYClassTail(NULL); }
1743 : ClassElementListOpt ClassElement
1752 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1753 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1758 /* 15.1 Scripts {{{ */
1760 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1764 : StatementList { $$ = $1; }
1768 : ScriptBody { $$ = $1; }
1769 | LexSetStatement LexSetRegExp { $$ = NULL; }
1772 /* 15.2 Modules {{{ */
1787 : ModuleItemListOpt ModuleItem
1796 : LexSetStatement LexSetRegExp ImportDeclaration
1797 | LexSetStatement LexSetRegExp ExportDeclaration
1801 /* 15.2.2 Imports {{{ */
1803 : "import" ImportClause FromClause Terminator
1804 | "import" ModuleSpecifier Terminator
1808 : ImportedDefaultBinding
1811 | ImportedDefaultBinding "," NameSpaceImport
1812 | ImportedDefaultBinding "," NamedImports
1815 ImportedDefaultBinding
1820 : "*" "as" ImportedBinding
1824 : BRACE ImportsListOpt "}"
1828 : "from" ModuleSpecifier
1832 : "," ImportsListOpt
1837 : ImportSpecifier ImportsList_
1847 | IdentifierName "as" ImportedBinding
1858 /* 15.2.3 Exports {{{ */
1860 : "*" FromClause Terminator
1861 | ExportClause FromClause Terminator
1862 | ExportClause Terminator
1864 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1865 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1866 | "default" LexSetStatement AssignmentExpression Terminator
1870 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1871 | "export" Declaration
1875 : ";{" ExportsListOpt "}"
1879 : "," ExportsListOpt
1884 : ExportSpecifier ExportsList_
1894 | IdentifierName "as" IdentifierName
1899 /* Cycript (C): Type Encoding {{{ */
1901 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1902 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1906 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1907 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1908 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1909 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1910 | TypeSignifier { $$ = $1; }
1911 | { $$ = CYNew CYTypedIdentifier(@$); }
1915 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1920 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1921 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1925 : PrefixedType { $$ = $1; }
1926 | SuffixedType { $$ = $1; }
1927 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1928 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1932 : "int" { $$ = CYNew CYTypeVariable("int"); }
1933 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1934 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1935 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1936 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1940 : IntegerType { $$ = $1; }
1941 | { $$ = CYNew CYTypeVariable("int"); }
1945 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1946 | IntegerType { $$ = $1; }
1947 | "void" { $$ = CYNew CYTypeVoid(); }
1948 | "char" { $$ = CYNew CYTypeVariable("char"); }
1949 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1950 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1954 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1958 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1964 /* Cycript (Objective-C): @class Declaration {{{ */
1966 /* XXX: why the hell did I choose MemberExpression? */
1967 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1971 ImplementationFieldListOpt
1972 : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
1973 | LexSetRegExp { $$ = NULL; }
1976 ImplementationFields
1977 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1981 : "+" { $$ = false; }
1982 | "-" { $$ = true; }
1986 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1987 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1991 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1994 MessageParameterList
1995 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1998 MessageParameterListOpt
1999 : MessageParameterList { $$ = $1; }
2004 : MessageParameterList { $$ = $1; }
2005 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
2008 ClassMessageDeclaration
2009 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
2012 ClassMessageDeclarationListOpt
2013 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
2017 // XXX: this should be AssignmentExpressionNoRight
2019 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
2023 : "," ClassProtocols { $$ = $2; }
2027 ClassProtocolListOpt
2028 : "<" ClassProtocols ">" { $$ = $2; }
2032 ImplementationStatement
2033 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
2041 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
2045 : ImplementationStatement { $$ = $1; }
2046 | CategoryStatement { $$ = $1; }
2049 /* Cycript (Objective-C): Send Message {{{ */
2051 : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
2056 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
2057 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2061 : SelectorCall { $$ = $1; }
2062 | VariadicCall { $$ = $1; }
2066 : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
2070 : SelectorCall { $$ = $1; }
2071 | Word { $$ = CYNew CYArgument($1, NULL); }
2075 : "[" LexPushInOff AssignmentExpressionClassic { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2076 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2080 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2084 : SelectorExpression_ { $$ = $1; }
2085 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2088 SelectorExpressionOpt
2089 : SelectorExpression_ { $$ = $1; }
2094 : MessageExpression { $$ = $1; }
2095 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2100 /* Cycript: @import Directive {{{ */
2102 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2103 | Word { $$ = CYNew CYModule($1); }
2107 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2112 /* Cycript (Objective-C): Boxed Expressions {{{ */
2114 : NullLiteral { $$ = $1; }
2115 | BooleanLiteral { $$ = $1; }
2116 | NumericLiteral { $$ = $1; }
2117 | StringLiteral { $$ = $1; }
2118 | ArrayLiteral { $$ = $1; }
2119 | ObjectLiteral { $$ = $1; }
2120 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2121 | "YES" { $$ = CYNew CYTrue(); }
2122 | "NO" { $$ = CYNew CYFalse(); }
2126 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2127 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2128 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2129 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2130 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2131 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2134 /* Cycript (Objective-C): Block Expressions {{{ */
2136 : "^" 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"); }
2139 /* Cycript (Objective-C): Instance Literals {{{ */
2141 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2147 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2148 LeftHandSideExpression
2149 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2153 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2157 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2158 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2159 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2162 /* Cycript (C): auto Compatibility {{{ */
2167 /* Cycript (C): Lambda Expressions {{{ */
2169 : "," TypedParameterList { $$ = $2; }
2174 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2177 TypedParameterListOpt
2178 : TypedParameterList { $$ = $1; }
2183 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2186 /* Cycript (C): Type Definitions {{{ */
2188 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2191 /* Cycript (C): extern "C" {{{ */
2193 : "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); }
2200 /* Lexer State {{{ */
2202 : { driver.PushCondition(CYDriver::RegExpCondition); }
2206 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2210 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2214 : { driver.PopCondition(); }
2218 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2222 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2225 /* Virtual Tokens {{{ */
2232 /* 8.1 Context Keywords {{{ */
2234 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2235 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2238 /* 8.3 XML Initializer Input Elements {{{ */
2240 : XMLComment { $$ = $1; }
2241 | XMLCDATA { $$ = $1; }
2242 | XMLPI { $$ = $1; }
2246 /* 11.1 Primary Expressions {{{ */
2248 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2249 | XMLInitialiser { $$ = $1; }
2250 | XMLListInitialiser { $$ = $1; }
2254 : AttributeIdentifier { $$ = $1; }
2255 | QualifiedIdentifier { $$ = $1; }
2256 | WildcardIdentifier { $$ = $1; }
2259 /* 11.1.1 Attribute Identifiers {{{ */
2261 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2265 : PropertySelector { $$ = $1; }
2266 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2270 : Identifier { $$ = CYNew CYSelector($1); }
2271 | WildcardIdentifier { $$ = $1; }
2274 /* 11.1.2 Qualified Identifiers {{{ */
2275 QualifiedIdentifier_
2276 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2277 | QualifiedIdentifier { $$ = $1; }
2281 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2284 /* 11.1.3 Wildcard Identifiers {{{ */
2286 : "*" { $$ = CYNew CYWildcard(); }
2289 /* 11.1.4 XML Initializer {{{ */
2291 : XMLMarkup { $$ = $1; }
2292 | XMLElement { $$ = $1; }
2296 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2297 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2301 : LexPushXMLTag XMLTagName XMLAttributes
2305 : BRACE LexPushRegExp Expression LexPop "}"
2314 : XMLAttributes_ XMLAttribute
2319 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2320 | XMLAttributes_ XMLWhitespaceOpt
2329 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2333 : XMLExpression XMLElementContentOpt
2334 | XMLMarkup XMLElementContentOpt
2335 | XMLText XMLElementContentOpt
2336 | XMLElement XMLElementContentOpt
2339 XMLElementContentOpt
2344 /* 11.1.5 XMLList Initializer {{{ */
2346 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2350 /* 11.2 Left-Hand-Side Expressions {{{ */
2352 : Identifier { $$ = $1; }
2353 | PropertyIdentifier { $$ = $1; }
2357 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2358 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2359 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2362 /* 12.1 The default xml namespace Statement {{{ */
2363 /* XXX: DefaultXMLNamespaceStatement
2364 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2368 : DefaultXMLNamespaceStatement { $$ = $1; }
2373 /* JavaScript FTL: Array Comprehensions {{{ */
2375 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2379 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2382 /* JavaScript FTL: for each {{{ */
2384 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2388 /* JavaScript FTW: Array Comprehensions {{{ */
2390 : ArrayComprehension
2394 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2398 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2403 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2404 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2408 : "for" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2409 | "for" "(" LexPushInOn ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2413 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2416 /* JavaScript FTW: Coalesce Operator {{{ */
2417 ConditionalExpression
2418 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2421 /* JavaScript FTW: Named Arguments {{{ */
2423 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2426 /* JavaScript FTW: Ruby Blocks {{{ */
2427 RubyProcParameterList_
2428 : "," RubyProcParameterList { $$ = $2; }
2432 RubyProcParameterList
2433 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2438 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2439 | LexSetRegExp "||" { $$ = NULL; }
2442 RubyProcParametersOpt
2443 : RubyProcParameters { $$ = $1; }
2444 | LexSetRegExp { $$ = NULL; }
2448 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2452 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2456 : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2462 bool CYDriver::Parse(CYMark mark) {
2464 CYLocal<CYPool> local(&pool_);
2465 cy::parser parser(*this);
2467 parser.set_debug_level(debug_);
2469 return parser.parse() != 0;
2472 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2476 CYDriver::Error error;
2477 error.warning_ = true;
2478 error.location_ = location;
2479 error.message_ = message;
2480 errors_.push_back(error);
2483 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2484 CYDriver::Error error;
2485 error.warning_ = false;
2486 error.location_ = location;
2487 error.message_ = message;
2488 driver.errors_.push_back(error);