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