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 { CYThis *this_; }
78 %union { CYTrue *true_; }
79 %union { CYWord *word_; }
82 %union { CYTypeModifier *modifier_; }
83 %union { CYTypeSpecifier *specifier_; }
84 %union { CYTypedIdentifier *typedIdentifier_; }
85 %union { CYTypedParameter *typedParameter_; }
89 %union { CYMessage *message_; }
90 %union { CYMessageParameter *messageParameter_; }
91 %union { CYImplementationField *implementationField_; }
92 %union { CYProtocol *protocol_; }
93 %union { CYSelectorPart *selector_; }
97 %union { CYAttribute *attribute_; }
98 %union { CYPropertyIdentifier *propertyIdentifier_; }
99 %union { CYSelector *selector_; }
105 cy::parser::semantic_type semantic_;
106 hi::Value highlight_;
109 int cylex(YYSTYPE *, CYLocation *, void *);
116 _finline int yylex(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
117 if (driver.mark_ == CYMarkIgnore);
118 else if (driver.mark_ == CYMarkScript) {
119 driver.mark_ = CYMarkIgnore;
120 return cy::parser::token::MarkScript;
121 } else if (driver.mark_ == CYMarkModule) {
122 driver.mark_ = CYMarkIgnore;
123 return cy::parser::token::MarkModule;
127 int token(cylex(&data, location, driver.scanner_));
128 *semantic = data.semantic_;
132 #define CYMAP(to, from) do { \
134 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
135 if (yyla.type == yytranslate_(token::from)) \
136 yyla.type = yytranslate_(token::to); \
139 #define CYERR(location, message) do { \
140 error(location, message); \
144 #define CYNOT(location) \
145 CYERR(location, "unimplemented feature")
154 @$.begin.filename = @$.end.filename = &driver.filename_;
160 %define api.location.type { CYLocation }
167 %param { CYDriver &driver }
169 /* Token Declarations {{{ */
175 %token XMLAttributeValue
177 %token XMLTagCharacters
183 %token LeftRight "<>"
184 %token LeftSlashRight "</>"
186 %token SlashRight "/>"
187 %token LeftSlash "</"
189 %token ColonColon "::"
190 %token PeriodPeriod ".."
193 @begin E4X ObjectiveC
199 %token AmpersandAmpersand "&&"
200 %token AmpersandEqual "&="
202 %token CarrotEqual "^="
204 %token EqualEqual "=="
205 %token EqualEqualEqual "==="
206 %token EqualRight "=>"
207 %token EqualRight_ "\n=>"
208 %token Exclamation "!"
209 %token ExclamationEqual "!="
210 %token ExclamationEqualEqual "!=="
212 %token HyphenEqual "-="
213 %token HyphenHyphen "--"
214 %token HyphenHyphen_ "\n--"
215 %token HyphenRight "->"
217 %token LeftEqual "<="
219 %token LeftLeftEqual "<<="
221 %token PercentEqual "%="
223 %token PeriodPeriodPeriod "..."
225 %token PipeEqual "|="
228 %token PlusEqual "+="
230 %token PlusPlus_ "\n++"
232 %token RightEqual ">="
233 %token RightRight ">>"
234 %token RightRightEqual ">>="
235 %token RightRightRight ">>>"
236 %token RightRightRightEqual ">>>="
238 %token SlashEqual "/="
240 %token StarEqual "*="
252 %token CloseParen ")"
255 %token OpenBrace_ "\n{"
256 %token OpenBrace__ ";{"
257 %token CloseBrace "}"
259 %token OpenBracket "["
260 %token CloseBracket "]"
262 %token At_error_ "@error"
265 %token At_class_ "@class"
269 %token _typedef_ "typedef"
270 %token _unsigned_ "unsigned"
271 %token _signed_ "signed"
272 %token _extern_ "extern"
276 %token At_encode_ "@encode"
280 %token At_implementation_ "@implementation"
281 %token At_import_ "@import"
282 %token At_end_ "@end"
283 %token At_selector_ "@selector"
284 %token At_null_ "@null"
285 %token At_YES_ "@YES"
287 %token At_true_ "@true"
288 %token At_false_ "@false"
293 %token _false_ "false"
297 %token _break_ "break"
299 %token _catch_ "catch"
300 %token _class_ "class"
301 %token _class__ ";class"
302 %token _const_ "const"
303 %token _continue_ "continue"
304 %token _debugger_ "debugger"
305 %token _default_ "default"
306 %token _delete_ "delete"
310 %token _export_ "export"
311 %token _extends_ "extends"
312 %token _finally_ "finally"
314 %token _function_ "function"
315 %token _function__ ";function"
317 %token _import_ "import"
320 %token _instanceof_ "instanceof"
322 %token _return_ "return"
323 %token _return__ "!return"
324 %token _super_ "super"
325 %token _super__ "!super"
326 %token _switch_ "switch"
328 %token _throw_ "throw"
330 %token _typeof_ "typeof"
333 %token _while_ "while"
336 %token _abstract_ "abstract"
337 %token _await_ "await"
338 %token _boolean_ "boolean"
341 %token _constructor_ "constructor"
342 %token _double_ "double"
343 %token _final_ "final"
344 %token _float_ "float"
348 %token _implements_ "implements"
350 %token _interface_ "interface"
353 %token _native_ "native"
354 %token _package_ "package"
355 %token _private_ "private"
356 %token _protected_ "protected"
357 %token _prototype_ "prototype"
358 %token _public_ "public"
360 %token _short_ "short"
361 %token _static_ "static"
362 %token _synchronized_ "synchronized"
363 %token _throws_ "throws"
364 %token _transient_ "transient"
365 %token _volatile_ "volatile"
366 %token _yield_ "yield"
367 %token _yield__ "!yield"
369 %token _undefined_ "undefined"
385 %token _namespace_ "namespace"
392 %token <identifier_> Identifier_
393 %token <number_> NumericLiteral
394 %token <string_> StringLiteral
395 %token <literal_> RegularExpressionLiteral
397 %token <string_> NoSubstitutionTemplate
398 %token <string_> TemplateHead
399 %token <string_> TemplateMiddle
400 %token <string_> TemplateTail
402 %type <expression_> AdditiveExpression
403 %type <argument_> ArgumentList_
404 %type <argument_> ArgumentList
405 %type <argument_> ArgumentListOpt
406 %type <argument_> Arguments
407 %type <expression_> ArrayComprehension
408 %type <literal_> ArrayLiteral
409 %type <expression_> ArrowFunction
410 %type <functionParameter_> ArrowParameters
411 %type <expression_> AssignmentExpression
412 %type <expression_> AssignmentExpressionOpt
413 %type <identifier_> BindingIdentifier
414 %type <identifier_> BindingIdentifierOpt
415 %type <declarations_> BindingList_
416 %type <declarations_> BindingList
417 %type <expression_> BitwiseANDExpression
418 %type <statement_> Block
419 %type <statement_> BlockStatement
420 %type <boolean_> BooleanLiteral
421 %type <declaration_> BindingElement
422 %type <expression_> BitwiseORExpression
423 %type <expression_> BitwiseXORExpression
424 %type <statement_> BreakStatement
425 %type <statement_> BreakableStatement
426 %type <expression_> CallExpression_
427 %type <expression_> CallExpression
428 %type <clause_> CaseBlock
429 %type <clause_> CaseClause
430 %type <clause_> CaseClausesOpt
432 %type <identifier_> CatchParameter
433 %type <statement_> ClassDeclaration
434 %type <expression_> ClassExpression
435 %type <classTail_> ClassHeritage
436 %type <classTail_> ClassHeritageOpt
437 %type <classTail_> ClassTail
438 %type <expression_> Comprehension
439 %type <comprehension_> ComprehensionFor
440 %type <comprehension_> ComprehensionIf
441 %type <comprehension_> ComprehensionTail
442 %type <propertyName_> ComputedPropertyName
443 %type <expression_> ConditionalExpression
444 %type <statement_> ContinueStatement
445 %type <statement_> ConciseBody
446 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
447 %type <statement_> DebuggerStatement
448 %type <statement_> Declaration__
449 %type <statement_> Declaration_
450 %type <statement_> Declaration
451 %type <clause_> DefaultClause
452 %type <element_> ElementList
453 %type <element_> ElementListOpt
454 %type <statement_> ElseStatementOpt
455 %type <statement_> EmptyStatement
456 %type <expression_> EqualityExpression
457 %type <expression_> Expression
458 %type <expression_> ExpressionOpt
459 %type <statement_> ExpressionStatement
460 %type <finally_> Finally
461 %type <declaration_> ForBinding
462 %type <declaration_> ForDeclaration
463 %type <forin_> ForInStatementInitializer
464 %type <for_> ForStatementInitializer
465 %type <declaration_> FormalParameter
466 %type <functionParameter_> FormalParameterList_
467 %type <functionParameter_> FormalParameterList
468 %type <functionParameter_> FormalParameters
469 %type <statement_> FunctionBody
470 %type <statement_> FunctionDeclaration
471 %type <expression_> FunctionExpression
472 %type <statement_> FunctionStatementList
473 %type <statement_> GeneratorBody
474 %type <statement_> GeneratorDeclaration
475 %type <expression_> GeneratorExpression
476 %type <method_> GeneratorMethod
477 %type <statement_> HoistableDeclaration
478 %type <identifier_> Identifier
479 %type <identifier_> IdentifierType
480 %type <word_> IdentifierName
481 %type <variable_> IdentifierReference
482 %type <statement_> IfStatement
483 %type <expression_> Initializer
484 %type <expression_> InitializerOpt
485 %type <statement_> IterationStatement
486 %type <identifier_> LabelIdentifier
487 %type <statement_> LabelledItem
488 %type <statement_> LabelledStatement
489 %type <expression_> LeftHandSideExpression
490 %type <statement_> LetStatement
491 %type <declaration_> LexicalBinding
492 %type <statement_> LexicalDeclaration
493 %type <literal_> Literal
494 %type <propertyName_> LiteralPropertyName
495 %type <expression_> LogicalANDExpression
496 %type <expression_> LogicalORExpression
497 %type <access_> MemberAccess
498 %type <expression_> MemberExpression
499 %type <method_> MethodDefinition
500 %type <module_> ModulePath
501 %type <expression_> MultiplicativeExpression
502 %type <expression_> NewExpression
503 %type <null_> NullLiteral
504 %type <literal_> ObjectLiteral
505 %type <expression_> PostfixExpression
506 %type <expression_> PrimaryExpression
507 %type <propertyName_> PropertyName
508 %type <property_> PropertyDefinition
509 %type <property_> PropertyDefinitionList_
510 %type <property_> PropertyDefinitionList
511 %type <property_> PropertyDefinitionListOpt
512 %type <declaration_> PropertySetParameterList
513 %type <expression_> RelationalExpression
514 %type <statement_> ReturnStatement
515 %type <rubyProc_> RubyProcExpression
516 %type <functionParameter_> RubyProcParameterList_
517 %type <functionParameter_> RubyProcParameterList
518 %type <functionParameter_> RubyProcParameters
519 %type <functionParameter_> RubyProcParametersOpt
520 %type <statement_> Script
521 %type <statement_> ScriptBody
522 %type <statement_> ScriptBodyOpt
523 %type <expression_> ShiftExpression
524 %type <declaration_> SingleNameBinding
525 %type <statement_> Statement__
526 %type <statement_> Statement_
527 %type <statement_> Statement
528 %type <statement_> StatementList
529 %type <statement_> StatementListOpt
530 %type <statement_> StatementListItem
531 %type <functionParameter_> StrictFormalParameters
532 %type <expression_> SuperCall
533 %type <expression_> SuperProperty
534 %type <statement_> SwitchStatement
535 %type <expression_> TemplateLiteral
536 %type <span_> TemplateSpans
537 %type <statement_> ThrowStatement
538 %type <statement_> TryStatement
539 %type <expression_> UnaryExpression_
540 %type <expression_> UnaryExpression
541 %type <declaration_> VariableDeclaration
542 %type <declarations_> VariableDeclarationList_
543 %type <declarations_> VariableDeclarationList
544 %type <statement_> VariableStatement
545 %type <statement_> WithStatement
548 %type <word_> WordOpt
550 %type <expression_> YieldExpression
553 %type <specifier_> IntegerType
554 %type <specifier_> IntegerTypeOpt
555 %type <typedIdentifier_> PrefixedType
556 %type <specifier_> PrimitiveType
557 %type <typedIdentifier_> SuffixedType
558 %type <typedIdentifier_> TypeSignifier
559 %type <modifier_> TypeQualifierLeft
560 %type <typedIdentifier_> TypeQualifierRight
561 %type <typedIdentifier_> TypedIdentifier
562 %type <typedParameter_> TypedParameterList_
563 %type <typedParameter_> TypedParameterList
564 %type <typedParameter_> TypedParameterListOpt
568 %type <expression_> BoxableExpression
569 %type <statement_> CategoryStatement
570 %type <expression_> ClassSuperOpt
571 %type <implementationField_> ImplementationFieldListOpt
572 %type <implementationField_> ImplementationFields
573 %type <message_> ClassMessageDeclaration
574 %type <message_> ClassMessageDeclarationListOpt
575 %type <protocol_> ClassProtocolListOpt
576 %type <protocol_> ClassProtocols
577 %type <protocol_> ClassProtocolsOpt
578 %type <statement_> ImplementationStatement
579 %type <expression_> MessageExpression
580 %type <messageParameter_> MessageParameter
581 %type <messageParameter_> MessageParameters
582 %type <messageParameter_> MessageParameterList
583 %type <messageParameter_> MessageParameterListOpt
584 %type <bool_> MessageScope
585 %type <argument_> SelectorCall_
586 %type <argument_> SelectorCall
587 %type <selector_> SelectorExpression_
588 %type <selector_> SelectorExpression
589 %type <selector_> SelectorExpressionOpt
590 %type <argument_> SelectorList
591 %type <word_> SelectorWordOpt
592 %type <typedIdentifier_> TypeOpt
593 %type <argument_> VariadicCall
597 %type <propertyIdentifier_> PropertyIdentifier_
598 %type <selector_> PropertySelector_
599 %type <selector_> PropertySelector
600 %type <identifier_> QualifiedIdentifier_
601 %type <identifier_> QualifiedIdentifier
602 %type <identifier_> WildcardIdentifier
603 %type <identifier_> XMLComment
604 %type <identifier_> XMLCDATA
605 %type <identifier_> XMLElement
606 %type <identifier_> XMLElementContent
607 %type <identifier_> XMLMarkup
608 %type <identifier_> XMLPI
610 %type <attribute_> AttributeIdentifier
611 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
612 %type <expression_> PropertyIdentifier
613 %type <expression_> XMLListInitialiser
614 %type <expression_> XMLInitialiser
617 /* Token Priorities {{{ */
636 /* Lexer State {{{ */
637 LexPushInOn: { driver.in_.push(true); };
638 LexPushInOff: { driver.in_.push(false); };
639 LexPopIn: { driver.in_.pop(); };
641 LexPushReturnOn: { driver.return_.push(true); };
642 LexPopReturn: { driver.return_.pop(); };
644 LexPushSuperOn: { driver.super_.push(true); };
645 LexPushSuperOff: { driver.super_.push(false); };
646 LexPopSuper: { driver.super_.pop(); };
648 LexPushYieldOn: { driver.yield_.push(true); };
649 LexPushYieldOff: { driver.yield_.push(false); };
650 LexPopYield: { driver.yield_.pop(); };
653 : { driver.SetCondition(CYDriver::RegExpCondition); }
657 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
661 : { CYMAP(YieldStar, Star); }
665 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
669 : { CYMAP(_class__, _class_); }
673 : { CYMAP(_function__, _function_); }
677 : LexNoBrace LexNoClass LexNoFunction
680 /* Virtual Tokens {{{ */
691 /* 11.6 Names and Keywords {{{ */
694 | "for" { $$ = CYNew CYWord("for"); }
695 | "in" { $$ = CYNew CYWord("in"); }
696 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
705 : Identifier { $$ = $1; }
706 | "auto" { $$ = CYNew CYWord("auto"); }
707 | "break" { $$ = CYNew CYWord("break"); }
708 | "case" { $$ = CYNew CYWord("case"); }
709 | "catch" { $$ = CYNew CYWord("catch"); }
710 | "class" { $$ = CYNew CYWord("class"); }
711 | ";class" { $$ = CYNew CYWord("class"); }
712 | "const" { $$ = CYNew CYWord("const"); }
713 | "continue" { $$ = CYNew CYWord("continue"); }
714 | "debugger" { $$ = CYNew CYWord("debugger"); }
715 | "default" { $$ = CYNew CYWord("default"); }
716 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
717 | "do" { $$ = CYNew CYWord("do"); }
718 | "else" { $$ = CYNew CYWord("else"); }
719 | "enum" { $$ = CYNew CYWord("enum"); }
720 | "export" { $$ = CYNew CYWord("export"); }
721 | "extends" { $$ = CYNew CYWord("extends"); }
722 | "false" { $$ = CYNew CYWord("false"); }
723 | "finally" { $$ = CYNew CYWord("finally"); }
724 | "function" { $$ = CYNew CYWord("function"); }
725 | "if" { $$ = CYNew CYWord("if"); }
726 | "import" { $$ = CYNew CYWord("import"); }
727 | "!in" { $$ = CYNew CYWord("in"); }
728 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
729 | "null" { $$ = CYNew CYWord("null"); }
730 | "return" { $$ = CYNew CYWord("return"); }
731 | "!return" { $$ = CYNew CYWord("return"); }
732 | "super" { $$ = CYNew CYWord("super"); }
733 | "!super" { $$ = CYNew CYWord("super"); }
734 | "switch" { $$ = CYNew CYWord("switch"); }
735 | "this" { $$ = CYNew CYWord("this"); }
736 | "throw" { $$ = CYNew CYWord("throw"); }
737 | "true" { $$ = CYNew CYWord("true"); }
738 | "try" { $$ = CYNew CYWord("try"); }
739 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
740 | "var" { $$ = CYNew CYWord("var"); }
741 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
742 | "while" { $$ = CYNew CYWord("while"); }
743 | "with" { $$ = CYNew CYWord("with"); }
744 | "yield" { $$ = CYNew CYIdentifier("yield"); }
746 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
748 // XXX: should be Identifier
749 | "let" { $$ = CYNew CYIdentifier("let"); }
759 /* 11.8.1 Null Literals {{{ */
761 : "null" { $$ = CYNew CYNull(); }
764 /* 11.8.2 Boolean Literals {{{ */
766 : "true" { $$ = CYNew CYTrue(); }
767 | "false" { $$ = CYNew CYFalse(); }
771 /* 11.9 Automatic Semicolon Insertion {{{ */
773 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
783 | 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
788 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
792 /* 12.1 Identifiers {{{ */
794 : Identifier { $$ = CYNew CYVariable($1); }
795 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
799 : Identifier { $$ = $1; }
800 | "yield" { $$ = CYNew CYIdentifier("yield"); }
804 : BindingIdentifier { $$ = $1; }
809 : Identifier { $$ = $1; }
810 | "yield" { $$ = CYNew CYIdentifier("yield"); }
814 : Identifier_ { $$ = $1; }
815 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
816 | "await" { $$ = CYNew CYIdentifier("await"); }
817 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
818 | "byte" { $$ = CYNew CYIdentifier("byte"); }
819 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
820 | "double" { $$ = CYNew CYIdentifier("double"); }
821 | "each" { $$ = CYNew CYIdentifier("each"); }
822 | "final" { $$ = CYNew CYIdentifier("final"); }
823 | "float" { $$ = CYNew CYIdentifier("float"); }
824 | "from" { $$ = CYNew CYIdentifier("from"); }
825 | "get" { $$ = CYNew CYIdentifier("get"); }
826 | "goto" { $$ = CYNew CYIdentifier("goto"); }
827 | "implements" { $$ = CYNew CYIdentifier("implements"); }
828 | "interface" { $$ = CYNew CYIdentifier("interface"); }
829 | "native" { $$ = CYNew CYIdentifier("native"); }
830 | "of" { $$ = CYNew CYIdentifier("of"); }
831 | "package" { $$ = CYNew CYIdentifier("package"); }
832 | "private" { $$ = CYNew CYIdentifier("private"); }
833 | "protected" { $$ = CYNew CYIdentifier("protected"); }
834 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
835 | "public" { $$ = CYNew CYIdentifier("public"); }
836 | "set" { $$ = CYNew CYIdentifier("set"); }
837 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
838 | "throws" { $$ = CYNew CYIdentifier("throws"); }
839 | "transient" { $$ = CYNew CYIdentifier("transient"); }
840 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
842 | "bool" { $$ = CYNew CYIdentifier("bool"); }
843 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
844 | "id" { $$ = CYNew CYIdentifier("id"); }
845 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
851 | "char" { $$ = CYNew CYIdentifier("char"); }
852 | "int" { $$ = CYNew CYIdentifier("int"); }
853 | "long" { $$ = CYNew CYIdentifier("long"); }
854 | "short" { $$ = CYNew CYIdentifier("short"); }
855 | "static" { $$ = CYNew CYIdentifier("static"); }
856 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
858 | "extern" { $$ = CYNew CYIdentifier("extern"); }
859 | "signed" { $$ = CYNew CYIdentifier("signed"); }
860 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
861 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
864 | "nil" { $$ = CYNew CYIdentifier("nil"); }
865 | "NO" { $$ = CYNew CYIdentifier("NO"); }
866 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
867 | "YES" { $$ = CYNew CYIdentifier("YES"); }
871 /* 12.2 Primary Expression {{{ */
873 : "this" { $$ = CYNew CYThis(); }
874 | IdentifierReference { $$ = $1; }
875 | Literal { $$ = $1; }
876 | ArrayLiteral { $$ = $1; }
877 | ObjectLiteral { $$ = $1; }
878 | FunctionExpression { $$ = $1; }
879 | ClassExpression { $$ = $1; }
880 | GeneratorExpression { $$ = $1; }
881 | RegularExpressionLiteral { $$ = $1; }
882 | TemplateLiteral { $$ = $1; }
883 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
884 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
887 CoverParenthesizedExpressionAndArrowParameterList
888 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
889 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
890 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
891 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
894 /* 12.2.4 Literals {{{ */
896 : NullLiteral { $$ = $1; }
897 | BooleanLiteral { $$ = $1; }
898 | NumericLiteral { $$ = $1; }
899 | StringLiteral { $$ = $1; }
902 /* 12.2.5 Array Initializer {{{ */
904 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
908 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
909 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
910 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
914 : ElementList { $$ = $1; }
915 | LexSetRegExp { $$ = NULL; }
918 /* 12.2.6 Object Initializer {{{ */
920 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
923 PropertyDefinitionList_
924 : "," PropertyDefinitionListOpt { $$ = $2; }
928 PropertyDefinitionList
929 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
932 PropertyDefinitionListOpt
933 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
934 | LexSetRegExp { $$ = NULL; }
938 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
939 | CoverInitializedName { CYNOT(@$); }
940 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
941 | MethodDefinition { $$ = $1; }
945 : LiteralPropertyName { $$ = $1; }
946 | ComputedPropertyName { $$ = $1; }
950 : IdentifierName { $$ = $1; }
951 | StringLiteral { $$ = $1; }
952 | NumericLiteral { $$ = $1; }
956 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
960 : IdentifierReference Initializer
964 : "=" AssignmentExpression { $$ = $2; }
968 : Initializer { $$ = $1; }
972 /* 12.2.9 Template Literals {{{ */
974 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
975 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
979 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
980 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
984 /* 12.3 Left-Hand-Side Expressions {{{ */
986 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
987 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
988 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
989 | TemplateLiteral { CYNOT(@$); }
993 : LexSetRegExp PrimaryExpression { $$ = $2; }
994 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
995 | SuperProperty { $$ = $1; }
996 | MetaProperty { CYNOT(@$); }
997 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1001 : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
1002 | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
1010 : LexSetRegExp "new" LexSetRegExp "." "target"
1014 : MemberExpression { $$ = $1; }
1015 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1024 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
1025 | SuperCall { $$ = $1; }
1026 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1030 : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
1034 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1038 : "," ArgumentList { $$ = $2; }
1043 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1044 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1048 : ArgumentList { $$ = $1; }
1049 | LexSetRegExp { $$ = NULL; }
1052 LeftHandSideExpression
1053 : NewExpression { $$ = $1; }
1054 | CallExpression { $$ = $1; }
1057 /* 12.4 Postfix Expressions {{{ */
1059 : %prec "" LeftHandSideExpression { $$ = $1; }
1060 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1061 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1064 /* 12.5 Unary Operators {{{ */
1066 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1067 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1068 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1069 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1070 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1071 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1072 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1073 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1074 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1075 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1076 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1080 : %prec "" PostfixExpression { $$ = $1; }
1081 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1084 /* 12.6 Multiplicative Operators {{{ */
1085 MultiplicativeExpression
1086 : UnaryExpression { $$ = $1; }
1087 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1088 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1089 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1092 /* 12.7 Additive Operators {{{ */
1094 : MultiplicativeExpression { $$ = $1; }
1095 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1096 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1099 /* 12.8 Bitwise Shift Operators {{{ */
1101 : AdditiveExpression { $$ = $1; }
1102 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1103 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1104 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1107 /* 12.9 Relational Operators {{{ */
1108 RelationalExpression
1109 : ShiftExpression { $$ = $1; }
1110 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1111 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1112 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1113 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1114 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1115 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1118 /* 12.10 Equality Operators {{{ */
1120 : RelationalExpression { $$ = $1; }
1121 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1122 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1123 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1124 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1127 /* 12.11 Binary Bitwise Operators {{{ */
1128 BitwiseANDExpression
1129 : EqualityExpression { $$ = $1; }
1130 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1133 BitwiseXORExpression
1134 : BitwiseANDExpression { $$ = $1; }
1135 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1139 : BitwiseXORExpression { $$ = $1; }
1140 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1143 /* 12.12 Binary Logical Operators {{{ */
1144 LogicalANDExpression
1145 : BitwiseORExpression { $$ = $1; }
1146 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1150 : LogicalANDExpression { $$ = $1; }
1151 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1154 /* 12.13 Conditional Operator ( ? : ) {{{ */
1155 ConditionalExpression
1156 : LogicalORExpression { $$ = $1; }
1157 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1160 /* 12.14 Assignment Operators {{{ */
1161 AssignmentExpression
1162 : ConditionalExpression { $$ = $1; }
1163 | LexSetRegExp YieldExpression { $$ = $2; }
1164 | ArrowFunction { $$ = $1; }
1165 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1166 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1167 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1168 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1169 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1170 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1171 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1172 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1173 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1174 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1175 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1176 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1179 AssignmentExpressionOpt
1180 : AssignmentExpression { $$ = $1; }
1181 | LexSetRegExp { $$ = NULL; }
1184 /* 12.15 Comma Operator ( , ) {{{ */
1186 : AssignmentExpression { $$ = $1; }
1187 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1191 : Expression { $$ = $1; }
1192 | LexSetRegExp { $$ = NULL; }
1196 /* 13 Statements and Declarations {{{ */
1198 : BlockStatement { $$ = $1; }
1199 | VariableStatement { $$ = $1; }
1200 | EmptyStatement { $$ = $1; }
1201 | IfStatement { $$ = $1; }
1202 | BreakableStatement { $$ = $1; }
1203 | ContinueStatement { $$ = $1; }
1204 | BreakStatement { $$ = $1; }
1205 | ReturnStatement { $$ = $1; }
1206 | WithStatement { $$ = $1; }
1207 | LabelledStatement { $$ = $1; }
1208 | ThrowStatement { $$ = $1; }
1209 | TryStatement { $$ = $1; }
1210 | DebuggerStatement { $$ = $1; }
1214 : LexSetRegExp Statement__ { $$ = $2; }
1215 | ExpressionStatement { $$ = $1; }
1219 : LexSetStatement Statement_ { $$ = $2; }
1223 : HoistableDeclaration { $$ = $1; }
1224 | ClassDeclaration { $$ = $1; }
1225 | LexicalDeclaration { $$ = $1; }
1229 : LexSetRegExp Declaration__ { $$ = $2; }
1233 : LexSetStatement Declaration_ { $$ = $2; }
1236 HoistableDeclaration
1237 : FunctionDeclaration { $$ = $1; }
1238 | GeneratorDeclaration { $$ = $1; }
1242 : IterationStatement { $$ = $1; }
1243 | SwitchStatement { $$ = $1; }
1246 /* 13.2 Block {{{ */
1248 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1252 : BRACE StatementListOpt "}" { $$ = $2; }
1256 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1260 : StatementList { $$ = $1; }
1261 | LexSetStatement LexSetRegExp { $$ = NULL; }
1265 : Statement { $$ = $1; }
1266 | Declaration { $$ = $1; }
1269 /* 13.3 Let and Const Declarations {{{ */
1271 : LetOrConst BindingList Terminator { $$ = CYNew CYVar($2); }
1280 : "," BindingList { $$ = $2; }
1285 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1289 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1290 | BindingPattern Initializer { CYNOT(@1); }
1293 /* 13.3.2 Variable Statement {{{ */
1295 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1298 VariableDeclarationList_
1299 : "," VariableDeclarationList { $$ = $2; }
1303 VariableDeclarationList
1304 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1308 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1309 | BindingPattern Initializer { CYNOT(@1); }
1312 /* 13.3.3 Destructuring Binding Patterns {{{ */
1314 : ObjectBindingPattern
1315 | ArrayBindingPattern
1318 ObjectBindingPattern
1319 : BRACE BindingPropertyListOpt "}"
1323 : "[" { CYNOT(@$); }
1326 BindingPropertyList_
1327 : "," BindingPropertyListOpt
1332 : BindingProperty BindingPropertyList_
1335 BindingPropertyListOpt
1336 : BindingPropertyList
1342 | PropertyName ":" BindingElement
1346 : SingleNameBinding { $$ = $1; }
1347 | BindingPattern InitializerOpt { CYNOT(@$); }
1351 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1355 : "..." BindingIdentifier
1358 /* 13.4 Empty Statement {{{ */
1360 : ";" { $$ = CYNew CYEmpty(); }
1363 /* 13.5 Expression Statement {{{ */
1365 : Expression Terminator { $$ = CYNew CYExpress($1); }
1368 /* 13.6 The if Statement {{{ */
1370 : "else" Statement { $$ = $2; }
1371 | %prec "if" { $$ = NULL; }
1375 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1378 /* 13.7 Iteration Statements {{{ */
1380 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1381 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1382 | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1383 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1384 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1387 ForStatementInitializer
1388 : ExpressionOpt { $$ = $1; }
1389 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1390 | LexSetRegExp LexicalDeclaration { CYNOT(@$); }
1393 ForInStatementInitializer
1394 : LeftHandSideExpression { $$ = $1; }
1395 | LexSetRegExp Var_ ForBinding { $$ = $3; }
1396 | LexSetRegExp ForDeclaration { $$ = $2; }
1400 : LetOrConst ForBinding { $$ = $2; }
1404 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1405 | BindingPattern { CYNOT(@1); }
1408 /* 13.8 The continue Statement {{{ */
1410 : "continue" LexNewLine
1414 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1415 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1418 /* 13.9 The break Statement {{{ */
1420 : "break" LexNewLine
1424 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1425 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1428 /* 13.10 The return Statement {{{ */
1430 : "!return" LexNewLine
1434 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1435 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1438 /* 13.11 The with Statement {{{ */
1440 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1443 /* 13.12 The switch Statement {{{ */
1445 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1449 : BRACE CaseClausesOpt "}" { $$ = $2; }
1453 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1457 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1458 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1462 // XXX: the standard makes certain you can only have one of these
1464 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1467 /* 13.13 Labelled Statements {{{ */
1469 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1473 : Statement { $$ = $1; }
1474 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1477 /* 13.14 The throw Statement {{{ */
1479 : "throw" LexNewLine
1483 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1484 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1487 /* 13.15 The try Statement {{{ */
1489 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1490 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1491 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1495 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1499 : "finally" Block { $$ = CYNew CYFinally($2); }
1503 : BindingIdentifier { $$ = $1; }
1504 | BindingPattern { CYNOT(@$); }
1507 /* 13.16 The debugger Statement {{{ */
1509 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1513 /* 14.1 Function Definitions {{{ */
1515 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1519 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1522 StrictFormalParameters
1523 : FormalParameters { $$ = $1; }
1528 | FormalParameterList
1531 FormalParameterList_
1532 : "," FormalParameterList { $$ = $2; }
1537 : FunctionRestParameter { CYNOT(@$); }
1538 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1541 FunctionRestParameter
1542 : BindingRestElement
1546 : BindingElement { $$ = $1; }
1550 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1553 FunctionStatementList
1554 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1557 /* 14.2 Arrow Function Definitions {{{ */
1559 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1563 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1564 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1568 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1569 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1572 /* 14.3 Method Definitions {{{ */
1574 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1575 | GeneratorMethod { $$ = $1; }
1576 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1577 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1580 PropertySetParameterList
1581 : FormalParameter { $$ = $1; }
1584 /* 14.4 Generator Function Definitions {{{ */
1586 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1589 GeneratorDeclaration
1590 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1594 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1598 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1602 : "!yield" LexNewLine LexNoStar
1606 : Yield LexSetRegExp "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1607 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1608 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1611 /* 14.5 Class Definitions {{{ */
1613 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1617 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1621 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1625 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1629 : ClassHeritage { $$ = $1; }
1630 | { $$ = CYNew CYClassTail(NULL); }
1643 : ClassElementListOpt ClassElement
1652 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1653 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1658 /* 15.1 Scripts {{{ */
1660 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1664 : StatementList { $$ = $1; }
1668 : ScriptBody { $$ = $1; }
1669 | LexSetStatement LexSetRegExp { $$ = NULL; }
1672 /* 15.2 Modules {{{ */
1687 : ModuleItemListOpt ModuleItem
1696 : LexSetStatement LexSetRegExp ImportDeclaration
1697 | LexSetStatement LexSetRegExp ExportDeclaration
1701 /* 15.2.2 Imports {{{ */
1703 : "import" ImportClause FromClause Terminator
1704 | "import" ModuleSpecifier Terminator
1708 : ImportedDefaultBinding
1711 | ImportedDefaultBinding "," NameSpaceImport
1712 | ImportedDefaultBinding "," NamedImports
1715 ImportedDefaultBinding
1720 : "*" "as" ImportedBinding
1724 : BRACE ImportsListOpt "}"
1728 : "from" ModuleSpecifier
1732 : "," ImportsListOpt
1737 : ImportSpecifier ImportsList_
1747 | IdentifierName "as" ImportedBinding
1758 /* 15.2.3 Exports {{{ */
1760 : "*" FromClause Terminator
1761 | ExportClause FromClause Terminator
1762 | ExportClause Terminator
1764 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1765 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1766 | "default" LexSetStatement AssignmentExpression Terminator
1770 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1771 | "export" Declaration
1775 : ";{" ExportsListOpt "}"
1779 : "," ExportsListOpt
1784 : ExportSpecifier ExportsList_
1794 | IdentifierName "as" IdentifierName
1799 /* Cycript (C): Type Encoding {{{ */
1801 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1802 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1806 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1807 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1808 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1809 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1810 | TypeSignifier { $$ = $1; }
1811 | { $$ = CYNew CYTypedIdentifier(@$); }
1815 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1820 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1821 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1825 : PrefixedType { $$ = $1; }
1826 | SuffixedType { $$ = $1; }
1827 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1828 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1832 : "int" { $$ = CYNew CYTypeVariable("int"); }
1833 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1834 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1835 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1836 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1840 : IntegerType { $$ = $1; }
1841 | { $$ = CYNew CYTypeVariable("int"); }
1845 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1846 | IntegerType { $$ = $1; }
1847 | "void" { $$ = CYNew CYTypeVoid(); }
1848 | "char" { $$ = CYNew CYTypeVariable("char"); }
1849 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1850 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1854 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1858 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1864 /* Cycript (Objective-C): @class Declaration {{{ */
1866 /* XXX: why the hell did I choose MemberExpression? */
1867 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1871 ImplementationFieldListOpt
1872 : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
1873 | LexSetRegExp { $$ = NULL; }
1876 ImplementationFields
1877 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1881 : "+" { $$ = false; }
1882 | "-" { $$ = true; }
1886 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1887 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1891 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1894 MessageParameterList
1895 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1898 MessageParameterListOpt
1899 : MessageParameterList { $$ = $1; }
1904 : MessageParameterList { $$ = $1; }
1905 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
1908 ClassMessageDeclaration
1909 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
1912 ClassMessageDeclarationListOpt
1913 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1917 // XXX: this should be AssignmentExpressionNoRight
1919 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1923 : "," ClassProtocols { $$ = $2; }
1927 ClassProtocolListOpt
1928 : "<" ClassProtocols ">" { $$ = $2; }
1932 ImplementationStatement
1933 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
1941 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1945 : ImplementationStatement { $$ = $1; }
1946 | CategoryStatement { $$ = $1; }
1949 /* Cycript (Objective-C): Send Message {{{ */
1951 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1956 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1957 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1961 : SelectorCall { $$ = $1; }
1962 | VariadicCall { $$ = $1; }
1966 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
1970 : SelectorCall { $$ = $1; }
1971 | Word { $$ = CYNew CYArgument($1, NULL); }
1975 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1976 | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1980 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1984 : SelectorExpression_ { $$ = $1; }
1985 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1988 SelectorExpressionOpt
1989 : SelectorExpression_ { $$ = $1; }
1994 : MessageExpression { $$ = $1; }
1995 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2000 /* Cycript: @import Directive {{{ */
2002 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2003 | Word { $$ = CYNew CYModule($1); }
2007 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2012 /* Cycript (Objective-C): Boxed Expressions {{{ */
2014 : NullLiteral { $$ = $1; }
2015 | BooleanLiteral { $$ = $1; }
2016 | NumericLiteral { $$ = $1; }
2017 | StringLiteral { $$ = $1; }
2018 | ArrayLiteral { $$ = $1; }
2019 | ObjectLiteral { $$ = $1; }
2020 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2021 | "YES" { $$ = CYNew CYTrue(); }
2022 | "NO" { $$ = CYNew CYFalse(); }
2026 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2027 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2028 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2029 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2030 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2031 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2034 /* Cycript (Objective-C): Block Expressions {{{ */
2036 : "^" 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"); }
2039 /* Cycript (Objective-C): Instance Literals {{{ */
2041 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2047 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2048 LeftHandSideExpression
2049 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2053 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2057 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2058 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2059 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2062 /* Cycript (C): auto Compatibility {{{ */
2067 /* Cycript (C): Lambda Expressions {{{ */
2069 : "," TypedParameterList { $$ = $2; }
2074 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2077 TypedParameterListOpt
2078 : TypedParameterList { $$ = $1; }
2083 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2086 /* Cycript (C): Type Definitions {{{ */
2088 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2091 /* Cycript (C): extern "C" {{{ */
2093 : "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); }
2100 /* Lexer State {{{ */
2102 : { driver.PushCondition(CYDriver::RegExpCondition); }
2106 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2110 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2114 : { driver.PopCondition(); }
2118 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2122 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2125 /* Virtual Tokens {{{ */
2132 /* 8.1 Context Keywords {{{ */
2134 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2135 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2138 /* 8.3 XML Initializer Input Elements {{{ */
2140 : XMLComment { $$ = $1; }
2141 | XMLCDATA { $$ = $1; }
2142 | XMLPI { $$ = $1; }
2146 /* 11.1 Primary Expressions {{{ */
2148 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2149 | XMLInitialiser { $$ = $1; }
2150 | XMLListInitialiser { $$ = $1; }
2154 : AttributeIdentifier { $$ = $1; }
2155 | QualifiedIdentifier { $$ = $1; }
2156 | WildcardIdentifier { $$ = $1; }
2159 /* 11.1.1 Attribute Identifiers {{{ */
2161 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2165 : PropertySelector { $$ = $1; }
2166 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2170 : Identifier { $$ = CYNew CYSelector($1); }
2171 | WildcardIdentifier { $$ = $1; }
2174 /* 11.1.2 Qualified Identifiers {{{ */
2175 QualifiedIdentifier_
2176 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2177 | QualifiedIdentifier { $$ = $1; }
2181 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2184 /* 11.1.3 Wildcard Identifiers {{{ */
2186 : "*" { $$ = CYNew CYWildcard(); }
2189 /* 11.1.4 XML Initializer {{{ */
2191 : XMLMarkup { $$ = $1; }
2192 | XMLElement { $$ = $1; }
2196 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2197 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2201 : LexPushXMLTag XMLTagName XMLAttributes
2205 : BRACE LexPushRegExp Expression LexPop "}"
2214 : XMLAttributes_ XMLAttribute
2219 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2220 | XMLAttributes_ XMLWhitespaceOpt
2229 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2233 : XMLExpression XMLElementContentOpt
2234 | XMLMarkup XMLElementContentOpt
2235 | XMLText XMLElementContentOpt
2236 | XMLElement XMLElementContentOpt
2239 XMLElementContentOpt
2244 /* 11.1.5 XMLList Initializer {{{ */
2246 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2250 /* 11.2 Left-Hand-Side Expressions {{{ */
2252 : Identifier { $$ = $1; }
2253 | PropertyIdentifier { $$ = $1; }
2257 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2258 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2259 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2262 /* 12.1 The default xml namespace Statement {{{ */
2263 /* XXX: DefaultXMLNamespaceStatement
2264 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2268 : DefaultXMLNamespaceStatement { $$ = $1; }
2273 /* JavaScript FTL: Array Comprehensions {{{ */
2275 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2279 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2282 /* JavaScript FTL: for each {{{ */
2284 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2287 /* JavaScript FTL: let Statements {{{ */
2289 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
2297 /* JavaScript FTW: Array Comprehensions {{{ */
2299 : ArrayComprehension
2303 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2307 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2312 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2313 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2317 : "for" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2318 | "for" "(" LexPushInOn LexicalBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2322 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2325 /* JavaScript FTW: Coalesce Operator {{{ */
2326 ConditionalExpression
2327 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2330 /* JavaScript FTW: Named Arguments {{{ */
2332 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2335 /* JavaScript FTW: Ruby Blocks {{{ */
2336 RubyProcParameterList_
2337 : "," RubyProcParameterList { $$ = $2; }
2341 RubyProcParameterList
2342 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2347 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2348 | LexSetRegExp "||" { $$ = NULL; }
2351 RubyProcParametersOpt
2352 : RubyProcParameters { $$ = $1; }
2357 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2361 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2365 : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2371 bool CYDriver::Parse(CYMark mark) {
2373 CYLocal<CYPool> local(&pool_);
2374 cy::parser parser(*this);
2376 parser.set_debug_level(debug_);
2378 return parser.parse() != 0;
2381 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2385 CYDriver::Error error;
2386 error.warning_ = true;
2387 error.location_ = location;
2388 error.message_ = message;
2389 errors_.push_back(error);
2392 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2393 CYDriver::Error error;
2394 error.warning_ = false;
2395 error.location_ = location;
2396 error.message_ = message;
2397 driver.errors_.push_back(error);