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 _instanceof_ "instanceof"
328 %token _return_ "return"
329 %token _return__ "!return"
330 %token _super_ "super"
331 %token _super__ "!super"
332 %token _switch_ "switch"
334 %token _throw_ "throw"
336 %token _typeof_ "typeof"
339 %token _while_ "while"
342 %token _abstract_ "abstract"
343 %token _await_ "await"
344 %token _boolean_ "boolean"
347 %token _constructor_ "constructor"
348 %token _double_ "double"
350 %token _final_ "final"
351 %token _float_ "float"
355 %token _implements_ "implements"
357 %token _interface_ "interface"
360 %token _native_ "native"
361 %token _package_ "package"
362 %token _private_ "private"
363 %token _protected_ "protected"
364 %token _prototype_ "prototype"
365 %token _public_ "public"
367 %token _short_ "short"
368 %token _static_ "static"
369 %token _synchronized_ "synchronized"
370 %token _throws_ "throws"
371 %token _transient_ "transient"
372 %token _volatile_ "volatile"
373 %token _yield_ "yield"
374 %token _yield__ "!yield"
376 %token _undefined_ "undefined"
392 %token _namespace_ "namespace"
399 %token <identifier_> Identifier_
400 %token <number_> NumericLiteral
401 %token <string_> StringLiteral
402 %token <literal_> RegularExpressionLiteral
404 %token <string_> NoSubstitutionTemplate
405 %token <string_> TemplateHead
406 %token <string_> TemplateMiddle
407 %token <string_> TemplateTail
409 %type <expression_> AdditiveExpression
410 %type <argument_> ArgumentList_
411 %type <argument_> ArgumentList
412 %type <argument_> ArgumentListOpt
413 %type <argument_> Arguments
414 %type <target_> ArrayComprehension
415 %type <literal_> ArrayLiteral
416 %type <expression_> ArrowFunction
417 %type <functionParameter_> ArrowParameters
418 %type <expression_> AssignmentExpression
419 %type <expression_> AssignmentExpressionOpt
420 %type <identifier_> BindingIdentifier
421 %type <identifier_> BindingIdentifierOpt
422 %type <declarations_> BindingList_
423 %type <declarations_> BindingList
424 %type <expression_> BitwiseANDExpression
425 %type <statement_> Block
426 %type <statement_> BlockStatement
427 %type <boolean_> BooleanLiteral
428 %type <declaration_> BindingElement
429 %type <expression_> BitwiseORExpression
430 %type <expression_> BitwiseXORExpression
431 %type <statement_> BreakStatement
432 %type <statement_> BreakableStatement
433 %type <expression_> CallExpression_
434 %type <target_> CallExpression
435 %type <clause_> CaseBlock
436 %type <clause_> CaseClause
437 %type <clause_> CaseClausesOpt
439 %type <identifier_> CatchParameter
440 %type <statement_> ClassDeclaration
441 %type <target_> ClassExpression
442 %type <classTail_> ClassHeritage
443 %type <classTail_> ClassHeritageOpt
444 %type <classTail_> ClassTail
445 %type <target_> Comprehension
446 %type <comprehension_> ComprehensionFor
447 %type <comprehension_> ComprehensionIf
448 %type <comprehension_> ComprehensionTail
449 %type <propertyName_> ComputedPropertyName
450 %type <expression_> ConditionalExpression
451 %type <statement_> ContinueStatement
452 %type <statement_> ConciseBody
453 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
454 %type <statement_> DebuggerStatement
455 %type <statement_> Declaration__
456 %type <statement_> Declaration_
457 %type <statement_> Declaration
458 %type <clause_> DefaultClause
459 %type <element_> ElementList
460 %type <element_> ElementListOpt
461 %type <statement_> ElseStatementOpt
462 %type <for_> EmptyStatement
463 %type <expression_> EqualityExpression
464 %type <expression_> Expression
465 %type <expression_> ExpressionOpt
466 %type <for_> ExpressionStatement_
467 %type <statement_> ExpressionStatement
468 %type <finally_> Finally
469 %type <declaration_> ForBinding
470 %type <forin_> ForDeclaration
471 %type <forin_> ForInStatementInitializer
472 %type <for_> ForStatementInitializer
473 %type <declaration_> FormalParameter
474 %type <functionParameter_> FormalParameterList_
475 %type <functionParameter_> FormalParameterList
476 %type <functionParameter_> FormalParameters
477 %type <statement_> FunctionBody
478 %type <statement_> FunctionDeclaration
479 %type <target_> FunctionExpression
480 %type <statement_> FunctionStatementList
481 %type <statement_> GeneratorBody
482 %type <statement_> GeneratorDeclaration
483 %type <target_> GeneratorExpression
484 %type <method_> GeneratorMethod
485 %type <statement_> HoistableDeclaration
486 %type <identifier_> Identifier
487 %type <identifier_> IdentifierType
488 %type <word_> IdentifierName
489 %type <variable_> IdentifierReference
490 %type <statement_> IfStatement
491 %type <expression_> Initializer
492 %type <expression_> InitializerOpt
493 %type <statement_> IterationStatement
494 %type <identifier_> LabelIdentifier
495 %type <statement_> LabelledItem
496 %type <statement_> LabelledStatement
497 %type <target_> LeftHandSideExpression
498 %type <bool_> LetOrConst
499 %type <declaration_> LexicalBinding
500 %type <for_> LexicalDeclaration_
501 %type <statement_> LexicalDeclaration
502 %type <literal_> Literal
503 %type <propertyName_> LiteralPropertyName
504 %type <expression_> LogicalANDExpression
505 %type <expression_> LogicalORExpression
506 %type <access_> MemberAccess
507 %type <target_> MemberExpression
508 %type <method_> MethodDefinition
509 %type <module_> ModulePath
510 %type <expression_> MultiplicativeExpression
511 %type <target_> NewExpression
512 %type <null_> NullLiteral
513 %type <literal_> ObjectLiteral
514 %type <expression_> PostfixExpression
515 %type <target_> PrimaryExpression
516 %type <propertyName_> PropertyName
517 %type <property_> PropertyDefinition
518 %type <property_> PropertyDefinitionList_
519 %type <property_> PropertyDefinitionList
520 %type <property_> PropertyDefinitionListOpt
521 %type <declaration_> PropertySetParameterList
522 %type <expression_> RelationalExpression
523 %type <statement_> ReturnStatement
524 %type <rubyProc_> RubyProcExpression
525 %type <functionParameter_> RubyProcParameterList_
526 %type <functionParameter_> RubyProcParameterList
527 %type <functionParameter_> RubyProcParameters
528 %type <functionParameter_> RubyProcParametersOpt
529 %type <statement_> Script
530 %type <statement_> ScriptBody
531 %type <statement_> ScriptBodyOpt
532 %type <expression_> ShiftExpression
533 %type <declaration_> SingleNameBinding
534 %type <statement_> Statement__
535 %type <statement_> Statement_
536 %type <statement_> Statement
537 %type <statement_> StatementList
538 %type <statement_> StatementListOpt
539 %type <statement_> StatementListItem
540 %type <functionParameter_> StrictFormalParameters
541 %type <target_> SuperCall
542 %type <target_> SuperProperty
543 %type <statement_> SwitchStatement
544 %type <target_> TemplateLiteral
545 %type <span_> TemplateSpans
546 %type <statement_> ThrowStatement
547 %type <statement_> TryStatement
548 %type <expression_> UnaryExpression_
549 %type <expression_> UnaryExpression
550 %type <declaration_> VariableDeclaration
551 %type <declarations_> VariableDeclarationList_
552 %type <declarations_> VariableDeclarationList
553 %type <for_> VariableStatement_
554 %type <statement_> VariableStatement
555 %type <statement_> WithStatement
558 %type <word_> WordOpt
560 %type <expression_> YieldExpression
563 %type <specifier_> IntegerType
564 %type <specifier_> IntegerTypeOpt
565 %type <typedIdentifier_> PrefixedType
566 %type <specifier_> PrimitiveType
567 %type <typedIdentifier_> SuffixedType
568 %type <typedIdentifier_> TypeSignifier
569 %type <modifier_> TypeQualifierLeft
570 %type <typedIdentifier_> TypeQualifierRight
571 %type <typedIdentifier_> TypedIdentifier
572 %type <typedParameter_> TypedParameterList_
573 %type <typedParameter_> TypedParameterList
574 %type <typedParameter_> TypedParameterListOpt
578 %type <expression_> BoxableExpression
579 %type <statement_> CategoryStatement
580 %type <expression_> ClassSuperOpt
581 %type <implementationField_> ImplementationFieldListOpt
582 %type <implementationField_> ImplementationFields
583 %type <message_> ClassMessageDeclaration
584 %type <message_> ClassMessageDeclarationListOpt
585 %type <protocol_> ClassProtocolListOpt
586 %type <protocol_> ClassProtocols
587 %type <protocol_> ClassProtocolsOpt
588 %type <statement_> ImplementationStatement
589 %type <target_> MessageExpression
590 %type <messageParameter_> MessageParameter
591 %type <messageParameter_> MessageParameters
592 %type <messageParameter_> MessageParameterList
593 %type <messageParameter_> MessageParameterListOpt
594 %type <bool_> MessageScope
595 %type <argument_> SelectorCall_
596 %type <argument_> SelectorCall
597 %type <selector_> SelectorExpression_
598 %type <selector_> SelectorExpression
599 %type <selector_> SelectorExpressionOpt
600 %type <argument_> SelectorList
601 %type <word_> SelectorWordOpt
602 %type <typedIdentifier_> TypeOpt
603 %type <argument_> VariadicCall
607 %type <propertyIdentifier_> PropertyIdentifier_
608 %type <selector_> PropertySelector_
609 %type <selector_> PropertySelector
610 %type <identifier_> QualifiedIdentifier_
611 %type <identifier_> QualifiedIdentifier
612 %type <identifier_> WildcardIdentifier
613 %type <identifier_> XMLComment
614 %type <identifier_> XMLCDATA
615 %type <identifier_> XMLElement
616 %type <identifier_> XMLElementContent
617 %type <identifier_> XMLMarkup
618 %type <identifier_> XMLPI
620 %type <attribute_> AttributeIdentifier
621 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
622 %type <expression_> PropertyIdentifier
623 %type <expression_> XMLListInitialiser
624 %type <expression_> XMLInitialiser
627 /* Token Priorities {{{ */
646 /* Lexer State {{{ */
647 LexPushInOn: { driver.in_.push(true); };
648 LexPushInOff: { driver.in_.push(false); };
649 LexPopIn: { driver.in_.pop(); };
651 LexPushReturnOn: { driver.return_.push(true); };
652 LexPopReturn: { driver.return_.pop(); };
654 LexPushSuperOn: { driver.super_.push(true); };
655 LexPushSuperOff: { driver.super_.push(false); };
656 LexPopSuper: { driver.super_.pop(); };
658 LexPushYieldOn: { driver.yield_.push(true); };
659 LexPushYieldOff: { driver.yield_.push(false); };
660 LexPopYield: { driver.yield_.pop(); };
663 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
667 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
671 : { CYMAP(YieldStar, Star); }
675 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
679 : { CYMAP(_class__, _class_); }
683 : { CYMAP(_function__, _function_); }
687 : LexNoBrace LexNoClass LexNoFunction
690 /* Virtual Tokens {{{ */
701 /* 11.6 Names and Keywords {{{ */
704 | "for" { $$ = CYNew CYWord("for"); }
705 | "in" { $$ = CYNew CYWord("in"); }
706 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
715 : Identifier { $$ = $1; }
716 | "auto" { $$ = CYNew CYWord("auto"); }
717 | "break" { $$ = CYNew CYWord("break"); }
718 | "case" { $$ = CYNew CYWord("case"); }
719 | "catch" { $$ = CYNew CYWord("catch"); }
720 | "class" { $$ = CYNew CYWord("class"); }
721 | ";class" { $$ = CYNew CYWord("class"); }
722 | "const" { $$ = CYNew CYWord("const"); }
723 | "continue" { $$ = CYNew CYWord("continue"); }
724 | "debugger" { $$ = CYNew CYWord("debugger"); }
725 | "default" { $$ = CYNew CYWord("default"); }
726 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
727 | "do" { $$ = CYNew CYWord("do"); }
728 | "else" { $$ = CYNew CYWord("else"); }
729 | "enum" { $$ = CYNew CYWord("enum"); }
730 | "export" { $$ = CYNew CYWord("export"); }
731 | "extends" { $$ = CYNew CYWord("extends"); }
732 | "false" { $$ = CYNew CYWord("false"); }
733 | "finally" { $$ = CYNew CYWord("finally"); }
734 | "function" { $$ = CYNew CYWord("function"); }
735 | "if" { $$ = CYNew CYWord("if"); }
736 | "import" { $$ = CYNew CYWord("import"); }
737 | "!in" { $$ = CYNew CYWord("in"); }
738 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
739 | "null" { $$ = CYNew CYWord("null"); }
740 | "return" { $$ = CYNew CYWord("return"); }
741 | "!return" { $$ = CYNew CYWord("return"); }
742 | "super" { $$ = CYNew CYWord("super"); }
743 | "!super" { $$ = CYNew CYWord("super"); }
744 | "switch" { $$ = CYNew CYWord("switch"); }
745 | "this" { $$ = CYNew CYWord("this"); }
746 | "throw" { $$ = CYNew CYWord("throw"); }
747 | "true" { $$ = CYNew CYWord("true"); }
748 | "try" { $$ = CYNew CYWord("try"); }
749 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
750 | "var" { $$ = CYNew CYWord("var"); }
751 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
752 | "while" { $$ = CYNew CYWord("while"); }
753 | "with" { $$ = CYNew CYWord("with"); }
754 | "yield" { $$ = CYNew CYIdentifier("yield"); }
756 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
758 // XXX: should be Identifier
759 | "let" { $$ = CYNew CYIdentifier("let"); }
769 /* 11.8.1 Null Literals {{{ */
771 : "null" { $$ = CYNew CYNull(); }
774 /* 11.8.2 Boolean Literals {{{ */
776 : "true" { $$ = CYNew CYTrue(); }
777 | "false" { $$ = CYNew CYFalse(); }
781 /* 11.9 Automatic Semicolon Insertion {{{ */
783 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
793 | 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
798 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
802 /* 12.1 Identifiers {{{ */
804 : Identifier { $$ = CYNew CYVariable($1); }
805 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
809 : Identifier { $$ = $1; }
810 | "yield" { $$ = CYNew CYIdentifier("yield"); }
814 : BindingIdentifier { $$ = $1; }
819 : Identifier { $$ = $1; }
820 | "yield" { $$ = CYNew CYIdentifier("yield"); }
824 : Identifier_ { $$ = $1; }
825 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
826 | "await" { $$ = CYNew CYIdentifier("await"); }
827 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
828 | "byte" { $$ = CYNew CYIdentifier("byte"); }
829 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
830 | "double" { $$ = CYNew CYIdentifier("double"); }
831 | "each" { $$ = CYNew CYIdentifier("each"); }
832 | "eval" { $$ = CYNew CYIdentifier("eval"); }
833 | "final" { $$ = CYNew CYIdentifier("final"); }
834 | "float" { $$ = CYNew CYIdentifier("float"); }
835 | "from" { $$ = CYNew CYIdentifier("from"); }
836 | "get" { $$ = CYNew CYIdentifier("get"); }
837 | "goto" { $$ = CYNew CYIdentifier("goto"); }
838 | "implements" { $$ = CYNew CYIdentifier("implements"); }
839 | "interface" { $$ = CYNew CYIdentifier("interface"); }
840 | "native" { $$ = CYNew CYIdentifier("native"); }
841 | "of" { $$ = CYNew CYIdentifier("of"); }
842 | "package" { $$ = CYNew CYIdentifier("package"); }
843 | "private" { $$ = CYNew CYIdentifier("private"); }
844 | "protected" { $$ = CYNew CYIdentifier("protected"); }
845 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
846 | "public" { $$ = CYNew CYIdentifier("public"); }
847 | "set" { $$ = CYNew CYIdentifier("set"); }
848 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
849 | "throws" { $$ = CYNew CYIdentifier("throws"); }
850 | "transient" { $$ = CYNew CYIdentifier("transient"); }
851 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
853 | "bool" { $$ = CYNew CYIdentifier("bool"); }
854 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
855 | "id" { $$ = CYNew CYIdentifier("id"); }
856 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
862 | "char" { $$ = CYNew CYIdentifier("char"); }
863 | "int" { $$ = CYNew CYIdentifier("int"); }
864 | "long" { $$ = CYNew CYIdentifier("long"); }
865 | "short" { $$ = CYNew CYIdentifier("short"); }
866 | "static" { $$ = CYNew CYIdentifier("static"); }
867 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
869 | "extern" { $$ = CYNew CYIdentifier("extern"); }
870 | "signed" { $$ = CYNew CYIdentifier("signed"); }
871 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
872 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
875 | "nil" { $$ = CYNew CYIdentifier("nil"); }
876 | "NO" { $$ = CYNew CYIdentifier("NO"); }
877 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
878 | "YES" { $$ = CYNew CYIdentifier("YES"); }
882 /* 12.2 Primary Expression {{{ */
884 : "this" { $$ = CYNew CYThis(); }
885 | IdentifierReference { $$ = $1; }
886 | Literal { $$ = $1; }
887 | ArrayLiteral { $$ = $1; }
888 | ObjectLiteral { $$ = $1; }
889 | FunctionExpression { $$ = $1; }
890 | ClassExpression { $$ = $1; }
891 | GeneratorExpression { $$ = $1; }
892 | RegularExpressionLiteral { $$ = $1; }
893 | TemplateLiteral { $$ = $1; }
894 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
895 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
898 CoverParenthesizedExpressionAndArrowParameterList
899 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
900 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
901 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
902 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
905 /* 12.2.4 Literals {{{ */
907 : NullLiteral { $$ = $1; }
908 | BooleanLiteral { $$ = $1; }
909 | NumericLiteral { $$ = $1; }
910 | StringLiteral { $$ = $1; }
913 /* 12.2.5 Array Initializer {{{ */
915 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
919 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
920 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
921 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
925 : ElementList { $$ = $1; }
926 | LexSetRegExp { $$ = NULL; }
929 /* 12.2.6 Object Initializer {{{ */
931 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
934 PropertyDefinitionList_
935 : "," PropertyDefinitionListOpt { $$ = $2; }
939 PropertyDefinitionList
940 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
943 PropertyDefinitionListOpt
944 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
945 | LexSetRegExp { $$ = NULL; }
949 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
950 | CoverInitializedName { CYNOT(@$); }
951 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
952 | MethodDefinition { $$ = $1; }
956 : LiteralPropertyName { $$ = $1; }
957 | ComputedPropertyName { $$ = $1; }
961 : IdentifierName { $$ = $1; }
962 | StringLiteral { $$ = $1; }
963 | NumericLiteral { $$ = $1; }
967 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
971 : IdentifierReference Initializer
975 : "=" AssignmentExpression { $$ = $2; }
979 : Initializer { $$ = $1; }
983 /* 12.2.9 Template Literals {{{ */
985 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
986 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
990 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
991 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
995 /* 12.3 Left-Hand-Side Expressions {{{ */
997 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
998 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
999 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1000 | TemplateLiteral { CYNOT(@$); }
1004 : LexSetRegExp PrimaryExpression { $$ = $2; }
1005 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1006 | SuperProperty { $$ = $1; }
1007 | MetaProperty { CYNOT(@$); }
1008 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1012 : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
1013 | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
1021 : LexSetRegExp "new" LexSetRegExp "." "target"
1025 : MemberExpression { $$ = $1; }
1026 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1030 : MemberExpression { $$ = $1; }
1031 | CallExpression { $$ = $1; }
1035 : CallExpression_ Arguments { if (!$1->Eval()) $$ = CYNew CYCall($1, $2); else $$ = CYNew CYEval($2); }
1036 | SuperCall { $$ = $1; }
1037 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1041 : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
1045 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1049 : "," ArgumentList { $$ = $2; }
1054 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1055 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1059 : ArgumentList { $$ = $1; }
1060 | LexSetRegExp { $$ = NULL; }
1063 LeftHandSideExpression
1064 : NewExpression { $$ = $1; }
1065 | CallExpression { $$ = $1; }
1068 /* 12.4 Postfix Expressions {{{ */
1070 : %prec "" LeftHandSideExpression { $$ = $1; }
1071 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1072 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1075 /* 12.5 Unary Operators {{{ */
1077 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1078 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1079 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1080 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1081 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1082 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1083 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1084 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1085 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1086 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1087 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1091 : %prec "" PostfixExpression { $$ = $1; }
1092 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1095 /* 12.6 Multiplicative Operators {{{ */
1096 MultiplicativeExpression
1097 : UnaryExpression { $$ = $1; }
1098 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1099 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1100 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1103 /* 12.7 Additive Operators {{{ */
1105 : MultiplicativeExpression { $$ = $1; }
1106 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1107 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1110 /* 12.8 Bitwise Shift Operators {{{ */
1112 : AdditiveExpression { $$ = $1; }
1113 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1114 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1115 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1118 /* 12.9 Relational Operators {{{ */
1119 RelationalExpression
1120 : ShiftExpression { $$ = $1; }
1121 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1122 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1123 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1124 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1125 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1126 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1129 /* 12.10 Equality Operators {{{ */
1131 : RelationalExpression { $$ = $1; }
1132 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1133 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1134 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1135 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1138 /* 12.11 Binary Bitwise Operators {{{ */
1139 BitwiseANDExpression
1140 : EqualityExpression { $$ = $1; }
1141 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1144 BitwiseXORExpression
1145 : BitwiseANDExpression { $$ = $1; }
1146 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1150 : BitwiseXORExpression { $$ = $1; }
1151 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1154 /* 12.12 Binary Logical Operators {{{ */
1155 LogicalANDExpression
1156 : BitwiseORExpression { $$ = $1; }
1157 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1161 : LogicalANDExpression { $$ = $1; }
1162 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1165 /* 12.13 Conditional Operator ( ? : ) {{{ */
1166 ConditionalExpression
1167 : LogicalORExpression { $$ = $1; }
1168 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1171 /* 12.14 Assignment Operators {{{ */
1172 AssignmentExpression
1173 : ConditionalExpression { $$ = $1; }
1174 | LexSetRegExp YieldExpression { $$ = $2; }
1175 | ArrowFunction { $$ = $1; }
1176 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1177 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1178 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1179 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1180 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1181 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1182 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1183 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1184 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1185 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1186 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1187 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1190 AssignmentExpressionOpt
1191 : AssignmentExpression { $$ = $1; }
1192 | LexSetRegExp { $$ = NULL; }
1195 /* 12.15 Comma Operator ( , ) {{{ */
1197 : AssignmentExpression { $$ = $1; }
1198 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1202 : Expression { $$ = $1; }
1203 | LexSetRegExp { $$ = NULL; }
1207 /* 13 Statements and Declarations {{{ */
1209 : BlockStatement { $$ = $1; }
1210 | VariableStatement { $$ = $1; }
1211 | EmptyStatement { $$ = $1; }
1212 | IfStatement { $$ = $1; }
1213 | BreakableStatement { $$ = $1; }
1214 | ContinueStatement { $$ = $1; }
1215 | BreakStatement { $$ = $1; }
1216 | ReturnStatement { $$ = $1; }
1217 | WithStatement { $$ = $1; }
1218 | LabelledStatement { $$ = $1; }
1219 | ThrowStatement { $$ = $1; }
1220 | TryStatement { $$ = $1; }
1221 | DebuggerStatement { $$ = $1; }
1225 : LexSetRegExp Statement__ { $$ = $2; }
1226 | ExpressionStatement { $$ = $1; }
1230 : LexSetStatement Statement_ { $$ = $2; }
1234 : HoistableDeclaration { $$ = $1; }
1235 | ClassDeclaration { $$ = $1; }
1236 | LexicalDeclaration { $$ = $1; }
1240 : LexSetRegExp Declaration__ { $$ = $2; }
1244 : LexSetStatement Declaration_ { $$ = $2; }
1247 HoistableDeclaration
1248 : FunctionDeclaration { $$ = $1; }
1249 | GeneratorDeclaration { $$ = $1; }
1253 : IterationStatement { $$ = $1; }
1254 | SwitchStatement { $$ = $1; }
1257 /* 13.2 Block {{{ */
1259 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1263 : BRACE StatementListOpt "}" { $$ = $2; }
1267 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1271 : StatementList { $$ = $1; }
1272 | LexSetStatement LexSetRegExp { $$ = NULL; }
1276 : Statement { $$ = $1; }
1277 | Declaration { $$ = $1; }
1280 /* 13.3 Let and Const Declarations {{{ */
1282 : LetOrConst BindingList { $$ = CYNew CYLet($1, $2); }
1286 : LexicalDeclaration_ Terminator { $$ = $1; }
1290 : "let" { $$ = false; }
1291 | "const" { $$ = true; }
1295 : "," BindingList { $$ = $2; }
1300 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1304 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1305 | BindingPattern Initializer { CYNOT(@1); }
1308 /* 13.3.2 Variable Statement {{{ */
1310 : Var_ VariableDeclarationList { $$ = CYNew CYVar($2); }
1314 : VariableStatement_ Terminator { $$ = $1; }
1317 VariableDeclarationList_
1318 : "," VariableDeclarationList { $$ = $2; }
1322 VariableDeclarationList
1323 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1327 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1328 | BindingPattern Initializer { CYNOT(@1); }
1331 /* 13.3.3 Destructuring Binding Patterns {{{ */
1333 : ObjectBindingPattern
1334 | ArrayBindingPattern
1337 ObjectBindingPattern
1338 : BRACE BindingPropertyListOpt "}"
1342 : "[" { CYNOT(@$); }
1345 BindingPropertyList_
1346 : "," BindingPropertyListOpt
1351 : BindingProperty BindingPropertyList_
1354 BindingPropertyListOpt
1355 : BindingPropertyList
1361 | PropertyName ":" BindingElement
1365 : SingleNameBinding { $$ = $1; }
1366 | BindingPattern InitializerOpt { CYNOT(@$); }
1370 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1374 : "..." BindingIdentifier
1377 /* 13.4 Empty Statement {{{ */
1379 : ";" { $$ = CYNew CYEmpty(); }
1382 /* 13.5 Expression Statement {{{ */
1383 ExpressionStatement_
1384 : Expression { $$ = CYNew CYExpress($1); }
1387 : ExpressionStatement_ Terminator { $$ = $1; }
1390 /* 13.6 The if Statement {{{ */
1392 : "else" Statement { $$ = $2; }
1393 | %prec "if" { $$ = NULL; }
1397 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1400 /* 13.7 Iteration Statements {{{ */
1402 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1403 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1404 | "for" "(" LexPushInOn ForStatementInitializer LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $6, $8, $10); }
1405 | "for" "(" LexPushInOn LexSetRegExp Var_ BindingIdentifier Initializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForInitialized(CYNew CYDeclaration($6, $7), $10, $12); }
1406 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1407 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn AssignmentExpression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1410 ForStatementInitializer
1411 : LexSetRegExp EmptyStatement { $$ = $2; }
1412 | ExpressionStatement_ ";" { $$ = $1; }
1413 | LexSetRegExp VariableStatement_ ";" { $$ = $2; }
1414 | LexSetRegExp LexicalDeclaration_ ";" { $$ = $2; }
1417 ForInStatementInitializer
1418 : LeftHandSideExpression { $$ = $1; }
1419 | LexSetRegExp Var_ ForBinding { $$ = CYNew CYForVariable($3); }
1420 | LexSetRegExp ForDeclaration { $$ = $2; }
1424 : LetOrConst ForBinding { $$ = CYNew CYForLexical($1, $2); }
1428 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1429 | BindingPattern { CYNOT(@1); }
1432 /* 13.8 The continue Statement {{{ */
1434 : "continue" LexNewLine
1438 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1439 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1442 /* 13.9 The break Statement {{{ */
1444 : "break" LexNewLine
1448 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1449 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1452 /* 13.10 The return Statement {{{ */
1454 : "!return" LexNewLine
1458 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1459 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1462 /* 13.11 The with Statement {{{ */
1464 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1467 /* 13.12 The switch Statement {{{ */
1469 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1473 : BRACE CaseClausesOpt "}" { $$ = $2; }
1477 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1481 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1482 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1486 // XXX: the standard makes certain you can only have one of these
1488 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1491 /* 13.13 Labelled Statements {{{ */
1493 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1497 : Statement { $$ = $1; }
1498 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1501 /* 13.14 The throw Statement {{{ */
1503 : "throw" LexNewLine
1507 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1508 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1511 /* 13.15 The try Statement {{{ */
1513 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1514 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1515 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1519 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1523 : "finally" Block { $$ = CYNew CYFinally($2); }
1527 : BindingIdentifier { $$ = $1; }
1528 | BindingPattern { CYNOT(@$); }
1531 /* 13.16 The debugger Statement {{{ */
1533 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1537 /* 14.1 Function Definitions {{{ */
1539 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1543 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1546 StrictFormalParameters
1547 : FormalParameters { $$ = $1; }
1552 | FormalParameterList
1555 FormalParameterList_
1556 : "," FormalParameterList { $$ = $2; }
1561 : FunctionRestParameter { CYNOT(@$); }
1562 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1565 FunctionRestParameter
1566 : BindingRestElement
1570 : BindingElement { $$ = $1; }
1574 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1577 FunctionStatementList
1578 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1581 /* 14.2 Arrow Function Definitions {{{ */
1583 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1587 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1588 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1592 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1593 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1596 /* 14.3 Method Definitions {{{ */
1598 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1599 | GeneratorMethod { $$ = $1; }
1600 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1601 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1604 PropertySetParameterList
1605 : FormalParameter { $$ = $1; }
1608 /* 14.4 Generator Function Definitions {{{ */
1610 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1613 GeneratorDeclaration
1614 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1618 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1622 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1626 : "!yield" LexNewLine LexNoStar
1630 : Yield LexSetRegExp "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1631 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1632 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1635 /* 14.5 Class Definitions {{{ */
1637 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1641 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1645 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1649 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1653 : ClassHeritage { $$ = $1; }
1654 | { $$ = CYNew CYClassTail(NULL); }
1667 : ClassElementListOpt ClassElement
1676 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1677 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1682 /* 15.1 Scripts {{{ */
1684 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1688 : StatementList { $$ = $1; }
1692 : ScriptBody { $$ = $1; }
1693 | LexSetStatement LexSetRegExp { $$ = NULL; }
1696 /* 15.2 Modules {{{ */
1711 : ModuleItemListOpt ModuleItem
1720 : LexSetStatement LexSetRegExp ImportDeclaration
1721 | LexSetStatement LexSetRegExp ExportDeclaration
1725 /* 15.2.2 Imports {{{ */
1727 : "import" ImportClause FromClause Terminator
1728 | "import" ModuleSpecifier Terminator
1732 : ImportedDefaultBinding
1735 | ImportedDefaultBinding "," NameSpaceImport
1736 | ImportedDefaultBinding "," NamedImports
1739 ImportedDefaultBinding
1744 : "*" "as" ImportedBinding
1748 : BRACE ImportsListOpt "}"
1752 : "from" ModuleSpecifier
1756 : "," ImportsListOpt
1761 : ImportSpecifier ImportsList_
1771 | IdentifierName "as" ImportedBinding
1782 /* 15.2.3 Exports {{{ */
1784 : "*" FromClause Terminator
1785 | ExportClause FromClause Terminator
1786 | ExportClause Terminator
1788 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1789 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1790 | "default" LexSetStatement AssignmentExpression Terminator
1794 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1795 | "export" Declaration
1799 : ";{" ExportsListOpt "}"
1803 : "," ExportsListOpt
1808 : ExportSpecifier ExportsList_
1818 | IdentifierName "as" IdentifierName
1823 /* Cycript (C): Type Encoding {{{ */
1825 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1826 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1830 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1831 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1832 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1833 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1834 | TypeSignifier { $$ = $1; }
1835 | { $$ = CYNew CYTypedIdentifier(@$); }
1839 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1844 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1845 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1849 : PrefixedType { $$ = $1; }
1850 | SuffixedType { $$ = $1; }
1851 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1852 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1856 : "int" { $$ = CYNew CYTypeVariable("int"); }
1857 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1858 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1859 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1860 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1864 : IntegerType { $$ = $1; }
1865 | { $$ = CYNew CYTypeVariable("int"); }
1869 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1870 | IntegerType { $$ = $1; }
1871 | "void" { $$ = CYNew CYTypeVoid(); }
1872 | "char" { $$ = CYNew CYTypeVariable("char"); }
1873 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1874 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1878 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1882 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1888 /* Cycript (Objective-C): @class Declaration {{{ */
1890 /* XXX: why the hell did I choose MemberExpression? */
1891 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1895 ImplementationFieldListOpt
1896 : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
1897 | LexSetRegExp { $$ = NULL; }
1900 ImplementationFields
1901 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1905 : "+" { $$ = false; }
1906 | "-" { $$ = true; }
1910 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1911 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1915 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1918 MessageParameterList
1919 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1922 MessageParameterListOpt
1923 : MessageParameterList { $$ = $1; }
1928 : MessageParameterList { $$ = $1; }
1929 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
1932 ClassMessageDeclaration
1933 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
1936 ClassMessageDeclarationListOpt
1937 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1941 // XXX: this should be AssignmentExpressionNoRight
1943 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1947 : "," ClassProtocols { $$ = $2; }
1951 ClassProtocolListOpt
1952 : "<" ClassProtocols ">" { $$ = $2; }
1956 ImplementationStatement
1957 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
1965 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1969 : ImplementationStatement { $$ = $1; }
1970 | CategoryStatement { $$ = $1; }
1973 /* Cycript (Objective-C): Send Message {{{ */
1975 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1980 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1981 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1985 : SelectorCall { $$ = $1; }
1986 | VariadicCall { $$ = $1; }
1990 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
1994 : SelectorCall { $$ = $1; }
1995 | Word { $$ = CYNew CYArgument($1, NULL); }
1999 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
2000 | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
2004 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
2008 : SelectorExpression_ { $$ = $1; }
2009 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
2012 SelectorExpressionOpt
2013 : SelectorExpression_ { $$ = $1; }
2018 : MessageExpression { $$ = $1; }
2019 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2024 /* Cycript: @import Directive {{{ */
2026 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2027 | Word { $$ = CYNew CYModule($1); }
2031 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2036 /* Cycript (Objective-C): Boxed Expressions {{{ */
2038 : NullLiteral { $$ = $1; }
2039 | BooleanLiteral { $$ = $1; }
2040 | NumericLiteral { $$ = $1; }
2041 | StringLiteral { $$ = $1; }
2042 | ArrayLiteral { $$ = $1; }
2043 | ObjectLiteral { $$ = $1; }
2044 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2045 | "YES" { $$ = CYNew CYTrue(); }
2046 | "NO" { $$ = CYNew CYFalse(); }
2050 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2051 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2052 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2053 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2054 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2055 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2058 /* Cycript (Objective-C): Block Expressions {{{ */
2060 : "^" 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"); }
2063 /* Cycript (Objective-C): Instance Literals {{{ */
2065 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2071 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2072 LeftHandSideExpression
2073 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2077 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2081 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2082 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2083 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2086 /* Cycript (C): auto Compatibility {{{ */
2091 /* Cycript (C): Lambda Expressions {{{ */
2093 : "," TypedParameterList { $$ = $2; }
2098 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2101 TypedParameterListOpt
2102 : TypedParameterList { $$ = $1; }
2107 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2110 /* Cycript (C): Type Definitions {{{ */
2112 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2115 /* Cycript (C): extern "C" {{{ */
2117 : "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); }
2124 /* Lexer State {{{ */
2126 : { driver.PushCondition(CYDriver::RegExpCondition); }
2130 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2134 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2138 : { driver.PopCondition(); }
2142 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2146 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2149 /* Virtual Tokens {{{ */
2156 /* 8.1 Context Keywords {{{ */
2158 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2159 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2162 /* 8.3 XML Initializer Input Elements {{{ */
2164 : XMLComment { $$ = $1; }
2165 | XMLCDATA { $$ = $1; }
2166 | XMLPI { $$ = $1; }
2170 /* 11.1 Primary Expressions {{{ */
2172 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2173 | XMLInitialiser { $$ = $1; }
2174 | XMLListInitialiser { $$ = $1; }
2178 : AttributeIdentifier { $$ = $1; }
2179 | QualifiedIdentifier { $$ = $1; }
2180 | WildcardIdentifier { $$ = $1; }
2183 /* 11.1.1 Attribute Identifiers {{{ */
2185 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2189 : PropertySelector { $$ = $1; }
2190 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2194 : Identifier { $$ = CYNew CYSelector($1); }
2195 | WildcardIdentifier { $$ = $1; }
2198 /* 11.1.2 Qualified Identifiers {{{ */
2199 QualifiedIdentifier_
2200 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2201 | QualifiedIdentifier { $$ = $1; }
2205 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2208 /* 11.1.3 Wildcard Identifiers {{{ */
2210 : "*" { $$ = CYNew CYWildcard(); }
2213 /* 11.1.4 XML Initializer {{{ */
2215 : XMLMarkup { $$ = $1; }
2216 | XMLElement { $$ = $1; }
2220 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2221 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2225 : LexPushXMLTag XMLTagName XMLAttributes
2229 : BRACE LexPushRegExp Expression LexPop "}"
2238 : XMLAttributes_ XMLAttribute
2243 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2244 | XMLAttributes_ XMLWhitespaceOpt
2253 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2257 : XMLExpression XMLElementContentOpt
2258 | XMLMarkup XMLElementContentOpt
2259 | XMLText XMLElementContentOpt
2260 | XMLElement XMLElementContentOpt
2263 XMLElementContentOpt
2268 /* 11.1.5 XMLList Initializer {{{ */
2270 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2274 /* 11.2 Left-Hand-Side Expressions {{{ */
2276 : Identifier { $$ = $1; }
2277 | PropertyIdentifier { $$ = $1; }
2281 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2282 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2283 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2286 /* 12.1 The default xml namespace Statement {{{ */
2287 /* XXX: DefaultXMLNamespaceStatement
2288 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2292 : DefaultXMLNamespaceStatement { $$ = $1; }
2297 /* JavaScript FTL: Array Comprehensions {{{ */
2299 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2303 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2306 /* JavaScript FTL: for each {{{ */
2308 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2312 /* JavaScript FTW: Array Comprehensions {{{ */
2314 : ArrayComprehension
2318 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2322 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2327 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2328 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2332 : "for" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2333 | "for" "(" LexPushInOn LexicalBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2337 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2340 /* JavaScript FTW: Coalesce Operator {{{ */
2341 ConditionalExpression
2342 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2345 /* JavaScript FTW: Named Arguments {{{ */
2347 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2350 /* JavaScript FTW: Ruby Blocks {{{ */
2351 RubyProcParameterList_
2352 : "," RubyProcParameterList { $$ = $2; }
2356 RubyProcParameterList
2357 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2362 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2363 | LexSetRegExp "||" { $$ = NULL; }
2366 RubyProcParametersOpt
2367 : RubyProcParameters { $$ = $1; }
2372 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2376 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2380 : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2386 bool CYDriver::Parse(CYMark mark) {
2388 CYLocal<CYPool> local(&pool_);
2389 cy::parser parser(*this);
2391 parser.set_debug_level(debug_);
2393 return parser.parse() != 0;
2396 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2400 CYDriver::Error error;
2401 error.warning_ = true;
2402 error.location_ = location;
2403 error.message_ = message;
2404 errors_.push_back(error);
2407 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2408 CYDriver::Error error;
2409 error.warning_ = false;
2410 error.location_ = location;
2411 error.message_ = message;
2412 driver.errors_.push_back(error);