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