]>
Commit | Line | Data |
---|---|---|
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 |
10 | typedef 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 { |
45 | int 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 | |
5befe15e | 192 | %type <expression_> ElementOpt |
cf7d4c69 | 193 | %type <element_> ElementList |
5befe15e | 194 | %type <element_> ElementListOpt |
cf7d4c69 JF |
195 | %type <statement_> ElseStatementOpt |
196 | %type <statement_> EmptyStatement | |
197 | %type <expression_> EqualityExpression | |
693d501b JF |
198 | %type <expression_> EqualityExpressionNoBF |
199 | %type <expression_> EqualityExpressionNoIn | |
cf7d4c69 | 200 | %type <expression_> Expression |
cf7d4c69 | 201 | %type <expression_> ExpressionOpt |
693d501b JF |
202 | %type <expression_> Expression_ |
203 | %type <expression_> ExpressionNoBF | |
204 | %type <expression_> ExpressionNoIn | |
205 | %type <expression_> ExpressionNoIn_ | |
206 | %type <expression_> ExpressionNoInOpt | |
cf7d4c69 JF |
207 | %type <statement_> ExpressionStatement |
208 | %type <statement_> FinallyOpt | |
209 | %type <statement_> ForStatement | |
210 | %type <for_> ForStatementInitialiser | |
211 | %type <statement_> ForInStatement | |
212 | %type <forin_> ForInStatementInitialiser | |
213 | %type <parameter_> FormalParameterList | |
214 | %type <parameter_> FormalParameterList_ | |
215 | %type <source_> FunctionBody | |
216 | %type <source_> FunctionDeclaration | |
217 | %type <expression_> FunctionExpression | |
218 | %type <identifier_> IdentifierOpt | |
219 | %type <statement_> IfStatement | |
220 | %type <expression_> Initialiser | |
221 | %type <expression_> InitialiserOpt | |
693d501b JF |
222 | %type <expression_> InitialiserNoIn |
223 | %type <expression_> InitialiserNoInOpt | |
cf7d4c69 JF |
224 | %type <statement_> IterationStatement |
225 | %type <statement_> LabelledStatement | |
226 | %type <expression_> LeftHandSideExpression | |
693d501b JF |
227 | %type <expression_> LeftHandSideExpression_ |
228 | %type <expression_> LeftHandSideExpressionNoBF | |
cf7d4c69 JF |
229 | %type <literal_> Literal |
230 | %type <expression_> LogicalANDExpression | |
693d501b JF |
231 | %type <expression_> LogicalANDExpressionNoBF |
232 | %type <expression_> LogicalANDExpressionNoIn | |
cf7d4c69 | 233 | %type <expression_> LogicalORExpression |
693d501b JF |
234 | %type <expression_> LogicalORExpressionNoBF |
235 | %type <expression_> LogicalORExpressionNoIn | |
cf7d4c69 | 236 | %type <expression_> MemberExpression |
693d501b JF |
237 | %type <expression_> MemberExpression_ |
238 | %type <expression_> MemberExpressionNoBF | |
cf7d4c69 | 239 | %type <expression_> MultiplicativeExpression |
693d501b | 240 | %type <expression_> MultiplicativeExpressionNoBF |
cf7d4c69 | 241 | %type <expression_> NewExpression |
693d501b JF |
242 | %type <expression_> NewExpression_ |
243 | %type <expression_> NewExpressionNoBF | |
cf7d4c69 JF |
244 | %type <null_> NullLiteral |
245 | %type <literal_> ObjectLiteral | |
cf7d4c69 | 246 | %type <expression_> PostfixExpression |
693d501b | 247 | %type <expression_> PostfixExpressionNoBF |
cf7d4c69 | 248 | %type <expression_> PrimaryExpression |
693d501b JF |
249 | %type <expression_> PrimaryExpression_ |
250 | %type <expression_> PrimaryExpressionNoBF | |
cf7d4c69 JF |
251 | %type <source_> Program |
252 | %type <name_> PropertyName | |
253 | %type <property_> PropertyNameAndValueList | |
254 | %type <property_> PropertyNameAndValueList_ | |
255 | %type <property_> PropertyNameAndValueListOpt | |
256 | %type <expression_> RelationalExpression | |
693d501b JF |
257 | %type <expression_> RelationalExpressionNoBF |
258 | %type <expression_> RelationalExpressionNoIn | |
cf7d4c69 | 259 | %type <statement_> ReturnStatement |
e7ed5354 JF |
260 | %type <selector_> SelectorExpression |
261 | %type <selector_> SelectorExpression_ | |
262 | %type <selector_> SelectorExpressionOpt | |
cf7d4c69 | 263 | %type <expression_> ShiftExpression |
693d501b | 264 | %type <expression_> ShiftExpressionNoBF |
cf7d4c69 JF |
265 | %type <source_> SourceElement |
266 | %type <source_> SourceElements | |
267 | %type <statement_> Statement | |
693d501b | 268 | %type <statement_> StatementList |
cf7d4c69 JF |
269 | %type <statement_> StatementListOpt |
270 | %type <statement_> SwitchStatement | |
271 | %type <statement_> ThrowStatement | |
272 | %type <statement_> TryStatement | |
273 | %type <expression_> UnaryExpression | |
693d501b JF |
274 | %type <expression_> UnaryExpression_ |
275 | %type <expression_> UnaryExpressionNoBF | |
cf7d4c69 | 276 | %type <declaration_> VariableDeclaration |
693d501b | 277 | %type <declaration_> VariableDeclarationNoIn |
cf7d4c69 JF |
278 | %type <declarations_> VariableDeclarationList |
279 | %type <declarations_> VariableDeclarationList_ | |
693d501b JF |
280 | %type <declarations_> VariableDeclarationListNoIn |
281 | %type <declarations_> VariableDeclarationListNoIn_ | |
cf7d4c69 | 282 | %type <statement_> VariableStatement |
cf7d4c69 JF |
283 | %type <statement_> WhileStatement |
284 | %type <statement_> WithStatement | |
285 | %type <word_> Word | |
286 | %type <word_> WordOpt | |
287 | ||
693d501b JF |
288 | %type <expression_> MessageExpression |
289 | %type <argument_> SelectorCall | |
290 | %type <argument_> SelectorCall_ | |
291 | %type <argument_> SelectorList | |
292 | %type <argument_> VariadicCall | |
293 | ||
c3c20102 JF |
294 | %nonassoc "if" |
295 | %nonassoc "else" | |
296 | ||
693d501b | 297 | %start Program |
e5332278 | 298 | |
693d501b | 299 | %% |
c3c20102 | 300 | |
c3c20102 JF |
301 | TerminatorOpt |
302 | : ";" | |
693d501b | 303 | | "\n" |
5befe15e | 304 | | error { yyerrok; driver.errors_.pop_back(); } |
c3c20102 JF |
305 | ; |
306 | ||
307 | Terminator | |
308 | : ";" | |
693d501b | 309 | | "\n" |
5befe15e | 310 | | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } |
c3c20102 JF |
311 | ; |
312 | ||
693d501b JF |
313 | CommaOpt |
314 | : "," | |
315 | | | |
316 | ; | |
317 | ||
c3c20102 | 318 | NewLineOpt |
693d501b | 319 | : "\n" |
c3c20102 JF |
320 | | |
321 | ; | |
1dbba6cc | 322 | |
36cd3cb9 | 323 | WordOpt |
cf7d4c69 JF |
324 | : Word { $$ = $1; } |
325 | | { $$ = NULL; } | |
2bf24581 JF |
326 | ; |
327 | ||
36cd3cb9 | 328 | Word |
cf7d4c69 | 329 | : Identifier { $$ = $1; } |
c3c20102 | 330 | | "break" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
331 | | "case" { $$ = $1; } |
332 | | "catch" { $$ = $1; } | |
c3c20102 | 333 | | "continue" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
334 | | "default" { $$ = $1; } |
335 | | "delete" { $$ = $1; } | |
336 | | "do" { $$ = $1; } | |
337 | | "else" { $$ = $1; } | |
338 | | "false" { $$ = $1; } | |
339 | | "finally" { $$ = $1; } | |
340 | | "for" { $$ = $1; } | |
341 | | "function" { $$ = $1; } | |
342 | | "if" { $$ = $1; } | |
693d501b JF |
343 | /* XXX: | "in" { $$ = $1; } */ |
344 | /* XXX: | "instanceof" { $$ = $1; } */ | |
cf7d4c69 JF |
345 | | "new" { $$ = $1; } |
346 | | "null" { $$ = $1; } | |
c3c20102 | 347 | | "return" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
348 | | "switch" { $$ = $1; } |
349 | | "this" { $$ = $1; } | |
c3c20102 | 350 | | "throw" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
351 | | "true" { $$ = $1; } |
352 | | "try" { $$ = $1; } | |
353 | | "typeof" { $$ = $1; } | |
354 | | "var" { $$ = $1; } | |
355 | | "void" { $$ = $1; } | |
356 | | "while" { $$ = $1; } | |
357 | | "with" { $$ = $1; } | |
2bf24581 JF |
358 | ; |
359 | ||
36cd3cb9 | 360 | IdentifierOpt |
cf7d4c69 JF |
361 | : Identifier { $$ = $1; } |
362 | | { $$ = NULL; } | |
1dbba6cc JF |
363 | ; |
364 | ||
36cd3cb9 | 365 | Literal |
cf7d4c69 JF |
366 | : NullLiteral { $$ = $1; } |
367 | | BooleanLiteral { $$ = $1; } | |
368 | | NumericLiteral { $$ = $1; } | |
369 | | StringLiteral { $$ = $1; } | |
1dbba6cc JF |
370 | ; |
371 | ||
36cd3cb9 | 372 | NullLiteral |
cf7d4c69 | 373 | : "null" { $$ = $1; } |
1dbba6cc JF |
374 | ; |
375 | ||
36cd3cb9 | 376 | BooleanLiteral |
cf7d4c69 JF |
377 | : "true" { $$ = $1; } |
378 | | "false" { $$ = $1; } | |
1dbba6cc JF |
379 | ; |
380 | ||
1dbba6cc | 381 | /* 11.1 Primary Expressions {{{ */ |
693d501b | 382 | PrimaryExpression_ |
cf7d4c69 | 383 | : "this" { $$ = $1; } |
b1ff2d78 | 384 | | Identifier { $$ = new(driver.pool_) CYVariable($1); } |
cf7d4c69 JF |
385 | | Literal { $$ = $1; } |
386 | | ArrayLiteral { $$ = $1; } | |
36cd3cb9 | 387 | | "(" Expression ")" { $$ = $2; } |
693d501b JF |
388 | ; |
389 | ||
390 | PrimaryExpression | |
391 | : ObjectLiteral { $$ = $1; } | |
392 | | PrimaryExpression_ { $$ = $1; } | |
393 | ; | |
394 | ||
395 | PrimaryExpressionNoBF | |
396 | : PrimaryExpression_ { $$ = $1; } | |
1dbba6cc JF |
397 | ; |
398 | /* }}} */ | |
399 | /* 11.1.4 Array Initialiser {{{ */ | |
36cd3cb9 | 400 | ArrayLiteral |
5befe15e | 401 | : "[" ElementList "]" { $$ = new(driver.pool_) CYArray($2); } |
1dbba6cc JF |
402 | ; |
403 | ||
36cd3cb9 | 404 | Element |
cf7d4c69 | 405 | : AssignmentExpression { $$ = $1; } |
5befe15e JF |
406 | ; |
407 | ||
408 | ElementOpt | |
409 | : Element { $$ = $1; } | |
cf7d4c69 | 410 | | { $$ = NULL; } |
1dbba6cc JF |
411 | ; |
412 | ||
5befe15e JF |
413 | ElementListOpt |
414 | : ElementList { $$ = $1; } | |
cf7d4c69 | 415 | | { $$ = NULL; } |
1dbba6cc JF |
416 | ; |
417 | ||
36cd3cb9 | 418 | ElementList |
5befe15e JF |
419 | : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); } |
420 | | Element { $$ = new(driver.pool_) CYElement($1, NULL); } | |
1dbba6cc JF |
421 | ; |
422 | /* }}} */ | |
423 | /* 11.1.5 Object Initialiser {{{ */ | |
36cd3cb9 | 424 | ObjectLiteral |
5befe15e | 425 | : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); } |
1dbba6cc JF |
426 | ; |
427 | ||
36cd3cb9 | 428 | PropertyNameAndValueList_ |
cf7d4c69 | 429 | : "," PropertyNameAndValueList { $$ = $2; } |
693d501b | 430 | | CommaOpt { $$ = NULL; } |
1dbba6cc JF |
431 | ; |
432 | ||
36cd3cb9 | 433 | PropertyNameAndValueListOpt |
cf7d4c69 | 434 | : PropertyNameAndValueList { $$ = $1; } |
36cd3cb9 | 435 | | { $$ = NULL; } |
1dbba6cc JF |
436 | ; |
437 | ||
36cd3cb9 JF |
438 | PropertyNameAndValueList |
439 | : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); } | |
1dbba6cc JF |
440 | ; |
441 | ||
442 | PropertyName | |
36cd3cb9 JF |
443 | : Identifier { $$ = $1; } |
444 | | StringLiteral { $$ = $1; } | |
445 | | NumericLiteral { $$ = $1; } | |
1dbba6cc JF |
446 | ; |
447 | /* }}} */ | |
448 | ||
693d501b JF |
449 | MemberExpression_ |
450 | : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); } | |
451 | ; | |
452 | ||
36cd3cb9 | 453 | MemberExpression |
cf7d4c69 JF |
454 | : PrimaryExpression { $$ = $1; } |
455 | | FunctionExpression { $$ = $1; } | |
36cd3cb9 JF |
456 | | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); } |
457 | | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); } | |
693d501b JF |
458 | | MemberExpression_ { $$ = $1; } |
459 | ; | |
460 | ||
461 | MemberExpressionNoBF | |
462 | : PrimaryExpressionNoBF { $$ = $1; } | |
463 | | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); } | |
464 | | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); } | |
465 | | MemberExpression_ { $$ = $1; } | |
466 | ; | |
467 | ||
468 | NewExpression_ | |
469 | : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } | |
1dbba6cc JF |
470 | ; |
471 | ||
36cd3cb9 | 472 | NewExpression |
cf7d4c69 | 473 | : MemberExpression { $$ = $1; } |
693d501b JF |
474 | | NewExpression_ { $$ = $1; } |
475 | ; | |
476 | ||
477 | NewExpressionNoBF | |
478 | : MemberExpressionNoBF { $$ = $1; } | |
479 | | NewExpression_ { $$ = $1; } | |
1dbba6cc JF |
480 | ; |
481 | ||
36cd3cb9 | 482 | CallExpression |
b1ff2d78 JF |
483 | : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } |
484 | | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
36cd3cb9 JF |
485 | | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); } |
486 | | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); } | |
1dbba6cc JF |
487 | ; |
488 | ||
693d501b JF |
489 | CallExpressionNoBF |
490 | : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
491 | | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
492 | | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); } | |
493 | | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); } | |
494 | ; | |
495 | ||
36cd3cb9 | 496 | ArgumentList_ |
cf7d4c69 JF |
497 | : "," ArgumentList { $$ = $2; } |
498 | | { $$ = NULL; } | |
1dbba6cc JF |
499 | ; |
500 | ||
36cd3cb9 | 501 | ArgumentListOpt |
cf7d4c69 | 502 | : ArgumentList { $$ = $1; } |
36cd3cb9 | 503 | | { $$ = NULL; } |
1dbba6cc JF |
504 | ; |
505 | ||
36cd3cb9 JF |
506 | ArgumentList |
507 | : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); } | |
1dbba6cc JF |
508 | ; |
509 | ||
510 | Arguments | |
36cd3cb9 | 511 | : "(" ArgumentListOpt ")" { $$ = $2; } |
1dbba6cc JF |
512 | ; |
513 | ||
36cd3cb9 | 514 | LeftHandSideExpression |
cf7d4c69 JF |
515 | : NewExpression { $$ = $1; } |
516 | | CallExpression { $$ = $1; } | |
693d501b JF |
517 | | LeftHandSideExpression_ { $$ = $1; } |
518 | ; | |
519 | ||
520 | LeftHandSideExpressionNoBF | |
521 | : NewExpressionNoBF { $$ = $1; } | |
522 | | CallExpressionNoBF { $$ = $1; } | |
523 | | LeftHandSideExpression_ { $$ = $1; } | |
1dbba6cc JF |
524 | ; |
525 | ||
36cd3cb9 | 526 | PostfixExpression |
cf7d4c69 | 527 | : LeftHandSideExpression { $$ = $1; } |
b1ff2d78 JF |
528 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } |
529 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
1dbba6cc JF |
530 | ; |
531 | ||
693d501b JF |
532 | PostfixExpressionNoBF |
533 | : LeftHandSideExpressionNoBF { $$ = $1; } | |
534 | | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
535 | | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
536 | ; | |
537 | ||
538 | UnaryExpression_ | |
539 | : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); } | |
36cd3cb9 JF |
540 | | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); } |
541 | | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); } | |
542 | | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
543 | | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
544 | | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
545 | | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
546 | | "+" UnaryExpression { $$ = $2; } | |
547 | | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); } | |
548 | | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); } | |
549 | | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); } | |
693d501b JF |
550 | ; |
551 | ||
552 | UnaryExpression | |
553 | : PostfixExpression { $$ = $1; } | |
554 | | UnaryExpression_ { $$ = $1; } | |
555 | ; | |
556 | ||
557 | UnaryExpressionNoBF | |
558 | : PostfixExpressionNoBF { $$ = $1; } | |
559 | | UnaryExpression_ { $$ = $1; } | |
1dbba6cc JF |
560 | ; |
561 | ||
36cd3cb9 | 562 | MultiplicativeExpression |
cf7d4c69 | 563 | : UnaryExpression { $$ = $1; } |
36cd3cb9 JF |
564 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } |
565 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
566 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1dbba6cc JF |
567 | ; |
568 | ||
693d501b JF |
569 | MultiplicativeExpressionNoBF |
570 | : UnaryExpressionNoBF { $$ = $1; } | |
571 | | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
572 | | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
573 | | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
574 | ; | |
575 | ||
36cd3cb9 | 576 | AdditiveExpression |
cf7d4c69 | 577 | : MultiplicativeExpression { $$ = $1; } |
36cd3cb9 JF |
578 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } |
579 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1dbba6cc JF |
580 | ; |
581 | ||
693d501b JF |
582 | AdditiveExpressionNoBF |
583 | : MultiplicativeExpressionNoBF { $$ = $1; } | |
584 | | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
585 | | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
586 | ; | |
587 | ||
36cd3cb9 | 588 | ShiftExpression |
cf7d4c69 | 589 | : AdditiveExpression { $$ = $1; } |
36cd3cb9 JF |
590 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } |
591 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
592 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1dbba6cc JF |
593 | ; |
594 | ||
693d501b JF |
595 | ShiftExpressionNoBF |
596 | : AdditiveExpressionNoBF { $$ = $1; } | |
597 | | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
598 | | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
599 | | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
600 | ; | |
601 | ||
36cd3cb9 | 602 | RelationalExpression |
cf7d4c69 | 603 | : ShiftExpression { $$ = $1; } |
36cd3cb9 JF |
604 | | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); } |
605 | | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); } | |
606 | | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); } | |
607 | | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); } | |
608 | | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); } | |
609 | | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); } | |
1dbba6cc JF |
610 | ; |
611 | ||
693d501b JF |
612 | RelationalExpressionNoIn |
613 | : ShiftExpression { $$ = $1; } | |
614 | | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); } | |
615 | | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); } | |
616 | | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); } | |
617 | | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); } | |
618 | | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); } | |
619 | ; | |
620 | ||
621 | RelationalExpressionNoBF | |
622 | : ShiftExpressionNoBF { $$ = $1; } | |
623 | | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); } | |
624 | | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); } | |
625 | | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); } | |
626 | | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); } | |
627 | | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); } | |
628 | | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); } | |
629 | ; | |
630 | ||
36cd3cb9 | 631 | EqualityExpression |
cf7d4c69 | 632 | : RelationalExpression { $$ = $1; } |
36cd3cb9 JF |
633 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } |
634 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
635 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
636 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1dbba6cc JF |
637 | ; |
638 | ||
693d501b JF |
639 | EqualityExpressionNoIn |
640 | : RelationalExpressionNoIn { $$ = $1; } | |
641 | | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); } | |
642 | | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
643 | | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
644 | | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
645 | ; | |
646 | ||
647 | EqualityExpressionNoBF | |
648 | : RelationalExpressionNoBF { $$ = $1; } | |
649 | | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
650 | | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
651 | | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
652 | | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
653 | ; | |
654 | ||
36cd3cb9 | 655 | BitwiseANDExpression |
cf7d4c69 | 656 | : EqualityExpression { $$ = $1; } |
36cd3cb9 | 657 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } |
1dbba6cc JF |
658 | ; |
659 | ||
693d501b JF |
660 | BitwiseANDExpressionNoIn |
661 | : EqualityExpressionNoIn { $$ = $1; } | |
662 | | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
663 | ; | |
664 | ||
665 | BitwiseANDExpressionNoBF | |
666 | : EqualityExpressionNoBF { $$ = $1; } | |
667 | | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
668 | ; | |
669 | ||
36cd3cb9 | 670 | BitwiseXORExpression |
cf7d4c69 | 671 | : BitwiseANDExpression { $$ = $1; } |
36cd3cb9 | 672 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } |
1dbba6cc JF |
673 | ; |
674 | ||
693d501b JF |
675 | BitwiseXORExpressionNoIn |
676 | : BitwiseANDExpressionNoIn { $$ = $1; } | |
677 | | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
678 | ; | |
679 | ||
680 | BitwiseXORExpressionNoBF | |
681 | : BitwiseANDExpressionNoBF { $$ = $1; } | |
682 | | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
683 | ; | |
684 | ||
36cd3cb9 | 685 | BitwiseORExpression |
cf7d4c69 | 686 | : BitwiseXORExpression { $$ = $1; } |
36cd3cb9 | 687 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } |
1dbba6cc JF |
688 | ; |
689 | ||
693d501b JF |
690 | BitwiseORExpressionNoIn |
691 | : BitwiseXORExpressionNoIn { $$ = $1; } | |
692 | | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
693 | ; | |
694 | ||
695 | BitwiseORExpressionNoBF | |
696 | : BitwiseXORExpressionNoBF { $$ = $1; } | |
697 | | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
698 | ; | |
699 | ||
36cd3cb9 | 700 | LogicalANDExpression |
cf7d4c69 | 701 | : BitwiseORExpression { $$ = $1; } |
36cd3cb9 | 702 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } |
1dbba6cc JF |
703 | ; |
704 | ||
693d501b JF |
705 | LogicalANDExpressionNoIn |
706 | : BitwiseORExpressionNoIn { $$ = $1; } | |
707 | | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
708 | ; | |
709 | ||
710 | LogicalANDExpressionNoBF | |
711 | : BitwiseORExpressionNoBF { $$ = $1; } | |
712 | | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
713 | ; | |
714 | ||
36cd3cb9 | 715 | LogicalORExpression |
cf7d4c69 | 716 | : LogicalANDExpression { $$ = $1; } |
36cd3cb9 | 717 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } |
1dbba6cc JF |
718 | ; |
719 | ||
693d501b JF |
720 | LogicalORExpressionNoIn |
721 | : LogicalANDExpressionNoIn { $$ = $1; } | |
722 | | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
723 | ; | |
724 | ||
725 | LogicalORExpressionNoBF | |
726 | : LogicalANDExpressionNoBF { $$ = $1; } | |
727 | | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
728 | ; | |
729 | ||
36cd3cb9 | 730 | ConditionalExpression |
cf7d4c69 | 731 | : LogicalORExpression { $$ = $1; } |
36cd3cb9 | 732 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } |
1dbba6cc JF |
733 | ; |
734 | ||
693d501b JF |
735 | ConditionalExpressionNoIn |
736 | : LogicalORExpressionNoIn { $$ = $1; } | |
737 | | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
738 | ; | |
739 | ||
740 | ConditionalExpressionNoBF | |
741 | : LogicalORExpressionNoBF { $$ = $1; } | |
742 | | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
743 | ; | |
744 | ||
36cd3cb9 | 745 | AssignmentExpression |
cf7d4c69 | 746 | : ConditionalExpression { $$ = $1; } |
36cd3cb9 JF |
747 | | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); } |
748 | | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
749 | | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
750 | | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
751 | | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
752 | | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
753 | | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
754 | | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
755 | | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
756 | | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
757 | | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
758 | | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
759 | ; | |
760 | ||
693d501b JF |
761 | AssignmentExpressionNoIn |
762 | : ConditionalExpressionNoIn { $$ = $1; } | |
763 | | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); } | |
764 | | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
765 | | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
766 | | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
767 | | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
768 | | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
769 | | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
770 | | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
771 | | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
772 | | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
773 | | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
774 | | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
775 | ; | |
776 | ||
777 | AssignmentExpressionNoBF | |
778 | : ConditionalExpressionNoBF { $$ = $1; } | |
779 | | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); } | |
780 | | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
781 | | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
782 | | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
783 | | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
784 | | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
785 | | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
786 | | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
787 | | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
788 | | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
789 | | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
790 | | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
791 | ; | |
792 | ||
36cd3cb9 JF |
793 | Expression_ |
794 | : "," Expression { $$ = $2; } | |
cf7d4c69 | 795 | | { $$ = NULL; } |
1dbba6cc JF |
796 | ; |
797 | ||
693d501b JF |
798 | ExpressionNoIn_ |
799 | : "," ExpressionNoIn { $$ = $2; } | |
800 | | { $$ = NULL; } | |
801 | ; | |
802 | ||
36cd3cb9 | 803 | ExpressionOpt |
cf7d4c69 | 804 | : Expression { $$ = $1; } |
36cd3cb9 | 805 | | { $$ = NULL; } |
1dbba6cc JF |
806 | ; |
807 | ||
693d501b JF |
808 | ExpressionNoInOpt |
809 | : ExpressionNoIn { $$ = $1; } | |
810 | | { $$ = NULL; } | |
811 | ; | |
812 | ||
36cd3cb9 | 813 | Expression |
c3c20102 | 814 | : AssignmentExpression Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; } |
1dbba6cc JF |
815 | ; |
816 | ||
693d501b JF |
817 | ExpressionNoIn |
818 | : AssignmentExpressionNoIn ExpressionNoIn_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; } | |
819 | ; | |
820 | ||
821 | ExpressionNoBF | |
822 | : AssignmentExpressionNoBF Expression_ { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; } | |
823 | ; | |
824 | ||
36cd3cb9 JF |
825 | Statement |
826 | : Block { $$ = $1; } | |
827 | | VariableStatement { $$ = $1; } | |
828 | | EmptyStatement { $$ = $1; } | |
829 | | ExpressionStatement { $$ = $1; } | |
cf7d4c69 JF |
830 | | IfStatement { $$ = $1; } |
831 | | IterationStatement { $$ = $1; } | |
36cd3cb9 JF |
832 | | ContinueStatement { $$ = $1; } |
833 | | BreakStatement { $$ = $1; } | |
834 | | ReturnStatement { $$ = $1; } | |
cf7d4c69 JF |
835 | | WithStatement { $$ = $1; } |
836 | | LabelledStatement { $$ = $1; } | |
36cd3cb9 JF |
837 | | SwitchStatement { $$ = $1; } |
838 | | ThrowStatement { $$ = $1; } | |
839 | | TryStatement { $$ = $1; } | |
1dbba6cc JF |
840 | ; |
841 | ||
36cd3cb9 | 842 | Block |
5befe15e | 843 | : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); } |
1dbba6cc JF |
844 | ; |
845 | ||
693d501b | 846 | StatementList |
cf7d4c69 | 847 | : Statement StatementListOpt { $1->SetNext($2); $$ = $1; } |
693d501b JF |
848 | ; |
849 | ||
850 | StatementListOpt | |
851 | : StatementList { $$ = $1; } | |
cf7d4c69 | 852 | | { $$ = NULL; } |
1dbba6cc JF |
853 | ; |
854 | ||
36cd3cb9 | 855 | VariableStatement |
c3c20102 | 856 | : "var" VariableDeclarationList Terminator { $$ = $2; } |
1dbba6cc JF |
857 | ; |
858 | ||
36cd3cb9 | 859 | VariableDeclarationList_ |
cf7d4c69 JF |
860 | : "," VariableDeclarationList { $$ = $2; } |
861 | | { $$ = NULL; } | |
1dbba6cc JF |
862 | ; |
863 | ||
693d501b JF |
864 | VariableDeclarationListNoIn_ |
865 | : "," VariableDeclarationListNoIn { $$ = $2; } | |
866 | | { $$ = NULL; } | |
867 | ; | |
868 | ||
36cd3cb9 | 869 | VariableDeclarationList |
b1ff2d78 | 870 | : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } |
1dbba6cc JF |
871 | ; |
872 | ||
693d501b JF |
873 | VariableDeclarationListNoIn |
874 | : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
875 | ; | |
876 | ||
36cd3cb9 JF |
877 | VariableDeclaration |
878 | : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1dbba6cc JF |
879 | ; |
880 | ||
693d501b JF |
881 | VariableDeclarationNoIn |
882 | : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
883 | ; | |
884 | ||
36cd3cb9 | 885 | InitialiserOpt |
cf7d4c69 | 886 | : Initialiser { $$ = $1; } |
36cd3cb9 | 887 | | { $$ = NULL; } |
1dbba6cc JF |
888 | ; |
889 | ||
693d501b JF |
890 | InitialiserNoInOpt |
891 | : InitialiserNoIn { $$ = $1; } | |
892 | | { $$ = NULL; } | |
893 | ; | |
894 | ||
36cd3cb9 JF |
895 | Initialiser |
896 | : "=" AssignmentExpression { $$ = $2; } | |
1dbba6cc JF |
897 | ; |
898 | ||
693d501b JF |
899 | InitialiserNoIn |
900 | : "=" AssignmentExpressionNoIn { $$ = $2; } | |
901 | ; | |
902 | ||
36cd3cb9 | 903 | EmptyStatement |
b1ff2d78 | 904 | : ";" { $$ = new(driver.pool_) CYEmpty(); } |
1dbba6cc JF |
905 | ; |
906 | ||
36cd3cb9 | 907 | ExpressionStatement |
693d501b | 908 | : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); } |
1dbba6cc JF |
909 | ; |
910 | ||
36cd3cb9 JF |
911 | ElseStatementOpt |
912 | : "else" Statement { $$ = $2; } | |
c3c20102 | 913 | | %prec "if" { $$ = NULL; } |
1dbba6cc JF |
914 | ; |
915 | ||
36cd3cb9 JF |
916 | IfStatement |
917 | : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); } | |
1dbba6cc JF |
918 | ; |
919 | ||
36cd3cb9 JF |
920 | IterationStatement |
921 | : DoWhileStatement { $$ = $1; } | |
cf7d4c69 JF |
922 | | WhileStatement { $$ = $1; } |
923 | | ForStatement { $$ = $1; } | |
924 | | ForInStatement { $$ = $1; } | |
1dbba6cc JF |
925 | ; |
926 | ||
36cd3cb9 JF |
927 | DoWhileStatement |
928 | : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); } | |
1dbba6cc JF |
929 | ; |
930 | ||
36cd3cb9 JF |
931 | WhileStatement |
932 | : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); } | |
1dbba6cc JF |
933 | ; |
934 | ||
36cd3cb9 JF |
935 | ForStatement |
936 | : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); } | |
1dbba6cc JF |
937 | ; |
938 | ||
36cd3cb9 | 939 | ForStatementInitialiser |
693d501b JF |
940 | : ExpressionNoInOpt { $$ = $1; } |
941 | | "var" VariableDeclarationListNoIn { $$ = $2; } | |
1dbba6cc JF |
942 | ; |
943 | ||
36cd3cb9 JF |
944 | ForInStatement |
945 | : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); } | |
1dbba6cc JF |
946 | ; |
947 | ||
36cd3cb9 JF |
948 | ForInStatementInitialiser |
949 | : LeftHandSideExpression { $$ = $1; } | |
693d501b | 950 | | "var" VariableDeclarationNoIn { $$ = $2; } |
1dbba6cc JF |
951 | ; |
952 | ||
36cd3cb9 JF |
953 | ContinueStatement |
954 | : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); } | |
1dbba6cc JF |
955 | ; |
956 | ||
36cd3cb9 JF |
957 | BreakStatement |
958 | : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); } | |
1dbba6cc JF |
959 | ; |
960 | ||
36cd3cb9 | 961 | ReturnStatement |
c3c20102 | 962 | : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); } |
1dbba6cc JF |
963 | ; |
964 | ||
36cd3cb9 JF |
965 | WithStatement |
966 | : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); } | |
1dbba6cc JF |
967 | ; |
968 | ||
36cd3cb9 JF |
969 | SwitchStatement |
970 | : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); } | |
1dbba6cc JF |
971 | ; |
972 | ||
973 | CaseBlock | |
36cd3cb9 | 974 | : "{" CaseClausesOpt "}" { $$ = $2; } |
1dbba6cc JF |
975 | ; |
976 | ||
36cd3cb9 | 977 | CaseClausesOpt |
cf7d4c69 JF |
978 | : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } |
979 | | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
980 | | { $$ = NULL; } | |
1dbba6cc JF |
981 | ; |
982 | ||
36cd3cb9 JF |
983 | CaseClause |
984 | : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); } | |
1dbba6cc JF |
985 | ; |
986 | ||
36cd3cb9 JF |
987 | DefaultClause |
988 | : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); } | |
1dbba6cc JF |
989 | ; |
990 | ||
36cd3cb9 JF |
991 | LabelledStatement |
992 | : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; } | |
1dbba6cc JF |
993 | ; |
994 | ||
36cd3cb9 | 995 | ThrowStatement |
c3c20102 | 996 | : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); } |
1dbba6cc JF |
997 | ; |
998 | ||
36cd3cb9 | 999 | TryStatement |
b1ff2d78 | 1000 | : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); } |
1dbba6cc JF |
1001 | ; |
1002 | ||
1003 | CatchOpt | |
36cd3cb9 | 1004 | : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); } |
cf7d4c69 | 1005 | | { $$ = NULL; } |
1dbba6cc JF |
1006 | ; |
1007 | ||
1008 | FinallyOpt | |
36cd3cb9 | 1009 | : "finally" Block { $$ = $2; } |
cf7d4c69 | 1010 | | { $$ = NULL; } |
1dbba6cc JF |
1011 | ; |
1012 | ||
36cd3cb9 JF |
1013 | FunctionDeclaration |
1014 | : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); } | |
1dbba6cc JF |
1015 | ; |
1016 | ||
36cd3cb9 JF |
1017 | FunctionExpression |
1018 | : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); } | |
1dbba6cc JF |
1019 | ; |
1020 | ||
1021 | FormalParameterList_ | |
36cd3cb9 | 1022 | : "," FormalParameterList { $$ = $2; } |
cf7d4c69 | 1023 | | { $$ = NULL; } |
1dbba6cc JF |
1024 | ; |
1025 | ||
1026 | FormalParameterList | |
36cd3cb9 | 1027 | : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYParameter($1, $2); } |
cf7d4c69 | 1028 | | { $$ = NULL; } |
1dbba6cc JF |
1029 | ; |
1030 | ||
36cd3cb9 JF |
1031 | FunctionBody |
1032 | : SourceElements { $$ = $1; } | |
1dbba6cc JF |
1033 | ; |
1034 | ||
1035 | Program | |
5befe15e | 1036 | : SourceElements { driver.source_ = $1; } |
1dbba6cc JF |
1037 | ; |
1038 | ||
36cd3cb9 JF |
1039 | SourceElements |
1040 | : SourceElement SourceElements { $1->SetNext($2); $$ = $1; } | |
cf7d4c69 | 1041 | | { $$ = NULL; } |
1dbba6cc JF |
1042 | ; |
1043 | ||
36cd3cb9 | 1044 | SourceElement |
cf7d4c69 | 1045 | : Statement { $$ = $1; } |
36cd3cb9 | 1046 | | FunctionDeclaration { $$ = $1; } |
1dbba6cc | 1047 | ; |
e5332278 | 1048 | |
693d501b JF |
1049 | /* Objective-C Extensions {{{ */ |
1050 | VariadicCall | |
1051 | : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); } | |
1052 | | { $$ = NULL; } | |
1053 | ; | |
1054 | ||
1055 | SelectorCall_ | |
1056 | : SelectorCall { $$ = $1; } | |
1057 | | VariadicCall { $$ = $1; } | |
1058 | ; | |
1059 | ||
1060 | SelectorCall | |
1061 | : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); } | |
1062 | ; | |
1063 | ||
1064 | SelectorList | |
1065 | : SelectorCall { $$ = $1; } | |
1066 | | Word { $$ = new(driver.pool_) CYArgument($1, NULL); } | |
1067 | ; | |
1068 | ||
1069 | MessageExpression | |
1070 | : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYMessage($2, $3); } | |
1071 | ; | |
1072 | ||
e7ed5354 JF |
1073 | SelectorExpressionOpt |
1074 | : SelectorExpression_ { $$ = $1; } | |
1075 | | { $$ = NULL; } | |
1076 | ; | |
1077 | ||
1078 | SelectorExpression_ | |
5befe15e | 1079 | : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelector($1, true, $3); } |
e7ed5354 JF |
1080 | ; |
1081 | ||
1082 | SelectorExpression | |
1083 | : SelectorExpression_ { $$ = $1; } | |
5befe15e | 1084 | | Word { $$ = new(driver.pool_) CYSelector($1, false, NULL); } |
e7ed5354 JF |
1085 | ; |
1086 | ||
457afcc9 | 1087 | PrimaryExpression_ |
693d501b | 1088 | : MessageExpression { $$ = $1; } |
e7ed5354 | 1089 | | "@selector" "(" SelectorExpression ")" { $$ = $3; } |
693d501b JF |
1090 | ; |
1091 | /* }}} */ | |
1092 | ||
1093 | LeftHandSideExpression_ | |
1094 | : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); } | |
1095 | ; | |
1096 | ||
1097 | UnaryExpression_ | |
1098 | : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); } | |
1099 | ; | |
1100 | ||
e5332278 | 1101 | %% |