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 <target_> AccessExpression
454 %type <expression_> AdditiveExpression
455 %type <argument_> ArgumentList_
456 %type <argument_> ArgumentList
457 %type <argument_> ArgumentListOpt
458 %type <argument_> Arguments
459 %type <target_> ArrayComprehension
460 %type <literal_> ArrayLiteral
461 %type <expression_> ArrowFunction
462 %type <functionParameter_> ArrowParameters
463 %type <expression_> AssignmentExpression
464 %type <expression_> AssignmentExpressionOpt
465 %type <identifier_> BindingIdentifier
466 %type <identifier_> BindingIdentifierOpt
467 %type <declarations_> BindingList_
468 %type <declarations_> BindingList
469 %type <expression_> BitwiseANDExpression
470 %type <statement_> Block
471 %type <statement_> BlockStatement
472 %type <boolean_> BooleanLiteral
473 %type <declaration_> BindingElement
474 %type <expression_> BitwiseORExpression
475 %type <expression_> BitwiseXORExpression
476 %type <statement_> BreakStatement
477 %type <statement_> BreakableStatement
478 %type <expression_> CallExpression_
479 %type <target_> CallExpression
480 %type <clause_> CaseBlock
481 %type <clause_> CaseClause
482 %type <clause_> CaseClausesOpt
484 %type <identifier_> CatchParameter
485 %type <statement_> ClassDeclaration
486 %type <target_> ClassExpression
487 %type <classTail_> ClassHeritage
488 %type <classTail_> ClassHeritageOpt
489 %type <classTail_> ClassTail
490 %type <target_> Comprehension
491 %type <comprehension_> ComprehensionFor
492 %type <comprehension_> ComprehensionIf
493 %type <comprehension_> ComprehensionTail
494 %type <propertyName_> ComputedPropertyName
495 %type <expression_> ConditionalExpression
496 %type <statement_> ContinueStatement
497 %type <statement_> ConciseBody
498 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
499 %type <statement_> DebuggerStatement
500 %type <statement_> Declaration__
501 %type <statement_> Declaration_
502 %type <statement_> Declaration
503 %type <clause_> DefaultClause
504 %type <element_> ElementList
505 %type <element_> ElementListOpt
506 %type <statement_> ElseStatementOpt
507 %type <for_> EmptyStatement
508 %type <expression_> EqualityExpression
509 %type <expression_> Expression
510 %type <expression_> ExpressionOpt
511 %type <for_> ExpressionStatement_
512 %type <statement_> ExpressionStatement
513 %type <finally_> Finally
514 %type <declaration_> ForBinding
515 %type <forin_> ForDeclaration
516 %type <forin_> ForInStatementInitializer
517 %type <for_> ForStatementInitializer
518 %type <declaration_> FormalParameter
519 %type <functionParameter_> FormalParameterList_
520 %type <functionParameter_> FormalParameterList
521 %type <functionParameter_> FormalParameters
522 %type <statement_> FunctionBody
523 %type <statement_> FunctionDeclaration
524 %type <target_> FunctionExpression
525 %type <statement_> FunctionStatementList
526 %type <statement_> GeneratorBody
527 %type <statement_> GeneratorDeclaration
528 %type <target_> GeneratorExpression
529 %type <method_> GeneratorMethod
530 %type <statement_> HoistableDeclaration
531 %type <identifier_> Identifier
532 %type <identifier_> IdentifierType
533 %type <word_> IdentifierName
534 %type <variable_> IdentifierReference
535 %type <statement_> IfStatement
536 %type <target_> IndirectExpression
537 %type <expression_> Initializer
538 %type <expression_> InitializerOpt
539 %type <statement_> IterationStatement
540 %type <identifier_> LabelIdentifier
541 %type <statement_> LabelledItem
542 %type <statement_> LabelledStatement
543 %type <assignment_> LeftHandSideAssignment
544 %type <target_> LeftHandSideExpression
545 %type <bool_> LetOrConst
546 %type <declaration_> LexicalBinding
547 %type <for_> LexicalDeclaration_
548 %type <statement_> LexicalDeclaration
549 %type <literal_> Literal
550 %type <propertyName_> LiteralPropertyName
551 %type <expression_> LogicalANDExpression
552 %type <expression_> LogicalORExpression
553 %type <access_> MemberAccess
554 %type <target_> MemberExpression
555 %type <method_> MethodDefinition
556 %type <module_> ModulePath
557 %type <expression_> MultiplicativeExpression
558 %type <target_> NewExpression
559 %type <null_> NullLiteral
560 %type <literal_> ObjectLiteral
561 %type <expression_> PostfixExpression
562 %type <target_> PrimaryExpression
563 %type <propertyName_> PropertyName
564 %type <property_> PropertyDefinition
565 %type <property_> PropertyDefinitionList_
566 %type <property_> PropertyDefinitionList
567 %type <property_> PropertyDefinitionListOpt
568 %type <declaration_> PropertySetParameterList
569 %type <expression_> RelationalExpression
570 %type <statement_> ReturnStatement
571 %type <rubyProc_> RubyProcExpression
572 %type <functionParameter_> RubyProcParameterList_
573 %type <functionParameter_> RubyProcParameterList
574 %type <functionParameter_> RubyProcParameters
575 %type <functionParameter_> RubyProcParametersOpt
576 %type <statement_> Script
577 %type <statement_> ScriptBody
578 %type <statement_> ScriptBodyOpt
579 %type <expression_> ShiftExpression
580 %type <declaration_> SingleNameBinding
581 %type <statement_> Statement__
582 %type <statement_> Statement_
583 %type <statement_> Statement
584 %type <statement_> StatementList
585 %type <statement_> StatementListOpt
586 %type <statement_> StatementListItem
587 %type <functionParameter_> StrictFormalParameters
588 %type <target_> SuperCall
589 %type <target_> SuperProperty
590 %type <statement_> SwitchStatement
591 %type <target_> TemplateLiteral
592 %type <span_> TemplateSpans
593 %type <statement_> ThrowStatement
594 %type <statement_> TryStatement
595 %type <expression_> UnaryExpression_
596 %type <expression_> UnaryExpression
597 %type <declaration_> VariableDeclaration
598 %type <declarations_> VariableDeclarationList_
599 %type <declarations_> VariableDeclarationList
600 %type <for_> VariableStatement_
601 %type <statement_> VariableStatement
602 %type <statement_> WithStatement
605 %type <word_> WordOpt
607 %type <expression_> YieldExpression
610 %type <specifier_> IntegerType
611 %type <specifier_> IntegerTypeOpt
612 %type <typedIdentifier_> PrefixedType
613 %type <specifier_> PrimitiveType
614 %type <typedIdentifier_> SuffixedType
615 %type <typedIdentifier_> TypeSignifier
616 %type <modifier_> TypeQualifierLeft
617 %type <typedIdentifier_> TypeQualifierRight
618 %type <typedIdentifier_> TypedIdentifier
619 %type <typedParameter_> TypedParameterList_
620 %type <typedParameter_> TypedParameterList
621 %type <typedParameter_> TypedParameterListOpt
625 %type <expression_> AssignmentExpressionClassic
626 %type <expression_> BoxableExpression
627 %type <statement_> CategoryStatement
628 %type <expression_> ClassSuperOpt
629 %type <expression_> ConditionalExpressionClassic
630 %type <implementationField_> ImplementationFieldListOpt
631 %type <implementationField_> ImplementationFields
632 %type <message_> ClassMessageDeclaration
633 %type <message_> ClassMessageDeclarationListOpt
634 %type <protocol_> ClassProtocolListOpt
635 %type <protocol_> ClassProtocols
636 %type <protocol_> ClassProtocolsOpt
637 %type <statement_> ImplementationStatement
638 %type <target_> MessageExpression
639 %type <messageParameter_> MessageParameter
640 %type <messageParameter_> MessageParameters
641 %type <messageParameter_> MessageParameterList
642 %type <messageParameter_> MessageParameterListOpt
643 %type <bool_> MessageScope
644 %type <argument_> SelectorCall_
645 %type <argument_> SelectorCall
646 %type <selector_> SelectorExpression_
647 %type <selector_> SelectorExpression
648 %type <selector_> SelectorExpressionOpt
649 %type <argument_> SelectorList
650 %type <word_> SelectorWordOpt
651 %type <typedIdentifier_> TypeOpt
652 %type <argument_> VariadicCall
656 %type <propertyIdentifier_> PropertyIdentifier_
657 %type <selector_> PropertySelector_
658 %type <selector_> PropertySelector
659 %type <identifier_> QualifiedIdentifier_
660 %type <identifier_> QualifiedIdentifier
661 %type <identifier_> WildcardIdentifier
662 %type <identifier_> XMLComment
663 %type <identifier_> XMLCDATA
664 %type <identifier_> XMLElement
665 %type <identifier_> XMLElementContent
666 %type <identifier_> XMLMarkup
667 %type <identifier_> XMLPI
669 %type <attribute_> AttributeIdentifier
670 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
671 %type <expression_> PropertyIdentifier
672 %type <expression_> XMLListInitialiser
673 %type <expression_> XMLInitialiser
676 /* Token Priorities {{{ */
695 /* Lexer State {{{ */
696 LexPushInOn: { driver.in_.push(true); };
697 LexPushInOff: { driver.in_.push(false); };
698 LexPopIn: { driver.in_.pop(); };
700 LexPushReturnOn: { driver.return_.push(true); };
701 LexPopReturn: { driver.return_.pop(); };
703 LexPushSuperOn: { driver.super_.push(true); };
704 LexPushSuperOff: { driver.super_.push(false); };
705 LexPopSuper: { driver.super_.pop(); };
707 LexPushYieldOn: { driver.yield_.push(true); };
708 LexPushYieldOff: { driver.yield_.push(false); };
709 LexPopYield: { driver.yield_.pop(); };
712 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
716 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
720 : { CYMAP(YieldStar, Star); }
724 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
728 : { CYMAP(_class__, _class_); }
732 : { CYMAP(_function__, _function_); }
736 : LexNoBrace LexNoClass LexNoFunction
739 /* Virtual Tokens {{{ */
750 /* 11.6 Names and Keywords {{{ */
753 | "for" { $$ = CYNew CYWord("for"); }
754 | "in" { $$ = CYNew CYWord("in"); }
755 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
764 : Identifier { $$ = $1; }
765 | "auto" { $$ = CYNew CYWord("auto"); }
766 | "break" { $$ = CYNew CYWord("break"); }
767 | "case" { $$ = CYNew CYWord("case"); }
768 | "catch" { $$ = CYNew CYWord("catch"); }
769 | "class" { $$ = CYNew CYWord("class"); }
770 | ";class" { $$ = CYNew CYWord("class"); }
771 | "const" { $$ = CYNew CYWord("const"); }
772 | "continue" { $$ = CYNew CYWord("continue"); }
773 | "debugger" { $$ = CYNew CYWord("debugger"); }
774 | "default" { $$ = CYNew CYWord("default"); }
775 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
776 | "do" { $$ = CYNew CYWord("do"); }
777 | "else" { $$ = CYNew CYWord("else"); }
778 | "enum" { $$ = CYNew CYWord("enum"); }
779 | "export" { $$ = CYNew CYWord("export"); }
780 | "extends" { $$ = CYNew CYWord("extends"); }
781 | "false" { $$ = CYNew CYWord("false"); }
782 | "finally" { $$ = CYNew CYWord("finally"); }
783 | "function" { $$ = CYNew CYWord("function"); }
784 | "if" { $$ = CYNew CYWord("if"); }
785 | "import" { $$ = CYNew CYWord("import"); }
786 | "!in" { $$ = CYNew CYWord("in"); }
787 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
788 | "null" { $$ = CYNew CYWord("null"); }
789 | "return" { $$ = CYNew CYWord("return"); }
790 | "super" { $$ = CYNew CYWord("super"); }
791 | "switch" { $$ = CYNew CYWord("switch"); }
792 | "this" { $$ = CYNew CYWord("this"); }
793 | "throw" { $$ = CYNew CYWord("throw"); }
794 | "true" { $$ = CYNew CYWord("true"); }
795 | "try" { $$ = CYNew CYWord("try"); }
796 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
797 | "var" { $$ = CYNew CYWord("var"); }
798 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
799 | "while" { $$ = CYNew CYWord("while"); }
800 | "with" { $$ = CYNew CYWord("with"); }
801 | "yield" { $$ = CYNew CYIdentifier("yield"); }
803 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
805 // XXX: should be Identifier
806 | "let" { $$ = CYNew CYIdentifier("let"); }
816 /* 11.8.1 Null Literals {{{ */
818 : "null" { $$ = CYNew CYNull(); }
821 /* 11.8.2 Boolean Literals {{{ */
823 : "true" { $$ = CYNew CYTrue(); }
824 | "false" { $$ = CYNew CYFalse(); }
828 /* 11.9 Automatic Semicolon Insertion {{{ */
830 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
840 | 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
845 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
849 /* 12.1 Identifiers {{{ */
851 : Identifier { $$ = CYNew CYVariable($1); }
852 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
856 : Identifier { $$ = $1; }
857 | "yield" { $$ = CYNew CYIdentifier("yield"); }
861 : BindingIdentifier { $$ = $1; }
866 : Identifier { $$ = $1; }
867 | "yield" { $$ = CYNew CYIdentifier("yield"); }
871 : Identifier_ { $$ = $1; }
872 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
873 | "await" { $$ = CYNew CYIdentifier("await"); }
874 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
875 | "byte" { $$ = CYNew CYIdentifier("byte"); }
876 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
877 | "double" { $$ = CYNew CYIdentifier("double"); }
878 | "each" { $$ = CYNew CYIdentifier("each"); }
879 | "eval" { $$ = CYNew CYIdentifier("eval"); }
880 | "final" { $$ = CYNew CYIdentifier("final"); }
881 | "float" { $$ = CYNew CYIdentifier("float"); }
882 | "from" { $$ = CYNew CYIdentifier("from"); }
883 | "get" { $$ = CYNew CYIdentifier("get"); }
884 | "goto" { $$ = CYNew CYIdentifier("goto"); }
885 | "implements" { $$ = CYNew CYIdentifier("implements"); }
886 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
887 | "interface" { $$ = CYNew CYIdentifier("interface"); }
888 | "native" { $$ = CYNew CYIdentifier("native"); }
889 | "of" { $$ = CYNew CYIdentifier("of"); }
890 | "package" { $$ = CYNew CYIdentifier("package"); }
891 | "private" { $$ = CYNew CYIdentifier("private"); }
892 | "protected" { $$ = CYNew CYIdentifier("protected"); }
893 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
894 | "public" { $$ = CYNew CYIdentifier("public"); }
895 | "set" { $$ = CYNew CYIdentifier("set"); }
896 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
897 | "target" { $$ = CYNew CYIdentifier("target"); }
898 | "throws" { $$ = CYNew CYIdentifier("throws"); }
899 | "transient" { $$ = CYNew CYIdentifier("transient"); }
900 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
902 | "bool" { $$ = CYNew CYIdentifier("bool"); }
903 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
904 | "id" { $$ = CYNew CYIdentifier("id"); }
905 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
911 | "char" { $$ = CYNew CYIdentifier("char"); }
912 | "int" { $$ = CYNew CYIdentifier("int"); }
913 | "long" { $$ = CYNew CYIdentifier("long"); }
914 | "short" { $$ = CYNew CYIdentifier("short"); }
915 | "static" { $$ = CYNew CYIdentifier("static"); }
916 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
918 | "extern" { $$ = CYNew CYIdentifier("extern"); }
919 | "signed" { $$ = CYNew CYIdentifier("signed"); }
920 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
921 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
924 | "nil" { $$ = CYNew CYIdentifier("nil"); }
925 | "NO" { $$ = CYNew CYIdentifier("NO"); }
926 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
927 | "YES" { $$ = CYNew CYIdentifier("YES"); }
931 /* 12.2 Primary Expression {{{ */
933 : "this" { $$ = CYNew CYThis(); }
934 | IdentifierReference { $$ = $1; }
935 | Literal { $$ = $1; }
936 | ArrayLiteral { $$ = $1; }
937 | ObjectLiteral { $$ = $1; }
938 | FunctionExpression { $$ = $1; }
939 | ClassExpression { $$ = $1; }
940 | GeneratorExpression { $$ = $1; }
941 | RegularExpressionLiteral { $$ = $1; }
942 | TemplateLiteral { $$ = $1; }
943 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
944 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
947 CoverParenthesizedExpressionAndArrowParameterList
948 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
949 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
950 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
951 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
954 /* 12.2.4 Literals {{{ */
956 : NullLiteral { $$ = $1; }
957 | BooleanLiteral { $$ = $1; }
958 | NumericLiteral { $$ = $1; }
959 | StringLiteral { $$ = $1; }
962 /* 12.2.5 Array Initializer {{{ */
964 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
968 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
969 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
970 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
974 : ElementList { $$ = $1; }
975 | LexSetRegExp { $$ = NULL; }
978 /* 12.2.6 Object Initializer {{{ */
980 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
983 PropertyDefinitionList_
984 : "," PropertyDefinitionListOpt { $$ = $2; }
988 PropertyDefinitionList
989 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
992 PropertyDefinitionListOpt
993 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
994 | LexSetRegExp { $$ = NULL; }
998 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
999 | CoverInitializedName { CYNOT(@$); }
1000 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
1001 | MethodDefinition { $$ = $1; }
1005 : LiteralPropertyName { $$ = $1; }
1006 | ComputedPropertyName { $$ = $1; }
1010 : IdentifierName { $$ = $1; }
1011 | StringLiteral { $$ = $1; }
1012 | NumericLiteral { $$ = $1; }
1015 ComputedPropertyName
1016 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
1019 CoverInitializedName
1020 : IdentifierReference Initializer
1024 : "=" AssignmentExpression { $$ = $2; }
1028 : Initializer { $$ = $1; }
1032 /* 12.2.9 Template Literals {{{ */
1034 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
1035 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
1039 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
1040 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
1044 /* 12.3 Left-Hand-Side Expressions {{{ */
1046 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
1047 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1048 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1049 | TemplateLiteral { CYNOT(@$); }
1053 : LexSetRegExp PrimaryExpression { $$ = $2; }
1054 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1055 | SuperProperty { $$ = $1; }
1056 | MetaProperty { CYNOT(@$); }
1057 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1061 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
1062 | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
1070 : LexSetRegExp "new" LexSetRegExp "." "target"
1074 : MemberExpression { $$ = $1; }
1075 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1079 : MemberExpression { $$ = $1; }
1080 | CallExpression { $$ = $1; }
1084 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1085 | SuperCall { $$ = $1; }
1086 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1090 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
1094 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1098 : "," ArgumentList { $$ = $2; }
1103 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1104 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1108 : ArgumentList { $$ = $1; }
1109 | LexSetRegExp { $$ = NULL; }
1113 : NewExpression { $$ = $1; }
1114 | CallExpression { $$ = $1; }
1117 LeftHandSideExpression
1118 : AccessExpression { $$ = $1; }
1119 | LexSetRegExp IndirectExpression { $$ = $2; }
1122 /* 12.4 Postfix Expressions {{{ */
1124 : AccessExpression { $$ = $1; }
1125 | AccessExpression "++" { $$ = CYNew CYPostIncrement($1); }
1126 | AccessExpression "--" { $$ = CYNew CYPostDecrement($1); }
1129 /* 12.5 Unary Operators {{{ */
1131 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1132 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1133 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1134 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1135 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1136 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1137 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1138 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1139 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1140 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1141 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1145 : %prec "" PostfixExpression LexOpenBrace { $$ = $1; }
1146 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1149 /* 12.6 Multiplicative Operators {{{ */
1150 MultiplicativeExpression
1151 : UnaryExpression { $$ = $1; }
1152 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1153 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1154 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1157 /* 12.7 Additive Operators {{{ */
1159 : MultiplicativeExpression { $$ = $1; }
1160 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1161 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1164 /* 12.8 Bitwise Shift Operators {{{ */
1166 : AdditiveExpression { $$ = $1; }
1167 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1168 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1169 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1172 /* 12.9 Relational Operators {{{ */
1173 RelationalExpression
1174 : ShiftExpression { $$ = $1; }
1175 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1176 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1177 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1178 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1179 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1180 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1183 /* 12.10 Equality Operators {{{ */
1185 : RelationalExpression { $$ = $1; }
1186 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1187 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1188 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1189 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1192 /* 12.11 Binary Bitwise Operators {{{ */
1193 BitwiseANDExpression
1194 : EqualityExpression { $$ = $1; }
1195 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1198 BitwiseXORExpression
1199 : BitwiseANDExpression { $$ = $1; }
1200 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1204 : BitwiseXORExpression { $$ = $1; }
1205 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1208 /* 12.12 Binary Logical Operators {{{ */
1209 LogicalANDExpression
1210 : BitwiseORExpression { $$ = $1; }
1211 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1215 : LogicalANDExpression { $$ = $1; }
1216 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1219 /* 12.13 Conditional Operator ( ? : ) {{{ */
1221 ConditionalExpressionClassic
1222 : LogicalORExpression { $$ = $1; }
1223 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
1227 ConditionalExpression
1228 : LogicalORExpression { $$ = $1; }
1229 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1232 /* 12.14 Assignment Operators {{{ */
1233 LeftHandSideAssignment
1234 : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
1235 | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
1236 | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
1237 | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
1238 | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
1239 | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
1240 | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
1241 | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
1242 | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
1243 | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
1244 | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
1245 | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
1249 AssignmentExpressionClassic
1250 : ConditionalExpressionClassic { $$ = $1; }
1251 | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
1255 AssignmentExpression
1256 : ConditionalExpression { $$ = $1; }
1257 | LexSetRegExp YieldExpression { $$ = $2; }
1258 | ArrowFunction { $$ = $1; }
1259 | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
1262 AssignmentExpressionOpt
1263 : AssignmentExpression { $$ = $1; }
1264 | LexSetRegExp { $$ = NULL; }
1267 /* 12.15 Comma Operator ( , ) {{{ */
1269 : AssignmentExpression { $$ = $1; }
1270 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1274 : Expression { $$ = $1; }
1275 | LexSetRegExp { $$ = NULL; }
1279 /* 13 Statements and Declarations {{{ */
1281 : BlockStatement { $$ = $1; }
1282 | VariableStatement { $$ = $1; }
1283 | EmptyStatement { $$ = $1; }
1284 | IfStatement { $$ = $1; }
1285 | BreakableStatement { $$ = $1; }
1286 | ContinueStatement { $$ = $1; }
1287 | BreakStatement { $$ = $1; }
1288 | ReturnStatement { $$ = $1; }
1289 | WithStatement { $$ = $1; }
1290 | LabelledStatement { $$ = $1; }
1291 | ThrowStatement { $$ = $1; }
1292 | TryStatement { $$ = $1; }
1293 | DebuggerStatement { $$ = $1; }
1297 : LexSetRegExp Statement__ { $$ = $2; }
1298 | ExpressionStatement { $$ = $1; }
1302 : LexSetStatement Statement_ { $$ = $2; }
1306 : HoistableDeclaration { $$ = $1; }
1307 | ClassDeclaration { $$ = $1; }
1308 | LexicalDeclaration { $$ = $1; }
1312 : LexSetRegExp Declaration__ { $$ = $2; }
1316 : LexSetStatement Declaration_ { $$ = $2; }
1319 HoistableDeclaration
1320 : FunctionDeclaration { $$ = $1; }
1321 | GeneratorDeclaration { $$ = $1; }
1325 : IterationStatement { $$ = $1; }
1326 | SwitchStatement { $$ = $1; }
1329 /* 13.2 Block {{{ */
1331 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1335 : BRACE StatementListOpt "}" { $$ = $2; }
1339 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1343 : StatementList { $$ = $1; }
1344 | LexSetStatement LexSetRegExp { $$ = NULL; }
1348 : Statement { $$ = $1; }
1349 | Declaration { $$ = $1; }
1352 /* 13.3 Let and Const Declarations {{{ */
1354 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1358 : LexicalDeclaration_ Terminator { $$ = $1; }
1362 : "let" { $$ = false; }
1363 | "const" { $$ = true; }
1367 : "," BindingList { $$ = $2; }
1372 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1376 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1377 | BindingPattern Initializer { CYNOT(@1); }
1380 /* 13.3.2 Variable Statement {{{ */
1382 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1386 : VariableStatement_ Terminator { $$ = $1; }
1389 VariableDeclarationList_
1390 : "," VariableDeclarationList { $$ = $2; }
1394 VariableDeclarationList
1395 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1399 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1400 | BindingPattern Initializer { CYNOT(@1); }
1403 /* 13.3.3 Destructuring Binding Patterns {{{ */
1405 : ObjectBindingPattern
1406 | ArrayBindingPattern
1409 ObjectBindingPattern
1410 : BRACE BindingPropertyListOpt "}"
1414 : "[" { CYNOT(@$); }
1417 BindingPropertyList_
1418 : "," BindingPropertyListOpt
1423 : BindingProperty BindingPropertyList_
1426 BindingPropertyListOpt
1427 : BindingPropertyList
1433 | PropertyName ":" BindingElement
1437 : SingleNameBinding { $$ = $1; }
1438 | BindingPattern InitializerOpt { CYNOT(@$); }
1442 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1446 : "..." BindingIdentifier
1449 /* 13.4 Empty Statement {{{ */
1451 : ";" { $$ = CYNew CYEmpty(); }
1454 /* 13.5 Expression Statement {{{ */
1455 ExpressionStatement_
1456 : Expression { $$ = CYNew CYExpress($1); }
1459 : ExpressionStatement_ Terminator { $$ = $1; }
1462 /* 13.6 The if Statement {{{ */
1464 : "else" Statement { $$ = $2; }
1465 | %prec "if" { $$ = NULL; }
1469 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1472 /* 13.7 Iteration Statements {{{ */
1474 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1475 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1476 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1477 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1478 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1479 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1482 ForStatementInitializer
1483 : LexSetRegExp EmptyStatement { $$ = $2; }
1484 | ExpressionStatement_ ";" { $$ = $1; }
1485 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1486 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1489 ForInStatementInitializer
1490 : AccessExpression { $$ = $1; }
1491 | LexSetRegExp IndirectExpression { $$ = $2; }
1492 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1493 | LexSetRegExp ForDeclaration { $$ = $2; }
1497 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1501 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1502 | BindingPattern { CYNOT(@1); }
1505 /* 13.8 The continue Statement {{{ */
1507 : "continue" LexNewLine
1511 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1512 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1515 /* 13.9 The break Statement {{{ */
1517 : "break" LexNewLine
1521 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1522 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1525 /* 13.10 The return Statement {{{ */
1527 : "return" { if (!driver.return_.top()) CYERR(@1, "invalid return"); } LexNewLine
1531 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1532 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1535 /* 13.11 The with Statement {{{ */
1537 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1540 /* 13.12 The switch Statement {{{ */
1542 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1546 : BRACE CaseClausesOpt "}" { $$ = $2; }
1550 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1554 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1555 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1559 // XXX: the standard makes certain you can only have one of these
1561 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1564 /* 13.13 Labelled Statements {{{ */
1566 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1570 : Statement { $$ = $1; }
1571 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1574 /* 13.14 The throw Statement {{{ */
1576 : "throw" LexNewLine
1580 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1581 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1584 /* 13.15 The try Statement {{{ */
1586 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1587 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1588 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1592 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1596 : "finally" Block { $$ = CYNew CYFinally($2); }
1600 : BindingIdentifier { $$ = $1; }
1601 | BindingPattern { CYNOT(@$); }
1604 /* 13.16 The debugger Statement {{{ */
1606 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1610 /* 14.1 Function Definitions {{{ */
1612 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1616 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1619 StrictFormalParameters
1620 : FormalParameters { $$ = $1; }
1625 | FormalParameterList
1628 FormalParameterList_
1629 : "," FormalParameterList { $$ = $2; }
1634 : FunctionRestParameter { CYNOT(@$); }
1635 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1638 FunctionRestParameter
1639 : BindingRestElement
1643 : BindingElement { $$ = $1; }
1647 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1650 FunctionStatementList
1651 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1654 /* 14.2 Arrow Function Definitions {{{ */
1656 : { CYLIN(EqualRight); }
1660 : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); }
1664 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1665 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1669 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1670 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1673 /* 14.3 Method Definitions {{{ */
1675 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1676 | GeneratorMethod { $$ = $1; }
1677 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1678 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1681 PropertySetParameterList
1682 : FormalParameter { $$ = $1; }
1685 /* 14.4 Generator Function Definitions {{{ */
1687 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1690 GeneratorDeclaration
1691 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1695 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1699 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1703 : "!yield" LexNewLine LexNoStar
1707 : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1708 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1709 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1712 /* 14.5 Class Definitions {{{ */
1714 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1718 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1722 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1726 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1730 : ClassHeritage { $$ = $1; }
1731 | { $$ = CYNew CYClassTail(NULL); }
1744 : ClassElementListOpt ClassElement
1753 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1754 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1759 /* 15.1 Scripts {{{ */
1761 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1765 : StatementList { $$ = $1; }
1769 : ScriptBody { $$ = $1; }
1770 | LexSetStatement LexSetRegExp { $$ = NULL; }
1773 /* 15.2 Modules {{{ */
1788 : ModuleItemListOpt ModuleItem
1797 : LexSetStatement LexSetRegExp ImportDeclaration
1798 | LexSetStatement LexSetRegExp ExportDeclaration
1802 /* 15.2.2 Imports {{{ */
1804 : "import" ImportClause FromClause Terminator
1805 | "import" ModuleSpecifier Terminator
1809 : ImportedDefaultBinding
1812 | ImportedDefaultBinding "," NameSpaceImport
1813 | ImportedDefaultBinding "," NamedImports
1816 ImportedDefaultBinding
1821 : "*" "as" ImportedBinding
1825 : BRACE ImportsListOpt "}"
1829 : "from" ModuleSpecifier
1833 : "," ImportsListOpt
1838 : ImportSpecifier ImportsList_
1848 | IdentifierName "as" ImportedBinding
1859 /* 15.2.3 Exports {{{ */
1861 : "*" FromClause Terminator
1862 | ExportClause FromClause Terminator
1863 | ExportClause Terminator
1865 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1866 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1867 | "default" LexSetStatement AssignmentExpression Terminator
1871 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1872 | "export" Declaration
1876 : ";{" ExportsListOpt "}"
1880 : "," ExportsListOpt
1885 : ExportSpecifier ExportsList_
1895 | IdentifierName "as" IdentifierName
1900 /* Cycript (C): Type Encoding {{{ */
1902 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1903 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1907 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1908 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1909 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1910 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1911 | TypeSignifier { $$ = $1; }
1912 | { $$ = CYNew CYTypedIdentifier(@$); }
1916 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1921 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1922 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1926 : PrefixedType { $$ = $1; }
1927 | SuffixedType { $$ = $1; }
1928 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1929 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1933 : "int" { $$ = CYNew CYTypeVariable("int"); }
1934 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1935 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1936 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1937 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1941 : IntegerType { $$ = $1; }
1942 | { $$ = CYNew CYTypeVariable("int"); }
1946 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1947 | IntegerType { $$ = $1; }
1948 | "void" { $$ = CYNew CYTypeVoid(); }
1949 | "char" { $$ = CYNew CYTypeVariable("char"); }
1950 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1951 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1955 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1959 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1965 /* Cycript (Objective-C): @class Declaration {{{ */
1967 /* XXX: why the hell did I choose MemberExpression? */
1968 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1972 ImplementationFieldListOpt
1973 : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
1974 | LexSetRegExp { $$ = NULL; }
1977 ImplementationFields
1978 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1982 : "+" { $$ = false; }
1983 | "-" { $$ = true; }
1987 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1988 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1992 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1995 MessageParameterList
1996 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1999 MessageParameterListOpt
2000 : MessageParameterList { $$ = $1; }
2005 : MessageParameterList { $$ = $1; }
2006 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
2009 ClassMessageDeclaration
2010 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
2013 ClassMessageDeclarationListOpt
2014 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
2018 // XXX: this should be AssignmentExpressionNoRight
2020 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
2024 : "," ClassProtocols { $$ = $2; }
2028 ClassProtocolListOpt
2029 : "<" ClassProtocols ">" { $$ = $2; }
2033 ImplementationStatement
2034 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
2042 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
2046 : ImplementationStatement { $$ = $1; }
2047 | CategoryStatement { $$ = $1; }
2050 /* Cycript (Objective-C): Send Message {{{ */
2052 : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
2057 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
2058 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2062 : SelectorCall { $$ = $1; }
2063 | VariadicCall { $$ = $1; }
2067 : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
2071 : SelectorCall { $$ = $1; }
2072 | Word { $$ = CYNew CYArgument($1, NULL); }
2076 : "[" LexPushInOff AssignmentExpressionClassic { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2077 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2081 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2085 : SelectorExpression_ { $$ = $1; }
2086 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2089 SelectorExpressionOpt
2090 : SelectorExpression_ { $$ = $1; }
2095 : MessageExpression { $$ = $1; }
2096 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2101 /* Cycript: @import Directive {{{ */
2103 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2104 | Word { $$ = CYNew CYModule($1); }
2108 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2113 /* Cycript (Objective-C): Boxed Expressions {{{ */
2115 : NullLiteral { $$ = $1; }
2116 | BooleanLiteral { $$ = $1; }
2117 | NumericLiteral { $$ = $1; }
2118 | StringLiteral { $$ = $1; }
2119 | ArrayLiteral { $$ = $1; }
2120 | ObjectLiteral { $$ = $1; }
2121 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2122 | "YES" { $$ = CYNew CYTrue(); }
2123 | "NO" { $$ = CYNew CYFalse(); }
2127 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2128 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2129 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2130 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2131 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2132 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2135 /* Cycript (Objective-C): Block Expressions {{{ */
2137 : "^" 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"); }
2140 /* Cycript (Objective-C): Instance Literals {{{ */
2142 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2148 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2150 : IndirectExpression { $$ = $1; }
2154 : "*" UnaryExpression { $$ = CYNew CYIndirect($2); }
2158 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2162 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2163 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2164 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2167 /* Cycript (C): auto Compatibility {{{ */
2172 /* Cycript (C): Lambda Expressions {{{ */
2174 : "," TypedParameterList { $$ = $2; }
2179 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2182 TypedParameterListOpt
2183 : TypedParameterList { $$ = $1; }
2188 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2191 /* Cycript (C): Type Definitions {{{ */
2193 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2196 /* Cycript (C): extern "C" {{{ */
2198 : "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); }
2205 /* Lexer State {{{ */
2207 : { driver.PushCondition(CYDriver::RegExpCondition); }
2211 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2215 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2219 : { driver.PopCondition(); }
2223 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2227 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2230 /* Virtual Tokens {{{ */
2237 /* 8.1 Context Keywords {{{ */
2239 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2240 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2243 /* 8.3 XML Initializer Input Elements {{{ */
2245 : XMLComment { $$ = $1; }
2246 | XMLCDATA { $$ = $1; }
2247 | XMLPI { $$ = $1; }
2251 /* 11.1 Primary Expressions {{{ */
2253 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2254 | XMLInitialiser { $$ = $1; }
2255 | XMLListInitialiser { $$ = $1; }
2259 : AttributeIdentifier { $$ = $1; }
2260 | QualifiedIdentifier { $$ = $1; }
2261 | WildcardIdentifier { $$ = $1; }
2264 /* 11.1.1 Attribute Identifiers {{{ */
2266 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2270 : PropertySelector { $$ = $1; }
2271 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2275 : Identifier { $$ = CYNew CYSelector($1); }
2276 | WildcardIdentifier { $$ = $1; }
2279 /* 11.1.2 Qualified Identifiers {{{ */
2280 QualifiedIdentifier_
2281 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2282 | QualifiedIdentifier { $$ = $1; }
2286 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2289 /* 11.1.3 Wildcard Identifiers {{{ */
2291 : "*" { $$ = CYNew CYWildcard(); }
2294 /* 11.1.4 XML Initializer {{{ */
2296 : XMLMarkup { $$ = $1; }
2297 | XMLElement { $$ = $1; }
2301 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2302 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2306 : LexPushXMLTag XMLTagName XMLAttributes
2310 : BRACE LexPushRegExp Expression LexPop "}"
2319 : XMLAttributes_ XMLAttribute
2324 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2325 | XMLAttributes_ XMLWhitespaceOpt
2334 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2338 : XMLExpression XMLElementContentOpt
2339 | XMLMarkup XMLElementContentOpt
2340 | XMLText XMLElementContentOpt
2341 | XMLElement XMLElementContentOpt
2344 XMLElementContentOpt
2349 /* 11.1.5 XMLList Initializer {{{ */
2351 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2355 /* 11.2 Left-Hand-Side Expressions {{{ */
2357 : Identifier { $$ = $1; }
2358 | PropertyIdentifier { $$ = $1; }
2362 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2363 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2364 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2367 /* 12.1 The default xml namespace Statement {{{ */
2368 /* XXX: DefaultXMLNamespaceStatement
2369 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2373 : DefaultXMLNamespaceStatement { $$ = $1; }
2378 /* JavaScript FTL: Array Comprehensions {{{ */
2380 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2384 : "for" "each" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2387 /* JavaScript FTL: for each {{{ */
2389 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2393 /* JavaScript FTW: Array Comprehensions {{{ */
2395 : ArrayComprehension
2399 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2403 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2408 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2409 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2413 : "for" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2414 | "for" "(" LexPushInOn ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2418 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2421 /* JavaScript FTW: Coalesce Operator {{{ */
2422 ConditionalExpression
2423 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2426 /* JavaScript FTW: Named Arguments {{{ */
2428 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2431 /* JavaScript FTW: Ruby Blocks {{{ */
2432 RubyProcParameterList_
2433 : "," RubyProcParameterList { $$ = $2; }
2437 RubyProcParameterList
2438 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2443 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2444 | LexSetRegExp "||" { $$ = NULL; }
2447 RubyProcParametersOpt
2448 : RubyProcParameters { $$ = $1; }
2449 | LexSetRegExp { $$ = NULL; }
2453 : { CYLIN(OpenBrace); }
2457 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2461 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2465 : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); }
2471 bool CYDriver::Parse(CYMark mark) {
2473 CYLocal<CYPool> local(&pool_);
2474 cy::parser parser(*this);
2476 parser.set_debug_level(debug_);
2478 return parser.parse() != 0;
2481 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2485 CYDriver::Error error;
2486 error.warning_ = true;
2487 error.location_ = location;
2488 error.message_ = message;
2489 errors_.push_back(error);
2492 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2493 CYDriver::Error error;
2494 error.warning_ = false;
2495 error.location_ = location;
2496 error.message_ = message;
2497 driver.errors_.push_back(error);