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 CYLEX() do if (yyla.empty()) { \
133 YYCDEBUG << "Mapping a token: "; \
134 yyla.type = yytranslate_(yylex(&yyla.value, &yyla.location, driver)); \
135 YY_SYMBOL_PRINT("Next token is", yyla); \
138 #define CYMAP(to, from) do { \
140 if (yyla.type == yytranslate_(token::from)) \
141 yyla.type = yytranslate_(token::to); \
144 #define CYERR(location, message) do { \
145 error(location, message); \
149 #define CYNOT(location) \
150 CYERR(location, "unimplemented feature")
159 @$.begin.filename = @$.end.filename = &driver.filename_;
165 %define api.location.type { CYLocation }
172 %param { CYDriver &driver }
174 /* Token Declarations {{{ */
180 %token XMLAttributeValue
182 %token XMLTagCharacters
188 %token LeftRight "<>"
189 %token LeftSlashRight "</>"
191 %token SlashRight "/>"
192 %token LeftSlash "</"
194 %token ColonColon "::"
195 %token PeriodPeriod ".."
198 @begin E4X ObjectiveC
204 %token AmpersandAmpersand "&&"
205 %token AmpersandEqual "&="
207 %token CarrotEqual "^="
209 %token EqualEqual "=="
210 %token EqualEqualEqual "==="
211 %token EqualRight "=>"
212 %token EqualRight_ "\n=>"
213 %token Exclamation "!"
214 %token ExclamationEqual "!="
215 %token ExclamationEqualEqual "!=="
217 %token HyphenEqual "-="
218 %token HyphenHyphen "--"
219 %token HyphenHyphen_ "\n--"
220 %token HyphenRight "->"
222 %token LeftEqual "<="
224 %token LeftLeftEqual "<<="
226 %token PercentEqual "%="
228 %token PeriodPeriodPeriod "..."
230 %token PipeEqual "|="
233 %token PlusEqual "+="
235 %token PlusPlus_ "\n++"
237 %token RightEqual ">="
238 %token RightRight ">>"
239 %token RightRightEqual ">>="
240 %token RightRightRight ">>>"
241 %token RightRightRightEqual ">>>="
243 %token SlashEqual "/="
245 %token StarEqual "*="
257 %token CloseParen ")"
260 %token OpenBrace_ "\n{"
261 %token OpenBrace__ ";{"
262 %token CloseBrace "}"
264 %token OpenBracket "["
265 %token CloseBracket "]"
267 %token At_error_ "@error"
270 %token At_class_ "@class"
274 %token _typedef_ "typedef"
275 %token _unsigned_ "unsigned"
276 %token _signed_ "signed"
277 %token _extern_ "extern"
281 %token At_encode_ "@encode"
285 %token At_implementation_ "@implementation"
286 %token At_import_ "@import"
287 %token At_end_ "@end"
288 %token At_selector_ "@selector"
289 %token At_null_ "@null"
290 %token At_YES_ "@YES"
292 %token At_true_ "@true"
293 %token At_false_ "@false"
298 %token _false_ "false"
302 %token _break_ "break"
304 %token _catch_ "catch"
305 %token _class_ "class"
306 %token _class__ ";class"
307 %token _const_ "const"
308 %token _continue_ "continue"
309 %token _debugger_ "debugger"
310 %token _default_ "default"
311 %token _delete_ "delete"
315 %token _export_ "export"
316 %token _extends_ "extends"
317 %token _finally_ "finally"
319 %token _function_ "function"
320 %token _function__ ";function"
322 %token _import_ "import"
325 %token _instanceof_ "instanceof"
327 %token _return_ "return"
328 %token _return__ "!return"
329 %token _super_ "super"
330 %token _super__ "!super"
331 %token _switch_ "switch"
333 %token _throw_ "throw"
335 %token _typeof_ "typeof"
338 %token _while_ "while"
341 %token _abstract_ "abstract"
342 %token _await_ "await"
343 %token _boolean_ "boolean"
346 %token _constructor_ "constructor"
347 %token _double_ "double"
348 %token _final_ "final"
349 %token _float_ "float"
353 %token _implements_ "implements"
355 %token _interface_ "interface"
358 %token _native_ "native"
359 %token _package_ "package"
360 %token _private_ "private"
361 %token _protected_ "protected"
362 %token _prototype_ "prototype"
363 %token _public_ "public"
365 %token _short_ "short"
366 %token _static_ "static"
367 %token _synchronized_ "synchronized"
368 %token _throws_ "throws"
369 %token _transient_ "transient"
370 %token _volatile_ "volatile"
371 %token _yield_ "yield"
372 %token _yield__ "!yield"
374 %token _undefined_ "undefined"
390 %token _namespace_ "namespace"
397 %token <identifier_> Identifier_
398 %token <number_> NumericLiteral
399 %token <string_> StringLiteral
400 %token <literal_> RegularExpressionLiteral
402 %token <string_> NoSubstitutionTemplate
403 %token <string_> TemplateHead
404 %token <string_> TemplateMiddle
405 %token <string_> TemplateTail
407 %type <expression_> AdditiveExpression
408 %type <argument_> ArgumentList_
409 %type <argument_> ArgumentList
410 %type <argument_> ArgumentListOpt
411 %type <argument_> Arguments
412 %type <expression_> ArrayComprehension
413 %type <literal_> ArrayLiteral
414 %type <expression_> ArrowFunction
415 %type <functionParameter_> ArrowParameters
416 %type <expression_> AssignmentExpression
417 %type <expression_> AssignmentExpressionOpt
418 %type <identifier_> BindingIdentifier
419 %type <identifier_> BindingIdentifierOpt
420 %type <declarations_> BindingList_
421 %type <declarations_> BindingList
422 %type <expression_> BitwiseANDExpression
423 %type <statement_> Block
424 %type <statement_> BlockStatement
425 %type <boolean_> BooleanLiteral
426 %type <declaration_> BindingElement
427 %type <expression_> BitwiseORExpression
428 %type <expression_> BitwiseXORExpression
429 %type <statement_> BreakStatement
430 %type <statement_> BreakableStatement
431 %type <expression_> CallExpression_
432 %type <expression_> CallExpression
433 %type <clause_> CaseBlock
434 %type <clause_> CaseClause
435 %type <clause_> CaseClausesOpt
437 %type <identifier_> CatchParameter
438 %type <statement_> ClassDeclaration
439 %type <expression_> ClassExpression
440 %type <classTail_> ClassHeritage
441 %type <classTail_> ClassHeritageOpt
442 %type <classTail_> ClassTail
443 %type <expression_> Comprehension
444 %type <comprehension_> ComprehensionFor
445 %type <comprehension_> ComprehensionIf
446 %type <comprehension_> ComprehensionTail
447 %type <propertyName_> ComputedPropertyName
448 %type <expression_> ConditionalExpression
449 %type <statement_> ContinueStatement
450 %type <statement_> ConciseBody
451 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
452 %type <statement_> DebuggerStatement
453 %type <statement_> Declaration__
454 %type <statement_> Declaration_
455 %type <statement_> Declaration
456 %type <clause_> DefaultClause
457 %type <element_> ElementList
458 %type <element_> ElementListOpt
459 %type <statement_> ElseStatementOpt
460 %type <statement_> EmptyStatement
461 %type <expression_> EqualityExpression
462 %type <expression_> Expression
463 %type <expression_> ExpressionOpt
464 %type <statement_> ExpressionStatement
465 %type <finally_> Finally
466 %type <declaration_> ForBinding
467 %type <declaration_> ForDeclaration
468 %type <forin_> ForInStatementInitializer
469 %type <for_> ForStatementInitializer
470 %type <declaration_> FormalParameter
471 %type <functionParameter_> FormalParameterList_
472 %type <functionParameter_> FormalParameterList
473 %type <functionParameter_> FormalParameters
474 %type <statement_> FunctionBody
475 %type <statement_> FunctionDeclaration
476 %type <expression_> FunctionExpression
477 %type <statement_> FunctionStatementList
478 %type <statement_> GeneratorBody
479 %type <statement_> GeneratorDeclaration
480 %type <expression_> GeneratorExpression
481 %type <method_> GeneratorMethod
482 %type <statement_> HoistableDeclaration
483 %type <identifier_> Identifier
484 %type <identifier_> IdentifierType
485 %type <word_> IdentifierName
486 %type <variable_> IdentifierReference
487 %type <statement_> IfStatement
488 %type <expression_> Initializer
489 %type <expression_> InitializerOpt
490 %type <statement_> IterationStatement
491 %type <identifier_> LabelIdentifier
492 %type <statement_> LabelledItem
493 %type <statement_> LabelledStatement
494 %type <expression_> LeftHandSideExpression
495 %type <declaration_> LexicalBinding
496 %type <statement_> LexicalDeclaration
497 %type <literal_> Literal
498 %type <propertyName_> LiteralPropertyName
499 %type <expression_> LogicalANDExpression
500 %type <expression_> LogicalORExpression
501 %type <access_> MemberAccess
502 %type <expression_> MemberExpression
503 %type <method_> MethodDefinition
504 %type <module_> ModulePath
505 %type <expression_> MultiplicativeExpression
506 %type <expression_> NewExpression
507 %type <null_> NullLiteral
508 %type <literal_> ObjectLiteral
509 %type <expression_> PostfixExpression
510 %type <expression_> PrimaryExpression
511 %type <propertyName_> PropertyName
512 %type <property_> PropertyDefinition
513 %type <property_> PropertyDefinitionList_
514 %type <property_> PropertyDefinitionList
515 %type <property_> PropertyDefinitionListOpt
516 %type <declaration_> PropertySetParameterList
517 %type <expression_> RelationalExpression
518 %type <statement_> ReturnStatement
519 %type <rubyProc_> RubyProcExpression
520 %type <functionParameter_> RubyProcParameterList_
521 %type <functionParameter_> RubyProcParameterList
522 %type <functionParameter_> RubyProcParameters
523 %type <functionParameter_> RubyProcParametersOpt
524 %type <statement_> Script
525 %type <statement_> ScriptBody
526 %type <statement_> ScriptBodyOpt
527 %type <expression_> ShiftExpression
528 %type <declaration_> SingleNameBinding
529 %type <statement_> Statement__
530 %type <statement_> Statement_
531 %type <statement_> Statement
532 %type <statement_> StatementList
533 %type <statement_> StatementListOpt
534 %type <statement_> StatementListItem
535 %type <functionParameter_> StrictFormalParameters
536 %type <expression_> SuperCall
537 %type <expression_> SuperProperty
538 %type <statement_> SwitchStatement
539 %type <expression_> TemplateLiteral
540 %type <span_> TemplateSpans
541 %type <statement_> ThrowStatement
542 %type <statement_> TryStatement
543 %type <expression_> UnaryExpression_
544 %type <expression_> UnaryExpression
545 %type <declaration_> VariableDeclaration
546 %type <declarations_> VariableDeclarationList_
547 %type <declarations_> VariableDeclarationList
548 %type <statement_> VariableStatement
549 %type <statement_> WithStatement
552 %type <word_> WordOpt
554 %type <expression_> YieldExpression
557 %type <specifier_> IntegerType
558 %type <specifier_> IntegerTypeOpt
559 %type <typedIdentifier_> PrefixedType
560 %type <specifier_> PrimitiveType
561 %type <typedIdentifier_> SuffixedType
562 %type <typedIdentifier_> TypeSignifier
563 %type <modifier_> TypeQualifierLeft
564 %type <typedIdentifier_> TypeQualifierRight
565 %type <typedIdentifier_> TypedIdentifier
566 %type <typedParameter_> TypedParameterList_
567 %type <typedParameter_> TypedParameterList
568 %type <typedParameter_> TypedParameterListOpt
572 %type <expression_> BoxableExpression
573 %type <statement_> CategoryStatement
574 %type <expression_> ClassSuperOpt
575 %type <implementationField_> ImplementationFieldListOpt
576 %type <implementationField_> ImplementationFields
577 %type <message_> ClassMessageDeclaration
578 %type <message_> ClassMessageDeclarationListOpt
579 %type <protocol_> ClassProtocolListOpt
580 %type <protocol_> ClassProtocols
581 %type <protocol_> ClassProtocolsOpt
582 %type <statement_> ImplementationStatement
583 %type <expression_> MessageExpression
584 %type <messageParameter_> MessageParameter
585 %type <messageParameter_> MessageParameters
586 %type <messageParameter_> MessageParameterList
587 %type <messageParameter_> MessageParameterListOpt
588 %type <bool_> MessageScope
589 %type <argument_> SelectorCall_
590 %type <argument_> SelectorCall
591 %type <selector_> SelectorExpression_
592 %type <selector_> SelectorExpression
593 %type <selector_> SelectorExpressionOpt
594 %type <argument_> SelectorList
595 %type <word_> SelectorWordOpt
596 %type <typedIdentifier_> TypeOpt
597 %type <argument_> VariadicCall
601 %type <propertyIdentifier_> PropertyIdentifier_
602 %type <selector_> PropertySelector_
603 %type <selector_> PropertySelector
604 %type <identifier_> QualifiedIdentifier_
605 %type <identifier_> QualifiedIdentifier
606 %type <identifier_> WildcardIdentifier
607 %type <identifier_> XMLComment
608 %type <identifier_> XMLCDATA
609 %type <identifier_> XMLElement
610 %type <identifier_> XMLElementContent
611 %type <identifier_> XMLMarkup
612 %type <identifier_> XMLPI
614 %type <attribute_> AttributeIdentifier
615 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
616 %type <expression_> PropertyIdentifier
617 %type <expression_> XMLListInitialiser
618 %type <expression_> XMLInitialiser
621 /* Token Priorities {{{ */
640 /* Lexer State {{{ */
641 LexPushInOn: { driver.in_.push(true); };
642 LexPushInOff: { driver.in_.push(false); };
643 LexPopIn: { driver.in_.pop(); };
645 LexPushReturnOn: { driver.return_.push(true); };
646 LexPopReturn: { driver.return_.pop(); };
648 LexPushSuperOn: { driver.super_.push(true); };
649 LexPushSuperOff: { driver.super_.push(false); };
650 LexPopSuper: { driver.super_.pop(); };
652 LexPushYieldOn: { driver.yield_.push(true); };
653 LexPushYieldOff: { driver.yield_.push(false); };
654 LexPopYield: { driver.yield_.pop(); };
657 : { CYLEX(); if (yyla.type == yytranslate_(token::Slash)) { yyla.clear(); driver.SetRegEx(false); } else if (yyla.type == yytranslate_(token::SlashEqual)) { yyla.clear(); driver.SetRegEx(true); } }
661 : { if (!yyla.empty() && yyla.type_get() != yyeof_) CYERR(@$, "unexpected lookahead"); driver.next_ = true; }
665 : { CYMAP(YieldStar, Star); }
669 : { CYMAP(OpenBrace__, OpenBrace); CYMAP(OpenBrace__, OpenBrace_); }
673 : { CYMAP(_class__, _class_); }
677 : { CYMAP(_function__, _function_); }
681 : LexNoBrace LexNoClass LexNoFunction
684 /* Virtual Tokens {{{ */
695 /* 11.6 Names and Keywords {{{ */
698 | "for" { $$ = CYNew CYWord("for"); }
699 | "in" { $$ = CYNew CYWord("in"); }
700 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
709 : Identifier { $$ = $1; }
710 | "auto" { $$ = CYNew CYWord("auto"); }
711 | "break" { $$ = CYNew CYWord("break"); }
712 | "case" { $$ = CYNew CYWord("case"); }
713 | "catch" { $$ = CYNew CYWord("catch"); }
714 | "class" { $$ = CYNew CYWord("class"); }
715 | ";class" { $$ = CYNew CYWord("class"); }
716 | "const" { $$ = CYNew CYWord("const"); }
717 | "continue" { $$ = CYNew CYWord("continue"); }
718 | "debugger" { $$ = CYNew CYWord("debugger"); }
719 | "default" { $$ = CYNew CYWord("default"); }
720 | "delete" LexSetRegExp { $$ = CYNew CYWord("delete"); }
721 | "do" { $$ = CYNew CYWord("do"); }
722 | "else" { $$ = CYNew CYWord("else"); }
723 | "enum" { $$ = CYNew CYWord("enum"); }
724 | "export" { $$ = CYNew CYWord("export"); }
725 | "extends" { $$ = CYNew CYWord("extends"); }
726 | "false" { $$ = CYNew CYWord("false"); }
727 | "finally" { $$ = CYNew CYWord("finally"); }
728 | "function" { $$ = CYNew CYWord("function"); }
729 | "if" { $$ = CYNew CYWord("if"); }
730 | "import" { $$ = CYNew CYWord("import"); }
731 | "!in" { $$ = CYNew CYWord("in"); }
732 | "new" LexSetRegExp { $$ = CYNew CYWord("new"); }
733 | "null" { $$ = CYNew CYWord("null"); }
734 | "return" { $$ = CYNew CYWord("return"); }
735 | "!return" { $$ = CYNew CYWord("return"); }
736 | "super" { $$ = CYNew CYWord("super"); }
737 | "!super" { $$ = CYNew CYWord("super"); }
738 | "switch" { $$ = CYNew CYWord("switch"); }
739 | "this" { $$ = CYNew CYWord("this"); }
740 | "throw" { $$ = CYNew CYWord("throw"); }
741 | "true" { $$ = CYNew CYWord("true"); }
742 | "try" { $$ = CYNew CYWord("try"); }
743 | "typeof" LexSetRegExp { $$ = CYNew CYWord("typeof"); }
744 | "var" { $$ = CYNew CYWord("var"); }
745 | "void" LexSetRegExp { $$ = CYNew CYWord("void"); }
746 | "while" { $$ = CYNew CYWord("while"); }
747 | "with" { $$ = CYNew CYWord("with"); }
748 | "yield" { $$ = CYNew CYIdentifier("yield"); }
750 | Yield LexSetRegExp NewLineOpt { $$ = CYNew CYIdentifier("yield"); }
752 // XXX: should be Identifier
753 | "let" { $$ = CYNew CYIdentifier("let"); }
763 /* 11.8.1 Null Literals {{{ */
765 : "null" { $$ = CYNew CYNull(); }
768 /* 11.8.2 Boolean Literals {{{ */
770 : "true" { $$ = CYNew CYTrue(); }
771 | "false" { $$ = CYNew CYFalse(); }
775 /* 11.9 Automatic Semicolon Insertion {{{ */
777 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
787 | 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
792 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
796 /* 12.1 Identifiers {{{ */
798 : Identifier { $$ = CYNew CYVariable($1); }
799 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
803 : Identifier { $$ = $1; }
804 | "yield" { $$ = CYNew CYIdentifier("yield"); }
808 : BindingIdentifier { $$ = $1; }
813 : Identifier { $$ = $1; }
814 | "yield" { $$ = CYNew CYIdentifier("yield"); }
818 : Identifier_ { $$ = $1; }
819 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
820 | "await" { $$ = CYNew CYIdentifier("await"); }
821 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
822 | "byte" { $$ = CYNew CYIdentifier("byte"); }
823 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
824 | "double" { $$ = CYNew CYIdentifier("double"); }
825 | "each" { $$ = CYNew CYIdentifier("each"); }
826 | "final" { $$ = CYNew CYIdentifier("final"); }
827 | "float" { $$ = CYNew CYIdentifier("float"); }
828 | "from" { $$ = CYNew CYIdentifier("from"); }
829 | "get" { $$ = CYNew CYIdentifier("get"); }
830 | "goto" { $$ = CYNew CYIdentifier("goto"); }
831 | "implements" { $$ = CYNew CYIdentifier("implements"); }
832 | "interface" { $$ = CYNew CYIdentifier("interface"); }
833 | "native" { $$ = CYNew CYIdentifier("native"); }
834 | "of" { $$ = CYNew CYIdentifier("of"); }
835 | "package" { $$ = CYNew CYIdentifier("package"); }
836 | "private" { $$ = CYNew CYIdentifier("private"); }
837 | "protected" { $$ = CYNew CYIdentifier("protected"); }
838 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
839 | "public" { $$ = CYNew CYIdentifier("public"); }
840 | "set" { $$ = CYNew CYIdentifier("set"); }
841 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
842 | "throws" { $$ = CYNew CYIdentifier("throws"); }
843 | "transient" { $$ = CYNew CYIdentifier("transient"); }
844 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
846 | "bool" { $$ = CYNew CYIdentifier("bool"); }
847 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
848 | "id" { $$ = CYNew CYIdentifier("id"); }
849 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
855 | "char" { $$ = CYNew CYIdentifier("char"); }
856 | "int" { $$ = CYNew CYIdentifier("int"); }
857 | "long" { $$ = CYNew CYIdentifier("long"); }
858 | "short" { $$ = CYNew CYIdentifier("short"); }
859 | "static" { $$ = CYNew CYIdentifier("static"); }
860 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
862 | "extern" { $$ = CYNew CYIdentifier("extern"); }
863 | "signed" { $$ = CYNew CYIdentifier("signed"); }
864 | "typedef" { $$ = CYNew CYIdentifier("typedef"); }
865 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
868 | "nil" { $$ = CYNew CYIdentifier("nil"); }
869 | "NO" { $$ = CYNew CYIdentifier("NO"); }
870 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
871 | "YES" { $$ = CYNew CYIdentifier("YES"); }
875 /* 12.2 Primary Expression {{{ */
877 : "this" { $$ = CYNew CYThis(); }
878 | IdentifierReference { $$ = $1; }
879 | Literal { $$ = $1; }
880 | ArrayLiteral { $$ = $1; }
881 | ObjectLiteral { $$ = $1; }
882 | FunctionExpression { $$ = $1; }
883 | ClassExpression { $$ = $1; }
884 | GeneratorExpression { $$ = $1; }
885 | RegularExpressionLiteral { $$ = $1; }
886 | TemplateLiteral { $$ = $1; }
887 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) CYERR(@1, "invalid parenthetical"); $$ = $1; }
888 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
891 CoverParenthesizedExpressionAndArrowParameterList
892 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
893 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
894 | "(" LexPushInOff LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
895 | "(" LexPushInOff Expression "," LexSetRegExp "..." BindingIdentifier ")" LexPopIn { CYNOT(@$); }
898 /* 12.2.4 Literals {{{ */
900 : NullLiteral { $$ = $1; }
901 | BooleanLiteral { $$ = $1; }
902 | NumericLiteral { $$ = $1; }
903 | StringLiteral { $$ = $1; }
906 /* 12.2.5 Array Initializer {{{ */
908 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
912 : AssignmentExpressionOpt "," ElementListOpt { $$ = CYNew CYElementValue($1, $3); }
913 | LexSetRegExp "..." AssignmentExpression { $$ = CYNew CYElementSpread($3); }
914 | AssignmentExpression { $$ = CYNew CYElementValue($1, NULL); }
918 : ElementList { $$ = $1; }
919 | LexSetRegExp { $$ = NULL; }
922 /* 12.2.6 Object Initializer {{{ */
924 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
927 PropertyDefinitionList_
928 : "," PropertyDefinitionListOpt { $$ = $2; }
932 PropertyDefinitionList
933 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
936 PropertyDefinitionListOpt
937 : LexSetRegExp PropertyDefinitionList { $$ = $2; }
938 | LexSetRegExp { $$ = NULL; }
942 : IdentifierReference { $$ = CYNew CYPropertyValue($1->name_, $1); }
943 | CoverInitializedName { CYNOT(@$); }
944 | PropertyName ":" AssignmentExpression { $$ = CYNew CYPropertyValue($1, $3); }
945 | MethodDefinition { $$ = $1; }
949 : LiteralPropertyName { $$ = $1; }
950 | ComputedPropertyName { $$ = $1; }
954 : IdentifierName { $$ = $1; }
955 | StringLiteral { $$ = $1; }
956 | NumericLiteral { $$ = $1; }
960 : "[" AssignmentExpression "]" { $$ = CYNew CYComputed($2); }
964 : IdentifierReference Initializer
968 : "=" AssignmentExpression { $$ = $2; }
972 : Initializer { $$ = $1; }
976 /* 12.2.9 Template Literals {{{ */
978 : NoSubstitutionTemplate { $$ = CYNew CYTemplate($1, NULL); }
979 | TemplateHead TemplateSpans { $$ = CYNew CYTemplate($1, $2); }
983 : Expression TemplateMiddle TemplateSpans { $$ = CYNew CYSpan($1, $2, $3); }
984 | Expression TemplateTail { $$ = CYNew CYSpan($1, $2, NULL); }
988 /* 12.3 Left-Hand-Side Expressions {{{ */
990 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
991 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
992 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
993 | TemplateLiteral { CYNOT(@$); }
997 : LexSetRegExp PrimaryExpression { $$ = $2; }
998 | MemberExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
999 | SuperProperty { $$ = $1; }
1000 | MetaProperty { CYNOT(@$); }
1001 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
1005 : LexSetRegExp "!super" "[" Expression "]" { $$ = CYNew CYSuperAccess($4); }
1006 | LexSetRegExp "!super" "." IdentifierName { $$ = CYNew CYSuperAccess(CYNew CYString($4)); }
1014 : LexSetRegExp "new" LexSetRegExp "." "target"
1018 : MemberExpression { $$ = $1; }
1019 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
1028 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
1029 | SuperCall { $$ = $1; }
1030 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
1034 : LexSetRegExp "!super" Arguments { $$ = CYNew CYSuperCall($3); }
1038 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
1042 : "," ArgumentList { $$ = $2; }
1047 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
1048 | LexSetRegExp "..." AssignmentExpression { CYNOT(@$); }
1052 : ArgumentList { $$ = $1; }
1053 | LexSetRegExp { $$ = NULL; }
1056 LeftHandSideExpression
1057 : NewExpression { $$ = $1; }
1058 | CallExpression { $$ = $1; }
1061 /* 12.4 Postfix Expressions {{{ */
1063 : %prec "" LeftHandSideExpression { $$ = $1; }
1064 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
1065 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
1068 /* 12.5 Unary Operators {{{ */
1070 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
1071 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
1072 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
1073 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1074 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
1075 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1076 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
1077 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
1078 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
1079 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
1080 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
1084 : %prec "" PostfixExpression { $$ = $1; }
1085 | LexSetRegExp UnaryExpression_ { $$ = $2; }
1088 /* 12.6 Multiplicative Operators {{{ */
1089 MultiplicativeExpression
1090 : UnaryExpression { $$ = $1; }
1091 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
1092 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
1093 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
1096 /* 12.7 Additive Operators {{{ */
1098 : MultiplicativeExpression { $$ = $1; }
1099 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
1100 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
1103 /* 12.8 Bitwise Shift Operators {{{ */
1105 : AdditiveExpression { $$ = $1; }
1106 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
1107 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
1108 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
1111 /* 12.9 Relational Operators {{{ */
1112 RelationalExpression
1113 : ShiftExpression { $$ = $1; }
1114 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1115 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1116 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1117 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1118 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1119 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1122 /* 12.10 Equality Operators {{{ */
1124 : RelationalExpression { $$ = $1; }
1125 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1126 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1127 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1128 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1131 /* 12.11 Binary Bitwise Operators {{{ */
1132 BitwiseANDExpression
1133 : EqualityExpression { $$ = $1; }
1134 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1137 BitwiseXORExpression
1138 : BitwiseANDExpression { $$ = $1; }
1139 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1143 : BitwiseXORExpression { $$ = $1; }
1144 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1147 /* 12.12 Binary Logical Operators {{{ */
1148 LogicalANDExpression
1149 : BitwiseORExpression { $$ = $1; }
1150 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1154 : LogicalANDExpression { $$ = $1; }
1155 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1158 /* 12.13 Conditional Operator ( ? : ) {{{ */
1159 ConditionalExpression
1160 : LogicalORExpression { $$ = $1; }
1161 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1164 /* 12.14 Assignment Operators {{{ */
1165 AssignmentExpression
1166 : ConditionalExpression { $$ = $1; }
1167 | LexSetRegExp YieldExpression { $$ = $2; }
1168 | ArrowFunction { $$ = $1; }
1169 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1170 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1171 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1172 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1173 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1174 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1175 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1176 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1177 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1178 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1179 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1180 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1183 AssignmentExpressionOpt
1184 : AssignmentExpression { $$ = $1; }
1185 | LexSetRegExp { $$ = NULL; }
1188 /* 12.15 Comma Operator ( , ) {{{ */
1190 : AssignmentExpression { $$ = $1; }
1191 | Expression "," AssignmentExpression { $$ = CYNew CYCompound($1, $3); }
1195 : Expression { $$ = $1; }
1196 | LexSetRegExp { $$ = NULL; }
1200 /* 13 Statements and Declarations {{{ */
1202 : BlockStatement { $$ = $1; }
1203 | VariableStatement { $$ = $1; }
1204 | EmptyStatement { $$ = $1; }
1205 | IfStatement { $$ = $1; }
1206 | BreakableStatement { $$ = $1; }
1207 | ContinueStatement { $$ = $1; }
1208 | BreakStatement { $$ = $1; }
1209 | ReturnStatement { $$ = $1; }
1210 | WithStatement { $$ = $1; }
1211 | LabelledStatement { $$ = $1; }
1212 | ThrowStatement { $$ = $1; }
1213 | TryStatement { $$ = $1; }
1214 | DebuggerStatement { $$ = $1; }
1218 : LexSetRegExp Statement__ { $$ = $2; }
1219 | ExpressionStatement { $$ = $1; }
1223 : LexSetStatement Statement_ { $$ = $2; }
1227 : HoistableDeclaration { $$ = $1; }
1228 | ClassDeclaration { $$ = $1; }
1229 | LexicalDeclaration { $$ = $1; }
1233 : LexSetRegExp Declaration__ { $$ = $2; }
1237 : LexSetStatement Declaration_ { $$ = $2; }
1240 HoistableDeclaration
1241 : FunctionDeclaration { $$ = $1; }
1242 | GeneratorDeclaration { $$ = $1; }
1246 : IterationStatement { $$ = $1; }
1247 | SwitchStatement { $$ = $1; }
1250 /* 13.2 Block {{{ */
1252 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1256 : BRACE StatementListOpt "}" { $$ = $2; }
1260 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1264 : StatementList { $$ = $1; }
1265 | LexSetStatement LexSetRegExp { $$ = NULL; }
1269 : Statement { $$ = $1; }
1270 | Declaration { $$ = $1; }
1273 /* 13.3 Let and Const Declarations {{{ */
1275 : LetOrConst BindingList Terminator { $$ = CYNew CYLet($2); }
1284 : "," BindingList { $$ = $2; }
1289 : LexicalBinding BindingList_ { $$ = CYNew CYDeclarations($1, $2); }
1293 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1294 | BindingPattern Initializer { CYNOT(@1); }
1297 /* 13.3.2 Variable Statement {{{ */
1299 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1302 VariableDeclarationList_
1303 : "," VariableDeclarationList { $$ = $2; }
1307 VariableDeclarationList
1308 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1312 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1313 | BindingPattern Initializer { CYNOT(@1); }
1316 /* 13.3.3 Destructuring Binding Patterns {{{ */
1318 : ObjectBindingPattern
1319 | ArrayBindingPattern
1322 ObjectBindingPattern
1323 : BRACE BindingPropertyListOpt "}"
1327 : "[" { CYNOT(@$); }
1330 BindingPropertyList_
1331 : "," BindingPropertyListOpt
1336 : BindingProperty BindingPropertyList_
1339 BindingPropertyListOpt
1340 : BindingPropertyList
1346 | PropertyName ":" BindingElement
1350 : SingleNameBinding { $$ = $1; }
1351 | BindingPattern InitializerOpt { CYNOT(@$); }
1355 : BindingIdentifier InitializerOpt { $$ = CYNew CYDeclaration($1, $2); }
1359 : "..." BindingIdentifier
1362 /* 13.4 Empty Statement {{{ */
1364 : ";" { $$ = CYNew CYEmpty(); }
1367 /* 13.5 Expression Statement {{{ */
1369 : Expression Terminator { $$ = CYNew CYExpress($1); }
1372 /* 13.6 The if Statement {{{ */
1374 : "else" Statement { $$ = $2; }
1375 | %prec "if" { $$ = NULL; }
1379 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1382 /* 13.7 Iteration Statements {{{ */
1384 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1385 | "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1386 | "for" "(" LexPushInOn ForStatementInitializer ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1387 | "for" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1388 | "for" "(" LexPushInOn ForInStatementInitializer "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1391 ForStatementInitializer
1392 : ExpressionOpt { $$ = $1; }
1393 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1394 | LexSetRegExp LexicalDeclaration { CYNOT(@$); }
1397 ForInStatementInitializer
1398 : LeftHandSideExpression { $$ = $1; }
1399 | LexSetRegExp Var_ ForBinding { $$ = $3; }
1400 | LexSetRegExp ForDeclaration { $$ = $2; }
1404 : LetOrConst ForBinding { $$ = $2; }
1408 : BindingIdentifier { $$ = CYNew CYDeclaration($1, NULL); }
1409 | BindingPattern { CYNOT(@1); }
1412 /* 13.8 The continue Statement {{{ */
1414 : "continue" LexNewLine
1418 : Continue TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1419 | Continue Identifier Terminator { $$ = CYNew CYContinue($2); }
1422 /* 13.9 The break Statement {{{ */
1424 : "break" LexNewLine
1428 : Break TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1429 | Break Identifier Terminator { $$ = CYNew CYBreak($2); }
1432 /* 13.10 The return Statement {{{ */
1434 : "!return" LexNewLine
1438 : Return LexSetRegExp TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1439 | Return Expression Terminator { $$ = CYNew CYReturn($2); }
1442 /* 13.11 The with Statement {{{ */
1444 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1447 /* 13.12 The switch Statement {{{ */
1449 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1453 : BRACE CaseClausesOpt "}" { $$ = $2; }
1457 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1461 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1462 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1466 // XXX: the standard makes certain you can only have one of these
1468 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1471 /* 13.13 Labelled Statements {{{ */
1473 : LabelIdentifier ":" LabelledItem { $$ = CYNew CYLabel($1, $3); }
1477 : Statement { $$ = $1; }
1478 | LexSetStatement LexSetRegExp FunctionDeclaration { $$ = $3; }
1481 /* 13.14 The throw Statement {{{ */
1483 : "throw" LexNewLine
1487 : Throw LexSetRegExp TerminatorSoft { CYERR(@1, "throw without exception"); }
1488 | Throw Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1491 /* 13.15 The try Statement {{{ */
1493 : "try" Block Catch { $$ = CYNew cy::Syntax::Try($2, $3, NULL); }
1494 | "try" Block Finally { $$ = CYNew cy::Syntax::Try($2, NULL, $3); }
1495 | "try" Block Catch Finally { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1499 : "catch" "(" CatchParameter ")" Block { $$ = CYNew cy::Syntax::Catch($3, $5); }
1503 : "finally" Block { $$ = CYNew CYFinally($2); }
1507 : BindingIdentifier { $$ = $1; }
1508 | BindingPattern { CYNOT(@$); }
1511 /* 13.16 The debugger Statement {{{ */
1513 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1517 /* 14.1 Function Definitions {{{ */
1519 : ";function" BindingIdentifier "(" FormalParameters ")" BRACE LexPushSuperOff FunctionBody "}" LexPopSuper { $$ = CYNew CYFunctionStatement($2, $4, $8); }
1523 : "function" BindingIdentifierOpt "(" LexPushInOff FormalParameters ")" LexPopIn BRACE LexPushSuperOff LexPushInOff FunctionBody "}" LexPopIn LexPopSuper { $$ = CYNew CYFunctionExpression($2, $5, $11); }
1526 StrictFormalParameters
1527 : FormalParameters { $$ = $1; }
1532 | FormalParameterList
1535 FormalParameterList_
1536 : "," FormalParameterList { $$ = $2; }
1541 : FunctionRestParameter { CYNOT(@$); }
1542 | FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1545 FunctionRestParameter
1546 : BindingRestElement
1550 : BindingElement { $$ = $1; }
1554 : LexPushYieldOff FunctionStatementList LexPopYield { $$ = $2; }
1557 FunctionStatementList
1558 : LexPushReturnOn StatementListOpt LexPopReturn { $$ = $2; }
1561 /* 14.2 Arrow Function Definitions {{{ */
1563 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1567 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1568 | CoverParenthesizedExpressionAndArrowParameterList { if ($1 == NULL) $$ = NULL; else { $$ = $1->expression_->Parameter(); if ($$ == NULL) CYERR(@1, "invalid parameter list"); } }
1572 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1573 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1576 /* 14.3 Method Definitions {{{ */
1578 : PropertyName "(" StrictFormalParameters ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyMethod($1, $3, $6); }
1579 | GeneratorMethod { $$ = $1; }
1580 | "get" PropertyName "(" ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertyGetter($2, $6); }
1581 | "set" PropertyName "(" PropertySetParameterList ")" BRACE FunctionBody "}" { $$ = CYNew CYPropertySetter($2, CYNew CYFunctionParameter($4), $7); }
1584 PropertySetParameterList
1585 : FormalParameter { $$ = $1; }
1588 /* 14.4 Generator Function Definitions {{{ */
1590 : "*" PropertyName "(" StrictFormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($2, $4, $7); */ }
1593 GeneratorDeclaration
1594 : ";function" "*" BindingIdentifier "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($3, $5, $8); */ }
1598 : "function" "*" BindingIdentifierOpt "(" FormalParameters ")" BRACE GeneratorBody "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($3, $5, $8); */ }
1602 : LexPushYieldOn FunctionStatementList LexPopYield { $$ = $2; }
1606 : "!yield" LexNewLine LexNoStar
1610 : Yield LexSetRegExp "\n" { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1611 | Yield AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldValue($2); */ }
1612 | Yield LexSetRegExp YieldStar AssignmentExpression { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($4); */ }
1615 /* 14.5 Class Definitions {{{ */
1617 : ";class" BindingIdentifier ClassTail { $$ = CYNew CYClassStatement($2, $3); }
1621 : "class" BindingIdentifierOpt ClassTail { $$ = CYNew CYClassExpression($2, $3); }
1625 : ClassHeritageOpt { driver.class_.push($1); } BRACE LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $1; }
1629 : "extends" LeftHandSideExpression { $$ = CYNew CYClassTail($2); }
1633 : ClassHeritage { $$ = $1; }
1634 | { $$ = CYNew CYClassTail(NULL); }
1647 : ClassElementListOpt ClassElement
1656 : MethodDefinition { if (CYFunctionExpression *constructor = $1->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$1; }
1657 | "static" MethodDefinition { driver.class_.top()->static_->*$2; }
1662 /* 15.1 Scripts {{{ */
1664 : ScriptBodyOpt { driver.script_ = CYNew CYScript($1); }
1668 : StatementList { $$ = $1; }
1672 : ScriptBody { $$ = $1; }
1673 | LexSetStatement LexSetRegExp { $$ = NULL; }
1676 /* 15.2 Modules {{{ */
1691 : ModuleItemListOpt ModuleItem
1700 : LexSetStatement LexSetRegExp ImportDeclaration
1701 | LexSetStatement LexSetRegExp ExportDeclaration
1705 /* 15.2.2 Imports {{{ */
1707 : "import" ImportClause FromClause Terminator
1708 | "import" ModuleSpecifier Terminator
1712 : ImportedDefaultBinding
1715 | ImportedDefaultBinding "," NameSpaceImport
1716 | ImportedDefaultBinding "," NamedImports
1719 ImportedDefaultBinding
1724 : "*" "as" ImportedBinding
1728 : BRACE ImportsListOpt "}"
1732 : "from" ModuleSpecifier
1736 : "," ImportsListOpt
1741 : ImportSpecifier ImportsList_
1751 | IdentifierName "as" ImportedBinding
1762 /* 15.2.3 Exports {{{ */
1764 : "*" FromClause Terminator
1765 | ExportClause FromClause Terminator
1766 | ExportClause Terminator
1768 | "default" LexSetStatement LexSetRegExp HoistableDeclaration
1769 | "default" LexSetStatement LexSetRegExp ClassDeclaration
1770 | "default" LexSetStatement AssignmentExpression Terminator
1774 : "export" LexSetStatement LexSetRegExp ExportDeclaration_
1775 | "export" Declaration
1779 : ";{" ExportsListOpt "}"
1783 : "," ExportsListOpt
1788 : ExportSpecifier ExportsList_
1798 | IdentifierName "as" IdentifierName
1803 /* Cycript (C): Type Encoding {{{ */
1805 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1806 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1810 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1811 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1812 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1813 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1814 | TypeSignifier { $$ = $1; }
1815 | { $$ = CYNew CYTypedIdentifier(@$); }
1819 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1824 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1825 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1829 : PrefixedType { $$ = $1; }
1830 | SuffixedType { $$ = $1; }
1831 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1832 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1836 : "int" { $$ = CYNew CYTypeVariable("int"); }
1837 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1838 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1839 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1840 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1844 : IntegerType { $$ = $1; }
1845 | { $$ = CYNew CYTypeVariable("int"); }
1849 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1850 | IntegerType { $$ = $1; }
1851 | "void" { $$ = CYNew CYTypeVoid(); }
1852 | "char" { $$ = CYNew CYTypeVariable("char"); }
1853 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1854 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1858 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1862 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1868 /* Cycript (Objective-C): @class Declaration {{{ */
1870 /* XXX: why the hell did I choose MemberExpression? */
1871 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1875 ImplementationFieldListOpt
1876 : TypedIdentifier ";" ImplementationFieldListOpt { $$ = CYNew CYImplementationField($1, $3); }
1877 | LexSetRegExp { $$ = NULL; }
1880 ImplementationFields
1881 : BRACE ImplementationFieldListOpt "}" { $$ = $2; }
1885 : "+" { $$ = false; }
1886 | "-" { $$ = true; }
1890 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) CYERR($3->location_, "unexpected identifier"); $$ = $3; }
1891 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1895 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1898 MessageParameterList
1899 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1902 MessageParameterListOpt
1903 : MessageParameterList { $$ = $1; }
1908 : MessageParameterList { $$ = $1; }
1909 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
1912 ClassMessageDeclaration
1913 : MessageScope TypeOpt MessageParameters BRACE LexPushSuperOn FunctionBody "}" LexPopSuper { $$ = CYNew CYMessage($1, $2, $3, $6); }
1916 ClassMessageDeclarationListOpt
1917 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1921 // XXX: this should be AssignmentExpressionNoRight
1923 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1927 : "," ClassProtocols { $$ = $2; }
1931 ClassProtocolListOpt
1932 : "<" ClassProtocols ">" { $$ = $2; }
1936 ImplementationStatement
1937 : "@implementation" Identifier ClassSuperOpt ClassProtocolListOpt ImplementationFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYImplementation($2, $3, $4, $5, $6); }
1945 : "@implementation" Identifier CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1949 : ImplementationStatement { $$ = $1; }
1950 | CategoryStatement { $$ = $1; }
1953 /* Cycript (Objective-C): Send Message {{{ */
1955 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1960 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1961 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1965 : SelectorCall { $$ = $1; }
1966 | VariadicCall { $$ = $1; }
1970 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYWord(""), $3, $4); }
1974 : SelectorCall { $$ = $1; }
1975 | Word { $$ = CYNew CYArgument($1, NULL); }
1979 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1980 | "[" LexPushInOff LexSetRegExp "!super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1984 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1988 : SelectorExpression_ { $$ = $1; }
1989 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1992 SelectorExpressionOpt
1993 : SelectorExpression_ { $$ = $1; }
1998 : MessageExpression { $$ = $1; }
1999 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
2004 /* Cycript: @import Directive {{{ */
2006 : ModulePath "." Word { $$ = CYNew CYModule($3, $1); }
2007 | Word { $$ = CYNew CYModule($1); }
2011 : "@import" ModulePath { $$ = CYNew CYImport($2); }
2016 /* Cycript (Objective-C): Boxed Expressions {{{ */
2018 : NullLiteral { $$ = $1; }
2019 | BooleanLiteral { $$ = $1; }
2020 | NumericLiteral { $$ = $1; }
2021 | StringLiteral { $$ = $1; }
2022 | ArrayLiteral { $$ = $1; }
2023 | ObjectLiteral { $$ = $1; }
2024 | CoverParenthesizedExpressionAndArrowParameterList { $$ = $1; }
2025 | "YES" { $$ = CYNew CYTrue(); }
2026 | "NO" { $$ = CYNew CYFalse(); }
2030 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
2031 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2032 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2033 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2034 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2035 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2038 /* Cycript (Objective-C): Block Expressions {{{ */
2040 : "^" 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"); }
2043 /* Cycript (Objective-C): Instance Literals {{{ */
2045 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
2051 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2052 LeftHandSideExpression
2053 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
2057 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
2061 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
2062 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
2063 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2066 /* Cycript (C): auto Compatibility {{{ */
2071 /* Cycript (C): Lambda Expressions {{{ */
2073 : "," TypedParameterList { $$ = $2; }
2078 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
2081 TypedParameterListOpt
2082 : TypedParameterList { $$ = $1; }
2087 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
2090 /* Cycript (C): Type Definitions {{{ */
2092 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) CYERR($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
2095 /* Cycript (C): extern "C" {{{ */
2097 : "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); }
2104 /* Lexer State {{{ */
2106 : { driver.PushCondition(CYDriver::RegExpCondition); }
2110 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2114 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2118 : { driver.PopCondition(); }
2122 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2126 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2129 /* Virtual Tokens {{{ */
2136 /* 8.1 Context Keywords {{{ */
2138 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2139 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2142 /* 8.3 XML Initializer Input Elements {{{ */
2144 : XMLComment { $$ = $1; }
2145 | XMLCDATA { $$ = $1; }
2146 | XMLPI { $$ = $1; }
2150 /* 11.1 Primary Expressions {{{ */
2152 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2153 | XMLInitialiser { $$ = $1; }
2154 | XMLListInitialiser { $$ = $1; }
2158 : AttributeIdentifier { $$ = $1; }
2159 | QualifiedIdentifier { $$ = $1; }
2160 | WildcardIdentifier { $$ = $1; }
2163 /* 11.1.1 Attribute Identifiers {{{ */
2165 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2169 : PropertySelector { $$ = $1; }
2170 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
2174 : Identifier { $$ = CYNew CYSelector($1); }
2175 | WildcardIdentifier { $$ = $1; }
2178 /* 11.1.2 Qualified Identifiers {{{ */
2179 QualifiedIdentifier_
2180 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2181 | QualifiedIdentifier { $$ = $1; }
2185 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2188 /* 11.1.3 Wildcard Identifiers {{{ */
2190 : "*" { $$ = CYNew CYWildcard(); }
2193 /* 11.1.4 XML Initializer {{{ */
2195 : XMLMarkup { $$ = $1; }
2196 | XMLElement { $$ = $1; }
2200 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2201 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2205 : LexPushXMLTag XMLTagName XMLAttributes
2209 : BRACE LexPushRegExp Expression LexPop "}"
2218 : XMLAttributes_ XMLAttribute
2223 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2224 | XMLAttributes_ XMLWhitespaceOpt
2233 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2237 : XMLExpression XMLElementContentOpt
2238 | XMLMarkup XMLElementContentOpt
2239 | XMLText XMLElementContentOpt
2240 | XMLElement XMLElementContentOpt
2243 XMLElementContentOpt
2248 /* 11.1.5 XMLList Initializer {{{ */
2250 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2254 /* 11.2 Left-Hand-Side Expressions {{{ */
2256 : Identifier { $$ = $1; }
2257 | PropertyIdentifier { $$ = $1; }
2261 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2262 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2263 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2266 /* 12.1 The default xml namespace Statement {{{ */
2267 /* XXX: DefaultXMLNamespaceStatement
2268 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2272 : DefaultXMLNamespaceStatement { $$ = $1; }
2277 /* JavaScript FTL: Array Comprehensions {{{ */
2279 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
2283 : "for" "each" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($5, $8); }
2286 /* JavaScript FTL: for each {{{ */
2288 : "for" "each" "(" LexPushInOn ForInStatementInitializer "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
2292 /* JavaScript FTW: Array Comprehensions {{{ */
2294 : ArrayComprehension
2298 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
2302 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
2307 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
2308 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
2312 : "for" "(" LexPushInOn LexicalBinding "!in" LexPopIn Expression ")" { $$ = CYNew CYForInComprehension($4, $7); }
2313 | "for" "(" LexPushInOn LexicalBinding "of" LexPopIn Expression ")" { $$ = CYNew CYForOfComprehension($4, $7); }
2317 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
2320 /* JavaScript FTW: Coalesce Operator {{{ */
2321 ConditionalExpression
2322 : LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
2325 /* JavaScript FTW: Named Arguments {{{ */
2327 : LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
2330 /* JavaScript FTW: Ruby Blocks {{{ */
2331 RubyProcParameterList_
2332 : "," RubyProcParameterList { $$ = $2; }
2336 RubyProcParameterList
2337 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
2342 : LexSetRegExp "|" RubyProcParameterList "|" { $$ = $3; }
2343 | LexSetRegExp "||" { $$ = NULL; }
2346 RubyProcParametersOpt
2347 : RubyProcParameters { $$ = $1; }
2352 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
2356 : BRACE LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
2360 : PostfixExpression RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
2366 bool CYDriver::Parse(CYMark mark) {
2368 CYLocal<CYPool> local(&pool_);
2369 cy::parser parser(*this);
2371 parser.set_debug_level(debug_);
2373 return parser.parse() != 0;
2376 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2380 CYDriver::Error error;
2381 error.warning_ = true;
2382 error.location_ = location;
2383 error.message_ = message;
2384 errors_.push_back(error);
2387 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2388 CYDriver::Error error;
2389 error.warning_ = false;
2390 error.location_ = location;
2391 error.message_ = message;
2392 driver.errors_.push_back(error);