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