]> git.saurik.com Git - cycript.git/blame - Cycript.y.in
Further makefile reorganization, header file fixes, code movement, and general massag...
[cycript.git] / Cycript.y.in
CommitLineData
b4aa79af
JF
1/* Cycript - Remove Execution Server and Disassembler
2 * Copyright (C) 2009 Jay Freeman (saurik)
3*/
4
5/* Modified BSD License {{{ */
6/*
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
18 * distribution.
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*/
38/* }}} */
39
1dbba6cc 40%code top {
63b4c5a8 41#include "Cycript.tab.hh"
5999c315 42#define scanner driver.scanner_
693d501b 43#define YYSTACKEXPANDABLE 1
1dbba6cc
JF
44}
45
63b4c5a8
JF
46%code requires {
47#include "Parser.hpp"
63b4c5a8 48
4de0686f
JF
49@begin ObjC
50#include "ObjectiveC.hpp"
51@end
52
c3c20102
JF
53typedef struct {
54 bool newline_;
55
56 union {
b09da87b
JF
57 bool bool_;
58
63cd45c9
JF
59 CYDriver::Condition condition_;
60
c3c20102 61 CYArgument *argument_;
0ff9f149 62 CYAssignment *assignment_;
c3c20102
JF
63 CYBoolean *boolean_;
64 CYClause *clause_;
65 CYCatch *catch_;
75b0a457 66 CYComprehension *comprehension_;
d35a3b07 67 CYCompound *compound_;
c3c20102
JF
68 CYDeclaration *declaration_;
69 CYDeclarations *declarations_;
70 CYElement *element_;
71 CYExpression *expression_;
72 CYFalse *false_;
b10bd496 73 CYFinally *finally_;
c3c20102
JF
74 CYForInitialiser *for_;
75 CYForInInitialiser *forin_;
b09da87b 76 CYFunctionParameter *functionParameter_;
c3c20102 77 CYIdentifier *identifier_;
0ff9f149 78 CYInfix *infix_;
c3c20102 79 CYLiteral *literal_;
9b5527f0 80 CYMember *member_;
c3c20102
JF
81 CYNull *null_;
82 CYNumber *number_;
3b52fd1a 83 CYProgram *program_;
c3c20102 84 CYProperty *property_;
e5bc40db 85 CYPropertyName *propertyName_;
c3c20102
JF
86 CYStatement *statement_;
87 CYString *string_;
88 CYThis *this_;
89 CYTrue *true_;
90 CYWord *word_;
4de0686f
JF
91
92@begin ObjC
328ad766
JF
93 CYClassName *className_;
94 CYField *field_;
4de0686f
JF
95 CYMessage *message_;
96 CYMessageParameter *messageParameter_;
97 CYSelectorPart *selector_;
98@end
c3c20102
JF
99 };
100} YYSTYPE;
101
63b4c5a8
JF
102}
103
693d501b
JF
104%code provides {
105int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
106}
107
1dbba6cc 108%name-prefix "cy"
e5332278 109
63b4c5a8 110%language "C++"
e5332278 111%locations
1dbba6cc 112
5999c315
JF
113%initial-action {
114 @$.begin.filename = @$.end.filename = &driver.filename_;
115};
116
e5332278 117%defines
1dbba6cc 118
534fb6da
JF
119//%glr-parser
120//%expect 1
cac61857 121
e5332278
JF
122%error-verbose
123
5999c315 124%parse-param { CYDriver &driver }
924f67b2 125%lex-param { void *scanner }
e5332278 126
ac9a5ce1
JF
127%token At "@"
128
63b4c5a8
JF
129%token Ampersand "&"
130%token AmpersandAmpersand "&&"
131%token AmpersandEqual "&="
132%token Carrot "^"
133%token CarrotEqual "^="
134%token Equal "="
135%token EqualEqual "=="
136%token EqualEqualEqual "==="
137%token Exclamation "!"
138%token ExclamationEqual "!="
139%token ExclamationEqualEqual "!=="
140%token Hyphen "-"
141%token HyphenEqual "-="
142%token HyphenHyphen "--"
c3c20102 143%token HyphenHyphen_ "\n--"
63b4c5a8
JF
144%token HyphenRight "->"
145%token Left "<"
146%token LeftEqual "<="
147%token LeftLeft "<<"
148%token LeftLeftEqual "<<="
149%token Percent "%"
150%token PercentEqual "%="
151%token Period "."
152%token Pipe "|"
153%token PipeEqual "|="
154%token PipePipe "||"
155%token Plus "+"
156%token PlusEqual "+="
157%token PlusPlus "++"
c3c20102 158%token PlusPlus_ "\n++"
63b4c5a8
JF
159%token Right ">"
160%token RightEqual ">="
161%token RightRight ">>"
162%token RightRightEqual ">>="
163%token RightRightRight ">>>"
164%token RightRightRightEqual ">>>="
165%token Slash "/"
166%token SlashEqual "/="
167%token Star "*"
168%token StarEqual "*="
169%token Tilde "~"
170
171%token Colon ":"
172%token Comma ","
173%token Question "?"
174%token SemiColon ";"
c3c20102 175%token NewLine "\n"
63b4c5a8
JF
176
177%token OpenParen "("
178%token CloseParen ")"
924f67b2 179
63b4c5a8
JF
180%token OpenBrace "{"
181%token CloseBrace "}"
924f67b2 182
63b4c5a8
JF
183%token OpenBracket "["
184%token CloseBracket "]"
185
b09da87b 186%token AtClass "@class"
e7ed5354 187%token AtSelector "@selector"
d35a3b07 188%token AtEnd "@end"
e7ed5354 189
534fb6da
JF
190%token <false_> False "false"
191%token <null_> Null "null"
192%token <true_> True "true"
193
194// ES3/ES5/WIE/JSC Reserved
cf7d4c69
JF
195%token <word_> Break "break"
196%token <word_> Case "case"
197%token <word_> Catch "catch"
198%token <word_> Continue "continue"
199%token <word_> Default "default"
200%token <word_> Delete "delete"
201%token <word_> Do "do"
202%token <word_> Else "else"
cf7d4c69
JF
203%token <word_> Finally "finally"
204%token <word_> For "for"
205%token <word_> Function "function"
206%token <word_> If "if"
207%token <word_> In "in"
208%token <word_> InstanceOf "instanceof"
209%token <word_> New "new"
cf7d4c69
JF
210%token <word_> Return "return"
211%token <word_> Switch "switch"
212%token <this_> This "this"
213%token <word_> Throw "throw"
cf7d4c69
JF
214%token <word_> Try "try"
215%token <word_> TypeOf "typeof"
216%token <word_> Var "var"
217%token <word_> Void "void"
218%token <word_> While "while"
219%token <word_> With "with"
63b4c5a8 220
534fb6da 221// ES3/IE6 Future, ES5/JSC Reserved
d35a3b07 222%token <word_> Debugger "debugger"
534fb6da
JF
223
224// ES3/ES5/IE6 Future, JSC Reserved
225%token <word_> Const "const"
226
227// ES3/ES5/IE6/JSC Future
228%token <word_> Class "class"
d35a3b07
JF
229%token <word_> Enum "enum"
230%token <word_> Export "export"
231%token <word_> Extends "extends"
d35a3b07 232%token <word_> Import "import"
d35a3b07 233%token <word_> Super "super"
d35a3b07 234
534fb6da
JF
235// ES3 Future, ES5 Strict Future
236%token <identifier_> Implements "implements"
237%token <identifier_> Interface "interface"
238%token <identifier_> Package "package"
239%token <identifier_> Private "private"
240%token <identifier_> Protected "protected"
241%token <identifier_> Public "public"
242%token <identifier_> Static "static"
243
244// ES3 Future
245%token <identifier_> Abstract "abstract"
246%token <identifier_> Boolean "boolean"
247%token <identifier_> Byte "byte"
248%token <identifier_> Char "char"
249%token <identifier_> Double "double"
250%token <identifier_> Final "final"
251%token <identifier_> Float "float"
252%token <identifier_> Goto "goto"
253%token <identifier_> Int "int"
254%token <identifier_> Long "long"
255%token <identifier_> Native "native"
256%token <identifier_> Short "short"
257%token <identifier_> Synchronized "synchronized"
258%token <identifier_> Throws "throws"
259%token <identifier_> Transient "transient"
260%token <identifier_> Volatile "volatile"
261
262// ES5 Strict
cac61857 263%token <identifier_> Let "let"
534fb6da
JF
264%token <identifier_> Yield "yield"
265
266// Woah?!
267%token <identifier_> Each "each"
75b0a457
JF
268
269%token <identifier_> Identifier_
63b4c5a8
JF
270%token <number_> NumericLiteral
271%token <string_> StringLiteral
63cd45c9 272%token <literal_> RegularExpressionLiteral
1dbba6cc 273
cf7d4c69 274%type <expression_> AdditiveExpression
693d501b 275%type <expression_> AdditiveExpressionNoBF
cf7d4c69
JF
276%type <argument_> ArgumentList
277%type <argument_> ArgumentList_
278%type <argument_> ArgumentListOpt
279%type <argument_> Arguments
280%type <literal_> ArrayLiteral
9b5527f0
JF
281%type <expression_> AssigneeExpression
282%type <expression_> AssigneeExpression_
283%type <expression_> AssigneeExpressionNoBF
cf7d4c69 284%type <expression_> AssignmentExpression
0ff9f149 285%type <assignment_> AssignmentExpression_
693d501b
JF
286%type <expression_> AssignmentExpressionNoBF
287%type <expression_> AssignmentExpressionNoIn
cf7d4c69 288%type <expression_> BitwiseANDExpression
693d501b
JF
289%type <expression_> BitwiseANDExpressionNoBF
290%type <expression_> BitwiseANDExpressionNoIn
cf7d4c69 291%type <statement_> Block
cac61857 292%type <statement_> Block_
cf7d4c69
JF
293%type <boolean_> BooleanLiteral
294%type <expression_> BitwiseORExpression
693d501b
JF
295%type <expression_> BitwiseORExpressionNoBF
296%type <expression_> BitwiseORExpressionNoIn
cf7d4c69 297%type <expression_> BitwiseXORExpression
693d501b
JF
298%type <expression_> BitwiseXORExpressionNoBF
299%type <expression_> BitwiseXORExpressionNoIn
cf7d4c69
JF
300%type <statement_> BreakStatement
301%type <expression_> CallExpression
693d501b 302%type <expression_> CallExpressionNoBF
cf7d4c69
JF
303%type <clause_> CaseBlock
304%type <clause_> CaseClause
305%type <clause_> CaseClausesOpt
306%type <catch_> CatchOpt
75b0a457
JF
307%type <comprehension_> ComprehensionList
308%type <comprehension_> ComprehensionListOpt
cf7d4c69 309%type <expression_> ConditionalExpression
693d501b
JF
310%type <expression_> ConditionalExpressionNoBF
311%type <expression_> ConditionalExpressionNoIn
cf7d4c69
JF
312%type <statement_> ContinueStatement
313%type <clause_> DefaultClause
314%type <statement_> DoWhileStatement
315%type <expression_> Element
5befe15e 316%type <expression_> ElementOpt
cf7d4c69 317%type <element_> ElementList
5befe15e 318%type <element_> ElementListOpt
cf7d4c69
JF
319%type <statement_> ElseStatementOpt
320%type <statement_> EmptyStatement
321%type <expression_> EqualityExpression
693d501b
JF
322%type <expression_> EqualityExpressionNoBF
323%type <expression_> EqualityExpressionNoIn
cf7d4c69 324%type <expression_> Expression
cf7d4c69 325%type <expression_> ExpressionOpt
d35a3b07 326%type <compound_> Expression_
693d501b
JF
327%type <expression_> ExpressionNoBF
328%type <expression_> ExpressionNoIn
d35a3b07 329%type <compound_> ExpressionNoIn_
693d501b 330%type <expression_> ExpressionNoInOpt
cf7d4c69 331%type <statement_> ExpressionStatement
b10bd496 332%type <finally_> FinallyOpt
75b0a457 333%type <comprehension_> ForComprehension
cf7d4c69
JF
334%type <statement_> ForStatement
335%type <for_> ForStatementInitialiser
336%type <statement_> ForInStatement
337%type <forin_> ForInStatementInitialiser
b09da87b
JF
338%type <functionParameter_> FormalParameterList
339%type <functionParameter_> FormalParameterList_
b10bd496
JF
340%type <statement_> FunctionBody
341%type <statement_> FunctionDeclaration
cf7d4c69 342%type <expression_> FunctionExpression
75b0a457 343%type <identifier_> Identifier
cf7d4c69 344%type <identifier_> IdentifierOpt
75b0a457 345%type <comprehension_> IfComprehension
cf7d4c69
JF
346%type <statement_> IfStatement
347%type <expression_> Initialiser
348%type <expression_> InitialiserOpt
693d501b
JF
349%type <expression_> InitialiserNoIn
350%type <expression_> InitialiserNoInOpt
cf7d4c69
JF
351%type <statement_> IterationStatement
352%type <statement_> LabelledStatement
353%type <expression_> LeftHandSideExpression
693d501b 354%type <expression_> LeftHandSideExpressionNoBF
534fb6da 355//%type <statement_> LetStatement
cf7d4c69
JF
356%type <literal_> Literal
357%type <expression_> LogicalANDExpression
693d501b
JF
358%type <expression_> LogicalANDExpressionNoBF
359%type <expression_> LogicalANDExpressionNoIn
cf7d4c69 360%type <expression_> LogicalORExpression
693d501b
JF
361%type <expression_> LogicalORExpressionNoBF
362%type <expression_> LogicalORExpressionNoIn
9b5527f0 363%type <member_> MemberAccess
cf7d4c69 364%type <expression_> MemberExpression
693d501b
JF
365%type <expression_> MemberExpression_
366%type <expression_> MemberExpressionNoBF
cf7d4c69 367%type <expression_> MultiplicativeExpression
693d501b 368%type <expression_> MultiplicativeExpressionNoBF
cf7d4c69 369%type <expression_> NewExpression
693d501b
JF
370%type <expression_> NewExpression_
371%type <expression_> NewExpressionNoBF
cf7d4c69
JF
372%type <null_> NullLiteral
373%type <literal_> ObjectLiteral
cf7d4c69 374%type <expression_> PostfixExpression
693d501b 375%type <expression_> PostfixExpressionNoBF
cf7d4c69 376%type <expression_> PrimaryExpression
693d501b
JF
377%type <expression_> PrimaryExpression_
378%type <expression_> PrimaryExpressionNoBF
b10bd496 379%type <statement_> Program
e5bc40db 380%type <propertyName_> PropertyName
cf7d4c69
JF
381%type <property_> PropertyNameAndValueList
382%type <property_> PropertyNameAndValueList_
383%type <property_> PropertyNameAndValueListOpt
63cd45c9
JF
384%type <literal_> RegularExpressionLiteral_
385%type <condition_> RegularExpressionToken
cf7d4c69 386%type <expression_> RelationalExpression
0ff9f149 387%type <infix_> RelationalExpression_
693d501b
JF
388%type <expression_> RelationalExpressionNoBF
389%type <expression_> RelationalExpressionNoIn
0ff9f149 390%type <infix_> RelationalExpressionNoIn_
cf7d4c69 391%type <statement_> ReturnStatement
cf7d4c69 392%type <expression_> ShiftExpression
693d501b 393%type <expression_> ShiftExpressionNoBF
b10bd496
JF
394%type <statement_> SourceElement
395%type <statement_> SourceElements
cf7d4c69 396%type <statement_> Statement
b10bd496 397%type <statement_> Statement_
693d501b 398%type <statement_> StatementList
cf7d4c69
JF
399%type <statement_> StatementListOpt
400%type <statement_> SwitchStatement
401%type <statement_> ThrowStatement
402%type <statement_> TryStatement
403%type <expression_> UnaryExpression
693d501b
JF
404%type <expression_> UnaryExpression_
405%type <expression_> UnaryExpressionNoBF
cf7d4c69 406%type <declaration_> VariableDeclaration
693d501b 407%type <declaration_> VariableDeclarationNoIn
cf7d4c69
JF
408%type <declarations_> VariableDeclarationList
409%type <declarations_> VariableDeclarationList_
693d501b
JF
410%type <declarations_> VariableDeclarationListNoIn
411%type <declarations_> VariableDeclarationListNoIn_
cf7d4c69 412%type <statement_> VariableStatement
cf7d4c69
JF
413%type <statement_> WhileStatement
414%type <statement_> WithStatement
cf7d4c69 415
328ad766
JF
416@begin ObjC
417%type <statement_> CategoryStatement
418%type <expression_> ClassExpression
419%type <statement_> ClassStatement
420%type <expression_> ClassSuperOpt
421%type <field_> ClassFieldList
422%type <message_> ClassMessageDeclaration
423%type <message_> ClassMessageDeclarationListOpt
424%type <className_> ClassName
425%type <className_> ClassNameOpt
693d501b 426%type <expression_> MessageExpression
328ad766
JF
427%type <messageParameter_> MessageParameter
428%type <messageParameter_> MessageParameters
429%type <messageParameter_> MessageParameterList
430%type <messageParameter_> MessageParameterListOpt
431%type <bool_> MessageScope
693d501b
JF
432%type <argument_> SelectorCall
433%type <argument_> SelectorCall_
328ad766
JF
434%type <selector_> SelectorExpression
435%type <selector_> SelectorExpression_
436%type <selector_> SelectorExpressionOpt
693d501b 437%type <argument_> SelectorList
328ad766 438%type <expression_> TypeOpt
693d501b 439%type <argument_> VariadicCall
328ad766
JF
440%type <word_> Word
441%type <word_> WordOpt
442@end
693d501b 443
cde525f7
JF
444%left "*" "/" "%"
445%left "+" "-"
446%left "<<" ">>" ">>>"
447%left "<" ">" "<=" ">=" "instanceof" "in"
448%left "==" "!=" "===" "!=="
449%left "&"
450%left "^"
451%left "|"
452%left "&&"
453%left "||"
454
455%right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
456
c3c20102
JF
457%nonassoc "if"
458%nonassoc "else"
459
693d501b 460%start Program
e5332278 461
693d501b 462%%
c3c20102 463
b10bd496
JF
464StrictSemi
465 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
466 ;
467
468Terminator_
c3c20102 469 : ";"
b10bd496
JF
470 | "\n" StrictSemi
471 ;
472
473TerminatorOpt
474 : Terminator_
475 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
c3c20102
JF
476 ;
477
478Terminator
b10bd496
JF
479 : Terminator_
480 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
c3c20102
JF
481 ;
482
cac61857 483/*CommaOpt
693d501b
JF
484 : ","
485 |
cac61857 486 ;*/
693d501b 487
328ad766 488@begin ObjC
c3c20102 489NewLineOpt
693d501b 490 : "\n"
c3c20102
JF
491 |
492 ;
1dbba6cc 493
36cd3cb9 494WordOpt
cf7d4c69
JF
495 : Word { $$ = $1; }
496 | { $$ = NULL; }
2bf24581
JF
497 ;
498
36cd3cb9 499Word
cf7d4c69 500 : Identifier { $$ = $1; }
c3c20102 501 | "break" NewLineOpt { $$ = $1; }
cf7d4c69
JF
502 | "case" { $$ = $1; }
503 | "catch" { $$ = $1; }
d35a3b07
JF
504 | "class" { $$ = $1; }
505 | "const" { $$ = $1; }
c3c20102 506 | "continue" NewLineOpt { $$ = $1; }
d35a3b07 507 | "debugger" { $$ = $1; }
cf7d4c69
JF
508 | "default" { $$ = $1; }
509 | "delete" { $$ = $1; }
510 | "do" { $$ = $1; }
511 | "else" { $$ = $1; }
d35a3b07
JF
512 | "enum" { $$ = $1; }
513 | "export" { $$ = $1; }
514 | "extends" { $$ = $1; }
cf7d4c69
JF
515 | "false" { $$ = $1; }
516 | "finally" { $$ = $1; }
517 | "for" { $$ = $1; }
518 | "function" { $$ = $1; }
519 | "if" { $$ = $1; }
d35a3b07 520 | "import" { $$ = $1; }
693d501b
JF
521 /* XXX: | "in" { $$ = $1; } */
522 /* XXX: | "instanceof" { $$ = $1; } */
cf7d4c69
JF
523 | "new" { $$ = $1; }
524 | "null" { $$ = $1; }
c3c20102 525 | "return" NewLineOpt { $$ = $1; }
d35a3b07 526 | "super" { $$ = $1; }
cf7d4c69
JF
527 | "switch" { $$ = $1; }
528 | "this" { $$ = $1; }
c3c20102 529 | "throw" NewLineOpt { $$ = $1; }
cf7d4c69
JF
530 | "true" { $$ = $1; }
531 | "try" { $$ = $1; }
532 | "typeof" { $$ = $1; }
533 | "var" { $$ = $1; }
534 | "void" { $$ = $1; }
535 | "while" { $$ = $1; }
536 | "with" { $$ = $1; }
2bf24581 537 ;
328ad766 538@end
2bf24581 539
75b0a457
JF
540Identifier
541 : Identifier_ { $$ = $1; }
534fb6da
JF
542
543 | "implements" { $$ = $1; }
544 | "interface" { $$ = $1; }
545 | "package" { $$ = $1; }
546 | "private" { $$ = $1; }
547 | "protected" { $$ = $1; }
548 | "public" { $$ = $1; }
549 | "static" { $$ = $1; }
550
551 | "abstract" { $$ = $1; }
552 | "boolean" { $$ = $1; }
553 | "byte" { $$ = $1; }
554 | "char" { $$ = $1; }
555 | "double" { $$ = $1; }
556 | "final" { $$ = $1; }
557 | "float" { $$ = $1; }
558 | "goto" { $$ = $1; }
559 | "int" { $$ = $1; }
560 | "long" { $$ = $1; }
561 | "native" { $$ = $1; }
562 | "short" { $$ = $1; }
563 | "synchronized" { $$ = $1; }
564 | "throws" { $$ = $1; }
565 | "transient" { $$ = $1; }
566 | "volatile" { $$ = $1; }
567
cac61857 568 | "let" { $$ = $1; }
534fb6da
JF
569 | "yield" { $$ = $1; }
570
571 | "each" { $$ = $1; }
75b0a457
JF
572 ;
573
36cd3cb9 574IdentifierOpt
cf7d4c69
JF
575 : Identifier { $$ = $1; }
576 | { $$ = NULL; }
1dbba6cc
JF
577 ;
578
63cd45c9
JF
579RegularExpressionToken
580 : "/" { $$ = CYDriver::RegExStart; }
581 | "/=" { $$ = CYDriver::RegExRest; }
582 ;
583
584RegularExpressionLiteral_
585 : RegularExpressionToken { driver.SetCondition($1); } RegularExpressionLiteral { $$ = $3; }
586 ;
587
36cd3cb9 588Literal
cf7d4c69
JF
589 : NullLiteral { $$ = $1; }
590 | BooleanLiteral { $$ = $1; }
591 | NumericLiteral { $$ = $1; }
592 | StringLiteral { $$ = $1; }
63cd45c9 593 | RegularExpressionLiteral_ { $$ = $1; }
1dbba6cc
JF
594 ;
595
36cd3cb9 596NullLiteral
cf7d4c69 597 : "null" { $$ = $1; }
1dbba6cc
JF
598 ;
599
36cd3cb9 600BooleanLiteral
cf7d4c69
JF
601 : "true" { $$ = $1; }
602 | "false" { $$ = $1; }
1dbba6cc
JF
603 ;
604
1dbba6cc 605/* 11.1 Primary Expressions {{{ */
693d501b 606PrimaryExpression_
cf7d4c69 607 : "this" { $$ = $1; }
b1ff2d78 608 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
cf7d4c69
JF
609 | Literal { $$ = $1; }
610 | ArrayLiteral { $$ = $1; }
36cd3cb9 611 | "(" Expression ")" { $$ = $2; }
693d501b
JF
612 ;
613
614PrimaryExpression
615 : ObjectLiteral { $$ = $1; }
616 | PrimaryExpression_ { $$ = $1; }
617 ;
618
619PrimaryExpressionNoBF
620 : PrimaryExpression_ { $$ = $1; }
1dbba6cc
JF
621 ;
622/* }}} */
623/* 11.1.4 Array Initialiser {{{ */
36cd3cb9 624ArrayLiteral
d35a3b07 625 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
1dbba6cc
JF
626 ;
627
36cd3cb9 628Element
cf7d4c69 629 : AssignmentExpression { $$ = $1; }
5befe15e
JF
630 ;
631
632ElementOpt
633 : Element { $$ = $1; }
cf7d4c69 634 | { $$ = NULL; }
1dbba6cc
JF
635 ;
636
5befe15e
JF
637ElementListOpt
638 : ElementList { $$ = $1; }
cf7d4c69 639 | { $$ = NULL; }
1dbba6cc
JF
640 ;
641
36cd3cb9 642ElementList
5befe15e
JF
643 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
644 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
1dbba6cc
JF
645 ;
646/* }}} */
647/* 11.1.5 Object Initialiser {{{ */
36cd3cb9 648ObjectLiteral
5befe15e 649 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
1dbba6cc
JF
650 ;
651
36cd3cb9 652PropertyNameAndValueList_
cf7d4c69 653 : "," PropertyNameAndValueList { $$ = $2; }
cac61857 654 | { $$ = NULL; }
1dbba6cc
JF
655 ;
656
36cd3cb9 657PropertyNameAndValueListOpt
cf7d4c69 658 : PropertyNameAndValueList { $$ = $1; }
36cd3cb9 659 | { $$ = NULL; }
1dbba6cc
JF
660 ;
661
36cd3cb9
JF
662PropertyNameAndValueList
663 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
1dbba6cc
JF
664 ;
665
666PropertyName
36cd3cb9
JF
667 : Identifier { $$ = $1; }
668 | StringLiteral { $$ = $1; }
669 | NumericLiteral { $$ = $1; }
1dbba6cc
JF
670 ;
671/* }}} */
672
63cd45c9 673/* 11.2 Left-Hand-Side Expressions {{{ */
693d501b
JF
674MemberExpression_
675 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
676 ;
677
9b5527f0
JF
678MemberAccess
679 : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); }
680 | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); }
681 ;
682
36cd3cb9 683MemberExpression
cf7d4c69
JF
684 : PrimaryExpression { $$ = $1; }
685 | FunctionExpression { $$ = $1; }
9b5527f0 686 | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
693d501b
JF
687 | MemberExpression_ { $$ = $1; }
688 ;
689
690MemberExpressionNoBF
691 : PrimaryExpressionNoBF { $$ = $1; }
9b5527f0 692 | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
693d501b
JF
693 | MemberExpression_ { $$ = $1; }
694 ;
695
696NewExpression_
697 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
1dbba6cc
JF
698 ;
699
36cd3cb9 700NewExpression
cf7d4c69 701 : MemberExpression { $$ = $1; }
693d501b
JF
702 | NewExpression_ { $$ = $1; }
703 ;
704
705NewExpressionNoBF
706 : MemberExpressionNoBF { $$ = $1; }
707 | NewExpression_ { $$ = $1; }
1dbba6cc
JF
708 ;
709
36cd3cb9 710CallExpression
b1ff2d78
JF
711 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
712 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
9b5527f0 713 | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; }
1dbba6cc
JF
714 ;
715
693d501b
JF
716CallExpressionNoBF
717 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
718 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
9b5527f0 719 | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; }
693d501b
JF
720 ;
721
36cd3cb9 722ArgumentList_
cf7d4c69
JF
723 : "," ArgumentList { $$ = $2; }
724 | { $$ = NULL; }
1dbba6cc
JF
725 ;
726
36cd3cb9 727ArgumentListOpt
cf7d4c69 728 : ArgumentList { $$ = $1; }
36cd3cb9 729 | { $$ = NULL; }
1dbba6cc
JF
730 ;
731
36cd3cb9
JF
732ArgumentList
733 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
1dbba6cc
JF
734 ;
735
736Arguments
36cd3cb9 737 : "(" ArgumentListOpt ")" { $$ = $2; }
1dbba6cc
JF
738 ;
739
36cd3cb9 740LeftHandSideExpression
cf7d4c69
JF
741 : NewExpression { $$ = $1; }
742 | CallExpression { $$ = $1; }
693d501b
JF
743 ;
744
745LeftHandSideExpressionNoBF
746 : NewExpressionNoBF { $$ = $1; }
747 | CallExpressionNoBF { $$ = $1; }
1dbba6cc 748 ;
63cd45c9
JF
749/* }}} */
750/* 11.3 Postfix Expressions {{{ */
36cd3cb9 751PostfixExpression
9b5527f0 752 : AssigneeExpression { $$ = $1; }
b1ff2d78
JF
753 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
754 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
1dbba6cc
JF
755 ;
756
693d501b 757PostfixExpressionNoBF
9b5527f0 758 : AssigneeExpressionNoBF { $$ = $1; }
693d501b
JF
759 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
760 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
761 ;
63cd45c9
JF
762/* }}} */
763/* 11.4 Unary Operators {{{ */
693d501b
JF
764UnaryExpression_
765 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
36cd3cb9
JF
766 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
767 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
768 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
769 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
770 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
771 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
c0bc320e 772 | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); }
36cd3cb9
JF
773 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
774 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
775 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
693d501b
JF
776 ;
777
778UnaryExpression
779 : PostfixExpression { $$ = $1; }
780 | UnaryExpression_ { $$ = $1; }
781 ;
782
783UnaryExpressionNoBF
784 : PostfixExpressionNoBF { $$ = $1; }
785 | UnaryExpression_ { $$ = $1; }
1dbba6cc 786 ;
63cd45c9
JF
787/* }}} */
788/* 11.5 Multiplicative Operators {{{ */
36cd3cb9 789MultiplicativeExpression
cf7d4c69 790 : UnaryExpression { $$ = $1; }
36cd3cb9
JF
791 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
792 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
793 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
1dbba6cc
JF
794 ;
795
693d501b
JF
796MultiplicativeExpressionNoBF
797 : UnaryExpressionNoBF { $$ = $1; }
798 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
799 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
800 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
801 ;
63cd45c9
JF
802/* }}} */
803/* 11.6 Additive Operators {{{ */
36cd3cb9 804AdditiveExpression
cf7d4c69 805 : MultiplicativeExpression { $$ = $1; }
36cd3cb9
JF
806 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
807 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
1dbba6cc
JF
808 ;
809
693d501b
JF
810AdditiveExpressionNoBF
811 : MultiplicativeExpressionNoBF { $$ = $1; }
812 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
813 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
814 ;
63cd45c9
JF
815/* }}} */
816/* 11.7 Bitwise Shift Operators {{{ */
36cd3cb9 817ShiftExpression
cf7d4c69 818 : AdditiveExpression { $$ = $1; }
36cd3cb9
JF
819 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
820 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
821 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
1dbba6cc
JF
822 ;
823
693d501b
JF
824ShiftExpressionNoBF
825 : AdditiveExpressionNoBF { $$ = $1; }
826 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
827 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
828 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
829 ;
63cd45c9
JF
830/* }}} */
831/* 11.8 Relational Operators {{{ */
0ff9f149
JF
832RelationalExpressionNoIn_
833 : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); }
834 | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); }
835 | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); }
836 | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); }
837 | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); }
838 ;
839
840RelationalExpression_
841 : RelationalExpressionNoIn_ { $$ = $1; }
842 | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); }
843 ;
844
36cd3cb9 845RelationalExpression
cf7d4c69 846 : ShiftExpression { $$ = $1; }
0ff9f149 847 | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
1dbba6cc
JF
848 ;
849
693d501b
JF
850RelationalExpressionNoIn
851 : ShiftExpression { $$ = $1; }
0ff9f149 852 | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; }
693d501b
JF
853 ;
854
855RelationalExpressionNoBF
856 : ShiftExpressionNoBF { $$ = $1; }
0ff9f149 857 | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; }
693d501b 858 ;
63cd45c9
JF
859/* }}} */
860/* 11.9 Equality Operators {{{ */
36cd3cb9 861EqualityExpression
cf7d4c69 862 : RelationalExpression { $$ = $1; }
36cd3cb9
JF
863 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
864 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
865 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
866 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
1dbba6cc
JF
867 ;
868
693d501b
JF
869EqualityExpressionNoIn
870 : RelationalExpressionNoIn { $$ = $1; }
871 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
872 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
873 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
874 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
875 ;
876
877EqualityExpressionNoBF
878 : RelationalExpressionNoBF { $$ = $1; }
879 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
880 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
881 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
882 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
883 ;
63cd45c9
JF
884/* }}} */
885/* 11.10 Binary Bitwise Operators {{{ */
36cd3cb9 886BitwiseANDExpression
cf7d4c69 887 : EqualityExpression { $$ = $1; }
36cd3cb9 888 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
1dbba6cc
JF
889 ;
890
693d501b
JF
891BitwiseANDExpressionNoIn
892 : EqualityExpressionNoIn { $$ = $1; }
893 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
894 ;
895
896BitwiseANDExpressionNoBF
897 : EqualityExpressionNoBF { $$ = $1; }
898 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
899 ;
900
36cd3cb9 901BitwiseXORExpression
cf7d4c69 902 : BitwiseANDExpression { $$ = $1; }
36cd3cb9 903 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
1dbba6cc
JF
904 ;
905
693d501b
JF
906BitwiseXORExpressionNoIn
907 : BitwiseANDExpressionNoIn { $$ = $1; }
908 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
909 ;
910
911BitwiseXORExpressionNoBF
912 : BitwiseANDExpressionNoBF { $$ = $1; }
913 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
914 ;
915
36cd3cb9 916BitwiseORExpression
cf7d4c69 917 : BitwiseXORExpression { $$ = $1; }
36cd3cb9 918 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
1dbba6cc
JF
919 ;
920
693d501b
JF
921BitwiseORExpressionNoIn
922 : BitwiseXORExpressionNoIn { $$ = $1; }
923 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
924 ;
925
926BitwiseORExpressionNoBF
927 : BitwiseXORExpressionNoBF { $$ = $1; }
928 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
929 ;
63cd45c9
JF
930/* }}} */
931/* 11.11 Binary Logical Operators {{{ */
36cd3cb9 932LogicalANDExpression
cf7d4c69 933 : BitwiseORExpression { $$ = $1; }
36cd3cb9 934 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
1dbba6cc
JF
935 ;
936
693d501b
JF
937LogicalANDExpressionNoIn
938 : BitwiseORExpressionNoIn { $$ = $1; }
939 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
940 ;
941
942LogicalANDExpressionNoBF
943 : BitwiseORExpressionNoBF { $$ = $1; }
944 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
945 ;
946
36cd3cb9 947LogicalORExpression
cf7d4c69 948 : LogicalANDExpression { $$ = $1; }
36cd3cb9 949 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
1dbba6cc
JF
950 ;
951
693d501b
JF
952LogicalORExpressionNoIn
953 : LogicalANDExpressionNoIn { $$ = $1; }
954 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
955 ;
956
957LogicalORExpressionNoBF
958 : LogicalANDExpressionNoBF { $$ = $1; }
959 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
960 ;
63cd45c9
JF
961/* }}} */
962/* 11.12 Conditional Operator ( ? : ) {{{ */
36cd3cb9 963ConditionalExpression
cf7d4c69 964 : LogicalORExpression { $$ = $1; }
36cd3cb9 965 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
1dbba6cc
JF
966 ;
967
693d501b
JF
968ConditionalExpressionNoIn
969 : LogicalORExpressionNoIn { $$ = $1; }
970 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
971 ;
972
973ConditionalExpressionNoBF
974 : LogicalORExpressionNoBF { $$ = $1; }
975 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
976 ;
63cd45c9
JF
977/* }}} */
978/* 11.13 Assignment Operators {{{ */
0ff9f149
JF
979AssignmentExpression_
980 : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); }
981 | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); }
982 | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); }
983 | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); }
984 | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); }
985 | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); }
986 | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); }
987 | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); }
988 | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); }
989 | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); }
990 | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); }
991 | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); }
992 ;
993
9b5527f0
JF
994AssigneeExpression
995 : LeftHandSideExpression { $$ = $1; }
996 | AssigneeExpression_ { $$ = $1; }
997 ;
998
999AssigneeExpressionNoBF
1000 : LeftHandSideExpressionNoBF { $$ = $1; }
1001 | AssigneeExpression_ { $$ = $1; }
1002 ;
1003
36cd3cb9 1004AssignmentExpression
cf7d4c69 1005 : ConditionalExpression { $$ = $1; }
9b5527f0 1006 | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
36cd3cb9
JF
1007 ;
1008
693d501b
JF
1009AssignmentExpressionNoIn
1010 : ConditionalExpressionNoIn { $$ = $1; }
9b5527f0
JF
1011 | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
1012 | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
1013 | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
1014 | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
1015 | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
1016 | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
1017 | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
1018 | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
1019 | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
1020 | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
1021 | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
1022 | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
693d501b
JF
1023 ;
1024
1025AssignmentExpressionNoBF
1026 : ConditionalExpressionNoBF { $$ = $1; }
9b5527f0 1027 | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; }
693d501b 1028 ;
63cd45c9
JF
1029/* }}} */
1030/* 11.14 Comma Operator {{{ */
36cd3cb9 1031Expression_
d35a3b07 1032 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
cf7d4c69 1033 | { $$ = NULL; }
1dbba6cc
JF
1034 ;
1035
693d501b 1036ExpressionNoIn_
d35a3b07 1037 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
693d501b
JF
1038 | { $$ = NULL; }
1039 ;
1040
36cd3cb9 1041ExpressionOpt
cf7d4c69 1042 : Expression { $$ = $1; }
36cd3cb9 1043 | { $$ = NULL; }
1dbba6cc
JF
1044 ;
1045
693d501b
JF
1046ExpressionNoInOpt
1047 : ExpressionNoIn { $$ = $1; }
1048 | { $$ = NULL; }
1049 ;
1050
36cd3cb9 1051Expression
d35a3b07 1052 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
1dbba6cc
JF
1053 ;
1054
693d501b 1055ExpressionNoIn
d35a3b07 1056 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
693d501b
JF
1057 ;
1058
1059ExpressionNoBF
d35a3b07 1060 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
693d501b 1061 ;
63cd45c9 1062/* }}} */
693d501b 1063
63cd45c9 1064/* 12 Statements {{{ */
b10bd496 1065Statement_
36cd3cb9
JF
1066 : Block { $$ = $1; }
1067 | VariableStatement { $$ = $1; }
1068 | EmptyStatement { $$ = $1; }
1069 | ExpressionStatement { $$ = $1; }
cf7d4c69
JF
1070 | IfStatement { $$ = $1; }
1071 | IterationStatement { $$ = $1; }
36cd3cb9
JF
1072 | ContinueStatement { $$ = $1; }
1073 | BreakStatement { $$ = $1; }
1074 | ReturnStatement { $$ = $1; }
cf7d4c69
JF
1075 | WithStatement { $$ = $1; }
1076 | LabelledStatement { $$ = $1; }
36cd3cb9
JF
1077 | SwitchStatement { $$ = $1; }
1078 | ThrowStatement { $$ = $1; }
1079 | TryStatement { $$ = $1; }
1dbba6cc 1080 ;
b10bd496
JF
1081
1082Statement
1083 : Statement_ { $$ = $1; }
1084 ;
63cd45c9
JF
1085/* }}} */
1086/* 12.1 Block {{{ */
cac61857
JF
1087Block_
1088 : "{" StatementListOpt "}" { $$ = $2; }
1089 ;
1090
36cd3cb9 1091Block
cac61857 1092 : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); }
1dbba6cc
JF
1093 ;
1094
693d501b 1095StatementList
cf7d4c69 1096 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
693d501b
JF
1097 ;
1098
1099StatementListOpt
1100 : StatementList { $$ = $1; }
cf7d4c69 1101 | { $$ = NULL; }
1dbba6cc 1102 ;
63cd45c9
JF
1103/* }}} */
1104/* 12.2 Variable Statement {{{ */
36cd3cb9 1105VariableStatement
cac61857 1106 : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); }
1dbba6cc
JF
1107 ;
1108
36cd3cb9 1109VariableDeclarationList_
cf7d4c69
JF
1110 : "," VariableDeclarationList { $$ = $2; }
1111 | { $$ = NULL; }
1dbba6cc
JF
1112 ;
1113
693d501b
JF
1114VariableDeclarationListNoIn_
1115 : "," VariableDeclarationListNoIn { $$ = $2; }
1116 | { $$ = NULL; }
1117 ;
1118
36cd3cb9 1119VariableDeclarationList
b1ff2d78 1120 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1dbba6cc
JF
1121 ;
1122
693d501b
JF
1123VariableDeclarationListNoIn
1124 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
1125 ;
1126
36cd3cb9
JF
1127VariableDeclaration
1128 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1dbba6cc
JF
1129 ;
1130
693d501b
JF
1131VariableDeclarationNoIn
1132 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
1133 ;
1134
36cd3cb9 1135InitialiserOpt
cf7d4c69 1136 : Initialiser { $$ = $1; }
36cd3cb9 1137 | { $$ = NULL; }
1dbba6cc
JF
1138 ;
1139
693d501b
JF
1140InitialiserNoInOpt
1141 : InitialiserNoIn { $$ = $1; }
1142 | { $$ = NULL; }
1143 ;
1144
36cd3cb9
JF
1145Initialiser
1146 : "=" AssignmentExpression { $$ = $2; }
1dbba6cc
JF
1147 ;
1148
693d501b
JF
1149InitialiserNoIn
1150 : "=" AssignmentExpressionNoIn { $$ = $2; }
1151 ;
63cd45c9
JF
1152/* }}} */
1153/* 12.3 Empty Statement {{{ */
36cd3cb9 1154EmptyStatement
b1ff2d78 1155 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1dbba6cc 1156 ;
63cd45c9
JF
1157/* }}} */
1158/* 12.4 Expression Statement {{{ */
36cd3cb9 1159ExpressionStatement
693d501b 1160 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1dbba6cc 1161 ;
63cd45c9
JF
1162/* }}} */
1163/* 12.5 The if Statement {{{ */
36cd3cb9
JF
1164ElseStatementOpt
1165 : "else" Statement { $$ = $2; }
c3c20102 1166 | %prec "if" { $$ = NULL; }
1dbba6cc
JF
1167 ;
1168
36cd3cb9
JF
1169IfStatement
1170 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1dbba6cc 1171 ;
63cd45c9 1172/* }}} */
1dbba6cc 1173
63cd45c9 1174/* 12.6 Iteration Statements {{{ */
36cd3cb9
JF
1175IterationStatement
1176 : DoWhileStatement { $$ = $1; }
cf7d4c69
JF
1177 | WhileStatement { $$ = $1; }
1178 | ForStatement { $$ = $1; }
1179 | ForInStatement { $$ = $1; }
1dbba6cc 1180 ;
63cd45c9
JF
1181/* }}} */
1182/* 12.6.1 The do-while Statement {{{ */
36cd3cb9
JF
1183DoWhileStatement
1184 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1dbba6cc 1185 ;
63cd45c9
JF
1186/* }}} */
1187/* 12.6.2 The while Statement {{{ */
36cd3cb9
JF
1188WhileStatement
1189 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1dbba6cc 1190 ;
63cd45c9
JF
1191/* }}} */
1192/* 12.6.3 The for Statement {{{ */
36cd3cb9
JF
1193ForStatement
1194 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1dbba6cc
JF
1195 ;
1196
36cd3cb9 1197ForStatementInitialiser
693d501b
JF
1198 : ExpressionNoInOpt { $$ = $1; }
1199 | "var" VariableDeclarationListNoIn { $$ = $2; }
1dbba6cc 1200 ;
63cd45c9
JF
1201/* }}} */
1202/* 12.6.4 The for-in Statement {{{ */
36cd3cb9
JF
1203ForInStatement
1204 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1dbba6cc
JF
1205 ;
1206
36cd3cb9
JF
1207ForInStatementInitialiser
1208 : LeftHandSideExpression { $$ = $1; }
693d501b 1209 | "var" VariableDeclarationNoIn { $$ = $2; }
1dbba6cc 1210 ;
63cd45c9 1211/* }}} */
1dbba6cc 1212
63cd45c9 1213/* 12.7 The continue Statement {{{ */
36cd3cb9
JF
1214ContinueStatement
1215 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1dbba6cc 1216 ;
63cd45c9
JF
1217/* }}} */
1218/* 12.8 The break Statement {{{ */
36cd3cb9
JF
1219BreakStatement
1220 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1dbba6cc 1221 ;
63cd45c9
JF
1222/* }}} */
1223/* 12.9 The return Statement {{{ */
36cd3cb9 1224ReturnStatement
c3c20102 1225 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1dbba6cc 1226 ;
63cd45c9
JF
1227/* }}} */
1228/* 12.10 The with Statement {{{ */
36cd3cb9
JF
1229WithStatement
1230 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1dbba6cc 1231 ;
63cd45c9 1232/* }}} */
1dbba6cc 1233
63cd45c9 1234/* 12.11 The switch Statement {{{ */
36cd3cb9
JF
1235SwitchStatement
1236 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1dbba6cc
JF
1237 ;
1238
1239CaseBlock
36cd3cb9 1240 : "{" CaseClausesOpt "}" { $$ = $2; }
1dbba6cc
JF
1241 ;
1242
36cd3cb9 1243CaseClausesOpt
cf7d4c69
JF
1244 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1245 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1246 | { $$ = NULL; }
1dbba6cc
JF
1247 ;
1248
36cd3cb9
JF
1249CaseClause
1250 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1dbba6cc
JF
1251 ;
1252
36cd3cb9
JF
1253DefaultClause
1254 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1dbba6cc 1255 ;
63cd45c9
JF
1256/* }}} */
1257/* 12.12 Labelled Statements {{{ */
36cd3cb9 1258LabelledStatement
3b52fd1a 1259 : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); }
1dbba6cc 1260 ;
63cd45c9
JF
1261/* }}} */
1262/* 12.13 The throw Statement {{{ */
36cd3cb9 1263ThrowStatement
c3c20102 1264 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1dbba6cc 1265 ;
63cd45c9
JF
1266/* }}} */
1267/* 12.14 The try Statement {{{ */
36cd3cb9 1268TryStatement
cac61857 1269 : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1dbba6cc
JF
1270 ;
1271
1272CatchOpt
cac61857 1273 : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) CYCatch($3, $5); }
cf7d4c69 1274 | { $$ = NULL; }
1dbba6cc
JF
1275 ;
1276
1277FinallyOpt
b10bd496 1278 : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); }
cf7d4c69 1279 | { $$ = NULL; }
1dbba6cc 1280 ;
63cd45c9 1281/* }}} */
1dbba6cc 1282
63cd45c9 1283/* 13 Function Definition {{{ */
36cd3cb9 1284FunctionDeclaration
fb98ac0c 1285 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); }
1dbba6cc
JF
1286 ;
1287
36cd3cb9 1288FunctionExpression
fb98ac0c 1289 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); }
1dbba6cc
JF
1290 ;
1291
1292FormalParameterList_
36cd3cb9 1293 : "," FormalParameterList { $$ = $2; }
cf7d4c69 1294 | { $$ = NULL; }
1dbba6cc
JF
1295 ;
1296
1297FormalParameterList
b09da87b 1298 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
cf7d4c69 1299 | { $$ = NULL; }
1dbba6cc
JF
1300 ;
1301
36cd3cb9
JF
1302FunctionBody
1303 : SourceElements { $$ = $1; }
1dbba6cc 1304 ;
63cd45c9
JF
1305/* }}} */
1306/* 14 Program {{{ */
1dbba6cc 1307Program
3b52fd1a 1308 : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); }
1dbba6cc
JF
1309 ;
1310
36cd3cb9
JF
1311SourceElements
1312 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
cf7d4c69 1313 | { $$ = NULL; }
1dbba6cc
JF
1314 ;
1315
36cd3cb9 1316SourceElement
b10bd496 1317 : Statement_ { $$ = $1; }
36cd3cb9 1318 | FunctionDeclaration { $$ = $1; }
1dbba6cc 1319 ;
63cd45c9 1320/* }}} */
e5332278 1321
4de0686f
JF
1322@begin ObjC
1323/* Cycript (Objective-C): @class Declaration {{{ */
b09da87b
JF
1324ClassSuperOpt
1325 : ":" MemberExpressionNoBF { $$ = $2; }
1326 | { $$ = NULL; }
1327 ;
1328
1329ClassFieldList
1330 : "{" "}" { $$ = NULL; }
1331 ;
1332
1333MessageScope
1334 : "+" { $$ = false; }
1335 | "-" { $$ = true; }
1336 ;
1337
1338TypeOpt
1339 : "(" Expression ")" { $$ = $2; }
1340 | { $$ = NULL; }
1341 ;
1342
1343MessageParameter
75b0a457 1344 : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); }
b09da87b
JF
1345 ;
1346
1347MessageParameterListOpt
1348 : MessageParameterList { $$ = $1; }
1349 | { $$ = NULL; }
1350 ;
1351
1352MessageParameterList
1353 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1354 ;
1355
1356MessageParameters
1357 : MessageParameterList { $$ = $1; }
75b0a457 1358 | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); }
b09da87b
JF
1359 ;
1360
1361ClassMessageDeclaration
75b0a457 1362 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); }
b09da87b
JF
1363 ;
1364
1365ClassMessageDeclarationListOpt
4e8c99fb 1366 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
b09da87b
JF
1367 | { $$ = NULL; }
1368 ;
1369
e5bc40db
JF
1370ClassName
1371 : Identifier { $$ = $1; }
1372 | "(" AssignmentExpression ")" { $$ = $2; }
1373 ;
1374
367eebb1
JF
1375ClassNameOpt
1376 : ClassName { $$ = $1; }
1377 | { $$ = NULL; }
b09da87b
JF
1378 ;
1379
fb98ac0c
JF
1380ClassExpression
1381 : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); }
1382 ;
1383
1384ClassStatement
1385 : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); }
367eebb1
JF
1386 ;
1387
1388CategoryStatement
75b0a457 1389 : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); }
367eebb1
JF
1390 ;
1391
365abb0a 1392PrimaryExpression
fb98ac0c 1393 : ClassExpression { $$ = $1; }
367eebb1
JF
1394 ;
1395
b10bd496 1396Statement_
fb98ac0c 1397 : ClassStatement { $$ = $1; }
365abb0a 1398 | CategoryStatement { $$ = $1; }
b09da87b 1399 ;
cac61857 1400/* }}} */
4de0686f 1401/* Cycript (Objective-C): Send Message {{{ */
693d501b
JF
1402VariadicCall
1403 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1404 | { $$ = NULL; }
1405 ;
1406
1407SelectorCall_
1408 : SelectorCall { $$ = $1; }
1409 | VariadicCall { $$ = $1; }
1410 ;
1411
1412SelectorCall
1413 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1414 ;
1415
1416SelectorList
1417 : SelectorCall { $$ = $1; }
1418 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1419 ;
1420
1421MessageExpression
b09da87b 1422 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
693d501b
JF
1423 ;
1424
e7ed5354
JF
1425SelectorExpressionOpt
1426 : SelectorExpression_ { $$ = $1; }
1427 | { $$ = NULL; }
1428 ;
1429
1430SelectorExpression_
62014ea9 1431 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
e7ed5354
JF
1432 ;
1433
1434SelectorExpression
1435 : SelectorExpression_ { $$ = $1; }
62014ea9 1436 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
e7ed5354
JF
1437 ;
1438
457afcc9 1439PrimaryExpression_
693d501b 1440 : MessageExpression { $$ = $1; }
75b0a457 1441 | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); }
693d501b
JF
1442 ;
1443/* }}} */
4de0686f
JF
1444@end
1445
1446@begin C
1447/* Cycript (C): Pointer Indirection/Addressing {{{ */
9b5527f0
JF
1448AssigneeExpression_
1449 : "*" UnaryExpression { $$ = new(driver.pool_) CYIndirect($2); }
693d501b
JF
1450 ;
1451
1452UnaryExpression_
1453 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1454 ;
1455
9b5527f0 1456MemberAccess
3b52fd1a
JF
1457 : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); }
1458 | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); }
9b5527f0 1459 ;
cac61857 1460/* }}} */
4de0686f
JF
1461@end
1462
cac61857
JF
1463/* ECMAScript5: Object Literal Trailing Comma {{{ */
1464PropertyNameAndValueList_
1465 : "," { $$ = NULL; }
1466 ;
1467/* }}} */
1468/* JavaScript 1.7: Array Comprehensions {{{ */
367eebb1 1469IfComprehension
75b0a457 1470 : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); }
367eebb1
JF
1471 ;
1472
1473ForComprehension
75b0a457
JF
1474 : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); }
1475 | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); }
367eebb1
JF
1476 ;
1477
1478ComprehensionListOpt
75b0a457
JF
1479 : ComprehensionList { $$ = $1; }
1480 | IfComprehension { $$ = $1; }
1481 | { $$ = NULL; }
367eebb1
JF
1482 ;
1483
1484ComprehensionList
75b0a457 1485 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
367eebb1
JF
1486 ;
1487
1488PrimaryExpression_
75b0a457 1489 : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); }
367eebb1 1490 ;
cac61857
JF
1491/* }}} */
1492/* JavaScript 1.7: for each {{{ */
1493ForInStatement
1494 : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); }
1495 ;
1496/* }}} */
b10bd496 1497/* JavaScript 1.7: let Statements {{{ *//*
cac61857
JF
1498LetStatement
1499 : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); }
1500 ;
1501
1502Statement
1503 : LetStatement
1504 ;
534fb6da 1505*//* }}} */
b10bd496
JF
1506/* JavaScript FTW: Function Statements {{{ */
1507Statement
1508 : FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $1; }
1509 ;
1510/* }}} */
367eebb1 1511
e5332278 1512%%