]> git.saurik.com Git - cycript.git/blame - Cycript.y
More interactivity and @selector start.
[cycript.git] / Cycript.y
CommitLineData
1dbba6cc 1%code top {
63b4c5a8 2#include "Cycript.tab.hh"
5999c315 3#define scanner driver.scanner_
693d501b 4#define YYSTACKEXPANDABLE 1
1dbba6cc
JF
5}
6
63b4c5a8
JF
7%code requires {
8#include "Parser.hpp"
63b4c5a8 9
c3c20102
JF
10typedef struct {
11 bool newline_;
12
13 union {
14 CYArgument *argument_;
15 CYBoolean *boolean_;
16 CYClause *clause_;
17 CYCatch *catch_;
18 CYDeclaration *declaration_;
19 CYDeclarations *declarations_;
20 CYElement *element_;
21 CYExpression *expression_;
22 CYFalse *false_;
23 CYForInitialiser *for_;
24 CYForInInitialiser *forin_;
25 CYIdentifier *identifier_;
26 CYLiteral *literal_;
27 CYName *name_;
28 CYNull *null_;
29 CYNumber *number_;
30 CYParameter *parameter_;
31 CYProperty *property_;
e7ed5354 32 CYSelector *selector_;
c3c20102
JF
33 CYSource *source_;
34 CYStatement *statement_;
35 CYString *string_;
36 CYThis *this_;
37 CYTrue *true_;
38 CYWord *word_;
39 };
40} YYSTYPE;
41
63b4c5a8
JF
42}
43
693d501b
JF
44%code provides {
45int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
46}
47
1dbba6cc 48%name-prefix "cy"
e5332278 49
63b4c5a8 50%language "C++"
e5332278 51%locations
1dbba6cc 52
5999c315
JF
53%initial-action {
54 @$.begin.filename = @$.end.filename = &driver.filename_;
55};
56
e5332278 57%defines
1dbba6cc
JF
58
59%debug
e5332278
JF
60%error-verbose
61
5999c315 62%parse-param { CYDriver &driver }
924f67b2 63%lex-param { void *scanner }
e5332278 64
63b4c5a8
JF
65%token Ampersand "&"
66%token AmpersandAmpersand "&&"
67%token AmpersandEqual "&="
68%token Carrot "^"
69%token CarrotEqual "^="
70%token Equal "="
71%token EqualEqual "=="
72%token EqualEqualEqual "==="
73%token Exclamation "!"
74%token ExclamationEqual "!="
75%token ExclamationEqualEqual "!=="
76%token Hyphen "-"
77%token HyphenEqual "-="
78%token HyphenHyphen "--"
c3c20102 79%token HyphenHyphen_ "\n--"
63b4c5a8
JF
80%token HyphenRight "->"
81%token Left "<"
82%token LeftEqual "<="
83%token LeftLeft "<<"
84%token LeftLeftEqual "<<="
85%token Percent "%"
86%token PercentEqual "%="
87%token Period "."
88%token Pipe "|"
89%token PipeEqual "|="
90%token PipePipe "||"
91%token Plus "+"
92%token PlusEqual "+="
93%token PlusPlus "++"
c3c20102 94%token PlusPlus_ "\n++"
63b4c5a8
JF
95%token Right ">"
96%token RightEqual ">="
97%token RightRight ">>"
98%token RightRightEqual ">>="
99%token RightRightRight ">>>"
100%token RightRightRightEqual ">>>="
101%token Slash "/"
102%token SlashEqual "/="
103%token Star "*"
104%token StarEqual "*="
105%token Tilde "~"
106
107%token Colon ":"
108%token Comma ","
109%token Question "?"
110%token SemiColon ";"
c3c20102 111%token NewLine "\n"
63b4c5a8
JF
112
113%token OpenParen "("
114%token CloseParen ")"
924f67b2 115
63b4c5a8
JF
116%token OpenBrace "{"
117%token CloseBrace "}"
924f67b2 118
63b4c5a8
JF
119%token OpenBracket "["
120%token CloseBracket "]"
121
e7ed5354
JF
122%token AtSelector "@selector"
123
cf7d4c69
JF
124%token <word_> Break "break"
125%token <word_> Case "case"
126%token <word_> Catch "catch"
127%token <word_> Continue "continue"
128%token <word_> Default "default"
129%token <word_> Delete "delete"
130%token <word_> Do "do"
131%token <word_> Else "else"
132%token <false_> False "false"
133%token <word_> Finally "finally"
134%token <word_> For "for"
135%token <word_> Function "function"
136%token <word_> If "if"
137%token <word_> In "in"
138%token <word_> InstanceOf "instanceof"
139%token <word_> New "new"
140%token <null_> Null "null"
141%token <word_> Return "return"
142%token <word_> Switch "switch"
143%token <this_> This "this"
144%token <word_> Throw "throw"
145%token <true_> True "true"
146%token <word_> Try "try"
147%token <word_> TypeOf "typeof"
148%token <word_> Var "var"
149%token <word_> Void "void"
150%token <word_> While "while"
151%token <word_> With "with"
63b4c5a8
JF
152
153%token <identifier_> Identifier
154%token <number_> NumericLiteral
155%token <string_> StringLiteral
1dbba6cc 156
cf7d4c69 157%type <expression_> AdditiveExpression
693d501b 158%type <expression_> AdditiveExpressionNoBF
cf7d4c69
JF
159%type <argument_> ArgumentList
160%type <argument_> ArgumentList_
161%type <argument_> ArgumentListOpt
162%type <argument_> Arguments
163%type <literal_> ArrayLiteral
164%type <expression_> AssignmentExpression
693d501b
JF
165%type <expression_> AssignmentExpressionNoBF
166%type <expression_> AssignmentExpressionNoIn
cf7d4c69 167%type <expression_> BitwiseANDExpression
693d501b
JF
168%type <expression_> BitwiseANDExpressionNoBF
169%type <expression_> BitwiseANDExpressionNoIn
cf7d4c69
JF
170%type <statement_> Block
171%type <boolean_> BooleanLiteral
172%type <expression_> BitwiseORExpression
693d501b
JF
173%type <expression_> BitwiseORExpressionNoBF
174%type <expression_> BitwiseORExpressionNoIn
cf7d4c69 175%type <expression_> BitwiseXORExpression
693d501b
JF
176%type <expression_> BitwiseXORExpressionNoBF
177%type <expression_> BitwiseXORExpressionNoIn
cf7d4c69
JF
178%type <statement_> BreakStatement
179%type <expression_> CallExpression
693d501b 180%type <expression_> CallExpressionNoBF
cf7d4c69
JF
181%type <clause_> CaseBlock
182%type <clause_> CaseClause
183%type <clause_> CaseClausesOpt
184%type <catch_> CatchOpt
185%type <expression_> ConditionalExpression
693d501b
JF
186%type <expression_> ConditionalExpressionNoBF
187%type <expression_> ConditionalExpressionNoIn
cf7d4c69
JF
188%type <statement_> ContinueStatement
189%type <clause_> DefaultClause
190%type <statement_> DoWhileStatement
191%type <expression_> Element
192%type <element_> ElementList
193%type <element_> ElementList_
194%type <statement_> ElseStatementOpt
195%type <statement_> EmptyStatement
196%type <expression_> EqualityExpression
693d501b
JF
197%type <expression_> EqualityExpressionNoBF
198%type <expression_> EqualityExpressionNoIn
cf7d4c69 199%type <expression_> Expression
cf7d4c69 200%type <expression_> ExpressionOpt
693d501b
JF
201%type <expression_> Expression_
202%type <expression_> ExpressionNoBF
203%type <expression_> ExpressionNoIn
204%type <expression_> ExpressionNoIn_
205%type <expression_> ExpressionNoInOpt
cf7d4c69
JF
206%type <statement_> ExpressionStatement
207%type <statement_> FinallyOpt
208%type <statement_> ForStatement
209%type <for_> ForStatementInitialiser
210%type <statement_> ForInStatement
211%type <forin_> ForInStatementInitialiser
212%type <parameter_> FormalParameterList
213%type <parameter_> FormalParameterList_
214%type <source_> FunctionBody
215%type <source_> FunctionDeclaration
216%type <expression_> FunctionExpression
217%type <identifier_> IdentifierOpt
218%type <statement_> IfStatement
219%type <expression_> Initialiser
220%type <expression_> InitialiserOpt
693d501b
JF
221%type <expression_> InitialiserNoIn
222%type <expression_> InitialiserNoInOpt
cf7d4c69
JF
223%type <statement_> IterationStatement
224%type <statement_> LabelledStatement
225%type <expression_> LeftHandSideExpression
693d501b
JF
226%type <expression_> LeftHandSideExpression_
227%type <expression_> LeftHandSideExpressionNoBF
cf7d4c69
JF
228%type <literal_> Literal
229%type <expression_> LogicalANDExpression
693d501b
JF
230%type <expression_> LogicalANDExpressionNoBF
231%type <expression_> LogicalANDExpressionNoIn
cf7d4c69 232%type <expression_> LogicalORExpression
693d501b
JF
233%type <expression_> LogicalORExpressionNoBF
234%type <expression_> LogicalORExpressionNoIn
cf7d4c69 235%type <expression_> MemberExpression
693d501b
JF
236%type <expression_> MemberExpression_
237%type <expression_> MemberExpressionNoBF
cf7d4c69 238%type <expression_> MultiplicativeExpression
693d501b 239%type <expression_> MultiplicativeExpressionNoBF
cf7d4c69 240%type <expression_> NewExpression
693d501b
JF
241%type <expression_> NewExpression_
242%type <expression_> NewExpressionNoBF
cf7d4c69
JF
243%type <null_> NullLiteral
244%type <literal_> ObjectLiteral
cf7d4c69 245%type <expression_> PostfixExpression
693d501b 246%type <expression_> PostfixExpressionNoBF
cf7d4c69 247%type <expression_> PrimaryExpression
693d501b
JF
248%type <expression_> PrimaryExpression_
249%type <expression_> PrimaryExpressionNoBF
cf7d4c69
JF
250%type <source_> Program
251%type <name_> PropertyName
252%type <property_> PropertyNameAndValueList
253%type <property_> PropertyNameAndValueList_
254%type <property_> PropertyNameAndValueListOpt
255%type <expression_> RelationalExpression
693d501b
JF
256%type <expression_> RelationalExpressionNoBF
257%type <expression_> RelationalExpressionNoIn
cf7d4c69 258%type <statement_> ReturnStatement
e7ed5354
JF
259%type <selector_> SelectorExpression
260%type <selector_> SelectorExpression_
261%type <selector_> SelectorExpressionOpt
cf7d4c69 262%type <expression_> ShiftExpression
693d501b 263%type <expression_> ShiftExpressionNoBF
cf7d4c69
JF
264%type <source_> SourceElement
265%type <source_> SourceElements
266%type <statement_> Statement
693d501b 267%type <statement_> StatementList
cf7d4c69
JF
268%type <statement_> StatementListOpt
269%type <statement_> SwitchStatement
270%type <statement_> ThrowStatement
271%type <statement_> TryStatement
272%type <expression_> UnaryExpression
693d501b
JF
273%type <expression_> UnaryExpression_
274%type <expression_> UnaryExpressionNoBF
cf7d4c69 275%type <declaration_> VariableDeclaration
693d501b 276%type <declaration_> VariableDeclarationNoIn
cf7d4c69
JF
277%type <declarations_> VariableDeclarationList
278%type <declarations_> VariableDeclarationList_
693d501b
JF
279%type <declarations_> VariableDeclarationListNoIn
280%type <declarations_> VariableDeclarationListNoIn_
cf7d4c69 281%type <statement_> VariableStatement
cf7d4c69
JF
282%type <statement_> WhileStatement
283%type <statement_> WithStatement
284%type <word_> Word
285%type <word_> WordOpt
286
693d501b
JF
287%type <expression_> MessageExpression
288%type <argument_> SelectorCall
289%type <argument_> SelectorCall_
290%type <argument_> SelectorList
291%type <argument_> VariadicCall
292
c3c20102
JF
293%nonassoc "if"
294%nonassoc "else"
295
693d501b 296%start Program
e5332278 297
693d501b 298%%
c3c20102 299
c3c20102
JF
300TerminatorOpt
301 : ";"
693d501b
JF
302 | "\n"
303 | error { yyerrok; }
c3c20102
JF
304 ;
305
306Terminator
307 : ";"
693d501b 308 | "\n"
55c229fd 309 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else yyerrok; }
c3c20102
JF
310 ;
311
693d501b
JF
312CommaOpt
313 : ","
314 |
315 ;
316
c3c20102 317NewLineOpt
693d501b 318 : "\n"
c3c20102
JF
319 |
320 ;
1dbba6cc 321
36cd3cb9 322WordOpt
cf7d4c69
JF
323 : Word { $$ = $1; }
324 | { $$ = NULL; }
2bf24581
JF
325 ;
326
36cd3cb9 327Word
cf7d4c69 328 : Identifier { $$ = $1; }
c3c20102 329 | "break" NewLineOpt { $$ = $1; }
cf7d4c69
JF
330 | "case" { $$ = $1; }
331 | "catch" { $$ = $1; }
c3c20102 332 | "continue" NewLineOpt { $$ = $1; }
cf7d4c69
JF
333 | "default" { $$ = $1; }
334 | "delete" { $$ = $1; }
335 | "do" { $$ = $1; }
336 | "else" { $$ = $1; }
337 | "false" { $$ = $1; }
338 | "finally" { $$ = $1; }
339 | "for" { $$ = $1; }
340 | "function" { $$ = $1; }
341 | "if" { $$ = $1; }
693d501b
JF
342 /* XXX: | "in" { $$ = $1; } */
343 /* XXX: | "instanceof" { $$ = $1; } */
cf7d4c69
JF
344 | "new" { $$ = $1; }
345 | "null" { $$ = $1; }
c3c20102 346 | "return" NewLineOpt { $$ = $1; }
cf7d4c69
JF
347 | "switch" { $$ = $1; }
348 | "this" { $$ = $1; }
c3c20102 349 | "throw" NewLineOpt { $$ = $1; }
cf7d4c69
JF
350 | "true" { $$ = $1; }
351 | "try" { $$ = $1; }
352 | "typeof" { $$ = $1; }
353 | "var" { $$ = $1; }
354 | "void" { $$ = $1; }
355 | "while" { $$ = $1; }
356 | "with" { $$ = $1; }
2bf24581
JF
357 ;
358
36cd3cb9 359IdentifierOpt
cf7d4c69
JF
360 : Identifier { $$ = $1; }
361 | { $$ = NULL; }
1dbba6cc
JF
362 ;
363
36cd3cb9 364Literal
cf7d4c69
JF
365 : NullLiteral { $$ = $1; }
366 | BooleanLiteral { $$ = $1; }
367 | NumericLiteral { $$ = $1; }
368 | StringLiteral { $$ = $1; }
1dbba6cc
JF
369 ;
370
36cd3cb9 371NullLiteral
cf7d4c69 372 : "null" { $$ = $1; }
1dbba6cc
JF
373 ;
374
36cd3cb9 375BooleanLiteral
cf7d4c69
JF
376 : "true" { $$ = $1; }
377 | "false" { $$ = $1; }
1dbba6cc
JF
378 ;
379
1dbba6cc 380/* 11.1 Primary Expressions {{{ */
693d501b 381PrimaryExpression_
cf7d4c69 382 : "this" { $$ = $1; }
b1ff2d78 383 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
cf7d4c69
JF
384 | Literal { $$ = $1; }
385 | ArrayLiteral { $$ = $1; }
36cd3cb9 386 | "(" Expression ")" { $$ = $2; }
693d501b
JF
387 ;
388
389PrimaryExpression
390 : ObjectLiteral { $$ = $1; }
391 | PrimaryExpression_ { $$ = $1; }
392 ;
393
394PrimaryExpressionNoBF
395 : PrimaryExpression_ { $$ = $1; }
1dbba6cc
JF
396 ;
397/* }}} */
398/* 11.1.4 Array Initialiser {{{ */
36cd3cb9
JF
399ArrayLiteral
400 : "[" ElementList "]" { $$ = $2; }
1dbba6cc
JF
401 ;
402
36cd3cb9 403Element
cf7d4c69
JF
404 : AssignmentExpression { $$ = $1; }
405 | { $$ = NULL; }
1dbba6cc
JF
406 ;
407
36cd3cb9
JF
408ElementList_
409 : "," ElementList { $$ = $2; }
cf7d4c69 410 | { $$ = NULL; }
1dbba6cc
JF
411 ;
412
36cd3cb9 413ElementList
b1ff2d78 414 : Element ElementList_ { $$ = new(driver.pool_) CYElement($1, $2); }
1dbba6cc
JF
415 ;
416/* }}} */
417/* 11.1.5 Object Initialiser {{{ */
36cd3cb9 418ObjectLiteral
693d501b 419 : "{" PropertyNameAndValueListOpt "}" { $$ = new CYObject($2); }
1dbba6cc
JF
420 ;
421
36cd3cb9 422PropertyNameAndValueList_
cf7d4c69 423 : "," PropertyNameAndValueList { $$ = $2; }
693d501b 424 | CommaOpt { $$ = NULL; }
1dbba6cc
JF
425 ;
426
36cd3cb9 427PropertyNameAndValueListOpt
cf7d4c69 428 : PropertyNameAndValueList { $$ = $1; }
36cd3cb9 429 | { $$ = NULL; }
1dbba6cc
JF
430 ;
431
36cd3cb9
JF
432PropertyNameAndValueList
433 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
1dbba6cc
JF
434 ;
435
436PropertyName
36cd3cb9
JF
437 : Identifier { $$ = $1; }
438 | StringLiteral { $$ = $1; }
439 | NumericLiteral { $$ = $1; }
1dbba6cc
JF
440 ;
441/* }}} */
442
693d501b
JF
443MemberExpression_
444 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
445 ;
446
36cd3cb9 447MemberExpression
cf7d4c69
JF
448 : PrimaryExpression { $$ = $1; }
449 | FunctionExpression { $$ = $1; }
36cd3cb9
JF
450 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
451 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
693d501b
JF
452 | MemberExpression_ { $$ = $1; }
453 ;
454
455MemberExpressionNoBF
456 : PrimaryExpressionNoBF { $$ = $1; }
457 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
458 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
459 | MemberExpression_ { $$ = $1; }
460 ;
461
462NewExpression_
463 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
1dbba6cc
JF
464 ;
465
36cd3cb9 466NewExpression
cf7d4c69 467 : MemberExpression { $$ = $1; }
693d501b
JF
468 | NewExpression_ { $$ = $1; }
469 ;
470
471NewExpressionNoBF
472 : MemberExpressionNoBF { $$ = $1; }
473 | NewExpression_ { $$ = $1; }
1dbba6cc
JF
474 ;
475
36cd3cb9 476CallExpression
b1ff2d78
JF
477 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
478 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
36cd3cb9
JF
479 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
480 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
1dbba6cc
JF
481 ;
482
693d501b
JF
483CallExpressionNoBF
484 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
485 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
486 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
487 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
488 ;
489
36cd3cb9 490ArgumentList_
cf7d4c69
JF
491 : "," ArgumentList { $$ = $2; }
492 | { $$ = NULL; }
1dbba6cc
JF
493 ;
494
36cd3cb9 495ArgumentListOpt
cf7d4c69 496 : ArgumentList { $$ = $1; }
36cd3cb9 497 | { $$ = NULL; }
1dbba6cc
JF
498 ;
499
36cd3cb9
JF
500ArgumentList
501 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
1dbba6cc
JF
502 ;
503
504Arguments
36cd3cb9 505 : "(" ArgumentListOpt ")" { $$ = $2; }
1dbba6cc
JF
506 ;
507
36cd3cb9 508LeftHandSideExpression
cf7d4c69
JF
509 : NewExpression { $$ = $1; }
510 | CallExpression { $$ = $1; }
693d501b
JF
511 | LeftHandSideExpression_ { $$ = $1; }
512 ;
513
514LeftHandSideExpressionNoBF
515 : NewExpressionNoBF { $$ = $1; }
516 | CallExpressionNoBF { $$ = $1; }
517 | LeftHandSideExpression_ { $$ = $1; }
1dbba6cc
JF
518 ;
519
36cd3cb9 520PostfixExpression
cf7d4c69 521 : LeftHandSideExpression { $$ = $1; }
b1ff2d78
JF
522 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
523 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
1dbba6cc
JF
524 ;
525
693d501b
JF
526PostfixExpressionNoBF
527 : LeftHandSideExpressionNoBF { $$ = $1; }
528 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
529 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
530 ;
531
532UnaryExpression_
533 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
36cd3cb9
JF
534 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
535 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
536 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
537 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
538 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
539 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
540 | "+" UnaryExpression { $$ = $2; }
541 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
542 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
543 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
693d501b
JF
544 ;
545
546UnaryExpression
547 : PostfixExpression { $$ = $1; }
548 | UnaryExpression_ { $$ = $1; }
549 ;
550
551UnaryExpressionNoBF
552 : PostfixExpressionNoBF { $$ = $1; }
553 | UnaryExpression_ { $$ = $1; }
1dbba6cc
JF
554 ;
555
36cd3cb9 556MultiplicativeExpression
cf7d4c69 557 : UnaryExpression { $$ = $1; }
36cd3cb9
JF
558 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
559 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
560 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
1dbba6cc
JF
561 ;
562
693d501b
JF
563MultiplicativeExpressionNoBF
564 : UnaryExpressionNoBF { $$ = $1; }
565 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
566 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
567 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
568 ;
569
36cd3cb9 570AdditiveExpression
cf7d4c69 571 : MultiplicativeExpression { $$ = $1; }
36cd3cb9
JF
572 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
573 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1dbba6cc
JF
574 ;
575
693d501b
JF
576AdditiveExpressionNoBF
577 : MultiplicativeExpressionNoBF { $$ = $1; }
578 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
579 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
580 ;
581
36cd3cb9 582ShiftExpression
cf7d4c69 583 : AdditiveExpression { $$ = $1; }
36cd3cb9
JF
584 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
585 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
586 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1dbba6cc
JF
587 ;
588
693d501b
JF
589ShiftExpressionNoBF
590 : AdditiveExpressionNoBF { $$ = $1; }
591 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
592 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
593 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
594 ;
595
36cd3cb9 596RelationalExpression
cf7d4c69 597 : ShiftExpression { $$ = $1; }
36cd3cb9
JF
598 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
599 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
600 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
601 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
602 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
603 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
1dbba6cc
JF
604 ;
605
693d501b
JF
606RelationalExpressionNoIn
607 : ShiftExpression { $$ = $1; }
608 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
609 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
610 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
611 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
612 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
613 ;
614
615RelationalExpressionNoBF
616 : ShiftExpressionNoBF { $$ = $1; }
617 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
618 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
619 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
620 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
621 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
622 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
623 ;
624
36cd3cb9 625EqualityExpression
cf7d4c69 626 : RelationalExpression { $$ = $1; }
36cd3cb9
JF
627 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
628 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
629 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
630 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1dbba6cc
JF
631 ;
632
693d501b
JF
633EqualityExpressionNoIn
634 : RelationalExpressionNoIn { $$ = $1; }
635 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
636 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
637 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
638 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
639 ;
640
641EqualityExpressionNoBF
642 : RelationalExpressionNoBF { $$ = $1; }
643 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
644 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
645 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
646 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
647 ;
648
36cd3cb9 649BitwiseANDExpression
cf7d4c69 650 : EqualityExpression { $$ = $1; }
36cd3cb9 651 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1dbba6cc
JF
652 ;
653
693d501b
JF
654BitwiseANDExpressionNoIn
655 : EqualityExpressionNoIn { $$ = $1; }
656 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
657 ;
658
659BitwiseANDExpressionNoBF
660 : EqualityExpressionNoBF { $$ = $1; }
661 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
662 ;
663
36cd3cb9 664BitwiseXORExpression
cf7d4c69 665 : BitwiseANDExpression { $$ = $1; }
36cd3cb9 666 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1dbba6cc
JF
667 ;
668
693d501b
JF
669BitwiseXORExpressionNoIn
670 : BitwiseANDExpressionNoIn { $$ = $1; }
671 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
672 ;
673
674BitwiseXORExpressionNoBF
675 : BitwiseANDExpressionNoBF { $$ = $1; }
676 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
677 ;
678
36cd3cb9 679BitwiseORExpression
cf7d4c69 680 : BitwiseXORExpression { $$ = $1; }
36cd3cb9 681 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1dbba6cc
JF
682 ;
683
693d501b
JF
684BitwiseORExpressionNoIn
685 : BitwiseXORExpressionNoIn { $$ = $1; }
686 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
687 ;
688
689BitwiseORExpressionNoBF
690 : BitwiseXORExpressionNoBF { $$ = $1; }
691 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
692 ;
693
36cd3cb9 694LogicalANDExpression
cf7d4c69 695 : BitwiseORExpression { $$ = $1; }
36cd3cb9 696 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1dbba6cc
JF
697 ;
698
693d501b
JF
699LogicalANDExpressionNoIn
700 : BitwiseORExpressionNoIn { $$ = $1; }
701 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
702 ;
703
704LogicalANDExpressionNoBF
705 : BitwiseORExpressionNoBF { $$ = $1; }
706 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
707 ;
708
36cd3cb9 709LogicalORExpression
cf7d4c69 710 : LogicalANDExpression { $$ = $1; }
36cd3cb9 711 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1dbba6cc
JF
712 ;
713
693d501b
JF
714LogicalORExpressionNoIn
715 : LogicalANDExpressionNoIn { $$ = $1; }
716 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
717 ;
718
719LogicalORExpressionNoBF
720 : LogicalANDExpressionNoBF { $$ = $1; }
721 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
722 ;
723
36cd3cb9 724ConditionalExpression
cf7d4c69 725 : LogicalORExpression { $$ = $1; }
36cd3cb9 726 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1dbba6cc
JF
727 ;
728
693d501b
JF
729ConditionalExpressionNoIn
730 : LogicalORExpressionNoIn { $$ = $1; }
731 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
732 ;
733
734ConditionalExpressionNoBF
735 : LogicalORExpressionNoBF { $$ = $1; }
736 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
737 ;
738
36cd3cb9 739AssignmentExpression
cf7d4c69 740 : ConditionalExpression { $$ = $1; }
36cd3cb9
JF
741 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
742 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
743 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
744 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
745 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
746 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
747 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
748 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
749 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
750 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
751 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
752 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
753 ;
754
693d501b
JF
755AssignmentExpressionNoIn
756 : ConditionalExpressionNoIn { $$ = $1; }
757 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
758 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
759 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
760 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
761 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
762 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
763 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
764 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
765 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
766 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
767 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
768 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
769 ;
770
771AssignmentExpressionNoBF
772 : ConditionalExpressionNoBF { $$ = $1; }
773 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
774 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
775 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
776 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
777 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
778 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
779 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
780 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
781 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
782 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
783 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
784 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
785 ;
786
36cd3cb9
JF
787Expression_
788 : "," Expression { $$ = $2; }
cf7d4c69 789 | { $$ = NULL; }
1dbba6cc
JF
790 ;
791
693d501b
JF
792ExpressionNoIn_
793 : "," ExpressionNoIn { $$ = $2; }
794 | { $$ = NULL; }
795 ;
796
36cd3cb9 797ExpressionOpt
cf7d4c69 798 : Expression { $$ = $1; }
36cd3cb9 799 | { $$ = NULL; }
1dbba6cc
JF
800 ;
801
693d501b
JF
802ExpressionNoInOpt
803 : ExpressionNoIn { $$ = $1; }
804 | { $$ = NULL; }
805 ;
806
36cd3cb9 807Expression
c3c20102 808 : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
1dbba6cc
JF
809 ;
810
693d501b
JF
811ExpressionNoIn
812 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
813 ;
814
815ExpressionNoBF
816 : AssignmentExpressionNoBF Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; }
817 ;
818
36cd3cb9
JF
819Statement
820 : Block { $$ = $1; }
821 | VariableStatement { $$ = $1; }
822 | EmptyStatement { $$ = $1; }
823 | ExpressionStatement { $$ = $1; }
cf7d4c69
JF
824 | IfStatement { $$ = $1; }
825 | IterationStatement { $$ = $1; }
36cd3cb9
JF
826 | ContinueStatement { $$ = $1; }
827 | BreakStatement { $$ = $1; }
828 | ReturnStatement { $$ = $1; }
cf7d4c69
JF
829 | WithStatement { $$ = $1; }
830 | LabelledStatement { $$ = $1; }
36cd3cb9
JF
831 | SwitchStatement { $$ = $1; }
832 | ThrowStatement { $$ = $1; }
833 | TryStatement { $$ = $1; }
1dbba6cc
JF
834 ;
835
36cd3cb9 836Block
693d501b
JF
837 : "{" "}" { $$ = new(driver.pool_) CYEmpty(); }
838 | "{" StatementList "}" { $$ = $2; }
1dbba6cc
JF
839 ;
840
693d501b 841StatementList
cf7d4c69 842 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
693d501b
JF
843 ;
844
845StatementListOpt
846 : StatementList { $$ = $1; }
cf7d4c69 847 | { $$ = NULL; }
1dbba6cc
JF
848 ;
849
36cd3cb9 850VariableStatement
c3c20102 851 : "var" VariableDeclarationList Terminator { $$ = $2; }
1dbba6cc
JF
852 ;
853
36cd3cb9 854VariableDeclarationList_
cf7d4c69
JF
855 : "," VariableDeclarationList { $$ = $2; }
856 | { $$ = NULL; }
1dbba6cc
JF
857 ;
858
693d501b
JF
859VariableDeclarationListNoIn_
860 : "," VariableDeclarationListNoIn { $$ = $2; }
861 | { $$ = NULL; }
862 ;
863
36cd3cb9 864VariableDeclarationList
b1ff2d78 865 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1dbba6cc
JF
866 ;
867
693d501b
JF
868VariableDeclarationListNoIn
869 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
870 ;
871
36cd3cb9
JF
872VariableDeclaration
873 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1dbba6cc
JF
874 ;
875
693d501b
JF
876VariableDeclarationNoIn
877 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
878 ;
879
36cd3cb9 880InitialiserOpt
cf7d4c69 881 : Initialiser { $$ = $1; }
36cd3cb9 882 | { $$ = NULL; }
1dbba6cc
JF
883 ;
884
693d501b
JF
885InitialiserNoInOpt
886 : InitialiserNoIn { $$ = $1; }
887 | { $$ = NULL; }
888 ;
889
36cd3cb9
JF
890Initialiser
891 : "=" AssignmentExpression { $$ = $2; }
1dbba6cc
JF
892 ;
893
693d501b
JF
894InitialiserNoIn
895 : "=" AssignmentExpressionNoIn { $$ = $2; }
896 ;
897
36cd3cb9 898EmptyStatement
b1ff2d78 899 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1dbba6cc
JF
900 ;
901
36cd3cb9 902ExpressionStatement
693d501b 903 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1dbba6cc
JF
904 ;
905
36cd3cb9
JF
906ElseStatementOpt
907 : "else" Statement { $$ = $2; }
c3c20102 908 | %prec "if" { $$ = NULL; }
1dbba6cc
JF
909 ;
910
36cd3cb9
JF
911IfStatement
912 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1dbba6cc
JF
913 ;
914
36cd3cb9
JF
915IterationStatement
916 : DoWhileStatement { $$ = $1; }
cf7d4c69
JF
917 | WhileStatement { $$ = $1; }
918 | ForStatement { $$ = $1; }
919 | ForInStatement { $$ = $1; }
1dbba6cc
JF
920 ;
921
36cd3cb9
JF
922DoWhileStatement
923 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1dbba6cc
JF
924 ;
925
36cd3cb9
JF
926WhileStatement
927 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1dbba6cc
JF
928 ;
929
36cd3cb9
JF
930ForStatement
931 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1dbba6cc
JF
932 ;
933
36cd3cb9 934ForStatementInitialiser
693d501b
JF
935 : ExpressionNoInOpt { $$ = $1; }
936 | "var" VariableDeclarationListNoIn { $$ = $2; }
1dbba6cc
JF
937 ;
938
36cd3cb9
JF
939ForInStatement
940 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1dbba6cc
JF
941 ;
942
36cd3cb9
JF
943ForInStatementInitialiser
944 : LeftHandSideExpression { $$ = $1; }
693d501b 945 | "var" VariableDeclarationNoIn { $$ = $2; }
1dbba6cc
JF
946 ;
947
36cd3cb9
JF
948ContinueStatement
949 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1dbba6cc
JF
950 ;
951
36cd3cb9
JF
952BreakStatement
953 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1dbba6cc
JF
954 ;
955
36cd3cb9 956ReturnStatement
c3c20102 957 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1dbba6cc
JF
958 ;
959
36cd3cb9
JF
960WithStatement
961 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1dbba6cc
JF
962 ;
963
36cd3cb9
JF
964SwitchStatement
965 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1dbba6cc
JF
966 ;
967
968CaseBlock
36cd3cb9 969 : "{" CaseClausesOpt "}" { $$ = $2; }
1dbba6cc
JF
970 ;
971
36cd3cb9 972CaseClausesOpt
cf7d4c69
JF
973 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
974 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
975 | { $$ = NULL; }
1dbba6cc
JF
976 ;
977
36cd3cb9
JF
978CaseClause
979 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1dbba6cc
JF
980 ;
981
36cd3cb9
JF
982DefaultClause
983 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1dbba6cc
JF
984 ;
985
36cd3cb9
JF
986LabelledStatement
987 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1dbba6cc
JF
988 ;
989
36cd3cb9 990ThrowStatement
c3c20102 991 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1dbba6cc
JF
992 ;
993
36cd3cb9 994TryStatement
b1ff2d78 995 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1dbba6cc
JF
996 ;
997
998CatchOpt
36cd3cb9 999 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
cf7d4c69 1000 | { $$ = NULL; }
1dbba6cc
JF
1001 ;
1002
1003FinallyOpt
36cd3cb9 1004 : "finally" Block { $$ = $2; }
cf7d4c69 1005 | { $$ = NULL; }
1dbba6cc
JF
1006 ;
1007
36cd3cb9
JF
1008FunctionDeclaration
1009 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1dbba6cc
JF
1010 ;
1011
36cd3cb9
JF
1012FunctionExpression
1013 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1dbba6cc
JF
1014 ;
1015
1016FormalParameterList_
36cd3cb9 1017 : "," FormalParameterList { $$ = $2; }
cf7d4c69 1018 | { $$ = NULL; }
1dbba6cc
JF
1019 ;
1020
1021FormalParameterList
36cd3cb9 1022 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($1, $2); }
cf7d4c69 1023 | { $$ = NULL; }
1dbba6cc
JF
1024 ;
1025
36cd3cb9
JF
1026FunctionBody
1027 : SourceElements { $$ = $1; }
1dbba6cc
JF
1028 ;
1029
1030Program
36cd3cb9 1031 : SourceElements { driver.source_.push_back($1); $$ = $1; }
1dbba6cc
JF
1032 ;
1033
36cd3cb9
JF
1034SourceElements
1035 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
cf7d4c69 1036 | { $$ = NULL; }
1dbba6cc
JF
1037 ;
1038
c3c20102 1039/*Command
36cd3cb9 1040 : SourceElement { driver.source_.push_back($2); if (driver.filename_.empty() && false) YYACCEPT; $2->Show(std::cout); }
c3c20102 1041 ;*/
b1ff2d78 1042
36cd3cb9 1043SourceElement
cf7d4c69 1044 : Statement { $$ = $1; }
36cd3cb9 1045 | FunctionDeclaration { $$ = $1; }
1dbba6cc 1046 ;
e5332278 1047
693d501b
JF
1048/* Objective-C Extensions {{{ */
1049VariadicCall
1050 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1051 | { $$ = NULL; }
1052 ;
1053
1054SelectorCall_
1055 : SelectorCall { $$ = $1; }
1056 | VariadicCall { $$ = $1; }
1057 ;
1058
1059SelectorCall
1060 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1061 ;
1062
1063SelectorList
1064 : SelectorCall { $$ = $1; }
1065 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1066 ;
1067
1068MessageExpression
1069 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); }
1070 ;
1071
e7ed5354
JF
1072SelectorExpressionOpt
1073 : SelectorExpression_ { $$ = $1; }
1074 | { $$ = NULL; }
1075 ;
1076
1077SelectorExpression_
1078 : WordOpt ":" SelectorExpressionOpt { $$ = new CYSelector($1, true, $3); }
1079 ;
1080
1081SelectorExpression
1082 : SelectorExpression_ { $$ = $1; }
1083 | Word { $$ = new CYSelector($1, false, NULL); }
1084 ;
1085
457afcc9 1086PrimaryExpression_
693d501b 1087 : MessageExpression { $$ = $1; }
e7ed5354 1088 | "@selector" "(" SelectorExpression ")" { $$ = $3; }
693d501b
JF
1089 ;
1090/* }}} */
1091
1092LeftHandSideExpression_
1093 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1094 ;
1095
1096UnaryExpression_
1097 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1098 ;
1099
e5332278 1100%%