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