]> git.saurik.com Git - cycript.git/blob - Parser.ypp.in
Drop to android-9 platform using -fno-PIE wrapper.
[cycript.git] / Parser.ypp.in
1 /* Cycript - The Truly Universal Scripting Language
2 * Copyright (C) 2009-2016 Jay Freeman (saurik)
3 */
4
5 /* GNU Affero General Public License, Version 3 {{{ */
6 /*
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.
11
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.
16
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/>.
19 **/
20 /* }}} */
21
22 %code top {
23 #define YYSTACKEXPANDABLE 1
24 }
25
26 %code requires {
27 #include "Driver.hpp"
28 #include "Parser.hpp"
29 #include "Stack.hpp"
30 #include "Syntax.hpp"
31 #define CYNew new(driver.pool_)
32
33 @begin ObjectiveC
34 #include "ObjectiveC/Syntax.hpp"
35 @end
36
37 @begin E4X
38 #include "E4X/Syntax.hpp"
39 @end
40
41 #include "Highlight.hpp"
42 }
43
44 %union { bool bool_; }
45
46 %union { CYMember *access_; }
47 %union { CYArgument *argument_; }
48 %union { CYAssignment *assignment_; }
49 %union { CYBinding *binding_; }
50 %union { CYBindings *bindings_; }
51 %union { CYBoolean *boolean_; }
52 %union { CYBraced *braced_; }
53 %union { CYClause *clause_; }
54 %union { cy::Syntax::Catch *catch_; }
55 %union { CYClassTail *classTail_; }
56 %union { CYComprehension *comprehension_; }
57 %union { CYElement *element_; }
58 %union { CYEnumConstant *constant_; }
59 %union { CYExpression *expression_; }
60 %union { CYFalse *false_; }
61 %union { CYVariable *variable_; }
62 %union { CYFinally *finally_; }
63 %union { CYForInitializer *for_; }
64 %union { CYForInInitializer *forin_; }
65 %union { CYFunctionParameter *functionParameter_; }
66 %union { CYIdentifier *identifier_; }
67 %union { CYImportSpecifier *import_; }
68 %union { CYInfix *infix_; }
69 %union { CYLiteral *literal_; }
70 %union { CYMethod *method_; }
71 %union { CYModule *module_; }
72 %union { CYNull *null_; }
73 %union { CYNumber *number_; }
74 %union { CYParenthetical *parenthetical_; }
75 %union { CYProperty *property_; }
76 %union { CYPropertyName *propertyName_; }
77 %union { CYTypeSigning signing_; }
78 %union { CYSpan *span_; }
79 %union { CYStatement *statement_; }
80 %union { CYString *string_; }
81 %union { CYTarget *target_; }
82 %union { CYThis *this_; }
83 %union { CYTrue *true_; }
84 %union { CYWord *word_; }
85
86 @begin C
87 %union { CYTypeIntegral *integral_; }
88 %union { CYTypeStructField *structField_; }
89 %union { CYTypeModifier *modifier_; }
90 %union { CYTypeSpecifier *specifier_; }
91 %union { CYTypedFormal *typedFormal_; }
92 %union { CYTypedIdentifier *typedIdentifier_; }
93 %union { CYTypedParameter *typedParameter_; }
94 @end
95
96 @begin ObjectiveC
97 %union { CYObjCKeyValue *keyValue_; }
98 %union { CYImplementationField *implementationField_; }
99 %union { CYMessage *message_; }
100 %union { CYMessageParameter *messageParameter_; }
101 %union { CYProtocol *protocol_; }
102 %union { CYSelectorPart *selector_; }
103 @end
104
105 @begin E4X
106 %union { CYAttribute *attribute_; }
107 %union { CYPropertyIdentifier *propertyIdentifier_; }
108 %union { CYSelector *selector_; }
109 @end
110
111 %code provides {
112
113 struct YYSTYPE {
114 cy::parser::semantic_type semantic_;
115 hi::Value highlight_;
116 };
117
118 int cylex(YYSTYPE *, CYLocation *, void *);
119
120 }
121
122 %code {
123
124 #undef yylex
125
126 typedef cy::parser::token tk;
127
128 _finline int cylex_(cy::parser::semantic_type *semantic, CYLocation *location, CYDriver &driver) {
129 driver.newline_ = false;
130 lex:
131 YYSTYPE data;
132 int token(cylex(&data, location, driver.scanner_));
133 *semantic = data.semantic_;
134
135 switch (token) {
136 case tk::OpenBrace:
137 case tk::OpenBracket:
138 case tk::OpenParen:
139 driver.in_.push(false);
140 break;
141
142 case tk::_in_:
143 if (driver.in_.top())
144 token = tk::_in__;
145 break;
146
147 case tk::CloseBrace:
148 case tk::CloseBracket:
149 case tk::CloseParen:
150 driver.in_.pop();
151 break;
152
153
154 case tk::_yield_:
155 if (driver.yield_.top())
156 token = tk::_yield__;
157 break;
158
159 case tk::NewLine:
160 driver.newline_ = true;
161 goto lex;
162 break;
163 }
164
165 return token;
166 }
167
168 #define yylex_(semantic, location, driver) ({ \
169 int type; \
170 if (driver.hold_ == cy::parser::empty_symbol) \
171 type = yytranslate_(cylex_(semantic, location, driver)); \
172 else { \
173 type = driver.hold_; \
174 driver.hold_ = cy::parser::empty_symbol; \
175 } \
176 type; })
177
178 #define CYLEX() do if (yyla.empty()) { \
179 YYCDEBUG << "Mapping a token: "; \
180 yyla.type = yylex_(&yyla.value, &yyla.location, driver); \
181 YY_SYMBOL_PRINT("Next token is", yyla); \
182 } while (false)
183
184 #define CYMAP(to, from) do { \
185 CYLEX(); \
186 if (yyla.type == yytranslate_(token::from)) \
187 yyla.type = yytranslate_(token::to); \
188 } while (false)
189
190 #define CYHLD(location, token) do { \
191 if (driver.hold_ != empty_symbol) \
192 CYERR(location, "unexpected hold"); \
193 driver.hold_ = yyla.type; \
194 yyla.type = yytranslate_(token); \
195 } while (false)
196
197 #define CYERR(location, message) do { \
198 error(location, message); \
199 YYABORT; \
200 } while (false)
201
202 #define CYEOK() do { \
203 yyerrok; \
204 driver.errors_.pop_back(); \
205 } while (false)
206
207 #define CYNOT(location) \
208 CYERR(location, "unimplemented feature")
209
210 #define CYMPT(location) do { \
211 if (!yyla.empty() && yyla.type_get() != yyeof_) \
212 CYERR(location, "unexpected lookahead"); \
213 } while (false)
214
215 }
216
217 %name-prefix "cy"
218
219 %language "C++"
220
221 %initial-action {
222 @$.begin.filename = @$.end.filename = &driver.filename_;
223
224 switch (driver.mark_) {
225 case CYMarkScript:
226 driver.hold_ = yytranslate_(token::MarkScript);
227 break;
228 case CYMarkModule:
229 driver.hold_ = yytranslate_(token::MarkModule);
230 break;
231 case CYMarkExpression:
232 driver.hold_ = yytranslate_(token::MarkExpression);
233 break;
234 }
235 };
236
237 %locations
238 %defines
239
240 %define api.location.type { CYLocation }
241
242 //%glr-parser
243 //%expect 1
244
245 %error-verbose
246
247 %param { CYDriver &driver }
248
249 /* Token Declarations {{{ */
250 @begin E4X
251 %token XMLCDATA
252 %token XMLComment
253 %token XMLPI
254
255 %token XMLAttributeValue
256 %token XMLName
257 %token XMLTagCharacters
258 %token XMLText
259 %token XMLWhitespace
260 @end
261
262 @begin E4X
263 %token LeftRight "<>"
264 %token LeftSlashRight "</>"
265
266 %token SlashRight "/>"
267 %token LeftSlash "</"
268
269 %token PeriodPeriod ".."
270 @end
271
272 @begin E4X ObjectiveC
273 %token At "@"
274 @end
275
276 %token Ampersand "&"
277 %token AmpersandAmpersand "&&"
278 %token AmpersandEqual "&="
279 %token Carrot "^"
280 %token CarrotEqual "^="
281 %token Equal "="
282 %token EqualEqual "=="
283 %token EqualEqualEqual "==="
284 %token EqualRight "=>"
285 %token Exclamation "!"
286 %token ExclamationEqual "!="
287 %token ExclamationEqualEqual "!=="
288 %token Hyphen "-"
289 %token HyphenEqual "-="
290 %token HyphenHyphen "--"
291 %token HyphenRight "->"
292 %token Left "<"
293 %token LeftEqual "<="
294 %token LeftLeft "<<"
295 %token LeftLeftEqual "<<="
296 %token Percent "%"
297 %token PercentEqual "%="
298 %token Period "."
299 %token PeriodPeriodPeriod "..."
300 %token Pipe "|"
301 %token PipeEqual "|="
302 %token PipePipe "||"
303 %token Plus "+"
304 %token PlusEqual "+="
305 %token PlusPlus "++"
306 %token Right ">"
307 %token RightEqual ">="
308 %token RightRight ">>"
309 %token RightRightEqual ">>="
310 %token RightRightRight ">>>"
311 %token RightRightRightEqual ">>>="
312 %token Slash "/"
313 %token SlashEqual "/="
314 %token Star "*"
315 %token StarEqual "*="
316 %token Tilde "~"
317
318 %token Colon ":"
319 %token ColonColon "::"
320 %token Comma ","
321 %token Question "?"
322 %token SemiColon ";"
323 %token Pound "#"
324 %token NewLine "\n"
325 %token __ ""
326
327 %token Comment
328
329 %token OpenParen "("
330 %token CloseParen ")"
331
332 %token OpenBrace "{"
333 %token OpenBrace_ ";{"
334 %token OpenBrace_let "let {"
335 %token CloseBrace "}"
336
337 %token OpenBracket "["
338 %token OpenBracket_let "let ["
339 %token CloseBracket "]"
340
341 %token At_error_ "@error"
342
343 @begin Java
344 %token At_class_ "@class"
345 @end
346
347 @begin C
348 %token _typedef_ "typedef"
349 %token _unsigned_ "unsigned"
350 %token _signed_ "signed"
351 %token _struct_ "struct"
352 %token _extern_ "extern"
353 @end
354
355 @begin C
356 %token At_encode_ "@encode"
357 @end
358
359 @begin ObjectiveC
360 %token At_implementation_ "@implementation"
361 %token At_import_ "@import"
362 %token At_end_ "@end"
363 %token At_selector_ "@selector"
364 %token At_null_ "@null"
365 %token At_YES_ "@YES"
366 %token At_NO_ "@NO"
367 %token At_true_ "@true"
368 %token At_false_ "@false"
369 %token _YES_ "YES"
370 %token _NO_ "NO"
371 @end
372
373 %token _false_ "false"
374 %token _null_ "null"
375 %token _true_ "true"
376
377 %token _as_ "as"
378 %token _break_ "break"
379 %token _case_ "case"
380 %token _catch_ "catch"
381 %token _class_ "class"
382 %token _class__ ";class"
383 %token _const_ "const"
384 %token _continue_ "continue"
385 %token _debugger_ "debugger"
386 %token _default_ "default"
387 %token _delete_ "delete"
388 %token _do_ "do"
389 %token _else_ "else"
390 %token _enum_ "enum"
391 %token _export_ "export"
392 %token _extends_ "extends"
393 %token _finally_ "finally"
394 %token _for_ "for"
395 %token _function_ "function"
396 %token _function__ ";function"
397 %token _if_ "if"
398 %token _import_ "import"
399 %token _in_ "in"
400 %token _in__ "!in"
401 %token _Infinity_ "Infinity"
402 %token _instanceof_ "instanceof"
403 %token _new_ "new"
404 %token _return_ "return"
405 %token _super_ "super"
406 %token _switch_ "switch"
407 %token _target_ "target"
408 %token _this_ "this"
409 %token _throw_ "throw"
410 %token _try_ "try"
411 %token _typeof_ "typeof"
412 %token _var_ "var"
413 %token _void_ "void"
414 %token _while_ "while"
415 %token _with_ "with"
416
417 %token _abstract_ "abstract"
418 %token _await_ "await"
419 %token _boolean_ "boolean"
420 %token _byte_ "byte"
421 %token _char_ "char"
422 %token _constructor_ "constructor"
423 %token _double_ "double"
424 %token _eval_ "eval"
425 %token _final_ "final"
426 %token _float_ "float"
427 %token _from_ "from"
428 %token _get_ "get"
429 %token _goto_ "goto"
430 %token _implements_ "implements"
431 %token _int_ "int"
432 %token ___int128_ "__int128"
433 %token _interface_ "interface"
434 %token _let_ "let"
435 %token _let__ "!let"
436 %token _long_ "long"
437 %token _native_ "native"
438 %token _package_ "package"
439 %token _private_ "private"
440 %token _protected_ "protected"
441 %token ___proto___ "__proto__"
442 %token _prototype_ "prototype"
443 %token _public_ "public"
444 %token ___restrict_ "__restrict"
445 %token _restrict_ "restrict"
446 %token _set_ "set"
447 %token _short_ "short"
448 %token _static_ "static"
449 %token _synchronized_ "synchronized"
450 %token _throws_ "throws"
451 %token _transient_ "transient"
452 %token _typeid_ "typeid"
453 %token _volatile_ "volatile"
454 %token _yield_ "yield"
455 %token _yield__ "!yield"
456
457 %token _undefined_ "undefined"
458
459 @begin ObjectiveC
460 %token _bool_ "bool"
461 %token _BOOL_ "BOOL"
462 %token _id_ "id"
463 %token _nil_ "nil"
464 %token _NULL_ "NULL"
465 %token _SEL_ "SEL"
466 @end
467
468 %token _each_ "each"
469 %token _of_ "of"
470 %token _of__ "!of"
471
472 @begin E4X
473 %token _namespace_ "namespace"
474 %token _xml_ "xml"
475 @end
476
477 %token AutoComplete
478 %token YieldStar "yield *"
479
480 %token <identifier_> Identifier_
481 %token <number_> NumericLiteral
482 %token <string_> StringLiteral
483 %token <literal_> RegularExpressionLiteral_
484
485 %token <string_> NoSubstitutionTemplate
486 %token <string_> TemplateHead
487 %token <string_> TemplateMiddle
488 %token <string_> TemplateTail
489
490 %type <target_> AccessExpression
491 %type <expression_> AdditiveExpression
492 %type <argument_> ArgumentList_
493 %type <argument_> ArgumentList
494 %type <argument_> ArgumentListOpt
495 %type <argument_> Arguments
496 %type <target_> ArrayComprehension
497 %type <element_> ArrayElement
498 %type <literal_> ArrayLiteral
499 %type <expression_> ArrowFunction
500 %type <functionParameter_> ArrowParameters
501 %type <expression_> AssignmentExpression
502 %type <identifier_> BindingIdentifier
503 %type <identifier_> BindingIdentifierOpt
504 %type <bindings_> BindingList_
505 %type <bindings_> BindingList
506 %type <expression_> BitwiseANDExpression
507 %type <statement_> Block
508 %type <statement_> BlockStatement
509 %type <boolean_> BooleanLiteral
510 %type <binding_> BindingElement
511 %type <expression_> BitwiseORExpression
512 %type <expression_> BitwiseXORExpression
513 %type <target_> BracedExpression_
514 %type <target_> BracedExpression
515 %type <statement_> BreakStatement
516 %type <statement_> BreakableStatement
517 %type <expression_> CallExpression_
518 %type <target_> CallExpression
519 %type <clause_> CaseBlock
520 %type <clause_> CaseClause
521 %type <clause_> CaseClausesOpt
522 %type <catch_> Catch
523 %type <identifier_> CatchParameter
524 %type <statement_> ClassDeclaration
525 %type <target_> ClassExpression
526 %type <classTail_> ClassHeritage
527 %type <classTail_> ClassHeritageOpt
528 %type <classTail_> ClassTail
529 %type <target_> Comprehension
530 %type <comprehension_> ComprehensionFor
531 %type <comprehension_> ComprehensionIf
532 %type <comprehension_> ComprehensionTail
533 %type <propertyName_> ComputedPropertyName
534 %type <expression_> ConditionalExpression
535 %type <statement_> ContinueStatement
536 %type <statement_> ConciseBody
537 %type <parenthetical_> CoverParenthesizedExpressionAndArrowParameterList
538 %type <statement_> DebuggerStatement
539 %type <statement_> Declaration_
540 %type <statement_> Declaration
541 %type <clause_> DefaultClause
542 %type <element_> ElementList_
543 %type <element_> ElementList
544 %type <element_> ElementListOpt
545 %type <statement_> ElseStatementOpt
546 %type <for_> EmptyStatement
547 %type <expression_> EqualityExpression
548 %type <expression_> Expression
549 %type <expression_> ExpressionOpt
550 %type <for_> ExpressionStatement_
551 %type <statement_> ExpressionStatement
552 %type <statement_> ExternC
553 %type <statement_> ExternCStatement
554 %type <statement_> ExternCStatementListOpt
555 %type <finally_> Finally
556 %type <binding_> ForBinding
557 %type <forin_> ForDeclaration
558 %type <forin_> ForInStatementInitializer
559 %type <for_> ForStatementInitializer
560 %type <binding_> FormalParameter
561 %type <functionParameter_> FormalParameterList_
562 %type <functionParameter_> FormalParameterList
563 %type <functionParameter_> FormalParameters
564 %type <string_> FromClause
565 %type <statement_> FunctionBody
566 %type <statement_> FunctionDeclaration
567 %type <target_> FunctionExpression
568 %type <statement_> FunctionStatementList
569 %type <statement_> GeneratorBody
570 %type <statement_> GeneratorDeclaration
571 %type <target_> GeneratorExpression
572 %type <method_> GeneratorMethod
573 %type <statement_> HoistableDeclaration
574 %type <identifier_> Identifier
575 %type <identifier_> IdentifierNoOf
576 %type <identifier_> IdentifierType
577 %type <identifier_> IdentifierTypeNoOf
578 %type <identifier_> IdentifierTypeOpt
579 %type <word_> IdentifierName
580 %type <variable_> IdentifierReference
581 %type <statement_> IfStatement
582 %type <import_> ImportClause
583 %type <statement_> ImportDeclaration
584 %type <import_> ImportSpecifier
585 %type <identifier_> ImportedBinding
586 %type <import_> ImportedDefaultBinding
587 %type <import_> ImportsList_
588 %type <import_> ImportsList
589 %type <import_> ImportsListOpt
590 %type <target_> IndirectExpression
591 %type <expression_> Initializer
592 %type <expression_> InitializerOpt
593 %type <statement_> IterationStatement
594 %type <identifier_> LabelIdentifier
595 %type <statement_> LabelledItem
596 %type <statement_> LabelledStatement
597 %type <assignment_> LeftHandSideAssignment
598 %type <target_> LeftHandSideExpression
599 %type <bool_> LetOrConst
600 %type <binding_> LexicalBinding
601 %type <for_> LexicalDeclaration_
602 %type <statement_> LexicalDeclaration
603 %type <literal_> Literal
604 %type <propertyName_> LiteralPropertyName
605 %type <expression_> LogicalANDExpression
606 %type <expression_> LogicalORExpression
607 %type <access_> MemberAccess
608 %type <target_> MemberExpression
609 %type <method_> MethodDefinition
610 %type <statement_> ModuleBody
611 %type <statement_> ModuleBodyOpt
612 %type <statement_> ModuleItem
613 %type <statement_> ModuleItemList
614 %type <statement_> ModuleItemListOpt
615 %type <module_> ModulePath
616 %type <string_> ModuleSpecifier
617 %type <expression_> MultiplicativeExpression
618 %type <import_> NameSpaceImport
619 %type <import_> NamedImports
620 %type <target_> NewExpression
621 %type <null_> NullLiteral
622 %type <literal_> ObjectLiteral
623 %type <expression_> PostfixExpression
624 %type <target_> PrimaryExpression
625 %type <propertyName_> PropertyName
626 %type <property_> PropertyDefinition
627 %type <property_> PropertyDefinitionList_
628 %type <property_> PropertyDefinitionList
629 %type <property_> PropertyDefinitionListOpt
630 %type <functionParameter_> PropertySetParameterList
631 %type <literal_> RegularExpressionLiteral
632 %type <bool_> RegularExpressionSlash
633 %type <expression_> RelationalExpression
634 %type <statement_> ReturnStatement
635 %type <braced_> BracedParameter
636 %type <functionParameter_> RubyProcParameterList_
637 %type <functionParameter_> RubyProcParameterList
638 %type <functionParameter_> RubyProcParameters
639 %type <functionParameter_> RubyProcParametersOpt
640 %type <statement_> Script
641 %type <statement_> ScriptBody
642 %type <statement_> ScriptBodyOpt
643 %type <expression_> ShiftExpression
644 %type <binding_> SingleNameBinding
645 %type <statement_> Statement__
646 %type <statement_> Statement_
647 %type <statement_> Statement
648 %type <statement_> StatementList
649 %type <statement_> StatementListOpt
650 %type <statement_> StatementListItem
651 %type <functionParameter_> StrictFormalParameters
652 %type <target_> SuperCall
653 %type <target_> SuperProperty
654 %type <statement_> SwitchStatement
655 %type <target_> TemplateLiteral
656 %type <span_> TemplateSpans
657 %type <statement_> ThrowStatement
658 %type <statement_> TryStatement
659 %type <statement_> TypeDefinition
660 %type <expression_> UnaryExpression_
661 %type <expression_> UnaryExpression
662 %type <binding_> VariableDeclaration
663 %type <bindings_> VariableDeclarationList_
664 %type <bindings_> VariableDeclarationList
665 %type <for_> VariableStatement_
666 %type <statement_> VariableStatement
667 %type <statement_> WithStatement
668 %type <word_> Word
669 %type <word_> WordNoUnary
670 @begin ObjectiveC
671 %type <word_> WordOpt
672 @end
673 %type <expression_> YieldExpression
674
675 @begin C
676 %type <constant_> EnumConstantListOpt_
677 %type <constant_> EnumConstantListOpt
678 %type <number_> IntegerNumber
679 %type <integral_> IntegerType
680 %type <integral_> IntegerTypeOpt
681 %type <typedIdentifier_> PrefixedType
682 %type <specifier_> PrimitiveReference
683 %type <specifier_> PrimitiveType
684 %type <structField_> StructFieldListOpt
685 %type <typedIdentifier_> SuffixedType
686 %type <typedIdentifier_> SuffixedTypeOpt
687 %type <typedIdentifier_> TypeSignifier
688 %type <typedIdentifier_> TypeSignifierNone
689 %type <typedIdentifier_> TypeSignifierOpt
690 %type <signing_> TypeSigning
691 %type <modifier_> ParameterTail
692 %type <modifier_> TypeQualifierLeft
693 %type <modifier_> TypeQualifierLeftOpt
694 %type <typedIdentifier_> TypeQualifierRight
695 %type <typedIdentifier_> TypeQualifierRightOpt
696 %type <typedIdentifier_> TypedIdentifierDefinition
697 %type <typedIdentifier_> TypedIdentifierEncoding
698 %type <typedIdentifier_> TypedIdentifierField
699 %type <typedIdentifier_> TypedIdentifierMaybe
700 %type <typedIdentifier_> TypedIdentifierNo
701 %type <typedIdentifier_> TypedIdentifierTagged
702 %type <typedIdentifier_> TypedIdentifierYes
703 %type <typedFormal_> TypedParameterList_
704 %type <typedFormal_> TypedParameterList
705 %type <typedFormal_> TypedParameterListOpt
706 %type <typedParameter_> TypedParameters
707 @end
708
709 @begin ObjectiveC
710 %type <expression_> AssignmentExpressionClassic
711 %type <expression_> BoxableExpression
712 %type <statement_> CategoryStatement
713 %type <expression_> ClassSuperOpt
714 %type <expression_> ConditionalExpressionClassic
715 %type <message_> ClassMessageDeclaration
716 %type <message_> ClassMessageDeclarationListOpt
717 %type <protocol_> ClassProtocolListOpt
718 %type <protocol_> ClassProtocols
719 %type <protocol_> ClassProtocolsOpt
720 %type <implementationField_> ImplementationFieldListOpt
721 %type <statement_> ImplementationStatement
722 %type <keyValue_> KeyValuePairList_
723 %type <keyValue_> KeyValuePairList
724 %type <keyValue_> KeyValuePairListOpt
725 %type <target_> MessageExpression
726 %type <messageParameter_> MessageParameter
727 %type <messageParameter_> MessageParameters
728 %type <messageParameter_> MessageParameterList
729 %type <messageParameter_> MessageParameterListOpt
730 %type <bool_> MessageScope
731 %type <argument_> SelectorCall_
732 %type <argument_> SelectorCall
733 %type <selector_> SelectorExpression_
734 %type <selector_> SelectorExpression
735 %type <selector_> SelectorExpressionOpt
736 %type <argument_> SelectorList
737 %type <word_> SelectorWordOpt
738 %type <typedIdentifier_> TypeOpt
739 %type <argument_> VariadicCall
740 @end
741
742 @begin E4X
743 %type <propertyIdentifier_> PropertyIdentifier_
744 %type <selector_> PropertySelector_
745 %type <selector_> PropertySelector
746 %type <identifier_> QualifiedIdentifier_
747 %type <identifier_> QualifiedIdentifier
748 %type <identifier_> WildcardIdentifier
749 %type <identifier_> XMLComment
750 %type <identifier_> XMLCDATA
751 %type <identifier_> XMLElement
752 %type <identifier_> XMLElementContent
753 %type <identifier_> XMLMarkup
754 %type <identifier_> XMLPI
755
756 %type <attribute_> AttributeIdentifier
757 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
758 %type <expression_> PropertyIdentifier
759 %type <expression_> XMLListInitilizer
760 %type <expression_> XMLInitilizer
761 @end
762 /* }}} */
763 /* Token Priorities {{{ */
764 %nonassoc "if"
765 %nonassoc "else"
766
767 %nonassoc ":"
768 %nonassoc "!yield"
769 /* }}} */
770
771 %start Program
772 %token MarkModule
773 %token MarkScript
774 %token MarkExpression
775
776 %%
777
778 Program
779 : MarkScript Script
780 | MarkModule Module
781 | MarkExpression Expression[expression] { driver.context_ = $expression; }
782 ;
783
784 /* Lexer State {{{ */
785 LexPushInOn: { driver.in_.push(true); };
786 LexPushInOff: { driver.in_.push(false); };
787 LexPopIn: { driver.in_.pop(); };
788
789 LexPushReturnOn: { driver.return_.push(true); };
790 LexPopReturn: { driver.return_.pop(); };
791 Return: "return"[return] { if (!driver.return_.top()) CYERR(@return, "invalid return"); };
792
793 LexPushSuperOn: { driver.super_.push(true); };
794 LexPushSuperOff: { driver.super_.push(false); };
795 LexPopSuper: { driver.super_.pop(); };
796 Super: "super"[super] { if (!driver.super_.top()) CYERR(@super, "invalid super"); };
797
798 LexPushYieldOn: { driver.yield_.push(true); };
799 LexPushYieldOff: { driver.yield_.push(false); };
800 LexPopYield: { driver.yield_.pop(); };
801
802 LexNewLineOrOpt
803 : { CYLEX(); if (driver.newline_) { CYHLD(@$, tk::NewLine); } }
804 ;
805
806 LexNewLineOrNot
807 : { CYLEX(); CYHLD(@$, driver.newline_ ? tk::NewLine : tk::__); }
808 ;
809
810 LexNoStar
811 : { CYMAP(YieldStar, Star); }
812 ;
813
814 LexNoBrace
815 : { CYMAP(OpenBrace_, OpenBrace); }
816 ;
817
818 LexNoClass
819 : { CYMAP(_class__, _class_); }
820 ;
821
822 LexNoFunction
823 : { CYMAP(_function__, _function_); }
824 ;
825
826 LexSetStatement
827 : LexNoBrace LexNoClass LexNoFunction
828 ;
829 /* }}} */
830 /* Virtual Tokens {{{ */
831 Var_
832 : "var"
833 ;
834 /* }}} */
835
836 /* 11.6 Names and Keywords {{{ */
837 IdentifierName
838 : Word[pass] { $$ = $pass; }
839 | "for" { $$ = CYNew CYWord("for"); }
840 | "in" { $$ = CYNew CYWord("in"); }
841 | "instanceof" { $$ = CYNew CYWord("instanceof"); }
842 ;
843
844 WordNoUnary
845 : IdentifierNoOf[pass] { $$ = $pass; }
846 | "break" { $$ = CYNew CYWord("break"); }
847 | "case" { $$ = CYNew CYWord("case"); }
848 | "catch" { $$ = CYNew CYWord("catch"); }
849 | "class" LexOf { $$ = CYNew CYWord("class"); }
850 | ";class" { $$ = CYNew CYWord("class"); }
851 | "const" { $$ = CYNew CYWord("const"); }
852 | "continue" { $$ = CYNew CYWord("continue"); }
853 | "debugger" { $$ = CYNew CYWord("debugger"); }
854 | "default" { $$ = CYNew CYWord("default"); }
855 | "do" { $$ = CYNew CYWord("do"); }
856 | "else" { $$ = CYNew CYWord("else"); }
857 | "enum" { $$ = CYNew CYWord("enum"); }
858 | "export" { $$ = CYNew CYWord("export"); }
859 | "extends" { $$ = CYNew CYWord("extends"); }
860 | "false" { $$ = CYNew CYWord("false"); }
861 | "finally" { $$ = CYNew CYWord("finally"); }
862 | "function" LexOf { $$ = CYNew CYWord("function"); }
863 | "if" { $$ = CYNew CYWord("if"); }
864 | "import" { $$ = CYNew CYWord("import"); }
865 | "!in" { $$ = CYNew CYWord("in"); }
866 | "!of" { $$ = CYNew CYWord("of"); }
867 | "null" { $$ = CYNew CYWord("null"); }
868 | "return" { $$ = CYNew CYWord("return"); }
869 | "super" { $$ = CYNew CYWord("super"); }
870 | "switch" { $$ = CYNew CYWord("switch"); }
871 | "this" { $$ = CYNew CYWord("this"); }
872 | "throw" { $$ = CYNew CYWord("throw"); }
873 | "true" { $$ = CYNew CYWord("true"); }
874 | "try" { $$ = CYNew CYWord("try"); }
875 | "var" { $$ = CYNew CYWord("var"); }
876 | "while" { $$ = CYNew CYWord("while"); }
877 | "with" { $$ = CYNew CYWord("with"); }
878 ;
879
880 Word
881 : WordNoUnary[pass] { $$ = $pass; }
882 | "delete" { $$ = CYNew CYWord("delete"); }
883 | "typeof" { $$ = CYNew CYWord("typeof"); }
884 | "void" { $$ = CYNew CYWord("void"); }
885 | "yield" { $$ = CYNew CYIdentifier("yield"); }
886 ;
887
888 @begin ObjectiveC
889 WordOpt
890 : Word[pass] { $$ = $pass; }
891 | { $$ = NULL; }
892 ;
893 @end
894 /* }}} */
895 /* 11.8.1 Null Literals {{{ */
896 NullLiteral
897 : "null" { $$ = CYNew CYNull(); }
898 ;
899 /* }}} */
900 /* 11.8.2 Boolean Literals {{{ */
901 BooleanLiteral
902 : "true" { $$ = CYNew CYTrue(); }
903 | "false" { $$ = CYNew CYFalse(); }
904 ;
905 /* }}} */
906 /* 11.8.5 Regular Expression Literals {{{ */
907 RegularExpressionSlash
908 : "/" { $$ = false; }
909 | "/=" { $$ = true; }
910 ;
911
912 RegularExpressionLiteral
913 : RegularExpressionSlash[equals] { CYMPT(@$); driver.SetRegEx($equals); } RegularExpressionLiteral_[pass] { $$ = $pass; }
914 ;
915 /* }}} */
916
917 /* 11.9 Automatic Semicolon Insertion {{{ */
918 StrictSemi
919 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
920 ;
921
922 NewLineNot
923 : LexNewLineOrNot ""
924 ;
925
926 NewLineOpt
927 : LexNewLineOrNot "\n"
928 | NewLineNot
929 ;
930
931 TerminatorSoft
932 : LexNewLineOrNot "\n" StrictSemi
933 | NewLineNot LexOf Terminator
934 ;
935
936 TerminatorHard
937 : ";"
938 | error { if (yyla.type_get() != yyeof_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
939 ;
940
941 Terminator
942 : ";"
943 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !driver.newline_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi
944 ;
945
946 TerminatorOpt
947 : ";"
948 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
949 ;
950 /* }}} */
951
952 /* 12.1 Identifiers {{{ */
953 IdentifierReference
954 : Identifier[pass] { $$ = CYNew CYVariable($pass); }
955 | "yield" { $$ = CYNew CYVariable(CYNew CYIdentifier("yield")); }
956 ;
957
958 BindingIdentifier
959 : LexOf IdentifierNoOf[pass] { $$ = $pass; }
960 | LexOf "!of" { $$ = CYNew CYIdentifier("of"); }
961 | LexOf "yield" { $$ = CYNew CYIdentifier("yield"); }
962 ;
963
964 BindingIdentifierOpt
965 : BindingIdentifier[pass] { $$ = $pass; }
966 | LexOf { $$ = NULL; }
967 ;
968
969 LabelIdentifier
970 : Identifier[pass] { $$ = $pass; }
971 | "yield" { $$ = CYNew CYIdentifier("yield"); }
972 ;
973
974 IdentifierTypeNoOf
975 : Identifier_[pass] { $$ = $pass; }
976 | "abstract" { $$ = CYNew CYIdentifier("abstract"); }
977 | "as" { $$ = CYNew CYIdentifier("as"); }
978 | "await" { $$ = CYNew CYIdentifier("await"); }
979 | "boolean" { $$ = CYNew CYIdentifier("boolean"); }
980 | "byte" { $$ = CYNew CYIdentifier("byte"); }
981 | "constructor" { $$ = CYNew CYIdentifier("constructor"); }
982 | "double" { $$ = CYNew CYIdentifier("double"); }
983 | "each" { $$ = CYNew CYIdentifier("each"); }
984 | "eval" { $$ = CYNew CYIdentifier("eval"); }
985 | "final" { $$ = CYNew CYIdentifier("final"); }
986 | "float" { $$ = CYNew CYIdentifier("float"); }
987 | "from" { $$ = CYNew CYIdentifier("from"); }
988 | "get" { $$ = CYNew CYIdentifier("get"); }
989 | "goto" { $$ = CYNew CYIdentifier("goto"); }
990 | "implements" { $$ = CYNew CYIdentifier("implements"); }
991 | "Infinity" { $$ = CYNew CYIdentifier("Infinity"); }
992 | "interface" { $$ = CYNew CYIdentifier("interface"); }
993 | "let" { $$ = CYNew CYIdentifier("let"); }
994 | "!let" LexBind LexOf { $$ = CYNew CYIdentifier("let"); }
995 | "native" { $$ = CYNew CYIdentifier("native"); }
996 | "package" { $$ = CYNew CYIdentifier("package"); }
997 | "private" { $$ = CYNew CYIdentifier("private"); }
998 | "protected" { $$ = CYNew CYIdentifier("protected"); }
999 | "__proto__" { $$ = CYNew CYIdentifier("__proto__"); }
1000 | "prototype" { $$ = CYNew CYIdentifier("prototype"); }
1001 | "public" { $$ = CYNew CYIdentifier("public"); }
1002 | "set" { $$ = CYNew CYIdentifier("set"); }
1003 | "synchronized" { $$ = CYNew CYIdentifier("synchronized"); }
1004 | "target" { $$ = CYNew CYIdentifier("target"); }
1005 | "throws" { $$ = CYNew CYIdentifier("throws"); }
1006 | "transient" { $$ = CYNew CYIdentifier("transient"); }
1007 | "typeid" { $$ = CYNew CYIdentifier("typeid"); }
1008 | "undefined" { $$ = CYNew CYIdentifier("undefined"); }
1009 @begin ObjectiveC
1010 | "bool" { $$ = CYNew CYIdentifier("bool"); }
1011 | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); }
1012 | "id" { $$ = CYNew CYIdentifier("id"); }
1013 | "SEL" { $$ = CYNew CYIdentifier("SEL"); }
1014 @end
1015 ;
1016
1017 IdentifierType
1018 : IdentifierTypeNoOf[pass] { $$ = $pass; }
1019 | "of" { $$ = CYNew CYIdentifier("of"); }
1020 ;
1021
1022 IdentifierTypeOpt
1023 : IdentifierType[pass] { $$ = $pass; }
1024 | { $$ = NULL; }
1025 ;
1026
1027 IdentifierNoOf
1028 : IdentifierTypeNoOf
1029 | "char" { $$ = CYNew CYIdentifier("char"); }
1030 | "int" { $$ = CYNew CYIdentifier("int"); }
1031 | "__int128" { $$ = CYNew CYIdentifier("__int128"); }
1032 | "long" { $$ = CYNew CYIdentifier("long"); }
1033 | "__restrict" { $$ = CYNew CYIdentifier("__restrict"); }
1034 | "restrict" { $$ = CYNew CYIdentifier("restrict"); }
1035 | "short" { $$ = CYNew CYIdentifier("short"); }
1036 | "static" { $$ = CYNew CYIdentifier("static"); }
1037 | "volatile" { $$ = CYNew CYIdentifier("volatile"); }
1038 @begin C
1039 | "signed" { $$ = CYNew CYIdentifier("signed"); }
1040 | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); }
1041 @end
1042 @begin ObjectiveC
1043 | "nil" { $$ = CYNew CYIdentifier("nil"); }
1044 | "NO" { $$ = CYNew CYIdentifier("NO"); }
1045 | "NULL" { $$ = CYNew CYIdentifier("NULL"); }
1046 | "YES" { $$ = CYNew CYIdentifier("YES"); }
1047 @end
1048 ;
1049
1050 Identifier
1051 : IdentifierNoOf[pass] { $$ = $pass; }
1052 | "of" { $$ = CYNew CYIdentifier("of"); }
1053 | "!of" { $$ = CYNew CYIdentifier("of"); }
1054 ;
1055 /* }}} */
1056 /* 12.2 Primary Expression {{{ */
1057 PrimaryExpression
1058 : "this" { $$ = CYNew CYThis(); }
1059 | IdentifierReference[pass] { $$ = $pass; }
1060 | Literal[pass] { $$ = $pass; }
1061 | ArrayLiteral[pass] { $$ = $pass; }
1062 | ObjectLiteral[pass] { $$ = $pass; }
1063 | FunctionExpression[pass] { $$ = $pass; }
1064 | ClassExpression[pass] { $$ = $pass; }
1065 | GeneratorExpression[pass] { $$ = $pass; }
1066 | RegularExpressionLiteral[pass] { $$ = $pass; }
1067 | TemplateLiteral[pass] { $$ = $pass; }
1068 | CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) CYERR(@cover, "invalid parenthetical"); $$ = $cover; }
1069 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
1070 ;
1071
1072 CoverParenthesizedExpressionAndArrowParameterList
1073 : "(" Expression[expression] ")" { $$ = CYNew CYParenthetical($expression); }
1074 | "(" LexOf ")" { $$ = NULL; }
1075 | "(" LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
1076 | "(" Expression "," LexOf "..." BindingIdentifier ")" { CYNOT(@$); }
1077 ;
1078 /* }}} */
1079 /* 12.2.4 Literals {{{ */
1080 Literal
1081 : NullLiteral[pass] { $$ = $pass; }
1082 | BooleanLiteral[pass] { $$ = $pass; }
1083 | NumericLiteral[pass] { $$ = $pass; }
1084 | StringLiteral[pass] { $$ = $pass; }
1085 ;
1086 /* }}} */
1087 /* 12.2.5 Array Initializer {{{ */
1088 ArrayLiteral
1089 : "[" ElementListOpt[elements] "]" { $$ = CYNew CYArray($elements); }
1090 ;
1091
1092 ArrayElement
1093 : AssignmentExpression[value] { $$ = CYNew CYElementValue($value); }
1094 | LexOf "..." AssignmentExpression[values] { $$ = CYNew CYElementSpread($values); }
1095 ;
1096
1097 ElementList_
1098 : "," ElementListOpt[elements] { $$ = $elements; }
1099 | { $$ = NULL; }
1100 ;
1101
1102 ElementList
1103 : ArrayElement[element] ElementList_[next] { $$ = $element; $$->SetNext($next); }
1104 | LexOf "," ElementListOpt[next] { $$ = CYNew CYElementValue(NULL, $next); }
1105 ;
1106
1107 ElementListOpt
1108 : ElementList[pass] { $$ = $pass; }
1109 | LexOf { $$ = NULL; }
1110 ;
1111 /* }}} */
1112 /* 12.2.6 Object Initializer {{{ */
1113 ObjectLiteral
1114 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYObject($properties); }
1115 ;
1116
1117 PropertyDefinitionList_
1118 : "," PropertyDefinitionListOpt[properties] { $$ = $properties; }
1119 | { $$ = NULL; }
1120 ;
1121
1122 PropertyDefinitionList
1123 : PropertyDefinition[property] PropertyDefinitionList_[next] { $property->SetNext($next); $$ = $property; }
1124 ;
1125
1126 PropertyDefinitionListOpt
1127 : PropertyDefinitionList[properties] { $$ = $properties; }
1128 | { $$ = NULL; }
1129 ;
1130
1131 PropertyDefinition
1132 : IdentifierReference[value] { $$ = CYNew CYPropertyValue($value->name_, $value); }
1133 | CoverInitializedName[name] { CYNOT(@$); }
1134 | PropertyName[name] ":" AssignmentExpression[value] { $$ = CYNew CYPropertyValue($name, $value); }
1135 | MethodDefinition[pass] { $$ = $pass; }
1136 ;
1137
1138 PropertyName
1139 : LiteralPropertyName[pass] { $$ = $pass; }
1140 | ComputedPropertyName[pass] { $$ = $pass; }
1141 ;
1142
1143 LiteralPropertyName
1144 : IdentifierName[pass] { $$ = $pass; }
1145 | StringLiteral[pass] { $$ = $pass; }
1146 | NumericLiteral[pass] { $$ = $pass; }
1147 ;
1148
1149 ComputedPropertyName
1150 : "[" AssignmentExpression[expression] "]" { $$ = CYNew CYComputed($expression); }
1151 ;
1152
1153 CoverInitializedName
1154 : IdentifierReference Initializer
1155 ;
1156
1157 Initializer
1158 : "=" AssignmentExpression[initializer] { $$ = $initializer; }
1159 ;
1160
1161 InitializerOpt
1162 : Initializer[pass] { $$ = $pass; }
1163 | { $$ = NULL; }
1164 ;
1165 /* }}} */
1166 /* 12.2.9 Template Literals {{{ */
1167 TemplateLiteral
1168 : NoSubstitutionTemplate[string] { $$ = CYNew CYTemplate($string, NULL); }
1169 | TemplateHead[string] LexPushInOff TemplateSpans[spans] { $$ = CYNew CYTemplate($string, $spans); }
1170 ;
1171
1172 TemplateSpans
1173 : Expression[value] TemplateMiddle[string] TemplateSpans[spans] { $$ = CYNew CYSpan($value, $string, $spans); }
1174 | Expression[value] TemplateTail[string] LexPopIn { $$ = CYNew CYSpan($value, $string, NULL); }
1175 ;
1176 /* }}} */
1177
1178 /* 12.3 Left-Hand-Side Expressions {{{ */
1179 MemberAccess
1180 : "[" Expression[property] "]" { $$ = CYNew CYDirectMember(NULL, $property); }
1181 | "." IdentifierName[property] { $$ = CYNew CYDirectMember(NULL, CYNew CYString($property)); }
1182 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
1183 | TemplateLiteral { CYNOT(@$); }
1184 ;
1185
1186 MemberExpression
1187 : PrimaryExpression[pass] { $$ = $pass; }
1188 | MemberExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1189 | SuperProperty[pass] { $$ = $pass; }
1190 | MetaProperty { CYNOT(@$); }
1191 | "new" MemberExpression[constructor] Arguments[arguments] { $$ = CYNew cy::Syntax::New($constructor, $arguments); }
1192 ;
1193
1194 SuperProperty
1195 : Super "[" Expression[property] "]" { $$ = CYNew CYSuperAccess($property); }
1196 | Super "." IdentifierName[property] { $$ = CYNew CYSuperAccess(CYNew CYString($property)); }
1197 ;
1198
1199 MetaProperty
1200 : NewTarget
1201 ;
1202
1203 NewTarget
1204 : "new" "." "target"
1205 ;
1206
1207 NewExpression
1208 : MemberExpression[pass] { $$ = $pass; }
1209 | "new" NewExpression[expression] { $$ = CYNew cy::Syntax::New($expression, NULL); }
1210 ;
1211
1212 CallExpression_
1213 : MemberExpression[pass] { $$ = $pass; }
1214 | CallExpression[pass] { $$ = $pass; }
1215 ;
1216
1217 CallExpression
1218 : CallExpression_[function] Arguments[arguments] { if (!$function->Eval()) $$ = CYNew CYCall($function, $arguments); else $$ = CYNew CYEval($arguments); }
1219 | SuperCall[pass] { $$ = $pass; }
1220 | CallExpression[object] { driver.context_ = $object; } MemberAccess[member] { $member->SetLeft($object); $$ = $member; }
1221 ;
1222
1223 SuperCall
1224 : Super Arguments[arguments] { $$ = CYNew CYSuperCall($arguments); }
1225 ;
1226
1227 Arguments
1228 : "(" ArgumentListOpt[arguments] ")" { $$ = $arguments; }
1229 ;
1230
1231 ArgumentList_
1232 : "," ArgumentList[arguments] { $$ = $arguments; }
1233 | { $$ = NULL; }
1234 ;
1235
1236 ArgumentList
1237 : AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
1238 | LexOf "..." AssignmentExpression { CYNOT(@$); }
1239 ;
1240
1241 ArgumentListOpt
1242 : ArgumentList[pass] { $$ = $pass; }
1243 | LexOf { $$ = NULL; }
1244 ;
1245
1246 AccessExpression
1247 : NewExpression[pass] { $$ = $pass; }
1248 | CallExpression[pass] { $$ = $pass; }
1249 ;
1250
1251 LeftHandSideExpression
1252 : BracedExpression[pass] { $$ = $pass; }
1253 | IndirectExpression[pass] { $$ = $pass; }
1254 ;
1255 /* }}} */
1256 /* 12.4 Postfix Expressions {{{ */
1257 PostfixExpression
1258 : BracedExpression[pass] { $$ = $pass; }
1259 | AccessExpression[lhs] LexNewLineOrOpt "++" { $$ = CYNew CYPostIncrement($lhs); }
1260 | AccessExpression[lhs] LexNewLineOrOpt "--" { $$ = CYNew CYPostDecrement($lhs); }
1261 ;
1262 /* }}} */
1263 /* 12.5 Unary Operators {{{ */
1264 UnaryExpression_
1265 : "delete" UnaryExpression[rhs] { $$ = CYNew CYDelete($rhs); }
1266 | "void" UnaryExpression[rhs] { $$ = CYNew CYVoid($rhs); }
1267 | "typeof" UnaryExpression[rhs] { $$ = CYNew CYTypeOf($rhs); }
1268 | "++" UnaryExpression[rhs] { $$ = CYNew CYPreIncrement($rhs); }
1269 | "--" UnaryExpression[rhs] { $$ = CYNew CYPreDecrement($rhs); }
1270 | "+" UnaryExpression[rhs] { $$ = CYNew CYAffirm($rhs); }
1271 | "-" UnaryExpression[rhs] { $$ = CYNew CYNegate($rhs); }
1272 | "~" UnaryExpression[rhs] { $$ = CYNew CYBitwiseNot($rhs); }
1273 | "!" UnaryExpression[rhs] { $$ = CYNew CYLogicalNot($rhs); }
1274 ;
1275
1276 UnaryExpression
1277 : PostfixExpression[expression] { $$ = $expression; }
1278 | UnaryExpression_[pass] { $$ = $pass; }
1279 ;
1280 /* }}} */
1281 /* 12.6 Multiplicative Operators {{{ */
1282 MultiplicativeExpression
1283 : UnaryExpression[pass] { $$ = $pass; }
1284 | MultiplicativeExpression[lhs] "*" UnaryExpression[rhs] { $$ = CYNew CYMultiply($lhs, $rhs); }
1285 | MultiplicativeExpression[lhs] "/" UnaryExpression[rhs] { $$ = CYNew CYDivide($lhs, $rhs); }
1286 | MultiplicativeExpression[lhs] "%" UnaryExpression[rhs] { $$ = CYNew CYModulus($lhs, $rhs); }
1287 ;
1288 /* }}} */
1289 /* 12.7 Additive Operators {{{ */
1290 AdditiveExpression
1291 : MultiplicativeExpression[pass] { $$ = $pass; }
1292 | AdditiveExpression[lhs] "+" MultiplicativeExpression[rhs] { $$ = CYNew CYAdd($lhs, $rhs); }
1293 | AdditiveExpression[lhs] "-" MultiplicativeExpression[rhs] { $$ = CYNew CYSubtract($lhs, $rhs); }
1294 ;
1295 /* }}} */
1296 /* 12.8 Bitwise Shift Operators {{{ */
1297 ShiftExpression
1298 : AdditiveExpression[pass] { $$ = $pass; }
1299 | ShiftExpression[lhs] "<<" AdditiveExpression[rhs] { $$ = CYNew CYShiftLeft($lhs, $rhs); }
1300 | ShiftExpression[lhs] ">>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightSigned($lhs, $rhs); }
1301 | ShiftExpression[lhs] ">>>" AdditiveExpression[rhs] { $$ = CYNew CYShiftRightUnsigned($lhs, $rhs); }
1302 ;
1303 /* }}} */
1304 /* 12.9 Relational Operators {{{ */
1305 RelationalExpression
1306 : ShiftExpression[pass] { $$ = $pass; }
1307 | RelationalExpression[lhs] "<" ShiftExpression[rhs] { $$ = CYNew CYLess($lhs, $rhs); }
1308 | RelationalExpression[lhs] ">" ShiftExpression[rhs] { $$ = CYNew CYGreater($lhs, $rhs); }
1309 | RelationalExpression[lhs] "<=" ShiftExpression[rhs] { $$ = CYNew CYLessOrEqual($lhs, $rhs); }
1310 | RelationalExpression[lhs] ">=" ShiftExpression[rhs] { $$ = CYNew CYGreaterOrEqual($lhs, $rhs); }
1311 | RelationalExpression[lhs] "instanceof" ShiftExpression[rhs] { $$ = CYNew CYInstanceOf($lhs, $rhs); }
1312 | RelationalExpression[lhs] "in" ShiftExpression[rhs] { $$ = CYNew CYIn($lhs, $rhs); }
1313 ;
1314 /* }}} */
1315 /* 12.10 Equality Operators {{{ */
1316 EqualityExpression
1317 : RelationalExpression[pass] { $$ = $pass; }
1318 | EqualityExpression[lhs] "==" RelationalExpression[rhs] { $$ = CYNew CYEqual($lhs, $rhs); }
1319 | EqualityExpression[lhs] "!=" RelationalExpression[rhs] { $$ = CYNew CYNotEqual($lhs, $rhs); }
1320 | EqualityExpression[lhs] "===" RelationalExpression[rhs] { $$ = CYNew CYIdentical($lhs, $rhs); }
1321 | EqualityExpression[lhs] "!==" RelationalExpression[rhs] { $$ = CYNew CYNotIdentical($lhs, $rhs); }
1322 ;
1323 /* }}} */
1324 /* 12.11 Binary Bitwise Operators {{{ */
1325 BitwiseANDExpression
1326 : EqualityExpression[pass] { $$ = $pass; }
1327 | BitwiseANDExpression[lhs] "&" EqualityExpression[rhs] { $$ = CYNew CYBitwiseAnd($lhs, $rhs); }
1328 ;
1329
1330 BitwiseXORExpression
1331 : BitwiseANDExpression[pass] { $$ = $pass; }
1332 | BitwiseXORExpression[lhs] "^" BitwiseANDExpression[rhs] { $$ = CYNew CYBitwiseXOr($lhs, $rhs); }
1333 ;
1334
1335 BitwiseORExpression
1336 : BitwiseXORExpression[pass] { $$ = $pass; }
1337 | BitwiseORExpression[lhs] "|" BitwiseXORExpression[rhs] { $$ = CYNew CYBitwiseOr($lhs, $rhs); }
1338 ;
1339 /* }}} */
1340 /* 12.12 Binary Logical Operators {{{ */
1341 LogicalANDExpression
1342 : BitwiseORExpression[pass] { $$ = $pass; }
1343 | LogicalANDExpression[lhs] "&&" BitwiseORExpression[rhs] { $$ = CYNew CYLogicalAnd($lhs, $rhs); }
1344 ;
1345
1346 LogicalORExpression
1347 : LogicalANDExpression[pass] { $$ = $pass; }
1348 | LogicalORExpression[lhs] "||" LogicalANDExpression[rhs] { $$ = CYNew CYLogicalOr($lhs, $rhs); }
1349 ;
1350 /* }}} */
1351 /* 12.13 Conditional Operator ( ? : ) {{{ */
1352 @begin ObjectiveC
1353 ConditionalExpressionClassic
1354 : LogicalORExpression[pass] { $$ = $pass; }
1355 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpressionClassic[false] { $$ = CYNew CYCondition($test, $true, $false); }
1356 ;
1357 @end
1358
1359 ConditionalExpression
1360 : LogicalORExpression[pass] { $$ = $pass; }
1361 | LogicalORExpression[test] "?" LexPushInOff AssignmentExpression[true] ":" LexPopIn AssignmentExpression[false] { $$ = CYNew CYCondition($test, $true, $false); }
1362 ;
1363 /* }}} */
1364 /* 12.14 Assignment Operators {{{ */
1365 LeftHandSideAssignment
1366 : LeftHandSideExpression[lhs] "=" { $$ = CYNew CYAssign($lhs, NULL); }
1367 | LeftHandSideExpression[lhs] "*=" { $$ = CYNew CYMultiplyAssign($lhs, NULL); }
1368 | LeftHandSideExpression[lhs] "/=" { $$ = CYNew CYDivideAssign($lhs, NULL); }
1369 | LeftHandSideExpression[lhs] "%=" { $$ = CYNew CYModulusAssign($lhs, NULL); }
1370 | LeftHandSideExpression[lhs] "+=" { $$ = CYNew CYAddAssign($lhs, NULL); }
1371 | LeftHandSideExpression[lhs] "-=" { $$ = CYNew CYSubtractAssign($lhs, NULL); }
1372 | LeftHandSideExpression[lhs] "<<=" { $$ = CYNew CYShiftLeftAssign($lhs, NULL); }
1373 | LeftHandSideExpression[lhs] ">>=" { $$ = CYNew CYShiftRightSignedAssign($lhs, NULL); }
1374 | LeftHandSideExpression[lhs] ">>>=" { $$ = CYNew CYShiftRightUnsignedAssign($lhs, NULL); }
1375 | LeftHandSideExpression[lhs] "&=" { $$ = CYNew CYBitwiseAndAssign($lhs, NULL); }
1376 | LeftHandSideExpression[lhs] "^=" { $$ = CYNew CYBitwiseXOrAssign($lhs, NULL); }
1377 | LeftHandSideExpression[lhs] "|=" { $$ = CYNew CYBitwiseOrAssign($lhs, NULL); }
1378 ;
1379
1380 @begin ObjectiveC
1381 AssignmentExpressionClassic
1382 : LexOf ConditionalExpressionClassic[pass] { $$ = $pass; }
1383 | LexOf LeftHandSideAssignment[assignment] AssignmentExpressionClassic[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1384 ;
1385 @end
1386
1387 AssignmentExpression
1388 : LexOf ConditionalExpression[pass] { $$ = $pass; }
1389 | LexOf YieldExpression[pass] { $$ = $pass; }
1390 | ArrowFunction[pass] { $$ = $pass; }
1391 | LexOf LeftHandSideAssignment[assignment] AssignmentExpression[rhs] { $assignment->SetRight($rhs); $$ = $assignment; }
1392 ;
1393 /* }}} */
1394 /* 12.15 Comma Operator ( , ) {{{ */
1395 Expression
1396 : AssignmentExpression[pass] { $$ = $pass; }
1397 | Expression[expression] "," AssignmentExpression[next] { $$ = CYNew CYCompound($expression, $next); }
1398 ;
1399
1400 ExpressionOpt
1401 : Expression[pass] { $$ = $pass; }
1402 | LexOf { $$ = NULL; }
1403 ;
1404 /* }}} */
1405
1406 /* 13 Statements and Declarations {{{ */
1407 Statement__
1408 : BlockStatement[pass] { $$ = $pass; }
1409 | VariableStatement[pass] { $$ = $pass; }
1410 | EmptyStatement[pass] { $$ = $pass; }
1411 | IfStatement[pass] { $$ = $pass; }
1412 | BreakableStatement[pass] { $$ = $pass; }
1413 | ContinueStatement[pass] { $$ = $pass; }
1414 | BreakStatement[pass] { $$ = $pass; }
1415 | ReturnStatement[pass] { $$ = $pass; }
1416 | WithStatement[pass] { $$ = $pass; }
1417 | LabelledStatement[pass] { $$ = $pass; }
1418 | ThrowStatement[pass] { $$ = $pass; }
1419 | TryStatement[pass] { $$ = $pass; }
1420 | DebuggerStatement[pass] { $$ = $pass; }
1421 ;
1422
1423 Statement_
1424 : LexOf Statement__[pass] { $$ = $pass; }
1425 | ExpressionStatement[pass] { $$ = $pass; }
1426 ;
1427
1428 Statement
1429 : LexSetStatement LexLet Statement_[pass] { $$ = $pass; }
1430 ;
1431
1432 Declaration_
1433 : HoistableDeclaration[pass] { $$ = $pass; }
1434 | ClassDeclaration[pass] { $$ = $pass; }
1435 ;
1436
1437 Declaration
1438 : LexSetStatement LexLet LexOf Declaration_[pass] { $$ = $pass; }
1439 | LexSetStatement LexicalDeclaration[pass] { $$ = $pass; }
1440 ;
1441
1442 HoistableDeclaration
1443 : FunctionDeclaration[pass] { $$ = $pass; }
1444 | GeneratorDeclaration[pass] { $$ = $pass; }
1445 ;
1446
1447 BreakableStatement
1448 : IterationStatement[pass] { $$ = $pass; }
1449 | SwitchStatement[pass] { $$ = $pass; }
1450 ;
1451 /* }}} */
1452 /* 13.2 Block {{{ */
1453 BlockStatement
1454 : ";{" StatementListOpt[code] "}" { $$ = CYNew CYBlock($code); }
1455 ;
1456
1457 Block
1458 : "{" StatementListOpt[code] "}" { $$ = $code; }
1459 ;
1460
1461 StatementList
1462 : StatementListItem[statement] StatementListOpt[next] { $$ = $statement; CYSetLast($$) = $next; }
1463 ;
1464
1465 StatementListOpt
1466 : StatementList[pass] { $$ = $pass; }
1467 | LexSetStatement LexLet LexOf { $$ = NULL; }
1468 ;
1469
1470 StatementListItem
1471 : Statement[pass] { $$ = $pass; }
1472 | Declaration[pass] { $$ = $pass; }
1473 ;
1474 /* }}} */
1475 /* 13.3 Let and Const Declarations {{{ */
1476 LexicalDeclaration_
1477 : LetOrConst[constant] BindingList[bindings] { $$ = CYNew CYLexical($constant, $bindings); }
1478 ;
1479
1480 LexicalDeclaration
1481 : LexicalDeclaration_[statement] Terminator { $$ = $statement; }
1482 ;
1483
1484 LexLet
1485 : { CYMAP(_let__, _let_); }
1486 ;
1487
1488 LexOf
1489 : { CYMAP(_of__, _of_); }
1490 ;
1491
1492 LexBind
1493 : { CYMAP(OpenBrace_let, OpenBrace); CYMAP(OpenBracket_let, OpenBracket); }
1494 ;
1495
1496 LetOrConst
1497 : LexLet LexOf "!let" LexBind LexOf { $$ = false; }
1498 | LexLet LexOf "const" { $$ = true; }
1499 ;
1500
1501 BindingList_
1502 : "," LexBind BindingList[bindings] { $$ = $bindings; }
1503 | { $$ = NULL; }
1504 ;
1505
1506 BindingList
1507 : LexicalBinding[binding] BindingList_[next] { $$ = CYNew CYBindings($binding, $next); }
1508 ;
1509
1510 LexicalBinding
1511 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1512 | LexOf BindingPattern Initializer { CYNOT(@$); }
1513 ;
1514 /* }}} */
1515 /* 13.3.2 Variable Statement {{{ */
1516 VariableStatement_
1517 : Var_ VariableDeclarationList[bindings] { $$ = CYNew CYVar($bindings); }
1518 ;
1519
1520 VariableStatement
1521 : VariableStatement_[statement] Terminator { $$ = $statement; }
1522 ;
1523
1524 VariableDeclarationList_
1525 : "," VariableDeclarationList[bindings] { $$ = $bindings; }
1526 | { $$ = NULL; }
1527 ;
1528
1529 VariableDeclarationList
1530 : LexBind VariableDeclaration[binding] VariableDeclarationList_[next] { $$ = CYNew CYBindings($binding, $next); }
1531 ;
1532
1533 VariableDeclaration
1534 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1535 | LexOf BindingPattern Initializer { CYNOT(@$); }
1536 ;
1537 /* }}} */
1538 /* 13.3.3 Destructuring Binding Patterns {{{ */
1539 BindingPattern
1540 : ObjectBindingPattern
1541 | ArrayBindingPattern
1542 ;
1543
1544 ObjectBindingPattern
1545 : "let {" BindingPropertyListOpt "}"
1546 ;
1547
1548 ArrayBindingPattern
1549 : "let [" BindingElementListOpt "]"
1550 ;
1551
1552 BindingPropertyList_
1553 : "," BindingPropertyListOpt
1554 |
1555 ;
1556
1557 BindingPropertyList
1558 : BindingProperty BindingPropertyList_
1559 ;
1560
1561 BindingPropertyListOpt
1562 : BindingPropertyList
1563 | LexOf
1564 ;
1565
1566 BindingElementList
1567 : BindingElementOpt[element] "," BindingElementListOpt[next]
1568 | BindingRestElement[element]
1569 | BindingElement[element]
1570 ;
1571
1572 BindingElementListOpt
1573 : BindingElementList[pass]
1574 | LexBind LexOf
1575 ;
1576
1577 BindingProperty
1578 : SingleNameBinding
1579 | LexOf PropertyName ":" BindingElement
1580 ;
1581
1582 BindingElement
1583 : LexBind SingleNameBinding[pass] { $$ = $pass; }
1584 | LexBind LexOf BindingPattern InitializerOpt[initializer] { CYNOT(@$); }
1585 ;
1586
1587 BindingElementOpt
1588 : BindingElement[pass]
1589 | LexBind LexOf
1590 ;
1591
1592 SingleNameBinding
1593 : BindingIdentifier[identifier] InitializerOpt[initializer] { $$ = CYNew CYBinding($identifier, $initializer); }
1594 ;
1595
1596 BindingRestElement
1597 : LexBind LexOf "..." BindingIdentifier
1598 ;
1599 /* }}} */
1600 /* 13.4 Empty Statement {{{ */
1601 EmptyStatement
1602 : ";" { $$ = CYNew CYEmpty(); }
1603 ;
1604 /* }}} */
1605 /* 13.5 Expression Statement {{{ */
1606 ExpressionStatement_
1607 : Expression[expression] { $$ = CYNew CYExpress($[expression]); }
1608
1609 ExpressionStatement
1610 : ExpressionStatement_[statement] Terminator { $$ = $statement; }
1611 ;
1612 /* }}} */
1613 /* 13.6 The if Statement {{{ */
1614 ElseStatementOpt
1615 : "else" Statement[false] { $$ = $false; }
1616 | %prec "if" { $$ = NULL; }
1617 ;
1618
1619 IfStatement
1620 : "if" "(" Expression[test] ")" Statement[true] ElseStatementOpt[false] { $$ = CYNew CYIf($test, $true, $false); }
1621 ;
1622 /* }}} */
1623 /* 13.7 Iteration Statements {{{ */
1624 IterationStatement
1625 : "do" Statement[code] "while" "(" Expression[test] ")" TerminatorOpt { $$ = CYNew CYDoWhile($test, $code); }
1626 | "while" "(" Expression[test] ")" Statement[code] { $$ = CYNew CYWhile($test, $code); }
1627 | "for" "(" LexPushInOn ForStatementInitializer[initializer] LexPopIn ExpressionOpt[test] ";" ExpressionOpt[increment] ")" Statement[code] { $$ = CYNew CYFor($initializer, $test, $increment, $code); }
1628 | "for" "(" LexPushInOn LexLet LexOf Var_ LexBind BindingIdentifier[identifier] Initializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForInitialized(CYNew CYBinding($identifier, $initializer), $iterable, $code); }
1629 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForIn($initializer, $iterable, $code); }
1630 | "for" "(" LexPushInOn ForInStatementInitializer[initializer] "of" LexPopIn AssignmentExpression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
1631 ;
1632
1633 ForStatementInitializer
1634 : LexLet LexOf EmptyStatement[pass] { $$ = $pass; }
1635 | LexLet ExpressionStatement_[initializer] ";" { $$ = $initializer; }
1636 | LexLet LexOf VariableStatement_[initializer] ";" { $$ = $initializer; }
1637 | LexicalDeclaration_[initializer] ";" { $$ = $initializer; }
1638 ;
1639
1640 ForInStatementInitializer
1641 : LexLet LexOf BracedExpression[pass] { $$ = $pass; }
1642 | LexLet LexOf IndirectExpression[pass] { $$ = $pass; }
1643 | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); }
1644 | ForDeclaration[pass] { $$ = $pass; }
1645 ;
1646
1647 ForDeclaration
1648 : LetOrConst[constant] ForBinding[binding] { $$ = CYNew CYForLexical($constant, $binding); }
1649 ;
1650
1651 ForBinding
1652 : BindingIdentifier[identifier] { $$ = CYNew CYBinding($identifier, NULL); }
1653 | LexOf BindingPattern { CYNOT(@$); }
1654 ;
1655 /* }}} */
1656 /* 13.8 The continue Statement {{{ */
1657 ContinueStatement
1658 : "continue" TerminatorSoft { $$ = CYNew CYContinue(NULL); }
1659 | "continue" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYContinue($label); }
1660 ;
1661 /* }}} */
1662 /* 13.9 The break Statement {{{ */
1663 BreakStatement
1664 : "break" TerminatorSoft { $$ = CYNew CYBreak(NULL); }
1665 | "break" NewLineNot LexOf Identifier[label] Terminator { $$ = CYNew CYBreak($label); }
1666 ;
1667 /* }}} */
1668 /* 13.10 The return Statement {{{ */
1669 ReturnStatement
1670 : Return TerminatorSoft { $$ = CYNew CYReturn(NULL); }
1671 | Return NewLineNot Expression[value] Terminator { $$ = CYNew CYReturn($value); }
1672 ;
1673 /* }}} */
1674 /* 13.11 The with Statement {{{ */
1675 WithStatement
1676 : "with" "(" Expression[scope] ")" Statement[code] { $$ = CYNew CYWith($scope, $code); }
1677 ;
1678 /* }}} */
1679 /* 13.12 The switch Statement {{{ */
1680 SwitchStatement
1681 : "switch" "(" Expression[value] ")" CaseBlock[clauses] { $$ = CYNew CYSwitch($value, $clauses); }
1682 ;
1683
1684 CaseBlock
1685 : "{" CaseClausesOpt[clauses] "}" { $$ = $clauses; }
1686 ;
1687
1688 CaseClause
1689 : "case" Expression[value] ":" StatementListOpt[code] { $$ = CYNew CYClause($value, $code); }
1690 ;
1691
1692 CaseClausesOpt
1693 : CaseClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1694 | DefaultClause[clause] CaseClausesOpt[next] { $clause->SetNext($next); $$ = $clause; }
1695 | { $$ = NULL; }
1696 ;
1697
1698 // XXX: the standard makes certain you can only have one of these
1699 DefaultClause
1700 : "default" ":" StatementListOpt[code] { $$ = CYNew CYClause(NULL, $code); }
1701 ;
1702 /* }}} */
1703 /* 13.13 Labelled Statements {{{ */
1704 LabelledStatement
1705 : LabelIdentifier[name] ":" LabelledItem[statement] { $$ = CYNew CYLabel($name, $statement); }
1706 ;
1707
1708 LabelledItem
1709 : Statement[pass] { $$ = $pass; }
1710 | LexSetStatement LexLet LexOf FunctionDeclaration[pass] { $$ = $pass; }
1711 ;
1712 /* }}} */
1713 /* 13.14 The throw Statement {{{ */
1714 ThrowStatement
1715 : "throw"[throw] TerminatorSoft { CYERR(@throw, "throw without exception"); }
1716 | "throw" NewLineNot Expression[value] Terminator { $$ = CYNew cy::Syntax::Throw($value); }
1717 ;
1718 /* }}} */
1719 /* 13.15 The try Statement {{{ */
1720 TryStatement
1721 : "try" Block[code] Catch[catch] { $$ = CYNew cy::Syntax::Try($code, $catch, NULL); }
1722 | "try" Block[code] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, NULL, $finally); }
1723 | "try" Block[code] Catch[catch] Finally[finally] { $$ = CYNew cy::Syntax::Try($code, $catch, $finally); }
1724 ;
1725
1726 Catch
1727 : "catch" "(" LexBind CatchParameter[name] ")" Block[code] { $$ = CYNew cy::Syntax::Catch($name, $code); }
1728 ;
1729
1730 Finally
1731 : "finally" Block[code] { $$ = CYNew CYFinally($code); }
1732 ;
1733
1734 CatchParameter
1735 : BindingIdentifier[pass] { $$ = $pass; }
1736 | LexOf BindingPattern { CYNOT(@$); }
1737 ;
1738 /* }}} */
1739 /* 13.16 The debugger Statement {{{ */
1740 DebuggerStatement
1741 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1742 ;
1743 /* }}} */
1744
1745 /* 14.1 Function Definitions {{{ */
1746 FunctionDeclaration
1747 : ";function" BindingIdentifier[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionStatement($name, $parameters, $code); }
1748 ;
1749
1750 FunctionExpression
1751 : "function" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" LexPushSuperOff FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYFunctionExpression($name, $parameters, $code); }
1752 ;
1753
1754 StrictFormalParameters
1755 : FormalParameters[pass] { $$ = $pass; }
1756 ;
1757
1758 FormalParameters
1759 : LexBind LexOf { $$ = NULL; }
1760 | FormalParameterList
1761 ;
1762
1763 FormalParameterList_
1764 : "," FormalParameterList[parameters] { $$ = $parameters; }
1765 | { $$ = NULL; }
1766 ;
1767
1768 FormalParameterList
1769 : FunctionRestParameter { CYNOT(@$); }
1770 | FormalParameter[binding] FormalParameterList_[next] { $$ = CYNew CYFunctionParameter($binding, $next); }
1771 ;
1772
1773 FunctionRestParameter
1774 : BindingRestElement
1775 ;
1776
1777 FormalParameter
1778 : BindingElement[pass] { $$ = $pass; }
1779 ;
1780
1781 FunctionBody
1782 : LexPushYieldOff FunctionStatementList[code] LexPopYield { $$ = $code; }
1783 ;
1784
1785 FunctionStatementList
1786 : LexPushReturnOn StatementListOpt[code] LexPopReturn { $$ = $code; }
1787 ;
1788 /* }}} */
1789 /* 14.2 Arrow Function Definitions {{{ */
1790 ArrowFunction
1791 : ArrowParameters[parameters] LexNewLineOrOpt "=>" LexNoBrace ConciseBody[code] { $$ = CYNew CYFatArrow($parameters, $code); }
1792 ;
1793
1794 ArrowParameters
1795 : BindingIdentifier[identifier] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier)); }
1796 | LexOf CoverParenthesizedExpressionAndArrowParameterList[cover] { if ($cover == NULL) $$ = NULL; else { $$ = $cover->expression_->Parameter(); if ($$ == NULL) CYERR(@cover, "invalid parameter list"); } }
1797 ;
1798
1799 ConciseBody
1800 : AssignmentExpression[expression] { $$ = CYNew CYReturn($expression); }
1801 | LexOf ";{" FunctionBody[code] "}" { $$ = $code; }
1802 ;
1803 /* }}} */
1804 /* 14.3 Method Definitions {{{ */
1805 MethodDefinition
1806 : PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyMethod($name, $parameters, $code); }
1807 | GeneratorMethod[pass] { $$ = $pass; }
1808 | "get" PropertyName[name] "(" ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertyGetter($name, $code); }
1809 | "set" PropertyName[name] "(" PropertySetParameterList[parameter] ")" "{" FunctionBody[code] "}" { $$ = CYNew CYPropertySetter($name, $parameter, $code); }
1810 ;
1811
1812 PropertySetParameterList
1813 : FormalParameter[binding] { $$ = CYNew CYFunctionParameter($binding); }
1814 ;
1815 /* }}} */
1816 /* 14.4 Generator Function Definitions {{{ */
1817 GeneratorMethod
1818 : "*" PropertyName[name] "(" StrictFormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorMethod($name, $parameters, $code); */ }
1819 ;
1820
1821 GeneratorDeclaration
1822 : ";function" LexOf "*" BindingIdentifier[name] "(" FormalParameters[code] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorStatement($name, $parameters, $code); */ }
1823 ;
1824
1825 GeneratorExpression
1826 : "function" LexOf "*" BindingIdentifierOpt[name] "(" FormalParameters[parameters] ")" "{" GeneratorBody[code] "}" { CYNOT(@$); /* $$ = CYNew CYGeneratorExpression($name, $parameters, $code); */ }
1827 ;
1828
1829 GeneratorBody
1830 : LexPushYieldOn FunctionStatementList[code] LexPopYield { $$ = $code; }
1831 ;
1832
1833 YieldExpression
1834 : "!yield" LexNewLineOrNot "\n" LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ }
1835 | "!yield" LexNewLineOrNot "" LexNoStar LexOf { CYNOT(@$); /* $$ = CYNew CYYieldValue(NULL); */ } %prec "!yield"
1836 | "!yield" LexNewLineOrNot "" LexNoStar AssignmentExpression[value] { CYNOT(@$); /* $$ = CYNew CYYieldValue($value); */ }
1837 | "!yield" LexNewLineOrNot "" LexNoStar LexOf "yield *" AssignmentExpression[generator] { CYNOT(@$); /* $$ = CYNew CYYieldGenerator($generator); */ }
1838 ;
1839 /* }}} */
1840 /* 14.5 Class Definitions {{{ */
1841 ClassDeclaration
1842 : ";class" BindingIdentifier[name] ClassTail[tail] { $$ = CYNew CYClassStatement($name, $tail); }
1843 ;
1844
1845 ClassExpression
1846 : "class" BindingIdentifierOpt[name] ClassTail[tail] { $$ = CYNew CYClassExpression($name, $tail); }
1847 ;
1848
1849 ClassTail
1850 : ClassHeritageOpt[tail] { driver.class_.push($tail); } "{" LexPushSuperOn ClassBodyOpt "}" LexPopSuper { driver.class_.pop(); $$ = $tail; }
1851 ;
1852
1853 ClassHeritage
1854 : "extends" AccessExpression[extends] { $$ = CYNew CYClassTail($extends); }
1855 ;
1856
1857 ClassHeritageOpt
1858 : ClassHeritage[pass] { $$ = $pass; }
1859 | { $$ = CYNew CYClassTail(NULL); }
1860 ;
1861
1862 ClassBody
1863 : ClassElementList
1864 ;
1865
1866 ClassBodyOpt
1867 : ClassBody
1868 |
1869 ;
1870
1871 ClassElementList
1872 : ClassElementListOpt ClassElement
1873 ;
1874
1875 ClassElementListOpt
1876 : ClassElementList
1877 |
1878 ;
1879
1880 ClassElement
1881 : MethodDefinition[method] { if (CYFunctionExpression *constructor = $method->Constructor()) driver.class_.top()->constructor_ = constructor; else driver.class_.top()->instance_->*$method; }
1882 | "static" MethodDefinition[method] { driver.class_.top()->static_->*$method; }
1883 | ";"
1884 ;
1885 /* }}} */
1886
1887 /* 15.1 Scripts {{{ */
1888 Script
1889 : ScriptBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1890 ;
1891
1892 ScriptBody
1893 : StatementList[pass] { $$ = $pass; }
1894 ;
1895
1896 ScriptBodyOpt
1897 : ScriptBody[pass] { $$ = $pass; }
1898 | LexSetStatement LexLet LexOf { $$ = NULL; }
1899 ;
1900 /* }}} */
1901 /* 15.2 Modules {{{ */
1902 Module
1903 : ModuleBodyOpt[code] { driver.script_ = CYNew CYScript($code); }
1904 ;
1905
1906 ModuleBody
1907 : ModuleItemList[pass] { $$ = $pass; }
1908 ;
1909
1910 ModuleBodyOpt
1911 : ModuleBody[pass] { $$ = $pass; }
1912 | LexSetStatement LexLet LexOf { $$ = NULL; }
1913 ;
1914
1915 ModuleItemList
1916 : ModuleItem[statement] ModuleItemListOpt[next] { $$ = $statement; CYSetLast($$) = $next; }
1917 ;
1918
1919 ModuleItemListOpt
1920 : ModuleItemList[pass] { $$ = $pass; }
1921 | LexSetStatement LexLet LexOf { $$ = NULL; }
1922 ;
1923
1924 ModuleItem
1925 : LexSetStatement LexLet LexOf ImportDeclaration[pass] { $$ = $pass; }
1926 | LexSetStatement LexLet LexOf ExportDeclaration { CYNOT(@$); }
1927 | StatementListItem[pass] { $$ = $pass; }
1928 ;
1929 /* }}} */
1930 /* 15.2.2 Imports {{{ */
1931 ImportDeclaration
1932 : "import" ImportClause[specifiers] FromClause[module] Terminator { $$ = CYNew CYImportDeclaration($specifiers, $module); }
1933 | "import" LexOf ModuleSpecifier[module] Terminator { $$ = CYNew CYImportDeclaration(NULL, $module); }
1934 ;
1935
1936 ImportClause
1937 : ImportedDefaultBinding[default] { $$ = $default; }
1938 | LexOf NameSpaceImport[pass] { $$ = $pass; }
1939 | LexOf NamedImports[pass] { $$ = $pass; }
1940 | ImportedDefaultBinding[default] "," NameSpaceImport[next] { $$ = $default; CYSetLast($$) = $next; }
1941 | ImportedDefaultBinding[default] "," NamedImports[next] { $$ = $default; CYSetLast($$) = $next; }
1942 ;
1943
1944 ImportedDefaultBinding
1945 : ImportedBinding[binding] { $$ = CYNew CYImportSpecifier(CYNew CYIdentifier("default"), $binding); }
1946 ;
1947
1948 NameSpaceImport
1949 : "*" "as" ImportedBinding[binding] { $$ = CYNew CYImportSpecifier(NULL, $binding); }
1950 ;
1951
1952 NamedImports
1953 : "{" ImportsListOpt[pass] "}" { $$ = $pass; }
1954 ;
1955
1956 FromClause
1957 : "from" ModuleSpecifier[pass] { $$ = $pass; }
1958 ;
1959
1960 ImportsList_
1961 : "," ImportsListOpt[pass] { $$ = $pass; }
1962 | { $$ = NULL; }
1963 ;
1964
1965 ImportsList
1966 : ImportSpecifier[import] ImportsList_[next] { $$ = $import; CYSetLast($$) = $next; }
1967 ;
1968
1969 ImportsListOpt
1970 : ImportsList[pass] { $$ = $pass; }
1971 | LexOf { $$ = NULL; }
1972 ;
1973
1974 ImportSpecifier
1975 : ImportedBinding[binding] { $$ = CYNew CYImportSpecifier($binding, $binding); }
1976 | LexOf IdentifierName[name] "as" ImportedBinding[binding] { $$ = CYNew CYImportSpecifier($name, $binding); }
1977 ;
1978
1979 ModuleSpecifier
1980 : StringLiteral[pass] { $$ = $pass; }
1981 ;
1982
1983 ImportedBinding
1984 : BindingIdentifier[pass] { $$ = $pass; }
1985 ;
1986 /* }}} */
1987 /* 15.2.3 Exports {{{ */
1988 ExportDeclaration_
1989 : "*" FromClause Terminator
1990 | ExportClause FromClause Terminator
1991 | ExportClause Terminator
1992 | VariableStatement
1993 | "default" LexSetStatement LexOf HoistableDeclaration
1994 | "default" LexSetStatement LexOf ClassDeclaration
1995 | "default" LexSetStatement AssignmentExpression Terminator
1996 ;
1997
1998 ExportDeclaration
1999 : "export" LexSetStatement LexLet LexOf ExportDeclaration_
2000 | "export" Declaration
2001 ;
2002
2003 ExportClause
2004 : ";{" ExportsListOpt "}"
2005 ;
2006
2007 ExportsList_
2008 : "," ExportsListOpt
2009 |
2010 ;
2011
2012 ExportsList
2013 : ExportSpecifier ExportsList_
2014 ;
2015
2016 ExportsListOpt
2017 : ExportsList
2018 |
2019 ;
2020
2021 ExportSpecifier
2022 : IdentifierName
2023 | IdentifierName "as" IdentifierName
2024 ;
2025 /* }}} */
2026
2027 @begin C
2028 /* Cycript (C): Type Encoding {{{ */
2029 TypeSignifier
2030 : IdentifierType[identifier] { $$ = CYNew CYTypedIdentifier(@identifier, $identifier); }
2031 | "(" "*" TypeQualifierRightOpt[typed] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
2032 ;
2033
2034 TypeSignifierNone
2035 : { $$ = CYNew CYTypedIdentifier(@$); }
2036 ;
2037
2038 TypeSignifierOpt
2039 : TypeSignifier[pass] { $$ = $pass; }
2040 | TypeSignifierNone[pass] { $$ = $pass; }
2041 ;
2042
2043 Restrict
2044 : "__restrict"
2045 | "restrict"
2046 ;
2047
2048 RestrictOpt
2049 : Restrict
2050 |
2051 ;
2052
2053 ParameterModifier
2054 : "throw" "(" ")"
2055 ;
2056
2057 ParameterModifierOpt
2058 : ParameterModifier
2059 |
2060 ;
2061
2062 ParameterTail
2063 : TypedParameterListOpt[formal] ")" ParameterModifierOpt { $$ = CYNew CYTypeFunctionWith($formal->variadic_, $formal->parameters_); }
2064 ;
2065
2066 SuffixedType
2067 : SuffixedTypeOpt[typed] "[" RestrictOpt NumericLiteral[size] "]" { $$ = $typed; $$->modifier_ = CYNew CYTypeArrayOf($size, $$->modifier_); }
2068 | "(" "^" TypeQualifierRightOpt[typed] ")" "(" TypedParameters[parameters] ")" { $$ = $typed; $$->modifier_ = CYNew CYTypeBlockWith($parameters, $$->modifier_); }
2069 | TypeSignifier[typed] "(" ParameterTail[modifier] { $$ = $typed; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2070 | "("[parenthesis] ParameterTail[modifier] { $$ = CYNew CYTypedIdentifier(@parenthesis); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2071 ;
2072
2073 SuffixedTypeOpt
2074 : SuffixedType[pass] { $$ = $pass; }
2075 | TypeSignifierOpt[pass] { $$ = $pass; }
2076 ;
2077
2078 PrefixedType
2079 : "*" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
2080 ;
2081
2082 TypeQualifierLeft
2083 : "const" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeConstant(); }
2084 | "volatile" TypeQualifierLeftOpt[modifier] { $$ = $modifier; CYSetLast($$) = CYNew CYTypeVolatile(); }
2085 ;
2086
2087 TypeQualifierLeftOpt
2088 : TypeQualifierLeft[pass] { $$ = $pass; }
2089 | { $$ = NULL; }
2090 ;
2091
2092 TypeQualifierRight
2093 : SuffixedType[pass] { $$ = $pass; }
2094 | PrefixedType[pass] { $$ = $pass; }
2095 | "const" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
2096 | "volatile" TypeQualifierRightOpt[typed] { $$ = $typed; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
2097 | Restrict TypeQualifierRightOpt[typed] { $$ = $typed; }
2098 ;
2099
2100 TypeQualifierRightOpt
2101 : TypeQualifierRight[pass] { $$ = $pass; }
2102 | TypeSignifierOpt[pass] { $$ = $pass; }
2103 ;
2104
2105 IntegerType
2106 : "int" { $$ = CYNew CYTypeIntegral(CYTypeNeutral); }
2107 | "unsigned" IntegerTypeOpt[integral] { $$ = $integral->Unsigned(); if ($$ == NULL) CYERR(@1, "incompatible unsigned"); }
2108 | "signed" IntegerTypeOpt[integral] { $$ = $integral->Signed(); if ($$ == NULL) CYERR(@1, "incompatible signed"); }
2109 | "long" IntegerTypeOpt[integral] { $$ = $integral->Long(); if ($$ == NULL) CYERR(@1, "incompatible long"); }
2110 | "short" IntegerTypeOpt[integral] { $$ = $integral->Short(); if ($$ == NULL) CYERR(@1, "incompatible short"); }
2111 ;
2112
2113 IntegerTypeOpt
2114 : IntegerType[pass] { $$ = $pass; }
2115 | { $$ = CYNew CYTypeIntegral(CYTypeNeutral); }
2116 ;
2117
2118 StructFieldListOpt
2119 : TypedIdentifierField[typed] ";" StructFieldListOpt[next] { $$ = CYNew CYTypeStructField($typed, $next); }
2120 | { $$ = NULL; }
2121 ;
2122
2123 IntegerNumber
2124 : NumericLiteral[pass] { $$ = $pass; }
2125 | "-" NumericLiteral[positive] { $$ = $positive; $$->value_ = -$$->value_; }
2126 ;
2127
2128 EnumConstantListOpt_
2129 : "," EnumConstantListOpt[pass] { $$ = $pass; }
2130 | { $$ = NULL; }
2131 ;
2132
2133 EnumConstantListOpt
2134 : IdentifierType[name] "=" IntegerNumber[value] EnumConstantListOpt_[next] { $$ = CYNew CYEnumConstant($name, $value, $next); }
2135 | { $$ = NULL; }
2136 ;
2137
2138 TypeSigning
2139 : { $$ = CYTypeNeutral; }
2140 | "signed" { $$ = CYTypeSigned; }
2141 | "unsigned" { $$ = CYTypeUnsigned; }
2142 ;
2143
2144 PrimitiveType
2145 : IdentifierType[name] { $$ = CYNew CYTypeVariable($name); }
2146 | IntegerType[pass] { $$ = $pass; }
2147 | TypeSigning[signing] "char" { $$ = CYNew CYTypeCharacter($signing); }
2148 | TypeSigning[signing] "__int128" { $$ = CYNew CYTypeInt128($signing); }
2149 ;
2150
2151 PrimitiveReference
2152 : PrimitiveType[pass] { $$ = $pass; }
2153 | "struct" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); }
2154 | "enum" IdentifierType[name] { $$ = CYNew CYTypeReference(CYTypeReferenceEnum, $name); }
2155 | "struct" AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; }
2156 | "enum" AutoComplete { driver.mode_ = CYDriver::AutoEnum; YYACCEPT; }
2157 ;
2158
2159 TypedIdentifierMaybe
2160 : TypeQualifierLeft[modifier] "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2161 | "void" TypeQualifierRight[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); }
2162 | TypeQualifierLeftOpt[modifier] PrimitiveReference[specifier] TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = $specifier; CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2163 ;
2164
2165 TypedIdentifierYes
2166 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; }
2167 ;
2168
2169 TypedIdentifierNo
2170 : TypedIdentifierMaybe[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; }
2171 ;
2172
2173 TypedIdentifierTagged
2174 : TypeQualifierLeftOpt[modifier] "struct" "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeStruct(NULL, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2175 | TypeQualifierLeftOpt[modifier] "enum" ":" PrimitiveType[specifier] "{" EnumConstantListOpt[constants] "}" TypeQualifierRightOpt[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeEnum(NULL, $specifier, $constants); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2176 ;
2177
2178 TypedIdentifierField
2179 : TypedIdentifierYes[pass] { $$ = $pass; }
2180 | TypedIdentifierTagged[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; }
2181 ;
2182
2183 TypedIdentifierEncoding
2184 : TypedIdentifierNo[pass] { $$ = $pass; }
2185 | TypedIdentifierTagged[typed] { if ($typed->identifier_ != NULL) CYERR($typed->location_, "unexpected identifier"); $$ = $typed; }
2186 | "void" TypeSignifierNone[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); }
2187 ;
2188
2189 TypedIdentifierDefinition
2190 : TypedIdentifierYes[pass] { $$ = $pass; }
2191 | TypeQualifierLeftOpt[modifier] "struct" IdentifierTypeOpt[name] "{" StructFieldListOpt[fields] "}" TypeQualifierRightOpt[typed] { if ($typed->identifier_ == NULL) CYERR($typed->location_, "expected identifier"); $$ = $typed; $$->specifier_ = CYNew CYTypeStruct($name, CYNew CYStructTail($fields)); CYSetLast($modifier) = $$->modifier_; $$->modifier_ = $modifier; }
2192 | "void" TypeSignifier[typed] { $$ = $typed; $$->specifier_ = CYNew CYTypeVoid(); }
2193 ;
2194
2195 PrimaryExpression
2196 : "@encode" "(" TypedIdentifierEncoding[typed] ")" { $$ = CYNew CYEncodedType($typed); }
2197 ;
2198 /* }}} */
2199 @end
2200
2201 @begin ObjectiveC
2202 /* Cycript (Objective-C): @class Declaration {{{ */
2203 ClassSuperOpt
2204 /* XXX: why the hell did I choose MemberExpression? */
2205 : ":" MemberExpression[extends] { $$ = $extends; }
2206 | { $$ = NULL; }
2207 ;
2208
2209 ImplementationFieldListOpt
2210 : TypedIdentifierField[typed] ";" ImplementationFieldListOpt[next] { $$ = CYNew CYImplementationField($typed, $next); }
2211 | { $$ = NULL; }
2212 ;
2213
2214 MessageScope
2215 : "+" { $$ = false; }
2216 | "-" { $$ = true; }
2217 ;
2218
2219 TypeOpt
2220 : "(" TypedIdentifierNo[type] ")" { $$ = $type; }
2221 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
2222 ;
2223
2224 MessageParameter
2225 : Word[tag] ":" TypeOpt[type] BindingIdentifier[identifier] { $type->identifier_ = $identifier; $$ = CYNew CYMessageParameter($tag, $type); }
2226 ;
2227
2228 MessageParameterList
2229 : MessageParameter[parameter] MessageParameterListOpt[next] { $parameter->SetNext($next); $$ = $parameter; }
2230 ;
2231
2232 MessageParameterListOpt
2233 : MessageParameterList[pass] { $$ = $pass; }
2234 | TypedParameterList_[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); /*XXX*/ if ($formal->parameters_ != NULL) CYERR(@$, "temporarily unsupported"); $$ = NULL; }
2235 ;
2236
2237 MessageParameters
2238 : MessageParameterList[pass] { $$ = $pass; }
2239 | Word[tag] { $$ = CYNew CYMessageParameter($tag, NULL); }
2240 ;
2241
2242 ClassMessageDeclaration
2243 : MessageScope[instance] TypeOpt[type] MessageParameters[parameters] "{" LexPushSuperOn FunctionBody[code] "}" LexPopSuper { $$ = CYNew CYMessage($instance, $type, $parameters, $code); }
2244 ;
2245
2246 ClassMessageDeclarationListOpt
2247 : ClassMessageDeclarationListOpt[next] ClassMessageDeclaration[message] { $message->SetNext($next); $$ = $message; }
2248 | { $$ = NULL; }
2249 ;
2250
2251 // XXX: this should be AssignmentExpressionNoRight
2252 ClassProtocols
2253 : ShiftExpression[name] ClassProtocolsOpt[next] { $$ = CYNew CYProtocol($name, $next); }
2254 ;
2255
2256 ClassProtocolsOpt
2257 : "," ClassProtocols[protocols] { $$ = $protocols; }
2258 | { $$ = NULL; }
2259 ;
2260
2261 ClassProtocolListOpt
2262 : "<" ClassProtocols[protocols] ">" { $$ = $protocols; }
2263 | { $$ = NULL; }
2264 ;
2265
2266 ImplementationStatement
2267 : "@implementation" Identifier[name] ClassSuperOpt[extends] ClassProtocolListOpt[protocols] "{" ImplementationFieldListOpt[fields] "}" ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYImplementation($name, $extends, $protocols, $fields, $messages); }
2268 ;
2269
2270 CategoryName
2271 : "(" WordOpt ")"
2272 ;
2273
2274 CategoryStatement
2275 : "@implementation" Identifier[name] CategoryName ClassMessageDeclarationListOpt[messages] "@end" { $$ = CYNew CYCategory($name, $messages); }
2276 ;
2277
2278 Statement__
2279 : ImplementationStatement[pass] { $$ = $pass; }
2280 | CategoryStatement[pass] { $$ = $pass; }
2281 ;
2282 /* }}} */
2283 /* Cycript (Objective-C): Send Message {{{ */
2284 VariadicCall
2285 : "," AssignmentExpressionClassic[value] VariadicCall[next] { $$ = CYNew CYArgument(NULL, $value, $next); }
2286 | { $$ = NULL; }
2287 ;
2288
2289 SelectorWordOpt
2290 : WordOpt[name] { driver.contexts_.back().words_.push_back($name); } { $$ = $name; }
2291 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
2292 ;
2293
2294 SelectorCall_
2295 : SelectorCall[pass] { $$ = $pass; }
2296 | VariadicCall[pass] { $$ = $pass; }
2297 ;
2298
2299 SelectorCall
2300 : SelectorWordOpt[name] ":" AssignmentExpressionClassic[value] SelectorCall_[next] { $$ = CYNew CYArgument($name ?: CYNew CYWord(""), $value, $next); }
2301 ;
2302
2303 SelectorList
2304 : SelectorCall[pass] { $$ = $pass; }
2305 | Word[name] { $$ = CYNew CYArgument($name, NULL); }
2306 ;
2307
2308 MessageExpression
2309 : "[" AssignmentExpressionClassic[self] { driver.contexts_.push_back($self); } SelectorList[arguments] "]" { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($self, $arguments); }
2310 | "[" LexOf "super" { driver.context_ = NULL; } SelectorList[arguments] "]" { $$ = CYNew CYSendSuper($arguments); }
2311 ;
2312
2313 SelectorExpression_
2314 : WordOpt[name] ":" SelectorExpressionOpt[next] { $$ = CYNew CYSelectorPart($name, true, $next); }
2315 ;
2316
2317 SelectorExpression
2318 : SelectorExpression_[pass] { $$ = $pass; }
2319 | Word[name] { $$ = CYNew CYSelectorPart($name, false, NULL); }
2320 ;
2321
2322 SelectorExpressionOpt
2323 : SelectorExpression_[pass] { $$ = $pass; }
2324 | { $$ = NULL; }
2325 ;
2326
2327 PrimaryExpression
2328 : MessageExpression[pass] { $$ = $pass; }
2329 | "@selector" "(" SelectorExpression[parts] ")" { $$ = CYNew CYSelector($parts); }
2330 ;
2331 /* }}} */
2332 @end
2333
2334 /* Cycript: @import Directive {{{ */
2335 ModulePath
2336 : ModulePath[next] "." Word[part] { $$ = CYNew CYModule($part, $next); }
2337 | Word[part] { $$ = CYNew CYModule($part); }
2338 ;
2339
2340 Declaration_
2341 : "@import" ModulePath[path] { $$ = CYNew CYImport($path); }
2342 ;
2343 /* }}} */
2344
2345 @begin ObjectiveC
2346 /* Cycript (Objective-C): Boxed Expressions {{{ */
2347 BoxableExpression
2348 : NullLiteral[pass] { $$ = $pass; }
2349 | BooleanLiteral[pass] { $$ = $pass; }
2350 | NumericLiteral[pass] { $$ = $pass; }
2351 | StringLiteral[pass] { $$ = $pass; }
2352 | CoverParenthesizedExpressionAndArrowParameterList[pass] { $$ = $pass; }
2353 | "YES" { $$ = CYNew CYTrue(); }
2354 | "NO" { $$ = CYNew CYFalse(); }
2355 ;
2356
2357 KeyValuePairList_
2358 : "," KeyValuePairListOpt[next] { $$ = $next; }
2359 | { $$ = NULL; }
2360
2361 KeyValuePairList
2362 : AssignmentExpression[key] ":" AssignmentExpression[value] KeyValuePairList_[next] { $$ = CYNew CYObjCKeyValue($key, $value, $next); }
2363 ;
2364
2365 KeyValuePairListOpt
2366 : KeyValuePairList[pass] { $$ = $pass; }
2367 | LexOf { $$ = NULL; }
2368 ;
2369
2370 PrimaryExpression
2371 : "@" BoxableExpression[expression] { $$ = CYNew CYBox($expression); }
2372 | "@" "[" ElementListOpt[elements] "]" { $$ = CYNew CYObjCArray($elements); }
2373 | "@" "{" KeyValuePairListOpt[pairs] "}" { $$ = CYNew CYObjCDictionary($pairs); }
2374
2375 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
2376 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
2377 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
2378 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
2379 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
2380 ;
2381 /* }}} */
2382 /* Cycript (Objective-C): Block Expressions {{{ */
2383 PrimaryExpression
2384 : "^" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { if (CYTypeFunctionWith *function = $type->Function()) $$ = CYNew CYObjCBlock($type, function->parameters_, $code); else CYERR($type->location_, "expected parameters"); }
2385 ;
2386 /* }}} */
2387 /* Cycript (Objective-C): Instance Literals {{{ */
2388 PrimaryExpression
2389 : "#" NumericLiteral[address] { $$ = CYNew CYInstanceLiteral($address); }
2390 ;
2391 /* }}} */
2392 @end
2393
2394 @begin C
2395 /* Cycript (C): Pointer Indirection/Addressing {{{ */
2396 UnaryExpression_
2397 : IndirectExpression[pass] { $$ = $pass; }
2398 ;
2399
2400 IndirectExpression
2401 : "*" UnaryExpression[rhs] { $$ = CYNew CYIndirect($rhs); }
2402 ;
2403
2404 UnaryExpression_
2405 : "&" UnaryExpression[rhs] { $$ = CYNew CYAddressOf($rhs); }
2406 ;
2407
2408 MemberAccess
2409 : "->" "[" Expression[property] "]" { $$ = CYNew CYIndirectMember(NULL, $property); }
2410 | "->" IdentifierName[property] { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($property)); }
2411 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
2412 ;
2413 /* }}} */
2414 /* Cycript (C): Lambda Expressions {{{ */
2415 TypedParameterList_
2416 : "," TypedParameterList[parameters] { $$ = $parameters; }
2417 | { $$ = CYNew CYTypedFormal(false); }
2418 ;
2419
2420 TypedParameterList
2421 : TypedIdentifierMaybe[typed] TypedParameterList_[formal] { $$ = $formal; $$->parameters_ = CYNew CYTypedParameter($typed, $$->parameters_); }
2422 | "..." { $$ = CYNew CYTypedFormal(true); }
2423 ;
2424
2425 TypedParameterListOpt
2426 : TypedParameterList[pass] { $$ = $pass; }
2427 | "void" { $$ = CYNew CYTypedFormal(false); }
2428 | { $$ = CYNew CYTypedFormal(false); }
2429 ;
2430
2431 TypedParameters
2432 : TypedParameterListOpt[formal] { if ($formal->variadic_) CYERR(@$, "unsupported variadic"); $$ = $formal->parameters_; }
2433 ;
2434
2435 PrimaryExpression
2436 : "[" LexOf "&" "]" "(" TypedParameters[parameters] ")" "->" TypedIdentifierNo[type] "{" FunctionBody[code] "}" { $$ = CYNew CYLambda($type, $parameters, $code); }
2437 ;
2438 /* }}} */
2439 /* Cycript (C): Structure Definitions {{{ */
2440 IdentifierNoOf
2441 : "struct" NewLineOpt { $$ = CYNew CYIdentifier("struct"); }
2442 ;
2443
2444 Statement__
2445 : "struct" NewLineNot IdentifierType[name] "{" StructFieldListOpt[fields] "}" { $$ = CYNew CYStructDefinition($name, CYNew CYStructTail($fields)); }
2446 ;
2447
2448 PrimaryExpression
2449 : "(" LexOf "struct" NewLineOpt IdentifierType[name] TypeQualifierRightOpt[typed] ")" { $typed->specifier_ = CYNew CYTypeReference(CYTypeReferenceStruct, $name); $$ = CYNew CYTypeExpression($typed); }
2450 | "(" LexOf "struct" NewLineOpt AutoComplete { driver.mode_ = CYDriver::AutoStruct; YYACCEPT; }
2451 ;
2452 /* }}} */
2453 /* Cycript (C): Type Definitions {{{ */
2454 IdentifierNoOf
2455 : "typedef" NewLineOpt { $$ = CYNew CYIdentifier("typedef"); }
2456 ;
2457
2458 TypeDefinition
2459 : "typedef" NewLineNot TypedIdentifierDefinition[typed] TerminatorHard { $$ = CYNew CYTypeDefinition($typed); }
2460 ;
2461
2462 Statement__
2463 : TypeDefinition[pass] { $$ = $pass; }
2464 ;
2465
2466 PrimaryExpression
2467 : "(" LexOf "typedef" NewLineOpt TypedIdentifierEncoding[typed] ")" { $$ = CYNew CYTypeExpression($typed); }
2468 ;
2469 /* }}} */
2470 /* Cycript (C): extern "C" {{{ */
2471 IdentifierNoOf
2472 : "extern" NewLineOpt { $$ = CYNew CYIdentifier("extern"); }
2473 ;
2474
2475 ExternCStatement
2476 : TypedIdentifierField[typed] TerminatorHard { $$ = CYNew CYExternalDefinition(CYNew CYString("C"), $typed); }
2477 | TypeDefinition[pass] { $$ = $pass; }
2478 ;
2479
2480 ExternCStatementListOpt
2481 : ExternCStatement[statement] ExternCStatementListOpt[next] { $$ = $statement; CYSetLast($$) = $next; }
2482 | { $$ = NULL; }
2483 ;
2484
2485 ExternC
2486 : "{" ExternCStatementListOpt[pass] "}" { $$ = $pass; }
2487 | ExternCStatement[pass] { $$ = $pass; }
2488 ;
2489
2490 ABI
2491 : StringLiteral[abi] { if (strcmp($abi->Value(), "C") != 0) CYERR(@abi, "unknown extern binding"); }
2492 ;
2493
2494 Statement__
2495 : "extern" NewLineNot ABI[abi] ExternC[pass] { $$ = $pass; }
2496 ;
2497
2498 PrimaryExpression
2499 : "(" LexOf "extern" NewLineOpt ABI[abi] TypedIdentifierField[typed] ")" { $$ = CYNew CYExternalExpression(CYNew CYString("C"), $typed); }
2500 ;
2501 /* }}} */
2502 @end
2503
2504 @begin E4X
2505 /* Lexer State {{{ */
2506 LexPushRegExp
2507 : { driver.PushCondition(CYDriver::RegExpCondition); }
2508 ;
2509
2510 LexPushXMLContent
2511 : { driver.PushCondition(CYDriver::XMLContentCondition); }
2512 ;
2513
2514 LexPushXMLTag
2515 : { driver.PushCondition(CYDriver::XMLTagCondition); }
2516 ;
2517
2518 LexPop
2519 : { driver.PopCondition(); }
2520 ;
2521
2522 LexSetXMLContent
2523 : { driver.SetCondition(CYDriver::XMLContentCondition); }
2524 ;
2525
2526 LexSetXMLTag
2527 : { driver.SetCondition(CYDriver::XMLTagCondition); }
2528 ;
2529 /* }}} */
2530 /* Virtual Tokens {{{ */
2531 XMLWhitespaceOpt
2532 : XMLWhitespace
2533 |
2534 ;
2535 /* }}} */
2536
2537 /* 8.1 Context Keywords {{{ */
2538 Identifier
2539 : "namespace" { $$ = CYNew CYIdentifier("namespace"); }
2540 | "xml" { $$ = CYNew CYIdentifier("xml"); }
2541 ;
2542 /* }}} */
2543 /* 8.3 XML Initializer Input Elements {{{ */
2544 XMLMarkup
2545 : XMLComment { $$ = $1; }
2546 | XMLCDATA { $$ = $1; }
2547 | XMLPI { $$ = $1; }
2548 ;
2549 /* }}} */
2550
2551 /* 11.1 Primary Expressions {{{ */
2552 PrimaryExpression
2553 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
2554 | XMLInitilizer { $$ = $1; }
2555 | XMLListInitilizer { $$ = $1; }
2556 ;
2557
2558 PropertyIdentifier
2559 : AttributeIdentifier { $$ = $1; }
2560 | QualifiedIdentifier { $$ = $1; }
2561 | WildcardIdentifier { $$ = $1; }
2562 ;
2563 /* }}} */
2564 /* 11.1.1 Attribute Identifiers {{{ */
2565 AttributeIdentifier
2566 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
2567 ;
2568
2569 PropertySelector_
2570 : PropertySelector { $$ = $1; }
2571 | "[" Expression "]" { $$ = CYNew CYSelector($2); }
2572 ;
2573
2574 PropertySelector
2575 : Identifier { $$ = CYNew CYSelector($1); }
2576 | WildcardIdentifier { $$ = $1; }
2577 ;
2578 /* }}} */
2579 /* 11.1.2 Qualified Identifiers {{{ */
2580 QualifiedIdentifier_
2581 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
2582 | QualifiedIdentifier { $$ = $1; }
2583 ;
2584
2585 QualifiedIdentifier
2586 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
2587 ;
2588 /* }}} */
2589 /* 11.1.3 Wildcard Identifiers {{{ */
2590 WildcardIdentifier
2591 : "*" { $$ = CYNew CYWildcard(); }
2592 ;
2593 /* }}} */
2594 /* 11.1.4 XML Initializer {{{ */
2595 XMLInitilizer
2596 : XMLMarkup { $$ = $1; }
2597 | XMLElement { $$ = $1; }
2598 ;
2599
2600 XMLElement
2601 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
2602 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
2603 ;
2604
2605 XMLTagContent
2606 : LexPushXMLTag XMLTagName XMLAttributes
2607 ;
2608
2609 XMLExpression
2610 : "{" LexPushRegExp Expression LexPop "}"
2611 ;
2612
2613 XMLTagName
2614 : XMLExpression
2615 | XMLName
2616 ;
2617
2618 XMLAttributes_
2619 : XMLAttributes_ XMLAttribute
2620 |
2621 ;
2622
2623 XMLAttributes
2624 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
2625 | XMLAttributes_ XMLWhitespaceOpt
2626 ;
2627
2628 XMLAttributeValue_
2629 : XMLExpression
2630 | XMLAttributeValue
2631 ;
2632
2633 XMLAttribute
2634 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
2635 ;
2636
2637 XMLElementContent
2638 : XMLExpression XMLElementContentOpt
2639 | XMLMarkup XMLElementContentOpt
2640 | XMLText XMLElementContentOpt
2641 | XMLElement XMLElementContentOpt
2642 ;
2643
2644 XMLElementContentOpt
2645 : XMLElementContent
2646 |
2647 ;
2648 /* }}} */
2649 /* 11.1.5 XMLList Initializer {{{ */
2650 XMLListInitilizer
2651 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
2652 ;
2653 /* }}} */
2654
2655 /* 11.2 Left-Hand-Side Expressions {{{ */
2656 PropertyIdentifier_
2657 : Identifier { $$ = $1; }
2658 | PropertyIdentifier { $$ = $1; }
2659 ;
2660
2661 MemberAccess
2662 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
2663 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
2664 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
2665 ;
2666 /* }}} */
2667 /* 12.1 The default xml namespace Statement {{{ */
2668 /* XXX: DefaultXMLNamespaceStatement
2669 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
2670 ;
2671
2672 Statement__
2673 : DefaultXMLNamespaceStatement { $$ = $1; }
2674 ; */
2675 /* }}} */
2676 @end
2677
2678 /* JavaScript FTL: Array Comprehensions {{{ */
2679 Comprehension
2680 : AssignmentExpression[expression] ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2681 ;
2682
2683 ComprehensionFor
2684 : "for" "each" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2685 ;
2686 /* }}} */
2687 /* JavaScript FTL: for each {{{ */
2688 IterationStatement
2689 : "for" "each" "(" LexPushInOn ForInStatementInitializer[initializer] "!in" LexPopIn Expression[iterable] ")" Statement[code] { $$ = CYNew CYForOf($initializer, $iterable, $code); }
2690 ;
2691 /* }}} */
2692
2693 /* JavaScript FTW: Array Comprehensions {{{ */
2694 PrimaryExpression
2695 : ArrayComprehension
2696 ;
2697
2698 ArrayComprehension
2699 : "[" Comprehension[comprehension] "]" { $$ = $comprehension; }
2700 ;
2701
2702 Comprehension
2703 : LexOf ComprehensionFor[comprehension] ComprehensionTail[next] AssignmentExpression[expression] { $comprehension->SetNext($next); $$ = CYNew CYArrayComprehension($expression, $comprehension); }
2704 ;
2705
2706 ComprehensionTail
2707 : { $$ = NULL; }
2708 | ComprehensionFor[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2709 | ComprehensionIf[comprehension] ComprehensionTail[next] { $comprehension->SetNext($next); $$ = $comprehension; }
2710 ;
2711
2712 ComprehensionFor
2713 : "for" "(" LexPushInOn LexBind ForBinding[binding] "!in" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForInComprehension($binding, $iterable); }
2714 | "for" "(" LexPushInOn LexBind ForBinding[binding] "of" LexPopIn Expression[iterable] ")" { $$ = CYNew CYForOfComprehension($binding, $iterable); }
2715 ;
2716
2717 ComprehensionIf
2718 : "if" "(" AssignmentExpression[test] ")" { $$ = CYNew CYIfComprehension($test); }
2719 ;
2720 /* }}} */
2721 /* JavaScript FTW: Named Arguments {{{ */
2722 ArgumentList
2723 : LexOf WordNoUnary[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
2724 ;
2725 /* }}} */
2726 /* JavaScript FTW: Subscript Access {{{ */
2727 MemberAccess
2728 : "." "[" AssignmentExpression[property] "]" { $$ = CYNew CYSubscriptMember(NULL, $property); }
2729 ;
2730 /* }}} */
2731
2732 /* JavaScript FTW: Java "Anonymous Inner Classes" {{{ */
2733 BracedParameter
2734 : "{" PropertyDefinitionListOpt[properties] "}" { $$ = CYNew CYExtend(NULL, $properties); }
2735 ;
2736 /* }}} */
2737
2738 /* JavaScript FTW: Ruby Blocks {{{ */
2739 RubyProcParameterList_
2740 : "," RubyProcParameterList[parameters] { $$ = $parameters; }
2741 | { $$ = NULL; }
2742 ;
2743
2744 RubyProcParameterList
2745 : BindingIdentifier[identifier] RubyProcParameterList_[next] { $$ = CYNew CYFunctionParameter(CYNew CYBinding($identifier), $next); }
2746 | LexOf { $$ = NULL; }
2747 ;
2748
2749 RubyProcParameters
2750 : "|" RubyProcParameterList[parameters] "|" { $$ = $parameters; }
2751 | "||" { $$ = NULL; }
2752 ;
2753
2754 RubyProcParametersOpt
2755 : RubyProcParameters[pass] { $$ = $pass; }
2756 | { $$ = NULL; }
2757 ;
2758
2759 BracedParameter
2760 : ";{" RubyProcParametersOpt[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyBlock(NULL, CYNew CYRubyProc($parameters, $code)); }
2761 ;
2762
2763 PrimaryExpression
2764 : "{" RubyProcParameters[parameters] StatementListOpt[code] "}" { $$ = CYNew CYRubyProc($parameters, $code); }
2765 ;
2766
2767 BracedExpression_
2768 : AccessExpression[pass] LexNewLineOrOpt { $$ = $pass; }
2769 | BracedExpression_[lhs] { if (!$lhs->IsNew()) CYMAP(OpenBrace_, OpenBrace); } BracedParameter[rhs] LexNewLineOrOpt { $rhs->SetLeft($lhs); $$ = $rhs; }
2770 ;
2771
2772 BracedExpression
2773 : BracedExpression_[pass] "\n" { $$ = $pass; }
2774 | BracedExpression_[pass] { $$ = $pass; }
2775 ;
2776 /* }}} */
2777 /* JavaScript FTW: Ruby Scopes {{{ */
2778 MemberAccess
2779 : "::" "[" Expression[property] "]" { $$ = CYNew CYResolveMember(NULL, $property); }
2780 | "::" IdentifierName[property] { $$ = CYNew CYResolveMember(NULL, CYNew CYString($property)); }
2781 | "::" AutoComplete { driver.mode_ = CYDriver::AutoResolve; YYACCEPT; }
2782 ;
2783 /* }}} */
2784 /* JavaScript FTW: Ruby Symbols {{{ */
2785 PrimaryExpression
2786 : ":" Word[name] { $$ = CYNew CYSymbol($name->Word()); }
2787 ;
2788 /* }}} */
2789
2790 %%
2791
2792 bool CYDriver::Parse(CYMark mark) {
2793 mark_ = mark;
2794 CYLocal<CYPool> local(&pool_);
2795 cy::parser parser(*this);
2796 #ifdef YYDEBUG
2797 parser.set_debug_level(debug_);
2798 #endif
2799 return parser.parse() != 0;
2800 }
2801
2802 void CYDriver::Warning(const cy::parser::location_type &location, const char *message) {
2803 if (!strict_)
2804 return;
2805
2806 CYDriver::Error error;
2807 error.warning_ = true;
2808 error.location_ = location;
2809 error.message_ = message;
2810 errors_.push_back(error);
2811 }
2812
2813 void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
2814 CYDriver::Error error;
2815 error.warning_ = false;
2816 error.location_ = location;
2817 error.message_ = message;
2818 driver.errors_.push_back(error);
2819 }