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