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