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