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 *);
117 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
118 if (driver.mark_ == CYMarkIgnore);
119 else if (driver.mark_ == CYMarkScript) {
120 driver.mark_ = CYMarkIgnore;
121 return cy::parser::token::MarkScript;
122 } else if (driver.mark_ == CYMarkModule) {
123 driver.mark_ = CYMarkIgnore;
124 return cy::parser::token::MarkModule;
128 int token(cylex(&data, location, driver.scanner_));
129 *semantic = data.semantic_;
133 #define CYLEX() do if (yyla.empty()) { \
134 YYCDEBUG << "Mapping a token: "; \
135 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
136 YY_SYMBOL_PRINT("Next token is", yyla); \
139 #define CYMAP(to, from) do { \
141 if (yyla.type == yytranslate_(token::from)) \
142 yyla.type = yytranslate_(token::to); \
145 #define CYERR(location, message) do { \
146 error(location, message); \
150 #define CYNOT(location) \
151 CYERR(location, "unimplemented feature")
160 @$.begin.filename = @$.end.filename = &driver.filename_;
166 %define api.location.type { CYLocation }
173 %param { CYDriver &driver }
175 /* Token Declarations {{{ */
181 %token XMLAttributeValue
183 %token XMLTagCharacters
189 %token LeftRight "<>"
190 %token LeftSlashRight "</>"
192 %token SlashRight "/>"
193 %token LeftSlash "</"
195 %token ColonColon "::"
196 %token PeriodPeriod ".."
199 @begin E4X ObjectiveC
205 %token AmpersandAmpersand "&&"
206 %token AmpersandEqual "&="
208 %token CarrotEqual "^="
210 %token EqualEqual "=="
211 %token EqualEqualEqual "==="
212 %token EqualRight "=>"
213 %token EqualRight_ "\n=>"
214 %token Exclamation "!"
215 %token ExclamationEqual "!="
216 %token ExclamationEqualEqual "!=="
218 %token HyphenEqual "-="
219 %token HyphenHyphen "--"
220 %token HyphenHyphen_ "\n--"
221 %token HyphenRight "->"
223 %token LeftEqual "<="
225 %token LeftLeftEqual "<<="
227 %token PercentEqual "%="
229 %token PeriodPeriodPeriod "..."
231 %token PipeEqual "|="
234 %token PlusEqual "+="
236 %token PlusPlus_ "\n++"
238 %token RightEqual ">="
239 %token RightRight ">>"
240 %token RightRightEqual ">>="
241 %token RightRightRight ">>>"
242 %token RightRightRightEqual ">>>="
244 %token SlashEqual "/="
246 %token StarEqual "*="
258 %token CloseParen ")"
261 %token OpenBrace_ "\n{"
262 %token OpenBrace__ ";{"
263 %token CloseBrace "}"
265 %token OpenBracket "["
266 %token CloseBracket "]"
268 %token At_error_ "@error"
271 %token At_class_ "@class"
275 %token _typedef_ "typedef"
276 %token _unsigned_ "unsigned"
277 %token _signed_ "signed"
278 %token _extern_ "extern"
282 %token At_encode_ "@encode"
286 %token At_implementation_ "@implementation"
287 %token At_import_ "@import"
288 %token At_end_ "@end"
289 %token At_selector_ "@selector"
290 %token At_null_ "@null"
291 %token At_YES_ "@YES"
293 %token At_true_ "@true"
294 %token At_false_ "@false"
299 %token _false_ "false"
303 %token _break_ "break"
305 %token _catch_ "catch"
306 %token _class_ "class"
307 %token _class__ ";class"
308 %token _const_ "const"
309 %token _continue_ "continue"
310 %token _debugger_ "debugger"
311 %token _default_ "default"
312 %token _delete_ "delete"
316 %token _export_ "export"
317 %token _extends_ "extends"
318 %token _finally_ "finally"
320 %token _function_ "function"
321 %token _function__ ";function"
323 %token _import_ "import"
326 %token _Infinity_ "Infinity"
327 %token _instanceof_ "instanceof"
329 %token _return_ "return"
330 %token _return__ "!return"
331 %token _super_ "super"
332 %token _super__ "!super"
333 %token _switch_ "switch"
335 %token _throw_ "throw"
337 %token _typeof_ "typeof"
340 %token _while_ "while"
343 %token _abstract_ "abstract"
344 %token _await_ "await"
345 %token _boolean_ "boolean"
348 %token _constructor_ "constructor"
349 %token _double_ "double"
351 %token _final_ "final"
352 %token _float_ "float"
356 %token _implements_ "implements"
358 %token _interface_ "interface"
361 %token _native_ "native"
362 %token _package_ "package"
363 %token _private_ "private"
364 %token _protected_ "protected"
365 %token _prototype_ "prototype"
366 %token _public_ "public"
368 %token _short_ "short"
369 %token _static_ "static"
370 %token _synchronized_ "synchronized"
371 %token _throws_ "throws"
372 %token _transient_ "transient"
373 %token _volatile_ "volatile"
374 %token _yield_ "yield"
375 %token _yield__ "!yield"
377 %token _undefined_ "undefined"
393 %token _namespace_ "namespace"
400 %token <identifier_> Identifier_
401 %token <number_> NumericLiteral
402 %token <string_> StringLiteral
403 %token <literal_> RegularExpressionLiteral
405 %token <string_> NoSubstitutionTemplate
406 %token <string_> TemplateHead
407 %token <string_> TemplateMiddle
408 %token <string_> TemplateTail
410 %type <expression_> AdditiveExpression
411 %type <argument_> ArgumentList_
412 %type <argument_> ArgumentList
413 %type <argument_> ArgumentListOpt
414 %type <argument_> Arguments
415 %type <target_> ArrayComprehension
416 %type <literal_> ArrayLiteral
417 %type <expression_> ArrowFunction
418 %type <functionParameter_> ArrowParameters
419 %type <expression_> AssignmentExpression
420 %type <expression_> AssignmentExpressionOpt
421 %type <identifier_> BindingIdentifier
422 %type <identifier_> BindingIdentifierOpt
423 %type <declarations_> BindingList_
424 %type <declarations_> BindingList
425 %type <expression_> BitwiseANDExpression
426 %type <statement_> Block
427 %type <statement_> BlockStatement
428 %type <boolean_> BooleanLiteral
429 %type <declaration_> BindingElement
430 %type <expression_> BitwiseORExpression
431 %type <expression_> BitwiseXORExpression
432 %type <statement_> BreakStatement
433 %type <statement_> BreakableStatement
434 %type <expression_> CallExpression_
435 %type <target_> CallExpression
436 %type <clause_> CaseBlock
437 %type <clause_> CaseClause
438 %type <clause_> CaseClausesOpt
440 %type <identifier_> CatchParameter
441 %type <statement_> ClassDeclaration
442 %type <target_> ClassExpression
443 %type <classTail_> ClassHeritage
444 %type <classTail_> ClassHeritageOpt
445 %type <classTail_> ClassTail
446 %type <target_> Comprehension
447 %type <comprehension_> ComprehensionFor
448 %type <comprehension_> ComprehensionIf
449 %type <comprehension_> ComprehensionTail
450 %type <propertyName_> ComputedPropertyName
451 %type <expression_> ConditionalExpression
452 %type <statement_> ContinueStatement
453 %type <statement_> ConciseBody
454 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
455 %type <statement_> DebuggerStatement
456 %type <statement_> Declaration__
457 %type <statement_> Declaration_
458 %type <statement_> Declaration
459 %type <clause_> DefaultClause
460 %type <element_> ElementList
461 %type <element_> ElementListOpt
462 %type <statement_> ElseStatementOpt
463 %type <for_> EmptyStatement
464 %type <expression_> EqualityExpression
465 %type <expression_> Expression
466 %type <expression_> ExpressionOpt
467 %type <for_> ExpressionStatement_
468 %type <statement_> ExpressionStatement
469 %type <finally_> Finally
470 %type <declaration_> ForBinding
471 %type <forin_> ForDeclaration
472 %type <forin_> ForInStatementInitializer
473 %type <for_> ForStatementInitializer
474 %type <declaration_> FormalParameter
475 %type <functionParameter_> FormalParameterList_
476 %type <functionParameter_> FormalParameterList
477 %type <functionParameter_> FormalParameters
478 %type <statement_> FunctionBody
479 %type <statement_> FunctionDeclaration
480 %type <target_> FunctionExpression
481 %type <statement_> FunctionStatementList
482 %type <statement_> GeneratorBody
483 %type <statement_> GeneratorDeclaration
484 %type <target_> GeneratorExpression
485 %type <method_> GeneratorMethod
486 %type <statement_> HoistableDeclaration
487 %type <identifier_> Identifier
488 %type <identifier_> IdentifierType
489 %type <word_> IdentifierName
490 %type <variable_> IdentifierReference
491 %type <statement_> IfStatement
492 %type <expression_> Initializer
493 %type <expression_> InitializerOpt
494 %type <statement_> IterationStatement
495 %type <identifier_> LabelIdentifier
496 %type <statement_> LabelledItem
497 %type <statement_> LabelledStatement
498 %type <target_> LeftHandSideExpression
499 %type <bool_> LetOrConst
500 %type <declaration_> LexicalBinding
501 %type <for_> LexicalDeclaration_
502 %type <statement_> LexicalDeclaration
503 %type <literal_> Literal
504 %type <propertyName_> LiteralPropertyName
505 %type <expression_> LogicalANDExpression
506 %type <expression_> LogicalORExpression
507 %type <access_> MemberAccess
508 %type <target_> MemberExpression
509 %type <method_> MethodDefinition
510 %type <module_> ModulePath
511 %type <expression_> MultiplicativeExpression
512 %type <target_> NewExpression
513 %type <null_> NullLiteral
514 %type <literal_> ObjectLiteral
515 %type <expression_> PostfixExpression
516 %type <target_> PrimaryExpression
517 %type <propertyName_> PropertyName
518 %type <property_> PropertyDefinition
519 %type <property_> PropertyDefinitionList_
520 %type <property_> PropertyDefinitionList
521 %type <property_> PropertyDefinitionListOpt
522 %type <declaration_> PropertySetParameterList
523 %type <expression_> RelationalExpression
524 %type <statement_> ReturnStatement
525 %type <rubyProc_> RubyProcExpression
526 %type <functionParameter_> RubyProcParameterList_
527 %type <functionParameter_> RubyProcParameterList
528 %type <functionParameter_> RubyProcParameters
529 %type <functionParameter_> RubyProcParametersOpt
530 %type <statement_> Script
531 %type <statement_> ScriptBody
532 %type <statement_> ScriptBodyOpt
533 %type <expression_> ShiftExpression
534 %type <declaration_> SingleNameBinding
535 %type <statement_> Statement__
536 %type <statement_> Statement_
537 %type <statement_> Statement
538 %type <statement_> StatementList
539 %type <statement_> StatementListOpt
540 %type <statement_> StatementListItem
541 %type <functionParameter_> StrictFormalParameters
542 %type <target_> SuperCall
543 %type <target_> SuperProperty
544 %type <statement_> SwitchStatement
545 %type <target_> TemplateLiteral
546 %type <span_> TemplateSpans
547 %type <statement_> ThrowStatement
548 %type <statement_> TryStatement
549 %type <expression_> UnaryExpression_
550 %type <expression_> UnaryExpression
551 %type <declaration_> VariableDeclaration
552 %type <declarations_> VariableDeclarationList_
553 %type <declarations_> VariableDeclarationList
554 %type <for_> VariableStatement_
555 %type <statement_> VariableStatement
556 %type <statement_> WithStatement
559 %type <word_> WordOpt
561 %type <expression_> YieldExpression
564 %type <specifier_> IntegerType
565 %type <specifier_> IntegerTypeOpt
566 %type <typedIdentifier_> PrefixedType
567 %type <specifier_> PrimitiveType
568 %type <typedIdentifier_> SuffixedType
569 %type <typedIdentifier_> TypeSignifier
570 %type <modifier_> TypeQualifierLeft
571 %type <typedIdentifier_> TypeQualifierRight
572 %type <typedIdentifier_> TypedIdentifier
573 %type <typedParameter_> TypedParameterList_
574 %type <typedParameter_> TypedParameterList
575 %type <typedParameter_> TypedParameterListOpt
579 %type <expression_> BoxableExpression
580 %type <statement_> CategoryStatement
581 %type <expression_> ClassSuperOpt
582 %type <implementationField_> ImplementationFieldListOpt
583 %type <implementationField_> ImplementationFields
584 %type <message_> ClassMessageDeclaration
585 %type <message_> ClassMessageDeclarationListOpt
586 %type <protocol_> ClassProtocolListOpt
587 %type <protocol_> ClassProtocols
588 %type <protocol_> ClassProtocolsOpt
589 %type <statement_> ImplementationStatement
590 %type <target_> MessageExpression
591 %type <messageParameter_> MessageParameter
592 %type <messageParameter_> MessageParameters
593 %type <messageParameter_> MessageParameterList
594 %type <messageParameter_> MessageParameterListOpt
595 %type <bool_> MessageScope
596 %type <argument_> SelectorCall_
597 %type <argument_> SelectorCall
598 %type <selector_> SelectorExpression_
599 %type <selector_> SelectorExpression
600 %type <selector_> SelectorExpressionOpt
601 %type <argument_> SelectorList
602 %type <word_> SelectorWordOpt
603 %type <typedIdentifier_> TypeOpt
604 %type <argument_> VariadicCall
608 %type <propertyIdentifier_> PropertyIdentifier_
609 %type <selector_> PropertySelector_
610 %type <selector_> PropertySelector
611 %type <identifier_> QualifiedIdentifier_
612 %type <identifier_> QualifiedIdentifier
613 %type <identifier_> WildcardIdentifier
614 %type <identifier_> XMLComment
615 %type <identifier_> XMLCDATA
616 %type <identifier_> XMLElement
617 %type <identifier_> XMLElementContent
618 %type <identifier_> XMLMarkup
619 %type <identifier_> XMLPI
621 %type <attribute_> AttributeIdentifier
622 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
623 %type <expression_> PropertyIdentifier
624 %type <expression_> XMLListInitialiser
625 %type <expression_> XMLInitialiser
628 /* Token Priorities {{{ */
647 /* Lexer State {{{ */
648 LexPushInOn: { driver.in_.push(true); };
649 LexPushInOff: { driver.in_.push(false); };
650 LexPopIn: { driver.in_.pop(); };
652 LexPushReturnOn: { driver.return_.push(true); };
653 LexPopReturn: { driver.return_.pop(); };
655 LexPushSuperOn: { driver.super_.push(true); };
656 LexPushSuperOff: { driver.super_.push(false); };
657 LexPopSuper: { driver.super_.pop(); };
659 LexPushYieldOn: { driver.yield_.push(true); };
660 LexPushYieldOff: { driver.yield_.push(false); };
661 LexPopYield: { driver.yield_.pop(); };
664 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
668 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
672 : { CYMAP(YieldStar, Star); }
676 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
680 : { CYMAP(_class__, _class_); }
684 : { CYMAP(_function__, _function_); }
688 : LexNoBrace LexNoClass LexNoFunction
691 /* Virtual Tokens {{{ */
702 /* 11.6 Names and Keywords {{{ */
705 | "for" { $$ = CYNew CYWord("for"); }
706 | "in" { $$ = CYNew CYWord("in"); }
707 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
708 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
717 : Identifier { $$ = $1; }
718 | "auto" { $$ = CYNew CYWord("auto"); }
719 | "break" { $$ = CYNew CYWord("break"); }
720 | "case" { $$ = CYNew CYWord("case"); }
721 | "catch" { $$ = CYNew CYWord("catch"); }
722 | "class" { $$ = CYNew CYWord("class"); }
723 | ";class" { $$ = CYNew CYWord("class"); }
724 | "const" { $$ = CYNew CYWord("const"); }
725 | "continue" { $$ = CYNew CYWord("continue"); }
726 | "debugger" { $$ = CYNew CYWord("debugger"); }
727 | "default" { $$ = CYNew CYWord("default"); }
728 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
729 | "do" { $$ = CYNew CYWord("do"); }
730 | "else" { $$ = CYNew CYWord("else"); }
731 | "enum" { $$ = CYNew CYWord("enum"); }
732 | "export" { $$ = CYNew CYWord("export"); }
733 | "extends" { $$ = CYNew CYWord("extends"); }
734 | "false" { $$ = CYNew CYWord("false"); }
735 | "finally" { $$ = CYNew CYWord("finally"); }
736 | "function" { $$ = CYNew CYWord("function"); }
737 | "if" { $$ = CYNew CYWord("if"); }
738 | "import" { $$ = CYNew CYWord("import"); }
739 | "!in" { $$ = CYNew CYWord("in"); }
740 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
741 | "null" { $$ = CYNew CYWord("null"); }
742 | "return" { $$ = CYNew CYWord("return"); }
743 | "!return" { $$ = CYNew CYWord("return"); }
744 | "super" { $$ = CYNew CYWord("super"); }
745 | "!super" { $$ = CYNew CYWord("super"); }
746 | "switch" { $$ = CYNew CYWord("switch"); }
747 | "this" { $$ = CYNew CYWord("this"); }
748 | "throw" { $$ = CYNew CYWord("throw"); }
749 | "true" { $$ = CYNew CYWord("true"); }
750 | "try" { $$ = CYNew CYWord("try"); }
751 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
752 | "var" { $$ = CYNew CYWord("var"); }
753 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
754 | "while" { $$ = CYNew CYWord("while"); }
755 | "with" { $$ = CYNew CYWord("with"); }
756 | "yield" { $$ = CYNew CYIdentifier("yield"); }
758 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
760 // XXX: should be Identifier
761 | "let" { $$ = CYNew CYIdentifier("let"); }
771 /* 11.8.1 Null Literals {{{ */
773 : "null" { $$ = CYNew CYNull(); }
776 /* 11.8.2 Boolean Literals {{{ */
778 : "true" { $$ = CYNew CYTrue(); }
779 | "false" { $$ = CYNew CYFalse(); }
783 /* 11.9 Automatic Semicolon Insertion {{{ */
785 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
795 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) { CYERR(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
800 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
804 /* 12.1 Identifiers {{{ */
806 : Identifier { $$ = CYNew CYVariable($1); }
807 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
811 : Identifier { $$ = $1; }
812 | "yield" { $$ = CYNew CYIdentifier("yield"); }
816 : BindingIdentifier { $$ = $1; }
821 : Identifier { $$ = $1; }
822 | "yield" { $$ = CYNew CYIdentifier("yield"); }
826 : Identifier_ { $$ = $1; }
827 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
828 | "await" { $$ = CYNew CYIdentifier("await"); }
829 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
830 | "byte" { $$ = CYNew CYIdentifier("byte"); }
831 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
832 | "double" { $$ = CYNew CYIdentifier("double"); }
833 | "each" { $$ = CYNew CYIdentifier("each"); }
834 | "eval" { $$ = CYNew CYIdentifier("eval"); }
835 | "final" { $$ = CYNew CYIdentifier("final"); }
836 | "float" { $$ = CYNew CYIdentifier("float"); }
837 | "from" { $$ = CYNew CYIdentifier("from"); }
838 | "get" { $$ = CYNew CYIdentifier("get"); }
839 | "goto" { $$ = CYNew CYIdentifier("goto"); }
840 | "implements" { $$ = CYNew CYIdentifier("implements"); }
841 | "interface" { $$ = CYNew CYIdentifier("interface"); }
842 | "native" { $$ = CYNew CYIdentifier("native"); }
843 | "of" { $$ = CYNew CYIdentifier("of"); }
844 | "package" { $$ = CYNew CYIdentifier("package"); }
845 | "private" { $$ = CYNew CYIdentifier("private"); }
846 | "protected" { $$ = CYNew CYIdentifier("protected"); }
847 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
848 | "public" { $$ = CYNew CYIdentifier("public"); }
849 | "set" { $$ = CYNew CYIdentifier("set"); }
850 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
851 | "throws" { $$ = CYNew CYIdentifier("throws"); }
852 | "transient" { $$ = CYNew CYIdentifier("transient"); }
853 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
855 | "bool" { $$ = CYNew CYIdentifier("bool"); }
856 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
857 | "id" { $$ = CYNew CYIdentifier("id"); }
858 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
864 | "char" { $$ = CYNew CYIdentifier("char"); }
865 | "int" { $$ = CYNew CYIdentifier("int"); }
866 | "long" { $$ = CYNew CYIdentifier("long"); }
867 | "short" { $$ = CYNew CYIdentifier("short"); }
868 | "static" { $$ = CYNew CYIdentifier("static"); }
869 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
871 | "extern" { $$ = CYNew CYIdentifier("extern"); }
872 | "signed" { $$ = CYNew CYIdentifier("signed"); }
873 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
874 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
877 | "nil" { $$ = CYNew CYIdentifier("nil"); }
878 | "NO" { $$ = CYNew CYIdentifier("NO"); }
879 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
880 | "YES" { $$ = CYNew CYIdentifier("YES"); }
884 /* 12.2 Primary Expression {{{ */
886 : "this" { $$ = CYNew CYThis(); }
887 | IdentifierReference { $$ = $1; }
888 | Literal { $$ = $1; }
889 | ArrayLiteral { $$ = $1; }
890 | ObjectLiteral { $$ = $1; }
891 | FunctionExpression { $$ = $1; }
892 | ClassExpression { $$ = $1; }
893 | GeneratorExpression { $$ = $1; }
894 | RegularExpressionLiteral { $$ = $1; }
895 | TemplateLiteral { $$ = $1; }
896 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
897 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
900 CoverParenthesizedExpressionAndArrowParameterList
901 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
902 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
903 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
904 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
907 /* 12.2.4 Literals {{{ */
909 : NullLiteral { $$ = $1; }
910 | BooleanLiteral { $$ = $1; }
911 | NumericLiteral { $$ = $1; }
912 | "Infinity" { $$ = CYNew CYNumber(std::numeric_limits<double>::infinity()); }
913 | StringLiteral { $$ = $1; }
916 /* 12.2.5 Array Initializer {{{ */
918 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
922 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
923 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
924 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
928 : ElementList { $$ = $1; }
929 | LexSetRegExp { $$ = NULL; }
932 /* 12.2.6 Object Initializer {{{ */
934 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
937 PropertyDefinitionList_
938 : "," PropertyDefinitionListOpt { $$ = $2; }
942 PropertyDefinitionList
943 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
946 PropertyDefinitionListOpt
947 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
948 | LexSetRegExp { $$ = NULL; }
952 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
953 | CoverInitializedName { CYNOT(@$); }
954 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
955 | MethodDefinition { $$ = $1; }
959 : LiteralPropertyName { $$ = $1; }
960 | ComputedPropertyName { $$ = $1; }
964 : IdentifierName { $$ = $1; }
965 | StringLiteral { $$ = $1; }
966 | NumericLiteral { $$ = $1; }
970 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
974 : IdentifierReference Initializer
978 : "=" AssignmentExpression { $$ = $2; }
982 : Initializer { $$ = $1; }
986 /* 12.2.9 Template Literals {{{ */
988 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
989 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
993 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
994 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
998 /* 12.3 Left-Hand-Side Expressions {{{ */
1000 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
1001 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
1002 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1003 | TemplateLiteral { CYNOT(@$); }
1007 : LexSetRegExp PrimaryExpression { $$ = $2; }
1008 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1009 | SuperProperty { $$ = $1; }
1010 | MetaProperty { CYNOT(@$); }
1011 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1015 : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
1016 | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
1024 : LexSetRegExp "new" LexSetRegExp "." "target"
1028 : MemberExpression { $$ = $1; }
1029 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1033 : MemberExpression { $$ = $1; }
1034 | CallExpression { $$ = $1; }
1038 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1039 | SuperCall { $$ = $1; }
1040 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1044 : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
1048 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1052 : "," ArgumentList { $$ = $2; }
1057 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1058 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1062 : ArgumentList { $$ = $1; }
1063 | LexSetRegExp { $$ = NULL; }
1066 LeftHandSideExpression
1067 : NewExpression { $$ = $1; }
1068 | CallExpression { $$ = $1; }
1071 /* 12.4 Postfix Expressions {{{ */
1073 : %prec "" LeftHandSideExpression { $$ = $1; }
1074 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1075 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1078 /* 12.5 Unary Operators {{{ */
1080 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1081 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1082 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1083 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1084 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1085 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1086 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1087 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1088 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1089 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1090 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1094 : %prec "" PostfixExpression { $$ = $1; }
1095 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1098 /* 12.6 Multiplicative Operators {{{ */
1099 MultiplicativeExpression
1100 : UnaryExpression { $$ = $1; }
1101 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1102 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1103 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1106 /* 12.7 Additive Operators {{{ */
1108 : MultiplicativeExpression { $$ = $1; }
1109 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1110 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1113 /* 12.8 Bitwise Shift Operators {{{ */
1115 : AdditiveExpression { $$ = $1; }
1116 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1117 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1118 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1121 /* 12.9 Relational Operators {{{ */
1122 RelationalExpression
1123 : ShiftExpression { $$ = $1; }
1124 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1125 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1126 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1127 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1128 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1129 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1132 /* 12.10 Equality Operators {{{ */
1134 : RelationalExpression { $$ = $1; }
1135 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1136 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1137 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1138 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1141 /* 12.11 Binary Bitwise Operators {{{ */
1142 BitwiseANDExpression
1143 : EqualityExpression { $$ = $1; }
1144 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1147 BitwiseXORExpression
1148 : BitwiseANDExpression { $$ = $1; }
1149 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1153 : BitwiseXORExpression { $$ = $1; }
1154 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1157 /* 12.12 Binary Logical Operators {{{ */
1158 LogicalANDExpression
1159 : BitwiseORExpression { $$ = $1; }
1160 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1164 : LogicalANDExpression { $$ = $1; }
1165 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1168 /* 12.13 Conditional Operator ( ? : ) {{{ */
1169 ConditionalExpression
1170 : LogicalORExpression { $$ = $1; }
1171 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1174 /* 12.14 Assignment Operators {{{ */
1175 AssignmentExpression
1176 : ConditionalExpression { $$ = $1; }
1177 | LexSetRegExp YieldExpression { $$ = $2; }
1178 | ArrowFunction { $$ = $1; }
1179 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1180 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1181 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1182 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1183 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1184 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1185 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1186 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1187 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1188 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1189 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1190 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1193 AssignmentExpressionOpt
1194 : AssignmentExpression { $$ = $1; }
1195 | LexSetRegExp { $$ = NULL; }
1198 /* 12.15 Comma Operator ( , ) {{{ */
1200 : AssignmentExpression { $$ = $1; }
1201 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1205 : Expression { $$ = $1; }
1206 | LexSetRegExp { $$ = NULL; }
1210 /* 13 Statements and Declarations {{{ */
1212 : BlockStatement { $$ = $1; }
1213 | VariableStatement { $$ = $1; }
1214 | EmptyStatement { $$ = $1; }
1215 | IfStatement { $$ = $1; }
1216 | BreakableStatement { $$ = $1; }
1217 | ContinueStatement { $$ = $1; }
1218 | BreakStatement { $$ = $1; }
1219 | ReturnStatement { $$ = $1; }
1220 | WithStatement { $$ = $1; }
1221 | LabelledStatement { $$ = $1; }
1222 | ThrowStatement { $$ = $1; }
1223 | TryStatement { $$ = $1; }
1224 | DebuggerStatement { $$ = $1; }
1228 : LexSetRegExp Statement__ { $$ = $2; }
1229 | ExpressionStatement { $$ = $1; }
1233 : LexSetStatement Statement_ { $$ = $2; }
1237 : HoistableDeclaration { $$ = $1; }
1238 | ClassDeclaration { $$ = $1; }
1239 | LexicalDeclaration { $$ = $1; }
1243 : LexSetRegExp Declaration__ { $$ = $2; }
1247 : LexSetStatement Declaration_ { $$ = $2; }
1250 HoistableDeclaration
1251 : FunctionDeclaration { $$ = $1; }
1252 | GeneratorDeclaration { $$ = $1; }
1256 : IterationStatement { $$ = $1; }
1257 | SwitchStatement { $$ = $1; }
1260 /* 13.2 Block {{{ */
1262 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1266 : BRACE StatementListOpt "}" { $$ = $2; }
1270 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1274 : StatementList { $$ = $1; }
1275 | LexSetStatement LexSetRegExp { $$ = NULL; }
1279 : Statement { $$ = $1; }
1280 | Declaration { $$ = $1; }
1283 /* 13.3 Let and Const Declarations {{{ */
1285 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1289 : LexicalDeclaration_ Terminator { $$ = $1; }
1293 : "let" { $$ = false; }
1294 | "const" { $$ = true; }
1298 : "," BindingList { $$ = $2; }
1303 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1307 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1308 | BindingPattern Initializer { CYNOT(@1); }
1311 /* 13.3.2 Variable Statement {{{ */
1313 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1317 : VariableStatement_ Terminator { $$ = $1; }
1320 VariableDeclarationList_
1321 : "," VariableDeclarationList { $$ = $2; }
1325 VariableDeclarationList
1326 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1330 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1331 | BindingPattern Initializer { CYNOT(@1); }
1334 /* 13.3.3 Destructuring Binding Patterns {{{ */
1336 : ObjectBindingPattern
1337 | ArrayBindingPattern
1340 ObjectBindingPattern
1341 : BRACE BindingPropertyListOpt "}"
1345 : "[" { CYNOT(@$); }
1348 BindingPropertyList_
1349 : "," BindingPropertyListOpt
1354 : BindingProperty BindingPropertyList_
1357 BindingPropertyListOpt
1358 : BindingPropertyList
1364 | PropertyName ":" BindingElement
1368 : SingleNameBinding { $$ = $1; }
1369 | BindingPattern InitializerOpt { CYNOT(@$); }
1373 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1377 : "..." BindingIdentifier
1380 /* 13.4 Empty Statement {{{ */
1382 : ";" { $$ = CYNew CYEmpty(); }
1385 /* 13.5 Expression Statement {{{ */
1386 ExpressionStatement_
1387 : Expression { $$ = CYNew CYExpress($1); }
1390 : ExpressionStatement_ Terminator { $$ = $1; }
1393 /* 13.6 The if Statement {{{ */
1395 : "else" Statement { $$ = $2; }
1396 | %prec "if" { $$ = NULL; }
1400 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1403 /* 13.7 Iteration Statements {{{ */
1405 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1406 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1407 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1408 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1409 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1410 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1413 ForStatementInitializer
1414 : LexSetRegExp EmptyStatement { $$ = $2; }
1415 | ExpressionStatement_ ";" { $$ = $1; }
1416 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1417 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1420 ForInStatementInitializer
1421 : LeftHandSideExpression { $$ = $1; }
1422 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1423 | LexSetRegExp ForDeclaration { $$ = $2; }
1427 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1431 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1432 | BindingPattern { CYNOT(@1); }
1435 /* 13.8 The continue Statement {{{ */
1437 : "continue" LexNewLine
1441 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1442 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1445 /* 13.9 The break Statement {{{ */
1447 : "break" LexNewLine
1451 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1452 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1455 /* 13.10 The return Statement {{{ */
1457 : "!return" LexNewLine
1461 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1462 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1465 /* 13.11 The with Statement {{{ */
1467 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1470 /* 13.12 The switch Statement {{{ */
1472 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1476 : BRACE CaseClausesOpt "}" { $$ = $2; }
1480 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1484 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1485 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1489 // XXX: the standard makes certain you can only have one of these
1491 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1494 /* 13.13 Labelled Statements {{{ */
1496 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1500 : Statement { $$ = $1; }
1501 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1504 /* 13.14 The throw Statement {{{ */
1506 : "throw" LexNewLine
1510 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1511 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1514 /* 13.15 The try Statement {{{ */
1516 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1517 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1518 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1522 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1526 : "finally" Block { $$ = CYNew CYFinally($2); }
1530 : BindingIdentifier { $$ = $1; }
1531 | BindingPattern { CYNOT(@$); }
1534 /* 13.16 The debugger Statement {{{ */
1536 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1540 /* 14.1 Function Definitions {{{ */
1542 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1546 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1549 StrictFormalParameters
1550 : FormalParameters { $$ = $1; }
1555 | FormalParameterList
1558 FormalParameterList_
1559 : "," FormalParameterList { $$ = $2; }
1564 : FunctionRestParameter { CYNOT(@$); }
1565 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1568 FunctionRestParameter
1569 : BindingRestElement
1573 : BindingElement { $$ = $1; }
1577 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1580 FunctionStatementList
1581 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1584 /* 14.2 Arrow Function Definitions {{{ */
1586 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1590 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1591 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1595 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1596 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1599 /* 14.3 Method Definitions {{{ */
1601 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1602 | GeneratorMethod { $$ = $1; }
1603 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1604 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1607 PropertySetParameterList
1608 : FormalParameter { $$ = $1; }
1611 /* 14.4 Generator Function Definitions {{{ */
1613 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1616 GeneratorDeclaration
1617 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1621 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1625 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1629 : "!yield" LexNewLine LexNoStar
1633 : Yield LexSetRegExp "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1634 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1635 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1638 /* 14.5 Class Definitions {{{ */
1640 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1644 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1648 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1652 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1656 : ClassHeritage { $$ = $1; }
1657 | { $$ = CYNew CYClassTail(NULL); }
1670 : ClassElementListOpt ClassElement
1679 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1680 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1685 /* 15.1 Scripts {{{ */
1687 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1691 : StatementList { $$ = $1; }
1695 : ScriptBody { $$ = $1; }
1696 | LexSetStatement LexSetRegExp { $$ = NULL; }
1699 /* 15.2 Modules {{{ */
1714 : ModuleItemListOpt ModuleItem
1723 : LexSetStatement LexSetRegExp ImportDeclaration
1724 | LexSetStatement LexSetRegExp ExportDeclaration
1728 /* 15.2.2 Imports {{{ */
1730 : "import" ImportClause FromClause Terminator
1731 | "import" ModuleSpecifier Terminator
1735 : ImportedDefaultBinding
1738 | ImportedDefaultBinding "," NameSpaceImport
1739 | ImportedDefaultBinding "," NamedImports
1742 ImportedDefaultBinding
1747 : "*" "as" ImportedBinding
1751 : BRACE ImportsListOpt "}"
1755 : "from" ModuleSpecifier
1759 : "," ImportsListOpt
1764 : ImportSpecifier ImportsList_
1774 | IdentifierName "as" ImportedBinding
1785 /* 15.2.3 Exports {{{ */
1787 : "*" FromClause Terminator
1788 | ExportClause FromClause Terminator
1789 | ExportClause Terminator
1791 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1792 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1793 | "default" LexSetStatement AssignmentExpression Terminator
1797 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1798 | "export" Declaration
1802 : ";{" ExportsListOpt "}"
1806 : "," ExportsListOpt
1811 : ExportSpecifier ExportsList_
1821 | IdentifierName "as" IdentifierName
1826 /* Cycript (C): Type Encoding {{{ */
1828 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1829 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1833 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1834 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1835 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1836 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1837 | TypeSignifier { $$ = $1; }
1838 | { $$ = CYNew CYTypedIdentifier(@$); }
1842 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1847 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1848 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1852 : PrefixedType { $$ = $1; }
1853 | SuffixedType { $$ = $1; }
1854 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1855 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1859 : "int" { $$ = CYNew CYTypeVariable("int"); }
1860 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1861 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1862 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1863 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1867 : IntegerType { $$ = $1; }
1868 | { $$ = CYNew CYTypeVariable("int"); }
1872 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1873 | IntegerType { $$ = $1; }
1874 | "void" { $$ = CYNew CYTypeVoid(); }
1875 | "char" { $$ = CYNew CYTypeVariable("char"); }
1876 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1877 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1881 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1885 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1891 /* Cycript (Objective-C): @class Declaration {{{ */
1893 /* XXX: why the hell did I choose MemberExpression? */
1894 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1898 ImplementationFieldListOpt
1899 : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
1900 | LexSetRegExp { $$ = NULL; }
1903 ImplementationFields
1904 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1908 : "+" { $$ = false; }
1909 | "-" { $$ = true; }
1913 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1914 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1918 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1921 MessageParameterList
1922 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1925 MessageParameterListOpt
1926 : MessageParameterList { $$ = $1; }
1931 : MessageParameterList { $$ = $1; }
1932 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
1935 ClassMessageDeclaration
1936 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
1939 ClassMessageDeclarationListOpt
1940 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1944 // XXX: this should be AssignmentExpressionNoRight
1946 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1950 : "," ClassProtocols { $$ = $2; }
1954 ClassProtocolListOpt
1955 : "<" ClassProtocols ">" { $$ = $2; }
1959 ImplementationStatement
1960 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
1968 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1972 : ImplementationStatement { $$ = $1; }
1973 | CategoryStatement { $$ = $1; }
1976 /* Cycript (Objective-C): Send Message {{{ */
1978 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1983 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1984 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1988 : SelectorCall { $$ = $1; }
1989 | VariadicCall { $$ = $1; }
1993 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
1997 : SelectorCall { $$ = $1; }
1998 | Word { $$ = CYNew CYArgument($1, NULL); }
2002 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2003 | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2007 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2011 : SelectorExpression_ { $$ = $1; }
2012 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2015 SelectorExpressionOpt
2016 : SelectorExpression_ { $$ = $1; }
2021 : MessageExpression { $$ = $1; }
2022 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2027 /* Cycript: @import Directive {{{ */
2029 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2030 | Word { $$ = CYNew CYModule($1); }
2034 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2039 /* Cycript (Objective-C): Boxed Expressions {{{ */
2041 : NullLiteral { $$ = $1; }
2042 | BooleanLiteral { $$ = $1; }
2043 | NumericLiteral { $$ = $1; }
2044 | StringLiteral { $$ = $1; }
2045 | ArrayLiteral { $$ = $1; }
2046 | ObjectLiteral { $$ = $1; }
2047 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2048 | "YES" { $$ = CYNew CYTrue(); }
2049 | "NO" { $$ = CYNew CYFalse(); }
2053 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2054 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2055 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2056 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2057 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2058 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2061 /* Cycript (Objective-C): Block Expressions {{{ */
2063 : "^" 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"); }
2066 /* Cycript (Objective-C): Instance Literals {{{ */
2068 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2074 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2075 LeftHandSideExpression
2076 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2080 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2084 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2085 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2086 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2089 /* Cycript (C): auto Compatibility {{{ */
2094 /* Cycript (C): Lambda Expressions {{{ */
2096 : "," TypedParameterList { $$ = $2; }
2101 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2104 TypedParameterListOpt
2105 : TypedParameterList { $$ = $1; }
2110 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2113 /* Cycript (C): Type Definitions {{{ */
2115 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2118 /* Cycript (C): extern "C" {{{ */
2120 : "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); }
2127 /* Lexer State {{{ */
2129 : { driver.PushCondition(CYDriver::RegExpCondition); }
2133 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2137 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2141 : { driver.PopCondition(); }
2145 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2149 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2152 /* Virtual Tokens {{{ */
2159 /* 8.1 Context Keywords {{{ */
2161 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2162 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2165 /* 8.3 XML Initializer Input Elements {{{ */
2167 : XMLComment { $$ = $1; }
2168 | XMLCDATA { $$ = $1; }
2169 | XMLPI { $$ = $1; }
2173 /* 11.1 Primary Expressions {{{ */
2175 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2176 | XMLInitialiser { $$ = $1; }
2177 | XMLListInitialiser { $$ = $1; }
2181 : AttributeIdentifier { $$ = $1; }
2182 | QualifiedIdentifier { $$ = $1; }
2183 | WildcardIdentifier { $$ = $1; }
2186 /* 11.1.1 Attribute Identifiers {{{ */
2188 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2192 : PropertySelector { $$ = $1; }
2193 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2197 : Identifier { $$ = CYNew CYSelector($1); }
2198 | WildcardIdentifier { $$ = $1; }
2201 /* 11.1.2 Qualified Identifiers {{{ */
2202 QualifiedIdentifier_
2203 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2204 | QualifiedIdentifier { $$ = $1; }
2208 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2211 /* 11.1.3 Wildcard Identifiers {{{ */
2213 : "*" { $$ = CYNew CYWildcard(); }
2216 /* 11.1.4 XML Initializer {{{ */
2218 : XMLMarkup { $$ = $1; }
2219 | XMLElement { $$ = $1; }
2223 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2224 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2228 : LexPushXMLTag XMLTagName XMLAttributes
2232 : BRACE LexPushRegExp Expression LexPop "}"
2241 : XMLAttributes_ XMLAttribute
2246 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2247 | XMLAttributes_ XMLWhitespaceOpt
2256 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2260 : XMLExpression XMLElementContentOpt
2261 | XMLMarkup XMLElementContentOpt
2262 | XMLText XMLElementContentOpt
2263 | XMLElement XMLElementContentOpt
2266 XMLElementContentOpt
2271 /* 11.1.5 XMLList Initializer {{{ */
2273 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2277 /* 11.2 Left-Hand-Side Expressions {{{ */
2279 : Identifier { $$ = $1; }
2280 | PropertyIdentifier { $$ = $1; }
2284 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2285 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2286 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2289 /* 12.1 The default xml namespace Statement {{{ */
2290 /* XXX: DefaultXMLNamespaceStatement
2291 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2295 : DefaultXMLNamespaceStatement { $$ = $1; }
2300 /* JavaScript FTL: Array Comprehensions {{{ */
2302 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2306 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2309 /* JavaScript FTL: for each {{{ */
2311 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2315 /* JavaScript FTW: Array Comprehensions {{{ */
2317 : ArrayComprehension
2321 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2325 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2330 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2331 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2335 : "for" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2336 | "for" "(" LexPushInOn LexicalBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2340 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2343 /* JavaScript FTW: Coalesce Operator {{{ */
2344 ConditionalExpression
2345 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2348 /* JavaScript FTW: Named Arguments {{{ */
2350 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2353 /* JavaScript FTW: Ruby Blocks {{{ */
2354 RubyProcParameterList_
2355 : "," RubyProcParameterList { $$ = $2; }
2359 RubyProcParameterList
2360 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2365 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2366 | LexSetRegExp "||" { $$ = NULL; }
2369 RubyProcParametersOpt
2370 : RubyProcParameters { $$ = $1; }
2375 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2379 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2383 : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2389 bool CYDriver::Parse(CYMark mark) {
2391 CYLocal<CYPool> local(&pool_);
2392 cy::parser parser(*this);
2394 parser.set_debug_level(debug_);
2396 return parser.parse() != 0;
2399 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2403 CYDriver::Error error;
2404 error.warning_ = true;
2405 error.location_ = location;
2406 error.message_ = message;
2407 errors_.push_back(error);
2410 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2411 CYDriver::Error error;
2412 error.warning_ = false;
2413 error.location_ = location;
2414 error.message_ = message;
2415 driver.errors_.push_back(error);