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