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__;
151 driver.newline_ = CYDriver::NewLineHere;
157 driver.next_ = false;
161 #define CYLEX() do if (yyla.empty()) { \
162 YYCDEBUG << "Mapping a token: "; \
163 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
164 YY_SYMBOL_PRINT("Next token is", yyla); \
167 #define CYMAP(to, from) do { \
169 if (yyla.type == yytranslate_(token::from)) \
170 yyla.type = yytranslate_(token::to); \
173 #define CYLIN(from) do { \
175 if (yyla.type == yytranslate_(token::from) && driver.newline_ == CYDriver::NewLineLast) \
176 yyla.type = yytranslate_(token::from ## _); \
179 #define CYERR(location, message) do { \
180 error(location, message); \
184 #define CYNOT(location) \
185 CYERR(location, "unimplemented feature")
194 @$.begin.filename = @$.end.filename = &driver.filename_;
200 %define api.location.type { CYLocation }
207 %param { CYDriver &driver }
209 /* Token Declarations {{{ */
215 %token XMLAttributeValue
217 %token XMLTagCharacters
223 %token LeftRight "<>"
224 %token LeftSlashRight "</>"
226 %token SlashRight "/>"
227 %token LeftSlash "</"
229 %token ColonColon "::"
230 %token PeriodPeriod ".."
233 @begin E4X ObjectiveC
239 %token AmpersandAmpersand "&&"
240 %token AmpersandEqual "&="
242 %token CarrotEqual "^="
244 %token EqualEqual "=="
245 %token EqualEqualEqual "==="
246 %token EqualRight "=>"
247 %token EqualRight_ "\n=>"
248 %token Exclamation "!"
249 %token ExclamationEqual "!="
250 %token ExclamationEqualEqual "!=="
252 %token HyphenEqual "-="
253 %token HyphenHyphen "--"
254 %token HyphenHyphen_ "\n--"
255 %token HyphenRight "->"
257 %token LeftEqual "<="
259 %token LeftLeftEqual "<<="
261 %token PercentEqual "%="
263 %token PeriodPeriodPeriod "..."
265 %token PipeEqual "|="
268 %token PlusEqual "+="
270 %token PlusPlus_ "\n++"
272 %token RightEqual ">="
273 %token RightRight ">>"
274 %token RightRightEqual ">>="
275 %token RightRightRight ">>>"
276 %token RightRightRightEqual ">>>="
278 %token SlashEqual "/="
280 %token StarEqual "*="
292 %token CloseParen ")"
295 %token OpenBrace_ "\n{"
296 %token OpenBrace__ ";{"
297 %token CloseBrace "}"
299 %token OpenBracket "["
300 %token CloseBracket "]"
302 %token At_error_ "@error"
305 %token At_class_ "@class"
309 %token _typedef_ "typedef"
310 %token _unsigned_ "unsigned"
311 %token _signed_ "signed"
312 %token _extern_ "extern"
316 %token At_encode_ "@encode"
320 %token At_implementation_ "@implementation"
321 %token At_import_ "@import"
322 %token At_end_ "@end"
323 %token At_selector_ "@selector"
324 %token At_null_ "@null"
325 %token At_YES_ "@YES"
327 %token At_true_ "@true"
328 %token At_false_ "@false"
333 %token _false_ "false"
337 %token _break_ "break"
339 %token _catch_ "catch"
340 %token _class_ "class"
341 %token _class__ ";class"
342 %token _const_ "const"
343 %token _continue_ "continue"
344 %token _debugger_ "debugger"
345 %token _default_ "default"
346 %token _delete_ "delete"
350 %token _export_ "export"
351 %token _extends_ "extends"
352 %token _finally_ "finally"
354 %token _function_ "function"
355 %token _function__ ";function"
357 %token _import_ "import"
360 %token _Infinity_ "Infinity"
361 %token _instanceof_ "instanceof"
363 %token _return_ "return"
364 %token _super_ "super"
365 %token _switch_ "switch"
366 %token _target_ "target"
368 %token _throw_ "throw"
370 %token _typeof_ "typeof"
373 %token _while_ "while"
376 %token _abstract_ "abstract"
377 %token _await_ "await"
378 %token _boolean_ "boolean"
381 %token _constructor_ "constructor"
382 %token _double_ "double"
384 %token _final_ "final"
385 %token _float_ "float"
389 %token _implements_ "implements"
391 %token _interface_ "interface"
394 %token _native_ "native"
395 %token _package_ "package"
396 %token _private_ "private"
397 %token _protected_ "protected"
398 %token _prototype_ "prototype"
399 %token _public_ "public"
401 %token _short_ "short"
402 %token _static_ "static"
403 %token _synchronized_ "synchronized"
404 %token _throws_ "throws"
405 %token _transient_ "transient"
406 %token _volatile_ "volatile"
407 %token _yield_ "yield"
408 %token _yield__ "!yield"
410 %token _undefined_ "undefined"
426 %token _namespace_ "namespace"
433 %token <identifier_> Identifier_
434 %token <number_> NumericLiteral
435 %token <string_> StringLiteral
436 %token <literal_> RegularExpressionLiteral
438 %token <string_> NoSubstitutionTemplate
439 %token <string_> TemplateHead
440 %token <string_> TemplateMiddle
441 %token <string_> TemplateTail
443 %type <target_> AccessExpression
444 %type <expression_> AdditiveExpression
445 %type <argument_> ArgumentList_
446 %type <argument_> ArgumentList
447 %type <argument_> ArgumentListOpt
448 %type <argument_> Arguments
449 %type <target_> ArrayComprehension
450 %type <literal_> ArrayLiteral
451 %type <expression_> ArrowFunction
452 %type <functionParameter_> ArrowParameters
453 %type <expression_> AssignmentExpression
454 %type <expression_> AssignmentExpressionOpt
455 %type <identifier_> BindingIdentifier
456 %type <identifier_> BindingIdentifierOpt
457 %type <declarations_> BindingList_
458 %type <declarations_> BindingList
459 %type <expression_> BitwiseANDExpression
460 %type <statement_> Block
461 %type <statement_> BlockStatement
462 %type <boolean_> BooleanLiteral
463 %type <declaration_> BindingElement
464 %type <expression_> BitwiseORExpression
465 %type <expression_> BitwiseXORExpression
466 %type <statement_> BreakStatement
467 %type <statement_> BreakableStatement
468 %type <expression_> CallExpression_
469 %type <target_> CallExpression
470 %type <clause_> CaseBlock
471 %type <clause_> CaseClause
472 %type <clause_> CaseClausesOpt
474 %type <identifier_> CatchParameter
475 %type <statement_> ClassDeclaration
476 %type <target_> ClassExpression
477 %type <classTail_> ClassHeritage
478 %type <classTail_> ClassHeritageOpt
479 %type <classTail_> ClassTail
480 %type <target_> Comprehension
481 %type <comprehension_> ComprehensionFor
482 %type <comprehension_> ComprehensionIf
483 %type <comprehension_> ComprehensionTail
484 %type <propertyName_> ComputedPropertyName
485 %type <expression_> ConditionalExpression
486 %type <statement_> ContinueStatement
487 %type <statement_> ConciseBody
488 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
489 %type <statement_> DebuggerStatement
490 %type <statement_> Declaration__
491 %type <statement_> Declaration_
492 %type <statement_> Declaration
493 %type <clause_> DefaultClause
494 %type <element_> ElementList
495 %type <element_> ElementListOpt
496 %type <statement_> ElseStatementOpt
497 %type <for_> EmptyStatement
498 %type <expression_> EqualityExpression
499 %type <expression_> Expression
500 %type <expression_> ExpressionOpt
501 %type <for_> ExpressionStatement_
502 %type <statement_> ExpressionStatement
503 %type <finally_> Finally
504 %type <declaration_> ForBinding
505 %type <forin_> ForDeclaration
506 %type <forin_> ForInStatementInitializer
507 %type <for_> ForStatementInitializer
508 %type <declaration_> FormalParameter
509 %type <functionParameter_> FormalParameterList_
510 %type <functionParameter_> FormalParameterList
511 %type <functionParameter_> FormalParameters
512 %type <statement_> FunctionBody
513 %type <statement_> FunctionDeclaration
514 %type <target_> FunctionExpression
515 %type <statement_> FunctionStatementList
516 %type <statement_> GeneratorBody
517 %type <statement_> GeneratorDeclaration
518 %type <target_> GeneratorExpression
519 %type <method_> GeneratorMethod
520 %type <statement_> HoistableDeclaration
521 %type <identifier_> Identifier
522 %type <identifier_> IdentifierType
523 %type <word_> IdentifierName
524 %type <variable_> IdentifierReference
525 %type <statement_> IfStatement
526 %type <target_> IndirectExpression
527 %type <expression_> Initializer
528 %type <expression_> InitializerOpt
529 %type <statement_> IterationStatement
530 %type <identifier_> LabelIdentifier
531 %type <statement_> LabelledItem
532 %type <statement_> LabelledStatement
533 %type <assignment_> LeftHandSideAssignment
534 %type <target_> LeftHandSideExpression
535 %type <bool_> LetOrConst
536 %type <declaration_> LexicalBinding
537 %type <for_> LexicalDeclaration_
538 %type <statement_> LexicalDeclaration
539 %type <literal_> Literal
540 %type <propertyName_> LiteralPropertyName
541 %type <expression_> LogicalANDExpression
542 %type <expression_> LogicalORExpression
543 %type <access_> MemberAccess
544 %type <target_> MemberExpression
545 %type <method_> MethodDefinition
546 %type <module_> ModulePath
547 %type <expression_> MultiplicativeExpression
548 %type <target_> NewExpression
549 %type <null_> NullLiteral
550 %type <literal_> ObjectLiteral
551 %type <expression_> PostfixExpression
552 %type <target_> PrimaryExpression
553 %type <propertyName_> PropertyName
554 %type <property_> PropertyDefinition
555 %type <property_> PropertyDefinitionList_
556 %type <property_> PropertyDefinitionList
557 %type <property_> PropertyDefinitionListOpt
558 %type <declaration_> PropertySetParameterList
559 %type <expression_> RelationalExpression
560 %type <statement_> ReturnStatement
561 %type <rubyProc_> RubyProcExpression
562 %type <functionParameter_> RubyProcParameterList_
563 %type <functionParameter_> RubyProcParameterList
564 %type <functionParameter_> RubyProcParameters
565 %type <functionParameter_> RubyProcParametersOpt
566 %type <statement_> Script
567 %type <statement_> ScriptBody
568 %type <statement_> ScriptBodyOpt
569 %type <expression_> ShiftExpression
570 %type <declaration_> SingleNameBinding
571 %type <statement_> Statement__
572 %type <statement_> Statement_
573 %type <statement_> Statement
574 %type <statement_> StatementList
575 %type <statement_> StatementListOpt
576 %type <statement_> StatementListItem
577 %type <functionParameter_> StrictFormalParameters
578 %type <target_> SuperCall
579 %type <target_> SuperProperty
580 %type <statement_> SwitchStatement
581 %type <target_> TemplateLiteral
582 %type <span_> TemplateSpans
583 %type <statement_> ThrowStatement
584 %type <statement_> TryStatement
585 %type <expression_> UnaryExpression_
586 %type <expression_> UnaryExpression
587 %type <declaration_> VariableDeclaration
588 %type <declarations_> VariableDeclarationList_
589 %type <declarations_> VariableDeclarationList
590 %type <for_> VariableStatement_
591 %type <statement_> VariableStatement
592 %type <statement_> WithStatement
595 %type <word_> WordOpt
597 %type <expression_> YieldExpression
600 %type <specifier_> IntegerType
601 %type <specifier_> IntegerTypeOpt
602 %type <typedIdentifier_> PrefixedType
603 %type <specifier_> PrimitiveType
604 %type <typedIdentifier_> SuffixedType
605 %type <typedIdentifier_> TypeSignifier
606 %type <modifier_> TypeQualifierLeft
607 %type <typedIdentifier_> TypeQualifierRight
608 %type <typedIdentifier_> TypedIdentifier
609 %type <typedParameter_> TypedParameterList_
610 %type <typedParameter_> TypedParameterList
611 %type <typedParameter_> TypedParameterListOpt
615 %type <expression_> AssignmentExpressionClassic
616 %type <expression_> BoxableExpression
617 %type <statement_> CategoryStatement
618 %type <expression_> ClassSuperOpt
619 %type <expression_> ConditionalExpressionClassic
620 %type <implementationField_> ImplementationFieldListOpt
621 %type <implementationField_> ImplementationFields
622 %type <message_> ClassMessageDeclaration
623 %type <message_> ClassMessageDeclarationListOpt
624 %type <protocol_> ClassProtocolListOpt
625 %type <protocol_> ClassProtocols
626 %type <protocol_> ClassProtocolsOpt
627 %type <statement_> ImplementationStatement
628 %type <target_> MessageExpression
629 %type <messageParameter_> MessageParameter
630 %type <messageParameter_> MessageParameters
631 %type <messageParameter_> MessageParameterList
632 %type <messageParameter_> MessageParameterListOpt
633 %type <bool_> MessageScope
634 %type <argument_> SelectorCall_
635 %type <argument_> SelectorCall
636 %type <selector_> SelectorExpression_
637 %type <selector_> SelectorExpression
638 %type <selector_> SelectorExpressionOpt
639 %type <argument_> SelectorList
640 %type <word_> SelectorWordOpt
641 %type <typedIdentifier_> TypeOpt
642 %type <argument_> VariadicCall
646 %type <propertyIdentifier_> PropertyIdentifier_
647 %type <selector_> PropertySelector_
648 %type <selector_> PropertySelector
649 %type <identifier_> QualifiedIdentifier_
650 %type <identifier_> QualifiedIdentifier
651 %type <identifier_> WildcardIdentifier
652 %type <identifier_> XMLComment
653 %type <identifier_> XMLCDATA
654 %type <identifier_> XMLElement
655 %type <identifier_> XMLElementContent
656 %type <identifier_> XMLMarkup
657 %type <identifier_> XMLPI
659 %type <attribute_> AttributeIdentifier
660 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
661 %type <expression_> PropertyIdentifier
662 %type <expression_> XMLListInitialiser
663 %type <expression_> XMLInitialiser
666 /* Token Priorities {{{ */
682 /* Lexer State {{{ */
683 LexPushInOn: { driver.in_.push(true); };
684 LexPushInOff: { driver.in_.push(false); };
685 LexPopIn: { driver.in_.pop(); };
687 LexPushReturnOn: { driver.return_.push(true); };
688 LexPopReturn: { driver.return_.pop(); };
690 LexPushSuperOn: { driver.super_.push(true); };
691 LexPushSuperOff: { driver.super_.push(false); };
692 LexPopSuper: { driver.super_.pop(); };
694 LexPushYieldOn: { driver.yield_.push(true); };
695 LexPushYieldOff: { driver.yield_.push(false); };
696 LexPopYield: { driver.yield_.pop(); };
699 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
703 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
707 : { CYMAP(YieldStar, Star); }
711 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
715 : { CYMAP(_class__, _class_); }
719 : { CYMAP(_function__, _function_); }
723 : LexNoBrace LexNoClass LexNoFunction
726 /* Virtual Tokens {{{ */
737 /* 11.6 Names and Keywords {{{ */
740 | "for" { $$ = CYNew CYWord("for"); }
741 | "in" { $$ = CYNew CYWord("in"); }
742 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
751 : Identifier { $$ = $1; }
752 | "auto" { $$ = CYNew CYWord("auto"); }
753 | "break" { $$ = CYNew CYWord("break"); }
754 | "case" { $$ = CYNew CYWord("case"); }
755 | "catch" { $$ = CYNew CYWord("catch"); }
756 | "class" { $$ = CYNew CYWord("class"); }
757 | ";class" { $$ = CYNew CYWord("class"); }
758 | "const" { $$ = CYNew CYWord("const"); }
759 | "continue" { $$ = CYNew CYWord("continue"); }
760 | "debugger" { $$ = CYNew CYWord("debugger"); }
761 | "default" { $$ = CYNew CYWord("default"); }
762 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
763 | "do" { $$ = CYNew CYWord("do"); }
764 | "else" { $$ = CYNew CYWord("else"); }
765 | "enum" { $$ = CYNew CYWord("enum"); }
766 | "export" { $$ = CYNew CYWord("export"); }
767 | "extends" { $$ = CYNew CYWord("extends"); }
768 | "false" { $$ = CYNew CYWord("false"); }
769 | "finally" { $$ = CYNew CYWord("finally"); }
770 | "function" { $$ = CYNew CYWord("function"); }
771 | "if" { $$ = CYNew CYWord("if"); }
772 | "import" { $$ = CYNew CYWord("import"); }
773 | "!in" { $$ = CYNew CYWord("in"); }
774 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
775 | "null" { $$ = CYNew CYWord("null"); }
776 | "return" { $$ = CYNew CYWord("return"); }
777 | "super" { $$ = CYNew CYWord("super"); }
778 | "switch" { $$ = CYNew CYWord("switch"); }
779 | "this" { $$ = CYNew CYWord("this"); }
780 | "throw" { $$ = CYNew CYWord("throw"); }
781 | "true" { $$ = CYNew CYWord("true"); }
782 | "try" { $$ = CYNew CYWord("try"); }
783 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
784 | "var" { $$ = CYNew CYWord("var"); }
785 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
786 | "while" { $$ = CYNew CYWord("while"); }
787 | "with" { $$ = CYNew CYWord("with"); }
788 | "yield" { $$ = CYNew CYIdentifier("yield"); }
790 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
792 // XXX: should be Identifier
793 | "let" { $$ = CYNew CYIdentifier("let"); }
803 /* 11.8.1 Null Literals {{{ */
805 : "null" { $$ = CYNew CYNull(); }
808 /* 11.8.2 Boolean Literals {{{ */
810 : "true" { $$ = CYNew CYTrue(); }
811 | "false" { $$ = CYNew CYFalse(); }
815 /* 11.9 Automatic Semicolon Insertion {{{ */
817 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
827 | 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
832 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
836 /* 12.1 Identifiers {{{ */
838 : Identifier { $$ = CYNew CYVariable($1); }
839 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
843 : Identifier { $$ = $1; }
844 | "yield" { $$ = CYNew CYIdentifier("yield"); }
848 : BindingIdentifier { $$ = $1; }
853 : Identifier { $$ = $1; }
854 | "yield" { $$ = CYNew CYIdentifier("yield"); }
858 : Identifier_ { $$ = $1; }
859 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
860 | "await" { $$ = CYNew CYIdentifier("await"); }
861 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
862 | "byte" { $$ = CYNew CYIdentifier("byte"); }
863 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
864 | "double" { $$ = CYNew CYIdentifier("double"); }
865 | "each" { $$ = CYNew CYIdentifier("each"); }
866 | "eval" { $$ = CYNew CYIdentifier("eval"); }
867 | "final" { $$ = CYNew CYIdentifier("final"); }
868 | "float" { $$ = CYNew CYIdentifier("float"); }
869 | "from" { $$ = CYNew CYIdentifier("from"); }
870 | "get" { $$ = CYNew CYIdentifier("get"); }
871 | "goto" { $$ = CYNew CYIdentifier("goto"); }
872 | "implements" { $$ = CYNew CYIdentifier("implements"); }
873 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
874 | "interface" { $$ = CYNew CYIdentifier("interface"); }
875 | "native" { $$ = CYNew CYIdentifier("native"); }
876 | "of" { $$ = CYNew CYIdentifier("of"); }
877 | "package" { $$ = CYNew CYIdentifier("package"); }
878 | "private" { $$ = CYNew CYIdentifier("private"); }
879 | "protected" { $$ = CYNew CYIdentifier("protected"); }
880 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
881 | "public" { $$ = CYNew CYIdentifier("public"); }
882 | "set" { $$ = CYNew CYIdentifier("set"); }
883 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
884 | "target" { $$ = CYNew CYIdentifier("target"); }
885 | "throws" { $$ = CYNew CYIdentifier("throws"); }
886 | "transient" { $$ = CYNew CYIdentifier("transient"); }
887 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
889 | "bool" { $$ = CYNew CYIdentifier("bool"); }
890 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
891 | "id" { $$ = CYNew CYIdentifier("id"); }
892 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
898 | "char" { $$ = CYNew CYIdentifier("char"); }
899 | "int" { $$ = CYNew CYIdentifier("int"); }
900 | "long" { $$ = CYNew CYIdentifier("long"); }
901 | "short" { $$ = CYNew CYIdentifier("short"); }
902 | "static" { $$ = CYNew CYIdentifier("static"); }
903 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
905 | "extern" { $$ = CYNew CYIdentifier("extern"); }
906 | "signed" { $$ = CYNew CYIdentifier("signed"); }
907 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
908 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
911 | "nil" { $$ = CYNew CYIdentifier("nil"); }
912 | "NO" { $$ = CYNew CYIdentifier("NO"); }
913 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
914 | "YES" { $$ = CYNew CYIdentifier("YES"); }
918 /* 12.2 Primary Expression {{{ */
920 : "this" { $$ = CYNew CYThis(); }
921 | IdentifierReference { $$ = $1; }
922 | Literal { $$ = $1; }
923 | ArrayLiteral { $$ = $1; }
924 | ObjectLiteral { $$ = $1; }
925 | FunctionExpression { $$ = $1; }
926 | ClassExpression { $$ = $1; }
927 | GeneratorExpression { $$ = $1; }
928 | RegularExpressionLiteral { $$ = $1; }
929 | TemplateLiteral { $$ = $1; }
930 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
931 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
934 CoverParenthesizedExpressionAndArrowParameterList
935 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
936 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
937 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
938 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
941 /* 12.2.4 Literals {{{ */
943 : NullLiteral { $$ = $1; }
944 | BooleanLiteral { $$ = $1; }
945 | NumericLiteral { $$ = $1; }
946 | StringLiteral { $$ = $1; }
949 /* 12.2.5 Array Initializer {{{ */
951 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
955 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
956 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
957 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
961 : ElementList { $$ = $1; }
962 | LexSetRegExp { $$ = NULL; }
965 /* 12.2.6 Object Initializer {{{ */
967 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
970 PropertyDefinitionList_
971 : "," PropertyDefinitionListOpt { $$ = $2; }
975 PropertyDefinitionList
976 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
979 PropertyDefinitionListOpt
980 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
981 | LexSetRegExp { $$ = NULL; }
985 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
986 | CoverInitializedName { CYNOT(@$); }
987 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
988 | MethodDefinition { $$ = $1; }
992 : LiteralPropertyName { $$ = $1; }
993 | ComputedPropertyName { $$ = $1; }
997 : IdentifierName { $$ = $1; }
998 | StringLiteral { $$ = $1; }
999 | NumericLiteral { $$ = $1; }
1002 ComputedPropertyName
1003 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
1006 CoverInitializedName
1007 : IdentifierReference Initializer
1011 : "=" AssignmentExpression { $$ = $2; }
1015 : Initializer { $$ = $1; }
1019 /* 12.2.9 Template Literals {{{ */
1021 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
1022 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
1026 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
1027 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
1031 /* 12.3 Left-Hand-Side Expressions {{{ */
1033 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
1034 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1035 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1036 | TemplateLiteral { CYNOT(@$); }
1040 : LexSetRegExp PrimaryExpression { $$ = $2; }
1041 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1042 | SuperProperty { $$ = $1; }
1043 | MetaProperty { CYNOT(@$); }
1044 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1048 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "[" Expression "]" { $$ = CYNew CYSuperAccess($5); }
1049 | LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($5)); }
1057 : LexSetRegExp "new" LexSetRegExp "." "target"
1061 : MemberExpression { $$ = $1; }
1062 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1066 : MemberExpression { $$ = $1; }
1067 | CallExpression { $$ = $1; }
1071 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1072 | SuperCall { $$ = $1; }
1073 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1077 : LexSetRegExp "super" { if (!driver.super_.top()) CYERR(@2, "invalid super"); } Arguments { $$ = CYNew CYSuperCall($4); }
1081 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1085 : "," ArgumentList { $$ = $2; }
1090 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1091 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1095 : ArgumentList { $$ = $1; }
1096 | LexSetRegExp { $$ = NULL; }
1100 : NewExpression { $$ = $1; }
1101 | CallExpression { $$ = $1; }
1104 LeftHandSideExpression
1105 : AccessExpression LexCrement { $$ = $1; }
1106 | LexSetRegExp IndirectExpression { $$ = $2; }
1109 /* 12.4 Postfix Expressions {{{ */
1111 : { CYLIN(PlusPlus); CYLIN(HyphenHyphen); }
1115 : AccessExpression LexCrement { $$ = $1; }
1116 | AccessExpression LexCrement "++" { $$ = CYNew CYPostIncrement($1); }
1117 | AccessExpression LexCrement "--" { $$ = CYNew CYPostDecrement($1); }
1120 /* 12.5 Unary Operators {{{ */
1122 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1123 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1124 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1125 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1126 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1127 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1128 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1129 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1130 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1131 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1132 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1136 : PostfixExpression LexOpenBrace { $$ = $1; }
1137 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1140 /* 12.6 Multiplicative Operators {{{ */
1141 MultiplicativeExpression
1142 : UnaryExpression { $$ = $1; }
1143 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1144 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1145 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1148 /* 12.7 Additive Operators {{{ */
1150 : MultiplicativeExpression { $$ = $1; }
1151 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1152 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1155 /* 12.8 Bitwise Shift Operators {{{ */
1157 : AdditiveExpression { $$ = $1; }
1158 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1159 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1160 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1163 /* 12.9 Relational Operators {{{ */
1164 RelationalExpression
1165 : ShiftExpression { $$ = $1; }
1166 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1167 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1168 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1169 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1170 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1171 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1174 /* 12.10 Equality Operators {{{ */
1176 : RelationalExpression { $$ = $1; }
1177 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1178 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1179 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1180 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1183 /* 12.11 Binary Bitwise Operators {{{ */
1184 BitwiseANDExpression
1185 : EqualityExpression { $$ = $1; }
1186 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1189 BitwiseXORExpression
1190 : BitwiseANDExpression { $$ = $1; }
1191 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1195 : BitwiseXORExpression { $$ = $1; }
1196 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1199 /* 12.12 Binary Logical Operators {{{ */
1200 LogicalANDExpression
1201 : BitwiseORExpression { $$ = $1; }
1202 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1206 : LogicalANDExpression { $$ = $1; }
1207 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1210 /* 12.13 Conditional Operator ( ? : ) {{{ */
1212 ConditionalExpressionClassic
1213 : LogicalORExpression { $$ = $1; }
1214 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpressionClassic { $$ = CYNew CYCondition($1, $4, $7); }
1218 ConditionalExpression
1219 : LogicalORExpression { $$ = $1; }
1220 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1223 /* 12.14 Assignment Operators {{{ */
1224 LeftHandSideAssignment
1225 : LeftHandSideExpression "=" { $$ = CYNew CYAssign($1, NULL); }
1226 | LeftHandSideExpression "*=" { $$ = CYNew CYMultiplyAssign($1, NULL); }
1227 | LeftHandSideExpression "/=" { $$ = CYNew CYDivideAssign($1, NULL); }
1228 | LeftHandSideExpression "%=" { $$ = CYNew CYModulusAssign($1, NULL); }
1229 | LeftHandSideExpression "+=" { $$ = CYNew CYAddAssign($1, NULL); }
1230 | LeftHandSideExpression "-=" { $$ = CYNew CYSubtractAssign($1, NULL); }
1231 | LeftHandSideExpression "<<=" { $$ = CYNew CYShiftLeftAssign($1, NULL); }
1232 | LeftHandSideExpression ">>=" { $$ = CYNew CYShiftRightSignedAssign($1, NULL); }
1233 | LeftHandSideExpression ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($1, NULL); }
1234 | LeftHandSideExpression "&=" { $$ = CYNew CYBitwiseAndAssign($1, NULL); }
1235 | LeftHandSideExpression "^=" { $$ = CYNew CYBitwiseXOrAssign($1, NULL); }
1236 | LeftHandSideExpression "|=" { $$ = CYNew CYBitwiseOrAssign($1, NULL); }
1240 AssignmentExpressionClassic
1241 : ConditionalExpressionClassic { $$ = $1; }
1242 | LeftHandSideAssignment AssignmentExpressionClassic { $1->SetRight($2); $$ = $1; }
1246 AssignmentExpression
1247 : ConditionalExpression { $$ = $1; }
1248 | LexSetRegExp YieldExpression { $$ = $2; }
1249 | ArrowFunction { $$ = $1; }
1250 | LeftHandSideAssignment AssignmentExpression { $1->SetRight($2); $$ = $1; }
1253 AssignmentExpressionOpt
1254 : AssignmentExpression { $$ = $1; }
1255 | LexSetRegExp { $$ = NULL; }
1258 /* 12.15 Comma Operator ( , ) {{{ */
1260 : AssignmentExpression { $$ = $1; }
1261 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1265 : Expression { $$ = $1; }
1266 | LexSetRegExp { $$ = NULL; }
1270 /* 13 Statements and Declarations {{{ */
1272 : BlockStatement { $$ = $1; }
1273 | VariableStatement { $$ = $1; }
1274 | EmptyStatement { $$ = $1; }
1275 | IfStatement { $$ = $1; }
1276 | BreakableStatement { $$ = $1; }
1277 | ContinueStatement { $$ = $1; }
1278 | BreakStatement { $$ = $1; }
1279 | ReturnStatement { $$ = $1; }
1280 | WithStatement { $$ = $1; }
1281 | LabelledStatement { $$ = $1; }
1282 | ThrowStatement { $$ = $1; }
1283 | TryStatement { $$ = $1; }
1284 | DebuggerStatement { $$ = $1; }
1288 : LexSetRegExp Statement__ { $$ = $2; }
1289 | ExpressionStatement { $$ = $1; }
1293 : LexSetStatement Statement_ { $$ = $2; }
1297 : HoistableDeclaration { $$ = $1; }
1298 | ClassDeclaration { $$ = $1; }
1299 | LexicalDeclaration { $$ = $1; }
1303 : LexSetRegExp Declaration__ { $$ = $2; }
1307 : LexSetStatement Declaration_ { $$ = $2; }
1310 HoistableDeclaration
1311 : FunctionDeclaration { $$ = $1; }
1312 | GeneratorDeclaration { $$ = $1; }
1316 : IterationStatement { $$ = $1; }
1317 | SwitchStatement { $$ = $1; }
1320 /* 13.2 Block {{{ */
1322 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1326 : BRACE StatementListOpt "}" { $$ = $2; }
1330 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1334 : StatementList { $$ = $1; }
1335 | LexSetStatement LexSetRegExp { $$ = NULL; }
1339 : Statement { $$ = $1; }
1340 | Declaration { $$ = $1; }
1343 /* 13.3 Let and Const Declarations {{{ */
1345 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1349 : LexicalDeclaration_ Terminator { $$ = $1; }
1353 : "let" { $$ = false; }
1354 | "const" { $$ = true; }
1358 : "," BindingList { $$ = $2; }
1363 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1367 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1368 | BindingPattern Initializer { CYNOT(@1); }
1371 /* 13.3.2 Variable Statement {{{ */
1373 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1377 : VariableStatement_ Terminator { $$ = $1; }
1380 VariableDeclarationList_
1381 : "," VariableDeclarationList { $$ = $2; }
1385 VariableDeclarationList
1386 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1390 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1391 | BindingPattern Initializer { CYNOT(@1); }
1394 /* 13.3.3 Destructuring Binding Patterns {{{ */
1396 : ObjectBindingPattern
1397 | ArrayBindingPattern
1400 ObjectBindingPattern
1401 : BRACE BindingPropertyListOpt "}"
1405 : "[" { CYNOT(@$); }
1408 BindingPropertyList_
1409 : "," BindingPropertyListOpt
1414 : BindingProperty BindingPropertyList_
1417 BindingPropertyListOpt
1418 : BindingPropertyList
1424 | PropertyName ":" BindingElement
1428 : SingleNameBinding { $$ = $1; }
1429 | BindingPattern InitializerOpt { CYNOT(@$); }
1433 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1437 : "..." BindingIdentifier
1440 /* 13.4 Empty Statement {{{ */
1442 : ";" { $$ = CYNew CYEmpty(); }
1445 /* 13.5 Expression Statement {{{ */
1446 ExpressionStatement_
1447 : Expression { $$ = CYNew CYExpress($1); }
1450 : ExpressionStatement_ Terminator { $$ = $1; }
1453 /* 13.6 The if Statement {{{ */
1455 : "else" Statement { $$ = $2; }
1456 | %prec "if" { $$ = NULL; }
1460 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1463 /* 13.7 Iteration Statements {{{ */
1465 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1466 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1467 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1468 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1469 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1470 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1473 ForStatementInitializer
1474 : LexSetRegExp EmptyStatement { $$ = $2; }
1475 | ExpressionStatement_ ";" { $$ = $1; }
1476 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1477 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1480 ForInStatementInitializer
1481 : AccessExpression LexCrement { $$ = $1; }
1482 | LexSetRegExp IndirectExpression { $$ = $2; }
1483 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1484 | LexSetRegExp ForDeclaration { $$ = $2; }
1488 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1492 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1493 | BindingPattern { CYNOT(@1); }
1496 /* 13.8 The continue Statement {{{ */
1498 : "continue" LexNewLine
1502 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1503 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1506 /* 13.9 The break Statement {{{ */
1508 : "break" LexNewLine
1512 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1513 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1516 /* 13.10 The return Statement {{{ */
1518 : "return" { if (!driver.return_.top()) CYERR(@1, "invalid return"); } LexNewLine
1522 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1523 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1526 /* 13.11 The with Statement {{{ */
1528 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1531 /* 13.12 The switch Statement {{{ */
1533 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1537 : BRACE CaseClausesOpt "}" { $$ = $2; }
1541 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1545 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1546 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1550 // XXX: the standard makes certain you can only have one of these
1552 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1555 /* 13.13 Labelled Statements {{{ */
1557 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1561 : Statement { $$ = $1; }
1562 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1565 /* 13.14 The throw Statement {{{ */
1567 : "throw" LexNewLine
1571 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1572 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1575 /* 13.15 The try Statement {{{ */
1577 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1578 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1579 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1583 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1587 : "finally" Block { $$ = CYNew CYFinally($2); }
1591 : BindingIdentifier { $$ = $1; }
1592 | BindingPattern { CYNOT(@$); }
1595 /* 13.16 The debugger Statement {{{ */
1597 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1601 /* 14.1 Function Definitions {{{ */
1603 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1607 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1610 StrictFormalParameters
1611 : FormalParameters { $$ = $1; }
1616 | FormalParameterList
1619 FormalParameterList_
1620 : "," FormalParameterList { $$ = $2; }
1625 : FunctionRestParameter { CYNOT(@$); }
1626 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1629 FunctionRestParameter
1630 : BindingRestElement
1634 : BindingElement { $$ = $1; }
1638 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1641 FunctionStatementList
1642 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1645 /* 14.2 Arrow Function Definitions {{{ */
1647 : { CYLIN(EqualRight); }
1651 : LexSetRegExp ArrowParameters LexEqualRight "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $6); }
1655 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1656 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1660 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1661 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1664 /* 14.3 Method Definitions {{{ */
1666 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1667 | GeneratorMethod { $$ = $1; }
1668 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1669 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1672 PropertySetParameterList
1673 : FormalParameter { $$ = $1; }
1676 /* 14.4 Generator Function Definitions {{{ */
1678 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1681 GeneratorDeclaration
1682 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1686 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1690 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1694 : "!yield" LexNewLine LexNoStar
1698 : Yield LexSetRegExp NewLineOpt { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1699 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1700 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1703 /* 14.5 Class Definitions {{{ */
1705 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1709 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1713 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1717 : "extends" AccessExpression { $$ = CYNew CYClassTail($2); }
1721 : ClassHeritage { $$ = $1; }
1722 | { $$ = CYNew CYClassTail(NULL); }
1735 : ClassElementListOpt ClassElement
1744 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1745 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1750 /* 15.1 Scripts {{{ */
1752 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1756 : StatementList { $$ = $1; }
1760 : ScriptBody { $$ = $1; }
1761 | LexSetStatement LexSetRegExp { $$ = NULL; }
1764 /* 15.2 Modules {{{ */
1779 : ModuleItemListOpt ModuleItem
1788 : LexSetStatement LexSetRegExp ImportDeclaration
1789 | LexSetStatement LexSetRegExp ExportDeclaration
1793 /* 15.2.2 Imports {{{ */
1795 : "import" ImportClause FromClause Terminator
1796 | "import" ModuleSpecifier Terminator
1800 : ImportedDefaultBinding
1803 | ImportedDefaultBinding "," NameSpaceImport
1804 | ImportedDefaultBinding "," NamedImports
1807 ImportedDefaultBinding
1812 : "*" "as" ImportedBinding
1816 : BRACE ImportsListOpt "}"
1820 : "from" ModuleSpecifier
1824 : "," ImportsListOpt
1829 : ImportSpecifier ImportsList_
1839 | IdentifierName "as" ImportedBinding
1850 /* 15.2.3 Exports {{{ */
1852 : "*" FromClause Terminator
1853 | ExportClause FromClause Terminator
1854 | ExportClause Terminator
1856 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1857 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1858 | "default" LexSetStatement AssignmentExpression Terminator
1862 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1863 | "export" Declaration
1867 : ";{" ExportsListOpt "}"
1871 : "," ExportsListOpt
1876 : ExportSpecifier ExportsList_
1886 | IdentifierName "as" IdentifierName
1891 /* Cycript (C): Type Encoding {{{ */
1893 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1894 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1898 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1899 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1900 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1901 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1902 | TypeSignifier { $$ = $1; }
1903 | { $$ = CYNew CYTypedIdentifier(@$); }
1907 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1912 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1913 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1917 : PrefixedType { $$ = $1; }
1918 | SuffixedType { $$ = $1; }
1919 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1920 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1924 : "int" { $$ = CYNew CYTypeVariable("int"); }
1925 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1926 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1927 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1928 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1932 : IntegerType { $$ = $1; }
1933 | { $$ = CYNew CYTypeVariable("int"); }
1937 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1938 | IntegerType { $$ = $1; }
1939 | "void" { $$ = CYNew CYTypeVoid(); }
1940 | "char" { $$ = CYNew CYTypeVariable("char"); }
1941 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1942 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1946 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1950 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1956 /* Cycript (Objective-C): @class Declaration {{{ */
1958 /* XXX: why the hell did I choose MemberExpression? */
1959 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1963 ImplementationFieldListOpt
1964 : LexSetRegExp TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($2, $4); }
1965 | LexSetRegExp { $$ = NULL; }
1968 ImplementationFields
1969 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1973 : "+" { $$ = false; }
1974 | "-" { $$ = true; }
1978 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1979 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1983 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1986 MessageParameterList
1987 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1990 MessageParameterListOpt
1991 : MessageParameterList { $$ = $1; }
1996 : MessageParameterList { $$ = $1; }
1997 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
2000 ClassMessageDeclaration
2001 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
2004 ClassMessageDeclarationListOpt
2005 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
2009 // XXX: this should be AssignmentExpressionNoRight
2011 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
2015 : "," ClassProtocols { $$ = $2; }
2019 ClassProtocolListOpt
2020 : "<" ClassProtocols ">" { $$ = $2; }
2024 ImplementationStatement
2025 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
2033 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
2037 : ImplementationStatement { $$ = $1; }
2038 | CategoryStatement { $$ = $1; }
2041 /* Cycript (Objective-C): Send Message {{{ */
2043 : "," AssignmentExpressionClassic VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
2048 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
2049 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2053 : SelectorCall { $$ = $1; }
2054 | VariadicCall { $$ = $1; }
2058 : SelectorWordOpt ":" AssignmentExpressionClassic SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
2062 : SelectorCall { $$ = $1; }
2063 | Word { $$ = CYNew CYArgument($1, NULL); }
2067 : "[" LexPushInOff AssignmentExpressionClassic { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2068 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2072 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2076 : SelectorExpression_ { $$ = $1; }
2077 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2080 SelectorExpressionOpt
2081 : SelectorExpression_ { $$ = $1; }
2086 : MessageExpression { $$ = $1; }
2087 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2092 /* Cycript: @import Directive {{{ */
2094 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2095 | Word { $$ = CYNew CYModule($1); }
2099 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2104 /* Cycript (Objective-C): Boxed Expressions {{{ */
2106 : NullLiteral { $$ = $1; }
2107 | BooleanLiteral { $$ = $1; }
2108 | NumericLiteral { $$ = $1; }
2109 | StringLiteral { $$ = $1; }
2110 | ArrayLiteral { $$ = $1; }
2111 | ObjectLiteral { $$ = $1; }
2112 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2113 | "YES" { $$ = CYNew CYTrue(); }
2114 | "NO" { $$ = CYNew CYFalse(); }
2118 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2119 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2120 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2121 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2122 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2123 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2126 /* Cycript (Objective-C): Block Expressions {{{ */
2128 : "^" 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"); }
2131 /* Cycript (Objective-C): Instance Literals {{{ */
2133 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2139 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2141 : IndirectExpression { $$ = $1; }
2145 : "*" UnaryExpression { $$ = CYNew CYIndirect($2); }
2149 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2153 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2154 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2155 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2158 /* Cycript (C): auto Compatibility {{{ */
2163 /* Cycript (C): Lambda Expressions {{{ */
2165 : "," TypedParameterList { $$ = $2; }
2170 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2173 TypedParameterListOpt
2174 : TypedParameterList { $$ = $1; }
2179 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2182 /* Cycript (C): Type Definitions {{{ */
2184 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2187 /* Cycript (C): extern "C" {{{ */
2189 : "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); }
2196 /* Lexer State {{{ */
2198 : { driver.PushCondition(CYDriver::RegExpCondition); }
2202 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2206 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2210 : { driver.PopCondition(); }
2214 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2218 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2221 /* Virtual Tokens {{{ */
2228 /* 8.1 Context Keywords {{{ */
2230 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2231 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2234 /* 8.3 XML Initializer Input Elements {{{ */
2236 : XMLComment { $$ = $1; }
2237 | XMLCDATA { $$ = $1; }
2238 | XMLPI { $$ = $1; }
2242 /* 11.1 Primary Expressions {{{ */
2244 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2245 | XMLInitialiser { $$ = $1; }
2246 | XMLListInitialiser { $$ = $1; }
2250 : AttributeIdentifier { $$ = $1; }
2251 | QualifiedIdentifier { $$ = $1; }
2252 | WildcardIdentifier { $$ = $1; }
2255 /* 11.1.1 Attribute Identifiers {{{ */
2257 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2261 : PropertySelector { $$ = $1; }
2262 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2266 : Identifier { $$ = CYNew CYSelector($1); }
2267 | WildcardIdentifier { $$ = $1; }
2270 /* 11.1.2 Qualified Identifiers {{{ */
2271 QualifiedIdentifier_
2272 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2273 | QualifiedIdentifier { $$ = $1; }
2277 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2280 /* 11.1.3 Wildcard Identifiers {{{ */
2282 : "*" { $$ = CYNew CYWildcard(); }
2285 /* 11.1.4 XML Initializer {{{ */
2287 : XMLMarkup { $$ = $1; }
2288 | XMLElement { $$ = $1; }
2292 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2293 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2297 : LexPushXMLTag XMLTagName XMLAttributes
2301 : BRACE LexPushRegExp Expression LexPop "}"
2310 : XMLAttributes_ XMLAttribute
2315 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2316 | XMLAttributes_ XMLWhitespaceOpt
2325 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2329 : XMLExpression XMLElementContentOpt
2330 | XMLMarkup XMLElementContentOpt
2331 | XMLText XMLElementContentOpt
2332 | XMLElement XMLElementContentOpt
2335 XMLElementContentOpt
2340 /* 11.1.5 XMLList Initializer {{{ */
2342 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2346 /* 11.2 Left-Hand-Side Expressions {{{ */
2348 : Identifier { $$ = $1; }
2349 | PropertyIdentifier { $$ = $1; }
2353 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2354 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2355 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2358 /* 12.1 The default xml namespace Statement {{{ */
2359 /* XXX: DefaultXMLNamespaceStatement
2360 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2364 : DefaultXMLNamespaceStatement { $$ = $1; }
2369 /* JavaScript FTL: Array Comprehensions {{{ */
2371 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2375 : "for" "each" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2378 /* JavaScript FTL: for each {{{ */
2380 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2384 /* JavaScript FTW: Array Comprehensions {{{ */
2386 : ArrayComprehension
2390 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2394 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2399 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2400 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2404 : "for" "(" LexPushInOn ForBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2405 | "for" "(" LexPushInOn ForBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2409 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2412 /* JavaScript FTW: Coalesce Operator {{{ */
2413 ConditionalExpression
2414 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2417 /* JavaScript FTW: Named Arguments {{{ */
2419 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2422 /* JavaScript FTW: Ruby Blocks {{{ */
2423 RubyProcParameterList_
2424 : "," RubyProcParameterList { $$ = $2; }
2428 RubyProcParameterList
2429 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2434 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2435 | LexSetRegExp "||" { $$ = NULL; }
2438 RubyProcParametersOpt
2439 : RubyProcParameters { $$ = $1; }
2440 | LexSetRegExp { $$ = NULL; }
2444 : { CYLIN(OpenBrace); }
2448 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2452 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2456 : PostfixExpression LexOpenBrace RubyProcExpression { $$ = CYNew CYRubyBlock($1, $3); }
2462 bool CYDriver::Parse(CYMark mark) {
2464 CYLocal<CYPool> local(&pool_);
2465 cy::parser parser(*this);
2467 parser.set_debug_level(debug_);
2469 return parser.parse() != 0;
2472 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2476 CYDriver::Error error;
2477 error.warning_ = true;
2478 error.location_ = location;
2479 error.message_ = message;
2480 errors_.push_back(error);
2483 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2484 CYDriver::Error error;
2485 error.warning_ = false;
2486 error.location_ = location;
2487 error.message_ = message;
2488 driver.errors_.push_back(error);