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