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