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