1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #define YYSTACKEXPANDABLE 1
30 #define CYNew new(driver.pool_)
33 #include "ObjectiveC/Syntax.hpp"
37 #include "E4X/Syntax.hpp"
40 #include "Highlight.hpp"
43 %union { bool bool_; }
45 %union { CYMember *access_; }
46 %union { CYArgument *argument_; }
47 %union { CYAssignment *assignment_; }
48 %union { CYBinding *binding_; }
49 %union { CYBindings *bindings_; }
50 %union { CYBoolean *boolean_; }
51 %union { CYClause *clause_; }
52 %union { cy::Syntax::Catch *catch_; }
53 %union { CYClassTail *classTail_; }
54 %union { CYComprehension *comprehension_; }
55 %union { CYElement *element_; }
56 %union { CYExpression *expression_; }
57 %union { CYFalse *false_; }
58 %union { CYVariable *variable_; }
59 %union { CYFinally *finally_; }
60 %union { CYForInitializer *for_; }
61 %union { CYForInInitializer *forin_; }
62 %union { CYFunctionParameter *functionParameter_; }
63 %union { CYIdentifier *identifier_; }
64 %union { CYInfix *infix_; }
65 %union { CYLiteral *literal_; }
66 %union { CYMethod *method_; }
67 %union { CYModule *module_; }
68 %union { CYNull *null_; }
69 %union { CYNumber *number_; }
70 %union { CYParenthetical *parenthetical_; }
71 %union { CYProperty *property_; }
72 %union { CYPropertyName *propertyName_; }
73 %union { CYRubyProc *rubyProc_; }
74 %union { CYSpan *span_; }
75 %union { CYStatement *statement_; }
76 %union { CYString *string_; }
77 %union { CYTarget *target_; }
78 %union { CYThis *this_; }
79 %union { CYTrue *true_; }
80 %union { CYWord *word_; }
83 %union { 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 *);
118 typedef cy::parser::token tk;
120 _finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
121 driver.newline_ = false;
124 int token(cylex(&data, location, driver.scanner_));
125 *semantic = data.semantic_;
129 case tk::OpenBracket:
131 driver.in_.push(false);
135 if (driver.in_.top())
140 case tk::CloseBracket:
147 if (driver.yield_.top())
148 token = tk::_yield__;
152 driver.newline_ = true;
160 #define yylex_(semantic, location, driver) ({ \
162 if (driver.hold_ == cy::parser::empty_symbol) \
163 type = yytranslate_(cylex_(semantic, location, driver)); \
165 type = driver.hold_; \
166 driver.hold_ = cy::parser::empty_symbol; \
170 #define CYLEX() do if (yyla.empty()) { \
171 YYCDEBUG << "Mapping a token: "; \
172 yyla.type = yylex_(&yyla.value, &yyla.location, driver); \
173 YY_SYMBOL_PRINT("Next token is", yyla); \
176 #define CYMAP(to, from) do { \
178 if (yyla.type == yytranslate_(token::from)) \
179 yyla.type = yytranslate_(token::to); \
182 #define CYERR(location, message) do { \
183 error(location, message); \
187 #define CYEOK() do { \
189 driver.errors_.pop_back(); \
192 #define CYNOT(location) \
193 CYERR(location, "unimplemented feature")
195 #define CYMPT(location) do { \
196 if (!yyla.empty() && yyla.type_get() != yyeof_) \
197 CYERR(location, "unexpected lookahead"); \
207 @$.begin.filename = @$.end.filename = &driver.filename_;
209 switch (driver.mark_) {
211 driver.hold_ = yytranslate_(token::MarkScript);
214 driver.hold_ = yytranslate_(token::MarkModule);
222 %define api.location.type { CYLocation }
229 %param { CYDriver &driver }
231 /* Token Declarations {{{ */
237 %token XMLAttributeValue
239 %token XMLTagCharacters
245 %token LeftRight "<>"
246 %token LeftSlashRight "</>"
248 %token SlashRight "/>"
249 %token LeftSlash "</"
251 %token ColonColon "::"
252 %token PeriodPeriod ".."
255 @begin E4X ObjectiveC
261 %token AmpersandAmpersand "&&"
262 %token AmpersandEqual "&="
264 %token CarrotEqual "^="
266 %token EqualEqual "=="
267 %token EqualEqualEqual "==="
268 %token EqualRight "=>"
269 %token Exclamation "!"
270 %token ExclamationEqual "!="
271 %token ExclamationEqualEqual "!=="
273 %token HyphenEqual "-="
274 %token HyphenHyphen "--"
275 %token HyphenRight "->"
277 %token LeftEqual "<="
279 %token LeftLeftEqual "<<="
281 %token PercentEqual "%="
283 %token PeriodPeriodPeriod "..."
285 %token PipeEqual "|="
288 %token PlusEqual "+="
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_ ";{"
315 %token OpenBrace_let "let {"
316 %token CloseBrace "}"
318 %token OpenBracket "["
319 %token OpenBracket_let "let ["
320 %token CloseBracket "]"
322 %token At_error_ "@error"
325 %token At_class_ "@class"
329 %token _typedef_ "typedef"
330 %token _unsigned_ "unsigned"
331 %token _signed_ "signed"
332 %token _extern_ "extern"
336 %token At_encode_ "@encode"
340 %token At_implementation_ "@implementation"
341 %token At_import_ "@import"
342 %token At_end_ "@end"
343 %token At_selector_ "@selector"
344 %token At_null_ "@null"
345 %token At_YES_ "@YES"
347 %token At_true_ "@true"
348 %token At_false_ "@false"
353 %token _false_ "false"
357 %token _break_ "break"
359 %token _catch_ "catch"
360 %token _class_ "class"
361 %token _class__ ";class"
362 %token _const_ "const"
363 %token _continue_ "continue"
364 %token _debugger_ "debugger"
365 %token _default_ "default"
366 %token _delete_ "delete"
370 %token _export_ "export"
371 %token _extends_ "extends"
372 %token _finally_ "finally"
374 %token _function_ "function"
375 %token _function__ ";function"
377 %token _import_ "import"
380 %token _Infinity_ "Infinity"
381 %token _instanceof_ "instanceof"
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"
415 %token _native_ "native"
416 %token _package_ "package"
417 %token _private_ "private"
418 %token _protected_ "protected"
419 %token _prototype_ "prototype"
420 %token _public_ "public"
422 %token _short_ "short"
423 %token _static_ "static"
424 %token _synchronized_ "synchronized"
425 %token _throws_ "throws"
426 %token _transient_ "transient"
427 %token _volatile_ "volatile"
428 %token _yield_ "yield"
429 %token _yield__ "!yield"
431 %token _undefined_ "undefined"
448 %token _namespace_ "namespace"
455 %token <identifier_> Identifier_
456 %token <number_> NumericLiteral
457 %token <string_> StringLiteral
458 %token <literal_> RegularExpressionLiteral_
460 %token <string_> NoSubstitutionTemplate
461 %token <string_> TemplateHead
462 %token <string_> TemplateMiddle
463 %token <string_> TemplateTail
465 %type <target_> AccessExpression
466 %type <expression_> AdditiveExpression
467 %type <argument_> ArgumentList_
468 %type <argument_> ArgumentList
469 %type <argument_> ArgumentListOpt
470 %type <argument_> Arguments
471 %type <target_> ArrayComprehension
472 %type <literal_> ArrayLiteral
473 %type <expression_> ArrowFunction
474 %type <functionParameter_> ArrowParameters
475 %type <expression_> AssignmentExpression
476 %type <expression_> AssignmentExpressionOpt
477 %type <identifier_> BindingIdentifier
478 %type <identifier_> BindingIdentifierOpt
479 %type <bindings_> BindingList_
480 %type <bindings_> BindingList
481 %type <expression_> BitwiseANDExpression
482 %type <statement_> Block
483 %type <statement_> BlockStatement
484 %type <boolean_> BooleanLiteral
485 %type <binding_> BindingElement
486 %type <expression_> BitwiseORExpression
487 %type <expression_> BitwiseXORExpression
488 %type <statement_> BreakStatement
489 %type <statement_> BreakableStatement
490 %type <expression_> CallExpression_
491 %type <target_> CallExpression
492 %type <clause_> CaseBlock
493 %type <clause_> CaseClause
494 %type <clause_> CaseClausesOpt
496 %type <identifier_> CatchParameter
497 %type <statement_> ClassDeclaration
498 %type <target_> ClassExpression
499 %type <classTail_> ClassHeritage
500 %type <classTail_> ClassHeritageOpt
501 %type <classTail_> ClassTail
502 %type <target_> Comprehension
503 %type <comprehension_> ComprehensionFor
504 %type <comprehension_> ComprehensionIf
505 %type <comprehension_> ComprehensionTail
506 %type <propertyName_> ComputedPropertyName
507 %type <expression_> ConditionalExpression
508 %type <statement_> ContinueStatement
509 %type <statement_> ConciseBody
510 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
511 %type <statement_> DebuggerStatement
512 %type <statement_> Declaration_
513 %type <statement_> Declaration
514 %type <clause_> DefaultClause
515 %type <element_> ElementList
516 %type <element_> ElementListOpt
517 %type <statement_> ElseStatementOpt
518 %type <for_> EmptyStatement
519 %type <expression_> EqualityExpression
520 %type <expression_> Expression
521 %type <expression_> ExpressionOpt
522 %type <for_> ExpressionStatement_
523 %type <statement_> ExpressionStatement
524 %type <finally_> Finally
525 %type <binding_> ForBinding
526 %type <forin_> ForDeclaration
527 %type <forin_> ForInStatementInitializer
528 %type <for_> ForStatementInitializer
529 %type <binding_> FormalParameter
530 %type <functionParameter_> FormalParameterList_
531 %type <functionParameter_> FormalParameterList
532 %type <functionParameter_> FormalParameters
533 %type <statement_> FunctionBody
534 %type <statement_> FunctionDeclaration
535 %type <target_> FunctionExpression
536 %type <statement_> FunctionStatementList
537 %type <statement_> GeneratorBody
538 %type <statement_> GeneratorDeclaration
539 %type <target_> GeneratorExpression
540 %type <method_> GeneratorMethod
541 %type <statement_> HoistableDeclaration
542 %type <identifier_> Identifier
543 %type <identifier_> IdentifierNoOf
544 %type <identifier_> IdentifierType
545 %type <identifier_> IdentifierTypeNoOf
546 %type <word_> IdentifierName
547 %type <variable_> IdentifierReference
548 %type <statement_> IfStatement
549 %type <target_> IndirectExpression
550 %type <expression_> Initializer
551 %type <expression_> InitializerOpt
552 %type <statement_> IterationStatement
553 %type <identifier_> LabelIdentifier
554 %type <statement_> LabelledItem
555 %type <statement_> LabelledStatement
556 %type <assignment_> LeftHandSideAssignment
557 %type <target_> LeftHandSideExpression
558 %type <bool_> LetOrConst
559 %type <binding_> LexicalBinding
560 %type <for_> LexicalDeclaration_
561 %type <statement_> LexicalDeclaration
562 %type <literal_> Literal
563 %type <propertyName_> LiteralPropertyName
564 %type <expression_> LogicalANDExpression
565 %type <expression_> LogicalORExpression
566 %type <access_> MemberAccess
567 %type <target_> MemberExpression
568 %type <method_> MethodDefinition
569 %type <module_> ModulePath
570 %type <expression_> MultiplicativeExpression
571 %type <target_> NewExpression
572 %type <null_> NullLiteral
573 %type <literal_> ObjectLiteral
574 %type <expression_> PostfixExpression
575 %type <target_> PrimaryExpression
576 %type <propertyName_> PropertyName
577 %type <property_> PropertyDefinition
578 %type <property_> PropertyDefinitionList_
579 %type <property_> PropertyDefinitionList
580 %type <property_> PropertyDefinitionListOpt
581 %type <functionParameter_> PropertySetParameterList
582 %type <literal_> RegularExpressionLiteral
583 %type <bool_> RegularExpressionSlash
584 %type <expression_> RelationalExpression
585 %type <statement_> ReturnStatement
586 %type <rubyProc_> RubyProcExpression
587 %type <functionParameter_> RubyProcParameterList_
588 %type <functionParameter_> RubyProcParameterList
589 %type <functionParameter_> RubyProcParameters
590 %type <functionParameter_> RubyProcParametersOpt
591 %type <statement_> Script
592 %type <statement_> ScriptBody
593 %type <statement_> ScriptBodyOpt
594 %type <expression_> ShiftExpression
595 %type <binding_> SingleNameBinding
596 %type <statement_> Statement__
597 %type <statement_> Statement_
598 %type <statement_> Statement
599 %type <statement_> StatementList
600 %type <statement_> StatementListOpt
601 %type <statement_> StatementListItem
602 %type <functionParameter_> StrictFormalParameters
603 %type <target_> SuperCall
604 %type <target_> SuperProperty
605 %type <statement_> SwitchStatement
606 %type <target_> TemplateLiteral
607 %type <span_> TemplateSpans
608 %type <statement_> ThrowStatement
609 %type <statement_> TryStatement
610 %type <expression_> UnaryExpression_
611 %type <expression_> UnaryExpression
612 %type <binding_> VariableDeclaration
613 %type <bindings_> VariableDeclarationList_
614 %type <bindings_> VariableDeclarationList
615 %type <for_> VariableStatement_
616 %type <statement_> VariableStatement
617 %type <statement_> WithStatement
620 %type <word_> WordOpt
622 %type <expression_> YieldExpression
625 %type <specifier_> IntegerType
626 %type <specifier_> IntegerTypeOpt
627 %type <typedIdentifier_> PrefixedType
628 %type <specifier_> PrimitiveType
629 %type <typedIdentifier_> SuffixedType
630 %type <typedIdentifier_> TypeSignifier
631 %type <modifier_> TypeQualifierLeft
632 %type <typedIdentifier_> TypeQualifierRight
633 %type <typedIdentifier_> TypedIdentifier
634 %type <typedParameter_> TypedParameterList_
635 %type <typedParameter_> TypedParameterList
636 %type <typedParameter_> TypedParameterListOpt
640 %type <expression_> AssignmentExpressionClassic
641 %type <expression_> BoxableExpression
642 %type <statement_> CategoryStatement
643 %type <expression_> ClassSuperOpt
644 %type <expression_> ConditionalExpressionClassic
645 %type <implementationField_> ImplementationFieldListOpt
646 %type <implementationField_> ImplementationFields
647 %type <message_> ClassMessageDeclaration
648 %type <message_> ClassMessageDeclarationListOpt
649 %type <protocol_> ClassProtocolListOpt
650 %type <protocol_> ClassProtocols
651 %type <protocol_> ClassProtocolsOpt
652 %type <statement_> ImplementationStatement
653 %type <target_> MessageExpression
654 %type <messageParameter_> MessageParameter
655 %type <messageParameter_> MessageParameters
656 %type <messageParameter_> MessageParameterList
657 %type <messageParameter_> MessageParameterListOpt
658 %type <bool_> MessageScope
659 %type <argument_> SelectorCall_
660 %type <argument_> SelectorCall
661 %type <selector_> SelectorExpression_
662 %type <selector_> SelectorExpression
663 %type <selector_> SelectorExpressionOpt
664 %type <argument_> SelectorList
665 %type <word_> SelectorWordOpt
666 %type <typedIdentifier_> TypeOpt
667 %type <argument_> VariadicCall
671 %type <propertyIdentifier_> PropertyIdentifier_
672 %type <selector_> PropertySelector_
673 %type <selector_> PropertySelector
674 %type <identifier_> QualifiedIdentifier_
675 %type <identifier_> QualifiedIdentifier
676 %type <identifier_> WildcardIdentifier
677 %type <identifier_> XMLComment
678 %type <identifier_> XMLCDATA
679 %type <identifier_> XMLElement
680 %type <identifier_> XMLElementContent
681 %type <identifier_> XMLMarkup
682 %type <identifier_> XMLPI
684 %type <attribute_> AttributeIdentifier
685 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
686 %type <expression_> PropertyIdentifier
687 %type <expression_> XMLListInitilizer
688 %type <expression_> XMLInitilizer
691 /* Token Priorities {{{ */
707 /* Lexer State {{{ */
708 LexPushInOn: { driver.in_.push(true); };
709 LexPushInOff: { driver.in_.push(false); };
710 LexPopIn: { driver.in_.pop(); };
712 LexPushReturnOn: { driver.return_.push(true); };
713 LexPopReturn: { driver.return_.pop(); };
715 LexPushSuperOn: { driver.super_.push(true); };
716 LexPushSuperOff: { driver.super_.push(false); };
717 LexPopSuper: { driver.super_.pop(); };
719 LexPushYieldOn: { driver.yield_.push(true); };
720 LexPushYieldOff: { driver.yield_.push(false); };
721 LexPopYield: { driver.yield_.pop(); };
724 : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } }
728 : { CYMAP(YieldStar, Star); }
732 : { CYMAP(OpenBrace_, OpenBrace); }
736 : { CYMAP(_class__, _class_); }
740 : { CYMAP(_function__, _function_); }
744 : LexNoBrace LexNoClass LexNoFunction
747 /* Virtual Tokens {{{ */
753 /* 11.6 Names and Keywords {{{ */
755 : Word[pass] { $$ = $pass; }
756 | "for" { $$ = CYNew CYWord("for"); }
757 | "in" { $$ = CYNew CYWord("in"); }
758 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
762 : IdentifierNoOf[pass] { $$ = $pass; }
763 | "auto" { $$ = CYNew CYWord("auto"); }
764 | "break" { $$ = CYNew CYWord("break"); }
765 | "case" { $$ = CYNew CYWord("case"); }
766 | "catch" { $$ = CYNew CYWord("catch"); }
767 | "class" LexOf { $$ = CYNew CYWord("class"); }
768 | ";class" { $$ = CYNew CYWord("class"); }
769 | "const" { $$ = CYNew CYWord("const"); }
770 | "continue" { $$ = CYNew CYWord("continue"); }
771 | "debugger" { $$ = CYNew CYWord("debugger"); }
772 | "default" { $$ = CYNew CYWord("default"); }
773 | "delete" { $$ = CYNew CYWord("delete"); }
774 | "do" { $$ = CYNew CYWord("do"); }
775 | "else" { $$ = CYNew CYWord("else"); }
776 | "enum" { $$ = CYNew CYWord("enum"); }
777 | "export" { $$ = CYNew CYWord("export"); }
778 | "extends" { $$ = CYNew CYWord("extends"); }
779 | "false" { $$ = CYNew CYWord("false"); }
780 | "finally" { $$ = CYNew CYWord("finally"); }
781 | "function" LexOf { $$ = CYNew CYWord("function"); }
782 | "if" { $$ = CYNew CYWord("if"); }
783 | "import" { $$ = CYNew CYWord("import"); }
784 | "!in" { $$ = CYNew CYWord("in"); }
785 | "!of" { $$ = CYNew CYWord("of"); }
786 | "new" { $$ = CYNew CYWord("new"); }
787 | "null" { $$ = CYNew CYWord("null"); }
788 | "return" { $$ = CYNew CYWord("return"); }
789 | "super" { $$ = CYNew CYWord("super"); }
790 | "switch" { $$ = CYNew CYWord("switch"); }
791 | "this" { $$ = CYNew CYWord("this"); }
792 | "throw" { $$ = CYNew CYWord("throw"); }
793 | "true" { $$ = CYNew CYWord("true"); }
794 | "try" { $$ = CYNew CYWord("try"); }
795 | "typeof" { $$ = CYNew CYWord("typeof"); }
796 | "var" { $$ = CYNew CYWord("var"); }
797 | "void" { $$ = CYNew CYWord("void"); }
798 | "while" { $$ = CYNew CYWord("while"); }
799 | "with" { $$ = CYNew CYWord("with"); }
800 | "yield" { $$ = CYNew CYIdentifier("yield"); }
805 : Word[pass] { $$ = $pass; }
810 /* 11.8.1 Null Literals {{{ */
812 : "null" { $$ = CYNew CYNull(); }
815 /* 11.8.2 Boolean Literals {{{ */
817 : "true" { $$ = CYNew CYTrue(); }
818 | "false" { $$ = CYNew CYFalse(); }
821 /* 11.8.5 Regular Expression Literals {{{ */
822 RegularExpressionSlash
823 : "/" { $$ = false; }
824 | "/=" { $$ = true; }
827 RegularExpressionLiteral
828 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
832 /* 11.9 Automatic Semicolon Insertion {{{ */
834 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
844 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
849 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
853 /* 12.1 Identifiers {{{ */
855 : Identifier[pass] { $$ = CYNew CYVariable($pass); }
856 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
860 : LexOf IdentifierNoOf[pass] { $$ = $pass; }
861 | LexOf "!of" { $$ = CYNew CYIdentifier("of"); }
862 | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); }
866 : BindingIdentifier[pass] { $$ = $pass; }
867 | LexOf { $$ = NULL; }
871 : Identifier[pass] { $$ = $pass; }
872 | "yield" { $$ = CYNew CYIdentifier("yield"); }
876 : Identifier_[pass] { $$ = $pass; }
877 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
878 | "await" { $$ = CYNew CYIdentifier("await"); }
879 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
880 | "byte" { $$ = CYNew CYIdentifier("byte"); }
881 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
882 | "double" { $$ = CYNew CYIdentifier("double"); }
883 | "each" { $$ = CYNew CYIdentifier("each"); }
884 | "eval" { $$ = CYNew CYIdentifier("eval"); }
885 | "final" { $$ = CYNew CYIdentifier("final"); }
886 | "float" { $$ = CYNew CYIdentifier("float"); }
887 | "from" { $$ = CYNew CYIdentifier("from"); }
888 | "get" { $$ = CYNew CYIdentifier("get"); }
889 | "goto" { $$ = CYNew CYIdentifier("goto"); }
890 | "implements" { $$ = CYNew CYIdentifier("implements"); }
891 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
892 | "interface" { $$ = CYNew CYIdentifier("interface"); }
893 | "let" { $$ = CYNew CYIdentifier("let"); }
894 | "!let" LexBind LexOf { $$ = CYNew CYIdentifier("let"); }
895 | "native" { $$ = CYNew CYIdentifier("native"); }
896 | "package" { $$ = CYNew CYIdentifier("package"); }
897 | "private" { $$ = CYNew CYIdentifier("private"); }
898 | "protected" { $$ = CYNew CYIdentifier("protected"); }
899 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
900 | "public" { $$ = CYNew CYIdentifier("public"); }
901 | "set" { $$ = CYNew CYIdentifier("set"); }
902 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
903 | "target" { $$ = CYNew CYIdentifier("target"); }
904 | "throws" { $$ = CYNew CYIdentifier("throws"); }
905 | "transient" { $$ = CYNew CYIdentifier("transient"); }
906 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
908 | "bool" { $$ = CYNew CYIdentifier("bool"); }
909 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
910 | "id" { $$ = CYNew CYIdentifier("id"); }
911 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
916 : IdentifierTypeNoOf[pass] { $$ = $pass; }
917 | "of" { $$ = CYNew CYIdentifier("of"); }
922 | "char" { $$ = CYNew CYIdentifier("char"); }
923 | "int" { $$ = CYNew CYIdentifier("int"); }
924 | "long" { $$ = CYNew CYIdentifier("long"); }
925 | "short" { $$ = CYNew CYIdentifier("short"); }
926 | "static" { $$ = CYNew CYIdentifier("static"); }
927 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
929 | "extern" { $$ = CYNew CYIdentifier("extern"); }
930 | "signed" { $$ = CYNew CYIdentifier("signed"); }
931 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
932 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
935 | "nil" { $$ = CYNew CYIdentifier("nil"); }
936 | "NO" { $$ = CYNew CYIdentifier("NO"); }
937 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
938 | "YES" { $$ = CYNew CYIdentifier("YES"); }
943 : IdentifierNoOf[pass] { $$ = $pass; }
944 | "of" { $$ = CYNew CYIdentifier("of"); }
945 | "!of" { $$ = CYNew CYIdentifier("of"); }
948 /* 12.2 Primary Expression {{{ */
950 : "this" { $$ = CYNew CYThis(); }
951 | IdentifierReference[pass] { $$ = $pass; }
952 | Literal[pass] { $$ = $pass; }
953 | ArrayLiteral[pass] { $$ = $pass; }
954 | ObjectLiteral[pass] { $$ = $pass; }
955 | FunctionExpression[pass] { $$ = $pass; }
956 | ClassExpression[pass] { $$ = $pass; }
957 | GeneratorExpression[pass] { $$ = $pass; }
958 | RegularExpressionLiteral[pass] { $$ = $pass; }
959 | TemplateLiteral[pass] { $$ = $pass; }
960 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
961 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
964 CoverParenthesizedExpressionAndArrowParameterList
965 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
966 | "(" LexOf ")" { $$ = NULL; }
967 | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
968 | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
971 /* 12.2.4 Literals {{{ */
973 : NullLiteral[pass] { $$ = $pass; }
974 | BooleanLiteral[pass] { $$ = $pass; }
975 | NumericLiteral[pass] { $$ = $pass; }
976 | StringLiteral[pass] { $$ = $pass; }
979 /* 12.2.5 Array Initializer {{{ */
981 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
985 : AssignmentExpressionOpt[value] "," ElementListOpt[next] { $$ = CYNew CYElementValue($value, $next); }
986 | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
987 | AssignmentExpression[value] { $$ = CYNew CYElementValue($value, NULL); }
991 : ElementList[pass] { $$ = $pass; }
992 | LexOf { $$ = NULL; }
995 /* 12.2.6 Object Initializer {{{ */
997 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
1000 PropertyDefinitionList_
1001 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1005 PropertyDefinitionList
1006 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1009 PropertyDefinitionListOpt
1010 : PropertyDefinitionList[properties] { $$ = $properties; }
1015 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1016 | CoverInitializedName[name] { CYNOT(@$); }
1017 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1018 | MethodDefinition[pass] { $$ = $pass; }
1022 : LiteralPropertyName[pass] { $$ = $pass; }
1023 | ComputedPropertyName[pass] { $$ = $pass; }
1027 : IdentifierName[pass] { $$ = $pass; }
1028 | StringLiteral[pass] { $$ = $pass; }
1029 | NumericLiteral[pass] { $$ = $pass; }
1032 ComputedPropertyName
1033 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1036 CoverInitializedName
1037 : IdentifierReference Initializer
1041 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1045 : Initializer[pass] { $$ = $pass; }
1049 /* 12.2.9 Template Literals {{{ */
1051 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1052 | TemplateHead[string] TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1056 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1057 | Expression[value] TemplateTail[string] { $$ = CYNew CYSpan($value, $string, NULL); }
1061 /* 12.3 Left-Hand-Side Expressions {{{ */
1063 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1064 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1065 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1066 | TemplateLiteral { CYNOT(@$); }
1070 : PrimaryExpression[pass] { $$ = $pass; }
1071 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1072 | SuperProperty[pass] { $$ = $pass; }
1073 | MetaProperty { CYNOT(@$); }
1074 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1078 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1079 | "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1087 : "new" "." "target"
1091 : MemberExpression[pass] { $$ = $pass; }
1092 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1096 : MemberExpression[pass] { $$ = $pass; }
1097 | CallExpression[pass] { $$ = $pass; }
1101 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1102 | SuperCall[pass] { $$ = $pass; }
1103 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1107 : "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); } Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1111 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1115 : "," ArgumentList[arguments] { $$ = $arguments; }
1120 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1121 | LexOf "..." AssignmentExpression { CYNOT(@$); }
1125 : ArgumentList[pass] { $$ = $pass; }
1126 | LexOf { $$ = NULL; }
1130 : NewExpression[pass] { $$ = $pass; }
1131 | CallExpression[pass] { $$ = $pass; }
1134 LeftHandSideExpression
1135 : AccessExpression[pass] LexNewLine { $$ = $pass; }
1136 | IndirectExpression[pass] { $$ = $pass; }
1139 /* 12.4 Postfix Expressions {{{ */
1141 : AccessExpression[lhs] LexNewLine { $$ = $lhs; }
1142 | AccessExpression[lhs] LexNewLine "++" { $$ = CYNew CYPostIncrement($lhs); }
1143 | AccessExpression[lhs] LexNewLine "--" { $$ = CYNew CYPostDecrement($lhs); }
1146 /* 12.5 Unary Operators {{{ */
1148 : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); }
1149 | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
1150 | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
1151 | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1152 | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1153 | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
1154 | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
1155 | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
1156 | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); }
1160 : PostfixExpression[expression] { $$ = $expression; }
1161 | PostfixExpression[expression] "\n" { $$ = $expression; }
1162 | UnaryExpression_[pass] { $$ = $pass; }
1165 /* 12.6 Multiplicative Operators {{{ */
1166 MultiplicativeExpression
1167 : UnaryExpression[pass] { $$ = $pass; }
1168 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1169 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1170 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1173 /* 12.7 Additive Operators {{{ */
1175 : MultiplicativeExpression[pass] { $$ = $pass; }
1176 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1177 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1180 /* 12.8 Bitwise Shift Operators {{{ */
1182 : AdditiveExpression[pass] { $$ = $pass; }
1183 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1184 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1185 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1188 /* 12.9 Relational Operators {{{ */
1189 RelationalExpression
1190 : ShiftExpression[pass] { $$ = $pass; }
1191 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1192 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1193 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1194 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1195 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1196 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1199 /* 12.10 Equality Operators {{{ */
1201 : RelationalExpression[pass] { $$ = $pass; }
1202 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1203 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1204 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1205 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1208 /* 12.11 Binary Bitwise Operators {{{ */
1209 BitwiseANDExpression
1210 : EqualityExpression[pass] { $$ = $pass; }
1211 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1214 BitwiseXORExpression
1215 : BitwiseANDExpression[pass] { $$ = $pass; }
1216 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1220 : BitwiseXORExpression[pass] { $$ = $pass; }
1221 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1224 /* 12.12 Binary Logical Operators {{{ */
1225 LogicalANDExpression
1226 : BitwiseORExpression[pass] { $$ = $pass; }
1227 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1231 : LogicalANDExpression[pass] { $$ = $pass; }
1232 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1235 /* 12.13 Conditional Operator ( ? : ) {{{ */
1237 ConditionalExpressionClassic
1238 : LogicalORExpression[pass] { $$ = $pass; }
1239 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1243 ConditionalExpression
1244 : LogicalORExpression[pass] { $$ = $pass; }
1245 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1248 /* 12.14 Assignment Operators {{{ */
1249 LeftHandSideAssignment
1250 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1251 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1252 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1253 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1254 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1255 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1256 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1257 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1258 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1259 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1260 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1261 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1265 AssignmentExpressionClassic
1266 : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; }
1267 | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1271 AssignmentExpression
1272 : LexOf ConditionalExpression[pass] { $$ = $pass; }
1273 | LexOf YieldExpression[pass] { $$ = $pass; }
1274 | ArrowFunction[pass] { $$ = $pass; }
1275 | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1278 AssignmentExpressionOpt
1279 : AssignmentExpression[pass] { $$ = $pass; }
1280 | LexOf { $$ = NULL; }
1283 /* 12.15 Comma Operator ( , ) {{{ */
1285 : AssignmentExpression[pass] { $$ = $pass; }
1286 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1290 : Expression[pass] { $$ = $pass; }
1291 | LexOf { $$ = NULL; }
1295 /* 13 Statements and Declarations {{{ */
1297 : BlockStatement[pass] { $$ = $pass; }
1298 | VariableStatement[pass] { $$ = $pass; }
1299 | EmptyStatement[pass] { $$ = $pass; }
1300 | IfStatement[pass] { $$ = $pass; }
1301 | BreakableStatement[pass] { $$ = $pass; }
1302 | ContinueStatement[pass] { $$ = $pass; }
1303 | BreakStatement[pass] { $$ = $pass; }
1304 | ReturnStatement[pass] { $$ = $pass; }
1305 | WithStatement[pass] { $$ = $pass; }
1306 | LabelledStatement[pass] { $$ = $pass; }
1307 | ThrowStatement[pass] { $$ = $pass; }
1308 | TryStatement[pass] { $$ = $pass; }
1309 | DebuggerStatement[pass] { $$ = $pass; }
1313 : LexOf Statement__[pass] { $$ = $pass; }
1314 | ExpressionStatement[pass] { $$ = $pass; }
1318 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1322 : HoistableDeclaration[pass] { $$ = $pass; }
1323 | ClassDeclaration[pass] { $$ = $pass; }
1327 : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; }
1328 | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; }
1331 HoistableDeclaration
1332 : FunctionDeclaration[pass] { $$ = $pass; }
1333 | GeneratorDeclaration[pass] { $$ = $pass; }
1337 : IterationStatement[pass] { $$ = $pass; }
1338 | SwitchStatement[pass] { $$ = $pass; }
1341 /* 13.2 Block {{{ */
1343 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1347 : "{" StatementListOpt[code] "}" { $$ = $code; }
1351 : StatementListItem[statement] StatementListOpt[next] { $statement->SetNext($next); $$ = $statement; }
1355 : StatementList[pass] { $$ = $pass; }
1356 | LexSetStatement LexLet LexOf { $$ = NULL; }
1360 : Statement[pass] { $$ = $pass; }
1361 | Declaration[pass] { $$ = $pass; }
1364 /* 13.3 Let and Const Declarations {{{ */
1366 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1370 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1374 : { CYMAP(_let__, _let_); }
1378 : { CYMAP(_of__, _of_); }
1382 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); }
1386 : LexLet LexOf "!let" LexBind LexOf { $$ = false; }
1387 | LexLet LexOf "const" { $$ = true; }
1391 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1396 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1400 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1401 | LexOf BindingPattern Initializer { CYNOT(@$); }
1404 /* 13.3.2 Variable Statement {{{ */
1406 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1410 : VariableStatement_[statement] Terminator { $$ = $statement; }
1413 VariableDeclarationList_
1414 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1418 VariableDeclarationList
1419 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1423 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1424 | LexOf BindingPattern Initializer { CYNOT(@$); }
1427 /* 13.3.3 Destructuring Binding Patterns {{{ */
1429 : ObjectBindingPattern
1430 | ArrayBindingPattern
1433 ObjectBindingPattern
1434 : "let {" BindingPropertyListOpt "}"
1438 : "let [" BindingElementListOpt "]"
1441 BindingPropertyList_
1442 : "," BindingPropertyListOpt
1447 : BindingProperty BindingPropertyList_
1450 BindingPropertyListOpt
1451 : BindingPropertyList
1456 : BindingElementOpt[element] "," BindingElementListOpt[next]
1457 | BindingRestElement[element]
1458 | BindingElement[element]
1461 BindingElementListOpt
1462 : BindingElementList[pass]
1468 | LexOf PropertyName ":" BindingElement
1472 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1473 | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1477 : BindingElement[pass]
1482 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1486 : LexBind LexOf "..." BindingIdentifier
1489 /* 13.4 Empty Statement {{{ */
1491 : ";" { $$ = CYNew CYEmpty(); }
1494 /* 13.5 Expression Statement {{{ */
1495 ExpressionStatement_
1496 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1499 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1502 /* 13.6 The if Statement {{{ */
1504 : "else" Statement[false] { $$ = $false; }
1505 | %prec "if" { $$ = NULL; }
1509 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1512 /* 13.7 Iteration Statements {{{ */
1514 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1515 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1516 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1517 | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1518 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1519 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1522 ForStatementInitializer
1523 : LexLet LexOf EmptyStatement[pass] { $$ = $pass; }
1524 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1525 | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; }
1526 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1529 ForInStatementInitializer
1530 : LexLet LexOf AccessExpression[pass] LexNewLine { $$ = $pass; }
1531 | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
1532 | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1533 | ForDeclaration[pass] { $$ = $pass; }
1537 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1541 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1542 | LexOf BindingPattern { CYNOT(@$); }
1545 /* 13.8 The continue Statement {{{ */
1547 : "continue" LexNewLine TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1548 | "continue" LexNewLine Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1551 /* 13.9 The break Statement {{{ */
1553 : "break" LexNewLine TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1554 | "break" LexNewLine Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1557 /* 13.10 The return Statement {{{ */
1559 : "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); }
1563 : Return LexNewLine LexOf TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1564 | Return LexNewLine Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1567 /* 13.11 The with Statement {{{ */
1569 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1572 /* 13.12 The switch Statement {{{ */
1574 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1578 : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1582 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1586 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1587 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1591 // XXX: the standard makes certain you can only have one of these
1593 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1596 /* 13.13 Labelled Statements {{{ */
1598 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1602 : Statement[pass] { $$ = $pass; }
1603 | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; }
1606 /* 13.14 The throw Statement {{{ */
1608 : "throw"[throw] LexNewLine LexOf TerminatorSoft { CYERR(@throw, "throw without exception"); }
1609 | "throw" LexNewLine Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1612 /* 13.15 The try Statement {{{ */
1614 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1615 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1616 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1620 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1624 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1628 : BindingIdentifier[pass] { $$ = $pass; }
1629 | LexOf BindingPattern { CYNOT(@$); }
1632 /* 13.16 The debugger Statement {{{ */
1634 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1638 /* 14.1 Function Definitions {{{ */
1640 : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1644 : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1647 StrictFormalParameters
1648 : FormalParameters[pass] { $$ = $pass; }
1652 : LexBind LexOf { $$ = NULL; }
1653 | FormalParameterList
1656 FormalParameterList_
1657 : "," FormalParameterList[parameters] { $$ = $parameters; }
1662 : FunctionRestParameter { CYNOT(@$); }
1663 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1666 FunctionRestParameter
1667 : BindingRestElement
1671 : BindingElement[pass] { $$ = $pass; }
1675 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1678 FunctionStatementList
1679 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1682 /* 14.2 Arrow Function Definitions {{{ */
1684 : ArrowParameters[parameters] LexNewLine "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1688 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1689 | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1693 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1694 | LexOf ";{" FunctionBody[code] "}" { $$ = $code; }
1697 /* 14.3 Method Definitions {{{ */
1699 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1700 | GeneratorMethod[pass] { $$ = $pass; }
1701 | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1702 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1705 PropertySetParameterList
1706 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1709 /* 14.4 Generator Function Definitions {{{ */
1711 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1714 GeneratorDeclaration
1715 : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1719 : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1723 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1727 : "!yield" LexNewLine LexNoStar
1731 : Yield LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1732 | Yield LexOf "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1733 | Yield AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1734 | Yield LexOf YieldStar AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1737 /* 14.5 Class Definitions {{{ */
1739 : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1743 : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1747 : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1751 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1755 : ClassHeritage[pass] { $$ = $pass; }
1756 | { $$ = CYNew CYClassTail(NULL); }
1769 : ClassElementListOpt ClassElement
1778 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1779 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1784 /* 15.1 Scripts {{{ */
1786 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1790 : StatementList[pass] { $$ = $pass; }
1794 : ScriptBody[pass] { $$ = $pass; }
1795 | LexSetStatement LexLet LexOf { $$ = NULL; }
1798 /* 15.2 Modules {{{ */
1813 : ModuleItemListOpt ModuleItem
1822 : LexSetStatement LexLet LexOf ImportDeclaration
1823 | LexSetStatement LexLet LexOf ExportDeclaration
1827 /* 15.2.2 Imports {{{ */
1829 : "import" ImportClause FromClause Terminator
1830 | "import" LexOf ModuleSpecifier Terminator
1834 : ImportedDefaultBinding
1835 | LexOf NameSpaceImport
1836 | LexOf NamedImports
1837 | ImportedDefaultBinding "," NameSpaceImport
1838 | ImportedDefaultBinding "," NamedImports
1841 ImportedDefaultBinding
1846 : "*" "as" ImportedBinding
1850 : "{" ImportsListOpt "}"
1854 : "from" ModuleSpecifier
1858 : "," ImportsListOpt
1863 : ImportSpecifier ImportsList_
1873 | LexOf IdentifierName "as" ImportedBinding
1884 /* 15.2.3 Exports {{{ */
1886 : "*" FromClause Terminator
1887 | ExportClause FromClause Terminator
1888 | ExportClause Terminator
1890 | "default" LexSetStatement LexOf HoistableDeclaration
1891 | "default" LexSetStatement LexOf ClassDeclaration
1892 | "default" LexSetStatement AssignmentExpression Terminator
1896 : "export" LexSetStatement LexLet LexOf ExportDeclaration_
1897 | "export" Declaration
1901 : ";{" ExportsListOpt "}"
1905 : "," ExportsListOpt
1910 : ExportSpecifier ExportsList_
1920 | IdentifierName "as" IdentifierName
1925 /* Cycript (C): Type Encoding {{{ */
1927 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
1928 | "(" "*" TypeQualifierRight[typed] ")" { $$ = $typed; }
1932 : SuffixedType[typed] "[" NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
1933 | "(" "^" TypeQualifierRight[typed] ")" "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
1934 | TypeSignifier[typed] "(" TypedParameterListOpt[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1935 | "("[parenthesis] TypedParameterListOpt[parameters] ")" { $$ = CYNew CYTypedIdentifier(@parenthesis); $$->modifier_ = CYNew CYTypeFunctionWith($parameters, $$->modifier_); }
1936 | TypeSignifier[pass] { $$ = $pass; }
1937 | { $$ = CYNew CYTypedIdentifier(@$); }
1941 : "*" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1946 | "const" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
1947 | "volatile" TypeQualifierLeft[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
1951 : PrefixedType[pass] { $$ = $pass; }
1952 | SuffixedType[pass] { $$ = $pass; }
1953 | "const" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1954 | "volatile" TypeQualifierRight[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1958 : "int" { $$ = CYNew CYTypeVariable("int"); }
1959 | "unsigned" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeUnsigned($specifier); }
1960 | "signed" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeSigned($specifier); }
1961 | "long" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeLong($specifier); }
1962 | "short" IntegerTypeOpt[specifier] { $$ = CYNew CYTypeShort($specifier); }
1966 : IntegerType[pass] { $$ = $pass; }
1967 | { $$ = CYNew CYTypeVariable("int"); }
1971 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
1972 | IntegerType[pass] { $$ = $pass; }
1973 | "void" { $$ = CYNew CYTypeVoid(); }
1974 | "char" { $$ = CYNew CYTypeVariable("char"); }
1975 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1976 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1980 : TypeQualifierLeft[modifier] PrimitiveType[specifier] TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
1984 : "@encode" "(" TypedIdentifier[typed] ")" { $$ = CYNew CYEncodedType($typed); }
1990 /* Cycript (Objective-C): @class Declaration {{{ */
1992 /* XXX: why the hell did I choose MemberExpression? */
1993 : ":" MemberExpression[extends] { $$ = $extends; }
1997 ImplementationFieldListOpt
1998 : TypedIdentifier[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2002 ImplementationFields
2003 : "{" ImplementationFieldListOpt[fields] "}" { $$ = $fields; }
2007 : "+" { $$ = false; }
2008 | "-" { $$ = true; }
2012 : "(" TypedIdentifier[type] ")" { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); $$ = $type; }
2013 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2017 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2020 MessageParameterList
2021 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2024 MessageParameterListOpt
2025 : MessageParameterList[pass] { $$ = $pass; }
2030 : MessageParameterList[pass] { $$ = $pass; }
2031 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2034 ClassMessageDeclaration
2035 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2038 ClassMessageDeclarationListOpt
2039 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2043 // XXX: this should be AssignmentExpressionNoRight
2045 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2049 : "," ClassProtocols[protocols] { $$ = $protocols; }
2053 ClassProtocolListOpt
2054 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2058 ImplementationStatement
2059 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] ImplementationFields[fields] ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2067 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2071 : ImplementationStatement[pass] { $$ = $pass; }
2072 | CategoryStatement[pass] { $$ = $pass; }
2075 /* Cycript (Objective-C): Send Message {{{ */
2077 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2082 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2083 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2087 : SelectorCall[pass] { $$ = $pass; }
2088 | VariadicCall[pass] { $$ = $pass; }
2092 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2096 : SelectorCall[pass] { $$ = $pass; }
2097 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2101 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2102 | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2106 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2110 : SelectorExpression_[pass] { $$ = $pass; }
2111 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2114 SelectorExpressionOpt
2115 : SelectorExpression_[pass] { $$ = $pass; }
2120 : MessageExpression[pass] { $$ = $pass; }
2121 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2126 /* Cycript: @import Directive {{{ */
2128 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2129 | Word[part] { $$ = CYNew CYModule($part); }
2133 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2138 /* Cycript (Objective-C): Boxed Expressions {{{ */
2140 : NullLiteral[pass] { $$ = $pass; }
2141 | BooleanLiteral[pass] { $$ = $pass; }
2142 | NumericLiteral[pass] { $$ = $pass; }
2143 | StringLiteral[pass] { $$ = $pass; }
2144 | ArrayLiteral[pass] { $$ = $pass; }
2145 | ObjectLiteral[pass] { $$ = $pass; }
2146 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2147 | "YES" { $$ = CYNew CYTrue(); }
2148 | "NO" { $$ = CYNew CYFalse(); }
2152 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2153 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2154 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2155 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2156 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2157 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2160 /* Cycript (Objective-C): Block Expressions {{{ */
2162 : "^" TypedIdentifier[type] { if ($type->identifier_ != NULL) CYERR($type->location_, "unexpected identifier"); } "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2165 /* Cycript (Objective-C): Instance Literals {{{ */
2167 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2173 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2175 : IndirectExpression[pass] { $$ = $pass; }
2179 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2183 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2187 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2188 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2189 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2192 /* Cycript (C): auto Compatibility {{{ */
2197 /* Cycript (C): Lambda Expressions {{{ */
2199 : "," TypedParameterList[parameters] { $$ = $parameters; }
2204 : TypedIdentifier[typed] TypedParameterList_[next] { $$ = CYNew CYTypedParameter($typed, $next); }
2207 TypedParameterListOpt
2208 : TypedParameterList[pass] { $$ = $pass; }
2213 : "[" LexOf "&" "]" "(" TypedParameterListOpt[parameters] ")" "->" TypedIdentifier[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2216 /* Cycript (C): Type Definitions {{{ */
2218 : "typedef" TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($typed); }
2221 /* Cycript (C): extern "C" {{{ */
2223 : "extern" StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); } TypedIdentifier[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($abi, $typed); }
2230 /* Lexer State {{{ */
2232 : { driver.PushCondition(CYDriver::RegExpCondition); }
2236 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2240 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2244 : { driver.PopCondition(); }
2248 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2252 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2255 /* Virtual Tokens {{{ */
2262 /* 8.1 Context Keywords {{{ */
2264 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2265 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2268 /* 8.3 XML Initializer Input Elements {{{ */
2270 : XMLComment { $$ = $1; }
2271 | XMLCDATA { $$ = $1; }
2272 | XMLPI { $$ = $1; }
2276 /* 11.1 Primary Expressions {{{ */
2278 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2279 | XMLInitilizer { $$ = $1; }
2280 | XMLListInitilizer { $$ = $1; }
2284 : AttributeIdentifier { $$ = $1; }
2285 | QualifiedIdentifier { $$ = $1; }
2286 | WildcardIdentifier { $$ = $1; }
2289 /* 11.1.1 Attribute Identifiers {{{ */
2291 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2295 : PropertySelector { $$ = $1; }
2296 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2300 : Identifier { $$ = CYNew CYSelector($1); }
2301 | WildcardIdentifier { $$ = $1; }
2304 /* 11.1.2 Qualified Identifiers {{{ */
2305 QualifiedIdentifier_
2306 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2307 | QualifiedIdentifier { $$ = $1; }
2311 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2314 /* 11.1.3 Wildcard Identifiers {{{ */
2316 : "*" { $$ = CYNew CYWildcard(); }
2319 /* 11.1.4 XML Initializer {{{ */
2321 : XMLMarkup { $$ = $1; }
2322 | XMLElement { $$ = $1; }
2326 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2327 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2331 : LexPushXMLTag XMLTagName XMLAttributes
2335 : "{" LexPushRegExp Expression LexPop "}"
2344 : XMLAttributes_ XMLAttribute
2349 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2350 | XMLAttributes_ XMLWhitespaceOpt
2359 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2363 : XMLExpression XMLElementContentOpt
2364 | XMLMarkup XMLElementContentOpt
2365 | XMLText XMLElementContentOpt
2366 | XMLElement XMLElementContentOpt
2369 XMLElementContentOpt
2374 /* 11.1.5 XMLList Initializer {{{ */
2376 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2380 /* 11.2 Left-Hand-Side Expressions {{{ */
2382 : Identifier { $$ = $1; }
2383 | PropertyIdentifier { $$ = $1; }
2387 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2388 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2389 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2392 /* 12.1 The default xml namespace Statement {{{ */
2393 /* XXX: DefaultXMLNamespaceStatement
2394 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2398 : DefaultXMLNamespaceStatement { $$ = $1; }
2403 /* JavaScript FTL: Array Comprehensions {{{ */
2405 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2409 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2412 /* JavaScript FTL: for each {{{ */
2414 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2418 /* JavaScript FTW: Array Comprehensions {{{ */
2420 : ArrayComprehension
2424 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2428 : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2433 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2434 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2438 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2439 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2443 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2446 /* JavaScript FTW: Coalesce Operator {{{ */
2447 ConditionalExpression
2448 : LogicalORExpression[test] "?" LexPushInOff LexOf ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $test, $false); }
2451 /* JavaScript FTW: Named Arguments {{{ */
2453 : LexOf Word[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2456 /* JavaScript FTW: Ruby Blocks {{{ */
2457 RubyProcParameterList_
2458 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2462 RubyProcParameterList
2463 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2464 | LexOf { $$ = NULL; }
2468 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2469 | "||" { $$ = NULL; }
2472 RubyProcParametersOpt
2473 : RubyProcParameters[pass] { $$ = $pass; }
2478 : "{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2482 : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2486 : PostfixExpression[lhs] RubyProcExpression[rhs] LexNewLine { $$ = CYNew CYRubyBlock($lhs, $rhs); }
2492 bool CYDriver::Parse(CYMark mark) {
2494 CYLocal<CYPool> local(&pool_);
2495 cy::parser parser(*this);
2497 parser.set_debug_level(debug_);
2499 return parser.parse() != 0;
2502 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2506 CYDriver::Error error;
2507 error.warning_ = true;
2508 error.location_ = location;
2509 error.message_ = message;
2510 errors_.push_back(error);
2513 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2514 CYDriver::Error error;
2515 error.warning_ = false;
2516 error.location_ = location;
2517 error.message_ = message;
2518 driver.errors_.push_back(error);