]>
Commit | Line | Data |
---|---|---|
d15b59f5 | 1 | /* Cycript - Inlining/Optimizing JavaScript Compiler |
b4aa79af JF |
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 | |
cbaa5f0f | 49 | @begin ObjectiveC |
3c1c3635 | 50 | #include "ObjectiveC/Syntax.hpp" |
4de0686f JF |
51 | @end |
52 | ||
691e4717 | 53 | @begin E4X |
b92ceddb | 54 | #include "E4X/Syntax.hpp" |
691e4717 JF |
55 | @end |
56 | ||
c3c20102 JF |
57 | typedef struct { |
58 | bool newline_; | |
59 | ||
60 | union { | |
b09da87b JF |
61 | bool bool_; |
62 | ||
63cd45c9 JF |
63 | CYDriver::Condition condition_; |
64 | ||
c3c20102 | 65 | CYArgument *argument_; |
0ff9f149 | 66 | CYAssignment *assignment_; |
c3c20102 JF |
67 | CYBoolean *boolean_; |
68 | CYClause *clause_; | |
37954781 | 69 | cy::Syntax::Catch *catch_; |
75b0a457 | 70 | CYComprehension *comprehension_; |
d35a3b07 | 71 | CYCompound *compound_; |
c3c20102 JF |
72 | CYDeclaration *declaration_; |
73 | CYDeclarations *declarations_; | |
74 | CYElement *element_; | |
75 | CYExpression *expression_; | |
76 | CYFalse *false_; | |
b10bd496 | 77 | CYFinally *finally_; |
c3c20102 JF |
78 | CYForInitialiser *for_; |
79 | CYForInInitialiser *forin_; | |
b09da87b | 80 | CYFunctionParameter *functionParameter_; |
c3c20102 | 81 | CYIdentifier *identifier_; |
0ff9f149 | 82 | CYInfix *infix_; |
c3c20102 | 83 | CYLiteral *literal_; |
9b5527f0 | 84 | CYMember *member_; |
c3c20102 JF |
85 | CYNull *null_; |
86 | CYNumber *number_; | |
3b52fd1a | 87 | CYProgram *program_; |
c3c20102 | 88 | CYProperty *property_; |
e5bc40db | 89 | CYPropertyName *propertyName_; |
c3c20102 JF |
90 | CYStatement *statement_; |
91 | CYString *string_; | |
92 | CYThis *this_; | |
93 | CYTrue *true_; | |
94 | CYWord *word_; | |
4de0686f | 95 | |
cbaa5f0f | 96 | @begin ObjectiveC |
328ad766 JF |
97 | CYClassName *className_; |
98 | CYField *field_; | |
4de0686f JF |
99 | CYMessage *message_; |
100 | CYMessageParameter *messageParameter_; | |
101 | CYSelectorPart *selector_; | |
102 | @end | |
691e4717 JF |
103 | |
104 | @begin E4X | |
105 | CYAttribute *attribute_; | |
b92ceddb JF |
106 | CYPropertyIdentifier *propertyIdentifier_; |
107 | CYSelector *selector_; | |
691e4717 | 108 | @end |
c3c20102 JF |
109 | }; |
110 | } YYSTYPE; | |
111 | ||
63b4c5a8 JF |
112 | } |
113 | ||
693d501b JF |
114 | %code provides { |
115 | int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); | |
116 | } | |
117 | ||
1dbba6cc | 118 | %name-prefix "cy" |
e5332278 | 119 | |
63b4c5a8 | 120 | %language "C++" |
e5332278 | 121 | %locations |
1dbba6cc | 122 | |
5999c315 JF |
123 | %initial-action { |
124 | @$.begin.filename = @$.end.filename = &driver.filename_; | |
125 | }; | |
126 | ||
e5332278 | 127 | %defines |
1dbba6cc | 128 | |
534fb6da JF |
129 | //%glr-parser |
130 | //%expect 1 | |
cac61857 | 131 | |
e5332278 JF |
132 | %error-verbose |
133 | ||
5999c315 | 134 | %parse-param { CYDriver &driver } |
924f67b2 | 135 | %lex-param { void *scanner } |
e5332278 | 136 | |
cb02f8ae | 137 | @begin E4X |
cb02f8ae JF |
138 | %token XMLCDATA |
139 | %token XMLComment | |
140 | %token XMLPI | |
691e4717 JF |
141 | |
142 | %token XMLAttributeValue | |
143 | %token XMLName | |
144 | %token XMLTagCharacters | |
145 | %token XMLText | |
146 | %token XMLWhitespace | |
147 | @end | |
148 | ||
149 | @begin E4X | |
150 | %token LeftRight "<>" | |
151 | %token LeftSlashRight "</>" | |
152 | ||
153 | %token SlashRight "/>" | |
154 | %token LeftSlash "</" | |
155 | ||
691e4717 JF |
156 | %token ColonColon "::" |
157 | %token PeriodPeriod ".." | |
cb02f8ae | 158 | @end |
ac9a5ce1 | 159 | |
b1589845 JF |
160 | @begin E4X ObjectiveC |
161 | %token At "@" | |
162 | @end | |
163 | ||
63b4c5a8 JF |
164 | %token Ampersand "&" |
165 | %token AmpersandAmpersand "&&" | |
166 | %token AmpersandEqual "&=" | |
167 | %token Carrot "^" | |
168 | %token CarrotEqual "^=" | |
169 | %token Equal "=" | |
170 | %token EqualEqual "==" | |
171 | %token EqualEqualEqual "===" | |
172 | %token Exclamation "!" | |
173 | %token ExclamationEqual "!=" | |
174 | %token ExclamationEqualEqual "!==" | |
175 | %token Hyphen "-" | |
176 | %token HyphenEqual "-=" | |
177 | %token HyphenHyphen "--" | |
c3c20102 | 178 | %token HyphenHyphen_ "\n--" |
63b4c5a8 JF |
179 | %token HyphenRight "->" |
180 | %token Left "<" | |
181 | %token LeftEqual "<=" | |
182 | %token LeftLeft "<<" | |
183 | %token LeftLeftEqual "<<=" | |
184 | %token Percent "%" | |
185 | %token PercentEqual "%=" | |
186 | %token Period "." | |
187 | %token Pipe "|" | |
188 | %token PipeEqual "|=" | |
189 | %token PipePipe "||" | |
190 | %token Plus "+" | |
191 | %token PlusEqual "+=" | |
192 | %token PlusPlus "++" | |
c3c20102 | 193 | %token PlusPlus_ "\n++" |
63b4c5a8 JF |
194 | %token Right ">" |
195 | %token RightEqual ">=" | |
196 | %token RightRight ">>" | |
197 | %token RightRightEqual ">>=" | |
198 | %token RightRightRight ">>>" | |
199 | %token RightRightRightEqual ">>>=" | |
200 | %token Slash "/" | |
201 | %token SlashEqual "/=" | |
202 | %token Star "*" | |
203 | %token StarEqual "*=" | |
204 | %token Tilde "~" | |
205 | ||
206 | %token Colon ":" | |
207 | %token Comma "," | |
208 | %token Question "?" | |
209 | %token SemiColon ";" | |
c3c20102 | 210 | %token NewLine "\n" |
63b4c5a8 JF |
211 | |
212 | %token OpenParen "(" | |
213 | %token CloseParen ")" | |
924f67b2 | 214 | |
63b4c5a8 JF |
215 | %token OpenBrace "{" |
216 | %token CloseBrace "}" | |
924f67b2 | 217 | |
63b4c5a8 JF |
218 | %token OpenBracket "[" |
219 | %token CloseBracket "]" | |
220 | ||
b09da87b | 221 | %token AtClass "@class" |
e7ed5354 | 222 | %token AtSelector "@selector" |
d35a3b07 | 223 | %token AtEnd "@end" |
e7ed5354 | 224 | |
534fb6da JF |
225 | %token <false_> False "false" |
226 | %token <null_> Null "null" | |
227 | %token <true_> True "true" | |
228 | ||
229 | // ES3/ES5/WIE/JSC Reserved | |
cf7d4c69 JF |
230 | %token <word_> Break "break" |
231 | %token <word_> Case "case" | |
232 | %token <word_> Catch "catch" | |
233 | %token <word_> Continue "continue" | |
234 | %token <word_> Default "default" | |
235 | %token <word_> Delete "delete" | |
236 | %token <word_> Do "do" | |
237 | %token <word_> Else "else" | |
cf7d4c69 JF |
238 | %token <word_> Finally "finally" |
239 | %token <word_> For "for" | |
240 | %token <word_> Function "function" | |
241 | %token <word_> If "if" | |
242 | %token <word_> In "in" | |
243 | %token <word_> InstanceOf "instanceof" | |
244 | %token <word_> New "new" | |
cf7d4c69 JF |
245 | %token <word_> Return "return" |
246 | %token <word_> Switch "switch" | |
247 | %token <this_> This "this" | |
248 | %token <word_> Throw "throw" | |
cf7d4c69 JF |
249 | %token <word_> Try "try" |
250 | %token <word_> TypeOf "typeof" | |
251 | %token <word_> Var "var" | |
252 | %token <word_> Void "void" | |
253 | %token <word_> While "while" | |
254 | %token <word_> With "with" | |
63b4c5a8 | 255 | |
534fb6da | 256 | // ES3/IE6 Future, ES5/JSC Reserved |
d35a3b07 | 257 | %token <word_> Debugger "debugger" |
534fb6da JF |
258 | |
259 | // ES3/ES5/IE6 Future, JSC Reserved | |
260 | %token <word_> Const "const" | |
261 | ||
262 | // ES3/ES5/IE6/JSC Future | |
263 | %token <word_> Class "class" | |
d35a3b07 JF |
264 | %token <word_> Enum "enum" |
265 | %token <word_> Export "export" | |
266 | %token <word_> Extends "extends" | |
d35a3b07 | 267 | %token <word_> Import "import" |
d35a3b07 | 268 | %token <word_> Super "super" |
d35a3b07 | 269 | |
534fb6da JF |
270 | // ES3 Future, ES5 Strict Future |
271 | %token <identifier_> Implements "implements" | |
272 | %token <identifier_> Interface "interface" | |
273 | %token <identifier_> Package "package" | |
274 | %token <identifier_> Private "private" | |
275 | %token <identifier_> Protected "protected" | |
276 | %token <identifier_> Public "public" | |
277 | %token <identifier_> Static "static" | |
278 | ||
279 | // ES3 Future | |
280 | %token <identifier_> Abstract "abstract" | |
281 | %token <identifier_> Boolean "boolean" | |
282 | %token <identifier_> Byte "byte" | |
283 | %token <identifier_> Char "char" | |
284 | %token <identifier_> Double "double" | |
285 | %token <identifier_> Final "final" | |
286 | %token <identifier_> Float "float" | |
287 | %token <identifier_> Goto "goto" | |
288 | %token <identifier_> Int "int" | |
289 | %token <identifier_> Long "long" | |
290 | %token <identifier_> Native "native" | |
291 | %token <identifier_> Short "short" | |
292 | %token <identifier_> Synchronized "synchronized" | |
293 | %token <identifier_> Throws "throws" | |
294 | %token <identifier_> Transient "transient" | |
295 | %token <identifier_> Volatile "volatile" | |
296 | ||
297 | // ES5 Strict | |
cac61857 | 298 | %token <identifier_> Let "let" |
534fb6da JF |
299 | %token <identifier_> Yield "yield" |
300 | ||
301 | // Woah?! | |
302 | %token <identifier_> Each "each" | |
75b0a457 | 303 | |
691e4717 JF |
304 | @begin E4X |
305 | // E4X Conditional | |
306 | %token <identifier_> Namespace "namespace" | |
307 | %token <identifier_> XML "xml" | |
308 | @end | |
309 | ||
b5dd57dc JF |
310 | @begin ObjectiveC |
311 | %type <expression_> AdditiveExpressionNoWC | |
312 | %type <expression_> AssigneeExpressionNoWC | |
313 | %type <expression_> AssignmentExpressionNoWC | |
314 | %type <expression_> BitwiseANDExpressionNoWC | |
315 | %type <expression_> BitwiseXORExpressionNoWC | |
316 | %type <expression_> BitwiseORExpressionNoWC | |
317 | %type <expression_> ConditionalExpressionNoWC | |
318 | %type <expression_> EqualityExpressionNoWC | |
319 | %type <expression_> LeftHandSideExpressionNoWC | |
320 | %type <expression_> LogicalANDExpressionNoWC | |
321 | %type <expression_> LogicalORExpressionNoWC | |
322 | %type <expression_> MemberExpressionNoWC | |
323 | %type <expression_> MultiplicativeExpressionNoWC | |
324 | %type <expression_> NewExpressionNoWC | |
325 | %type <expression_> PostfixExpressionNoWC | |
326 | %type <expression_> RelationalExpressionNoWC | |
327 | %type <expression_> ShiftExpressionNoWC | |
328 | %type <expression_> UnaryExpressionNoWC | |
329 | @end | |
330 | ||
75b0a457 | 331 | %token <identifier_> Identifier_ |
63b4c5a8 JF |
332 | %token <number_> NumericLiteral |
333 | %token <string_> StringLiteral | |
63cd45c9 | 334 | %token <literal_> RegularExpressionLiteral |
1dbba6cc | 335 | |
cf7d4c69 | 336 | %type <expression_> AdditiveExpression |
693d501b | 337 | %type <expression_> AdditiveExpressionNoBF |
cf7d4c69 JF |
338 | %type <argument_> ArgumentList |
339 | %type <argument_> ArgumentList_ | |
340 | %type <argument_> ArgumentListOpt | |
341 | %type <argument_> Arguments | |
342 | %type <literal_> ArrayLiteral | |
9b5527f0 | 343 | %type <expression_> AssigneeExpression |
9b5527f0 | 344 | %type <expression_> AssigneeExpressionNoBF |
b1589845 | 345 | %type <expression_> AssigneeExpressionNoRE |
cf7d4c69 | 346 | %type <expression_> AssignmentExpression |
0ff9f149 | 347 | %type <assignment_> AssignmentExpression_ |
693d501b JF |
348 | %type <expression_> AssignmentExpressionNoBF |
349 | %type <expression_> AssignmentExpressionNoIn | |
cf7d4c69 | 350 | %type <expression_> BitwiseANDExpression |
693d501b JF |
351 | %type <expression_> BitwiseANDExpressionNoBF |
352 | %type <expression_> BitwiseANDExpressionNoIn | |
cf7d4c69 | 353 | %type <statement_> Block |
cac61857 | 354 | %type <statement_> Block_ |
cf7d4c69 JF |
355 | %type <boolean_> BooleanLiteral |
356 | %type <expression_> BitwiseORExpression | |
693d501b JF |
357 | %type <expression_> BitwiseORExpressionNoBF |
358 | %type <expression_> BitwiseORExpressionNoIn | |
cf7d4c69 | 359 | %type <expression_> BitwiseXORExpression |
693d501b JF |
360 | %type <expression_> BitwiseXORExpressionNoBF |
361 | %type <expression_> BitwiseXORExpressionNoIn | |
cf7d4c69 JF |
362 | %type <statement_> BreakStatement |
363 | %type <expression_> CallExpression | |
693d501b | 364 | %type <expression_> CallExpressionNoBF |
b1589845 | 365 | %type <expression_> CallExpressionNoRE |
cf7d4c69 JF |
366 | %type <clause_> CaseBlock |
367 | %type <clause_> CaseClause | |
368 | %type <clause_> CaseClausesOpt | |
369 | %type <catch_> CatchOpt | |
75b0a457 JF |
370 | %type <comprehension_> ComprehensionList |
371 | %type <comprehension_> ComprehensionListOpt | |
cf7d4c69 | 372 | %type <expression_> ConditionalExpression |
693d501b JF |
373 | %type <expression_> ConditionalExpressionNoBF |
374 | %type <expression_> ConditionalExpressionNoIn | |
cf7d4c69 JF |
375 | %type <statement_> ContinueStatement |
376 | %type <clause_> DefaultClause | |
377 | %type <statement_> DoWhileStatement | |
378 | %type <expression_> Element | |
5befe15e | 379 | %type <expression_> ElementOpt |
cf7d4c69 | 380 | %type <element_> ElementList |
5befe15e | 381 | %type <element_> ElementListOpt |
cf7d4c69 JF |
382 | %type <statement_> ElseStatementOpt |
383 | %type <statement_> EmptyStatement | |
384 | %type <expression_> EqualityExpression | |
693d501b JF |
385 | %type <expression_> EqualityExpressionNoBF |
386 | %type <expression_> EqualityExpressionNoIn | |
cf7d4c69 | 387 | %type <expression_> Expression |
cf7d4c69 | 388 | %type <expression_> ExpressionOpt |
d35a3b07 | 389 | %type <compound_> Expression_ |
693d501b JF |
390 | %type <expression_> ExpressionNoBF |
391 | %type <expression_> ExpressionNoIn | |
d35a3b07 | 392 | %type <compound_> ExpressionNoIn_ |
693d501b | 393 | %type <expression_> ExpressionNoInOpt |
cf7d4c69 | 394 | %type <statement_> ExpressionStatement |
b10bd496 | 395 | %type <finally_> FinallyOpt |
75b0a457 | 396 | %type <comprehension_> ForComprehension |
cf7d4c69 JF |
397 | %type <statement_> ForStatement |
398 | %type <for_> ForStatementInitialiser | |
399 | %type <statement_> ForInStatement | |
400 | %type <forin_> ForInStatementInitialiser | |
b09da87b JF |
401 | %type <functionParameter_> FormalParameterList |
402 | %type <functionParameter_> FormalParameterList_ | |
b10bd496 JF |
403 | %type <statement_> FunctionBody |
404 | %type <statement_> FunctionDeclaration | |
cf7d4c69 | 405 | %type <expression_> FunctionExpression |
75b0a457 | 406 | %type <identifier_> Identifier |
cf7d4c69 | 407 | %type <identifier_> IdentifierOpt |
75b0a457 | 408 | %type <comprehension_> IfComprehension |
cf7d4c69 JF |
409 | %type <statement_> IfStatement |
410 | %type <expression_> Initialiser | |
411 | %type <expression_> InitialiserOpt | |
693d501b JF |
412 | %type <expression_> InitialiserNoIn |
413 | %type <expression_> InitialiserNoInOpt | |
cf7d4c69 JF |
414 | %type <statement_> IterationStatement |
415 | %type <statement_> LabelledStatement | |
416 | %type <expression_> LeftHandSideExpression | |
693d501b | 417 | %type <expression_> LeftHandSideExpressionNoBF |
b1589845 | 418 | %type <expression_> LeftHandSideExpressionNoRE |
534fb6da | 419 | //%type <statement_> LetStatement |
cf7d4c69 | 420 | %type <literal_> Literal |
561ac418 JF |
421 | %type <literal_> LiteralNoRE |
422 | %type <literal_> LiteralRE | |
cf7d4c69 | 423 | %type <expression_> LogicalANDExpression |
693d501b JF |
424 | %type <expression_> LogicalANDExpressionNoBF |
425 | %type <expression_> LogicalANDExpressionNoIn | |
cf7d4c69 | 426 | %type <expression_> LogicalORExpression |
693d501b JF |
427 | %type <expression_> LogicalORExpressionNoBF |
428 | %type <expression_> LogicalORExpressionNoIn | |
9b5527f0 | 429 | %type <member_> MemberAccess |
cf7d4c69 | 430 | %type <expression_> MemberExpression |
693d501b JF |
431 | %type <expression_> MemberExpression_ |
432 | %type <expression_> MemberExpressionNoBF | |
b1589845 | 433 | %type <expression_> MemberExpressionNoRE |
cf7d4c69 | 434 | %type <expression_> MultiplicativeExpression |
693d501b | 435 | %type <expression_> MultiplicativeExpressionNoBF |
cf7d4c69 | 436 | %type <expression_> NewExpression |
693d501b JF |
437 | %type <expression_> NewExpression_ |
438 | %type <expression_> NewExpressionNoBF | |
b1589845 | 439 | %type <expression_> NewExpressionNoRE |
cf7d4c69 JF |
440 | %type <null_> NullLiteral |
441 | %type <literal_> ObjectLiteral | |
cf7d4c69 | 442 | %type <expression_> PostfixExpression |
693d501b | 443 | %type <expression_> PostfixExpressionNoBF |
b1589845 | 444 | %type <expression_> PostfixExpressionNoRE |
cf7d4c69 | 445 | %type <expression_> PrimaryExpression |
561ac418 | 446 | %type <expression_> PrimaryExpressionNo |
693d501b | 447 | %type <expression_> PrimaryExpressionNoBF |
b1589845 | 448 | %type <expression_> PrimaryExpressionNoRE |
561ac418 JF |
449 | %type <expression_> PrimaryExpressionNoWC |
450 | %type <expression_> PrimaryExpressionNoWC_ | |
451 | @begin E4X | |
452 | %type <expression_> PrimaryExpressionWC | |
453 | @end | |
454 | %type <expression_> PrimaryExpressionBF | |
b10bd496 | 455 | %type <statement_> Program |
e5bc40db | 456 | %type <propertyName_> PropertyName |
b92ceddb | 457 | %type <propertyName_> PropertyName_ |
cf7d4c69 JF |
458 | %type <property_> PropertyNameAndValueList |
459 | %type <property_> PropertyNameAndValueList_ | |
460 | %type <property_> PropertyNameAndValueListOpt | |
461 | %type <expression_> RelationalExpression | |
0ff9f149 | 462 | %type <infix_> RelationalExpression_ |
693d501b JF |
463 | %type <expression_> RelationalExpressionNoBF |
464 | %type <expression_> RelationalExpressionNoIn | |
0ff9f149 | 465 | %type <infix_> RelationalExpressionNoIn_ |
cf7d4c69 | 466 | %type <statement_> ReturnStatement |
cf7d4c69 | 467 | %type <expression_> ShiftExpression |
693d501b | 468 | %type <expression_> ShiftExpressionNoBF |
b10bd496 | 469 | %type <statement_> SourceElement |
697d6fd2 | 470 | %type <statement_> SourceElement_ |
b10bd496 | 471 | %type <statement_> SourceElements |
cf7d4c69 | 472 | %type <statement_> Statement |
b10bd496 | 473 | %type <statement_> Statement_ |
693d501b | 474 | %type <statement_> StatementList |
cf7d4c69 JF |
475 | %type <statement_> StatementListOpt |
476 | %type <statement_> SwitchStatement | |
477 | %type <statement_> ThrowStatement | |
478 | %type <statement_> TryStatement | |
697d6fd2 | 479 | %type <expression_> UnaryAssigneeExpression |
cf7d4c69 | 480 | %type <expression_> UnaryExpression |
693d501b JF |
481 | %type <expression_> UnaryExpression_ |
482 | %type <expression_> UnaryExpressionNoBF | |
b1589845 | 483 | %type <expression_> UnaryExpressionNoRE |
cf7d4c69 | 484 | %type <declaration_> VariableDeclaration |
693d501b | 485 | %type <declaration_> VariableDeclarationNoIn |
cf7d4c69 JF |
486 | %type <declarations_> VariableDeclarationList |
487 | %type <declarations_> VariableDeclarationList_ | |
693d501b JF |
488 | %type <declarations_> VariableDeclarationListNoIn |
489 | %type <declarations_> VariableDeclarationListNoIn_ | |
cf7d4c69 | 490 | %type <statement_> VariableStatement |
cf7d4c69 JF |
491 | %type <statement_> WhileStatement |
492 | %type <statement_> WithStatement | |
cf7d4c69 | 493 | |
cbaa5f0f | 494 | @begin ObjectiveC |
328ad766 JF |
495 | %type <statement_> CategoryStatement |
496 | %type <expression_> ClassExpression | |
497 | %type <statement_> ClassStatement | |
498 | %type <expression_> ClassSuperOpt | |
499 | %type <field_> ClassFieldList | |
500 | %type <message_> ClassMessageDeclaration | |
501 | %type <message_> ClassMessageDeclarationListOpt | |
502 | %type <className_> ClassName | |
503 | %type <className_> ClassNameOpt | |
693d501b | 504 | %type <expression_> MessageExpression |
328ad766 JF |
505 | %type <messageParameter_> MessageParameter |
506 | %type <messageParameter_> MessageParameters | |
507 | %type <messageParameter_> MessageParameterList | |
508 | %type <messageParameter_> MessageParameterListOpt | |
509 | %type <bool_> MessageScope | |
693d501b JF |
510 | %type <argument_> SelectorCall |
511 | %type <argument_> SelectorCall_ | |
328ad766 JF |
512 | %type <selector_> SelectorExpression |
513 | %type <selector_> SelectorExpression_ | |
514 | %type <selector_> SelectorExpressionOpt | |
693d501b | 515 | %type <argument_> SelectorList |
328ad766 | 516 | %type <expression_> TypeOpt |
693d501b | 517 | %type <argument_> VariadicCall |
328ad766 JF |
518 | %type <word_> Word |
519 | %type <word_> WordOpt | |
520 | @end | |
693d501b | 521 | |
691e4717 | 522 | @begin E4X |
b92ceddb JF |
523 | %type <propertyIdentifier_> PropertyIdentifier_ |
524 | %type <selector_> PropertySelector | |
525 | %type <selector_> PropertySelector_ | |
691e4717 JF |
526 | %type <identifier_> QualifiedIdentifier |
527 | %type <identifier_> QualifiedIdentifier_ | |
528 | %type <identifier_> WildcardIdentifier | |
529 | %type <identifier_> XMLComment | |
530 | %type <identifier_> XMLCDATA | |
531 | %type <identifier_> XMLElement | |
532 | %type <identifier_> XMLElementContent | |
533 | %type <identifier_> XMLMarkup | |
534 | %type <identifier_> XMLPI | |
535 | ||
536 | %type <attribute_> AttributeIdentifier | |
b92ceddb | 537 | /* XXX: %type <statement_> DefaultXMLNamespaceStatement */ |
691e4717 JF |
538 | %type <expression_> PropertyIdentifier |
539 | %type <expression_> XMLListInitialiser | |
540 | %type <expression_> XMLInitialiser | |
541 | @end | |
542 | ||
b92ceddb JF |
543 | %token WC |
544 | ||
545 | %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield" | |
546 | ||
547 | %nonassoc "if" | |
548 | %nonassoc "else" | |
549 | ||
550 | %nonassoc "++" "--" | |
551 | %nonassoc "(" "[" | |
552 | ||
cde525f7 JF |
553 | %left "*" "/" "%" |
554 | %left "+" "-" | |
555 | %left "<<" ">>" ">>>" | |
556 | %left "<" ">" "<=" ">=" "instanceof" "in" | |
557 | %left "==" "!=" "===" "!==" | |
558 | %left "&" | |
559 | %left "^" | |
560 | %left "|" | |
561 | %left "&&" | |
562 | %left "||" | |
563 | ||
564 | %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|=" | |
c3c20102 | 565 | |
693d501b | 566 | %start Program |
e5332278 | 567 | |
693d501b | 568 | %% |
c3c20102 | 569 | |
691e4717 JF |
570 | /* Lexer State {{{ */ |
571 | LexSetRegExp | |
572 | : { driver.SetCondition(CYDriver::RegExpCondition); } | |
573 | ; | |
574 | /* }}} */ | |
575 | ||
b10bd496 JF |
576 | StrictSemi |
577 | : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } | |
578 | ; | |
579 | ||
580 | Terminator_ | |
c3c20102 | 581 | : ";" |
b10bd496 JF |
582 | | "\n" StrictSemi |
583 | ; | |
584 | ||
585 | TerminatorOpt | |
586 | : Terminator_ | |
587 | | error { yyerrok; driver.errors_.pop_back(); } StrictSemi | |
c3c20102 JF |
588 | ; |
589 | ||
590 | Terminator | |
b10bd496 JF |
591 | : Terminator_ |
592 | | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi | |
c3c20102 JF |
593 | ; |
594 | ||
cac61857 | 595 | /*CommaOpt |
693d501b JF |
596 | : "," |
597 | | | |
cac61857 | 598 | ;*/ |
693d501b | 599 | |
cbaa5f0f | 600 | @begin ObjectiveC |
c3c20102 | 601 | NewLineOpt |
693d501b | 602 | : "\n" |
c3c20102 JF |
603 | | |
604 | ; | |
1dbba6cc | 605 | |
36cd3cb9 | 606 | WordOpt |
cf7d4c69 JF |
607 | : Word { $$ = $1; } |
608 | | { $$ = NULL; } | |
2bf24581 JF |
609 | ; |
610 | ||
36cd3cb9 | 611 | Word |
cf7d4c69 | 612 | : Identifier { $$ = $1; } |
c3c20102 | 613 | | "break" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
614 | | "case" { $$ = $1; } |
615 | | "catch" { $$ = $1; } | |
d35a3b07 JF |
616 | | "class" { $$ = $1; } |
617 | | "const" { $$ = $1; } | |
c3c20102 | 618 | | "continue" NewLineOpt { $$ = $1; } |
d35a3b07 | 619 | | "debugger" { $$ = $1; } |
cf7d4c69 JF |
620 | | "default" { $$ = $1; } |
621 | | "delete" { $$ = $1; } | |
622 | | "do" { $$ = $1; } | |
623 | | "else" { $$ = $1; } | |
d35a3b07 JF |
624 | | "enum" { $$ = $1; } |
625 | | "export" { $$ = $1; } | |
626 | | "extends" { $$ = $1; } | |
cf7d4c69 JF |
627 | | "false" { $$ = $1; } |
628 | | "finally" { $$ = $1; } | |
561ac418 | 629 | /* XXX: | "for" { $$ = $1; } */ |
cf7d4c69 JF |
630 | | "function" { $$ = $1; } |
631 | | "if" { $$ = $1; } | |
d35a3b07 | 632 | | "import" { $$ = $1; } |
693d501b JF |
633 | /* XXX: | "in" { $$ = $1; } */ |
634 | /* XXX: | "instanceof" { $$ = $1; } */ | |
cf7d4c69 JF |
635 | | "new" { $$ = $1; } |
636 | | "null" { $$ = $1; } | |
c3c20102 | 637 | | "return" NewLineOpt { $$ = $1; } |
d35a3b07 | 638 | | "super" { $$ = $1; } |
cf7d4c69 JF |
639 | | "switch" { $$ = $1; } |
640 | | "this" { $$ = $1; } | |
c3c20102 | 641 | | "throw" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
642 | | "true" { $$ = $1; } |
643 | | "try" { $$ = $1; } | |
644 | | "typeof" { $$ = $1; } | |
645 | | "var" { $$ = $1; } | |
646 | | "void" { $$ = $1; } | |
647 | | "while" { $$ = $1; } | |
648 | | "with" { $$ = $1; } | |
2bf24581 | 649 | ; |
328ad766 | 650 | @end |
2bf24581 | 651 | |
75b0a457 JF |
652 | Identifier |
653 | : Identifier_ { $$ = $1; } | |
534fb6da JF |
654 | |
655 | | "implements" { $$ = $1; } | |
656 | | "interface" { $$ = $1; } | |
657 | | "package" { $$ = $1; } | |
658 | | "private" { $$ = $1; } | |
659 | | "protected" { $$ = $1; } | |
660 | | "public" { $$ = $1; } | |
661 | | "static" { $$ = $1; } | |
662 | ||
663 | | "abstract" { $$ = $1; } | |
664 | | "boolean" { $$ = $1; } | |
665 | | "byte" { $$ = $1; } | |
666 | | "char" { $$ = $1; } | |
667 | | "double" { $$ = $1; } | |
668 | | "final" { $$ = $1; } | |
669 | | "float" { $$ = $1; } | |
670 | | "goto" { $$ = $1; } | |
671 | | "int" { $$ = $1; } | |
672 | | "long" { $$ = $1; } | |
673 | | "native" { $$ = $1; } | |
674 | | "short" { $$ = $1; } | |
675 | | "synchronized" { $$ = $1; } | |
676 | | "throws" { $$ = $1; } | |
677 | | "transient" { $$ = $1; } | |
678 | | "volatile" { $$ = $1; } | |
679 | ||
cac61857 | 680 | | "let" { $$ = $1; } |
534fb6da JF |
681 | | "yield" { $$ = $1; } |
682 | ||
683 | | "each" { $$ = $1; } | |
75b0a457 JF |
684 | ; |
685 | ||
36cd3cb9 | 686 | IdentifierOpt |
cf7d4c69 JF |
687 | : Identifier { $$ = $1; } |
688 | | { $$ = NULL; } | |
1dbba6cc JF |
689 | ; |
690 | ||
561ac418 | 691 | LiteralNoRE |
cf7d4c69 JF |
692 | : NullLiteral { $$ = $1; } |
693 | | BooleanLiteral { $$ = $1; } | |
694 | | NumericLiteral { $$ = $1; } | |
695 | | StringLiteral { $$ = $1; } | |
b92ceddb | 696 | | "@" StringLiteral { $$ = $2; } |
561ac418 JF |
697 | ; |
698 | ||
699 | LiteralRE | |
700 | : RegularExpressionLiteral { $$ = $1; } | |
701 | ; | |
702 | ||
703 | Literal | |
704 | : LiteralNoRE { $$ = $1; } | |
705 | | LiteralRE { $$ = $1; } | |
1dbba6cc JF |
706 | ; |
707 | ||
36cd3cb9 | 708 | NullLiteral |
cf7d4c69 | 709 | : "null" { $$ = $1; } |
1dbba6cc JF |
710 | ; |
711 | ||
36cd3cb9 | 712 | BooleanLiteral |
cf7d4c69 JF |
713 | : "true" { $$ = $1; } |
714 | | "false" { $$ = $1; } | |
1dbba6cc JF |
715 | ; |
716 | ||
1dbba6cc | 717 | /* 11.1 Primary Expressions {{{ */ |
561ac418 JF |
718 | PrimaryExpression |
719 | : PrimaryExpressionNoWC { $$ = $1; } | |
720 | @begin E4X | |
0347fadf | 721 | | LexSetRegExp PrimaryExpressionWC { $$ = $2; } |
561ac418 | 722 | @end |
697d6fd2 JF |
723 | ; |
724 | ||
561ac418 JF |
725 | PrimaryExpressionNoBF |
726 | : PrimaryExpressionNo { $$ = $1; } | |
727 | @begin E4X | |
728 | | PrimaryExpressionWC { $$ = $1; } | |
729 | @end | |
730 | ; | |
731 | ||
b1589845 JF |
732 | PrimaryExpressionNoRE |
733 | : PrimaryExpressionNoWC_ { $$ = $1; } | |
734 | @begin E4X | |
735 | | PrimaryExpressionWC { $$ = $1; } | |
736 | @end | |
737 | ; | |
738 | ||
561ac418 JF |
739 | PrimaryExpressionNoWC_ |
740 | : PrimaryExpressionBF { $$ = $1; } | |
741 | | PrimaryExpressionNo { $$ = $1; } | |
742 | ; | |
743 | ||
744 | PrimaryExpressionNoWC | |
745 | : LexSetRegExp PrimaryExpressionNoWC_ { $$ = $2; } | |
746 | ; | |
747 | ||
748 | PrimaryExpressionNo | |
cf7d4c69 | 749 | : "this" { $$ = $1; } |
b1ff2d78 | 750 | | Identifier { $$ = new(driver.pool_) CYVariable($1); } |
cf7d4c69 JF |
751 | | Literal { $$ = $1; } |
752 | | ArrayLiteral { $$ = $1; } | |
36cd3cb9 | 753 | | "(" Expression ")" { $$ = $2; } |
693d501b JF |
754 | ; |
755 | ||
561ac418 JF |
756 | PrimaryExpressionBF |
757 | : ObjectLiteral { $$ = $1; } | |
1dbba6cc JF |
758 | ; |
759 | /* }}} */ | |
760 | /* 11.1.4 Array Initialiser {{{ */ | |
36cd3cb9 | 761 | ArrayLiteral |
d35a3b07 | 762 | : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); } |
1dbba6cc JF |
763 | ; |
764 | ||
36cd3cb9 | 765 | Element |
cf7d4c69 | 766 | : AssignmentExpression { $$ = $1; } |
5befe15e JF |
767 | ; |
768 | ||
769 | ElementOpt | |
770 | : Element { $$ = $1; } | |
691e4717 | 771 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
772 | ; |
773 | ||
5befe15e JF |
774 | ElementListOpt |
775 | : ElementList { $$ = $1; } | |
691e4717 | 776 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
777 | ; |
778 | ||
36cd3cb9 | 779 | ElementList |
5befe15e JF |
780 | : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); } |
781 | | Element { $$ = new(driver.pool_) CYElement($1, NULL); } | |
1dbba6cc JF |
782 | ; |
783 | /* }}} */ | |
784 | /* 11.1.5 Object Initialiser {{{ */ | |
36cd3cb9 | 785 | ObjectLiteral |
5befe15e | 786 | : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); } |
1dbba6cc JF |
787 | ; |
788 | ||
36cd3cb9 | 789 | PropertyNameAndValueList_ |
cf7d4c69 | 790 | : "," PropertyNameAndValueList { $$ = $2; } |
cac61857 | 791 | | { $$ = NULL; } |
1dbba6cc JF |
792 | ; |
793 | ||
36cd3cb9 | 794 | PropertyNameAndValueListOpt |
cf7d4c69 | 795 | : PropertyNameAndValueList { $$ = $1; } |
36cd3cb9 | 796 | | { $$ = NULL; } |
1dbba6cc JF |
797 | ; |
798 | ||
36cd3cb9 JF |
799 | PropertyNameAndValueList |
800 | : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); } | |
1dbba6cc JF |
801 | ; |
802 | ||
b92ceddb | 803 | PropertyName_ |
36cd3cb9 JF |
804 | : Identifier { $$ = $1; } |
805 | | StringLiteral { $$ = $1; } | |
806 | | NumericLiteral { $$ = $1; } | |
1dbba6cc | 807 | ; |
b92ceddb JF |
808 | |
809 | PropertyName | |
810 | : LexSetRegExp PropertyName_ { $$ = $2; } | |
811 | ; | |
1dbba6cc JF |
812 | /* }}} */ |
813 | ||
63cd45c9 | 814 | /* 11.2 Left-Hand-Side Expressions {{{ */ |
693d501b JF |
815 | MemberExpression_ |
816 | : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); } | |
817 | ; | |
818 | ||
9b5527f0 JF |
819 | MemberAccess |
820 | : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); } | |
821 | | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); } | |
822 | ; | |
823 | ||
36cd3cb9 | 824 | MemberExpression |
cf7d4c69 | 825 | : PrimaryExpression { $$ = $1; } |
b1589845 | 826 | | LexSetRegExp FunctionExpression { $$ = $2; } |
9b5527f0 | 827 | | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } |
691e4717 | 828 | | LexSetRegExp MemberExpression_ { $$ = $2; } |
693d501b JF |
829 | ; |
830 | ||
831 | MemberExpressionNoBF | |
832 | : PrimaryExpressionNoBF { $$ = $1; } | |
9b5527f0 | 833 | | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } |
693d501b JF |
834 | | MemberExpression_ { $$ = $1; } |
835 | ; | |
836 | ||
b1589845 JF |
837 | MemberExpressionNoRE |
838 | : PrimaryExpressionNoRE { $$ = $1; } | |
839 | | FunctionExpression { $$ = $1; } | |
840 | | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
841 | | MemberExpression_ { $$ = $1; } | |
842 | ; | |
843 | ||
b5dd57dc | 844 | @begin ObjectiveC |
561ac418 | 845 | MemberExpressionNoWC |
b92ceddb | 846 | : PrimaryExpression { $$ = $1; } |
b1589845 | 847 | | LexSetRegExp FunctionExpression { $$ = $2; } |
561ac418 JF |
848 | | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } |
849 | | LexSetRegExp MemberExpression_ { $$ = $2; } | |
850 | ; | |
b5dd57dc | 851 | @end |
561ac418 | 852 | |
693d501b JF |
853 | NewExpression_ |
854 | : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } | |
1dbba6cc JF |
855 | ; |
856 | ||
36cd3cb9 | 857 | NewExpression |
cf7d4c69 | 858 | : MemberExpression { $$ = $1; } |
691e4717 | 859 | | LexSetRegExp NewExpression_ { $$ = $2; } |
693d501b JF |
860 | ; |
861 | ||
862 | NewExpressionNoBF | |
863 | : MemberExpressionNoBF { $$ = $1; } | |
864 | | NewExpression_ { $$ = $1; } | |
1dbba6cc JF |
865 | ; |
866 | ||
b1589845 JF |
867 | NewExpressionNoRE |
868 | : MemberExpressionNoRE { $$ = $1; } | |
869 | | NewExpression_ { $$ = $1; } | |
870 | ; | |
871 | ||
b5dd57dc | 872 | @begin ObjectiveC |
561ac418 JF |
873 | NewExpressionNoWC |
874 | : MemberExpressionNoWC { $$ = $1; } | |
875 | | LexSetRegExp NewExpression_ { $$ = $2; } | |
876 | ; | |
b5dd57dc | 877 | @end |
561ac418 | 878 | |
36cd3cb9 | 879 | CallExpression |
561ac418 | 880 | : PrimaryExpressionNoWC Arguments { $$ = new(driver.pool_) CYCall($1, $2); } |
b1ff2d78 | 881 | | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } |
9b5527f0 | 882 | | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; } |
1dbba6cc JF |
883 | ; |
884 | ||
693d501b JF |
885 | CallExpressionNoBF |
886 | : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
887 | | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
9b5527f0 | 888 | | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } |
693d501b JF |
889 | ; |
890 | ||
b1589845 JF |
891 | CallExpressionNoRE |
892 | : PrimaryExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
893 | | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
894 | | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
895 | ; | |
896 | ||
36cd3cb9 | 897 | ArgumentList_ |
cf7d4c69 JF |
898 | : "," ArgumentList { $$ = $2; } |
899 | | { $$ = NULL; } | |
1dbba6cc JF |
900 | ; |
901 | ||
36cd3cb9 | 902 | ArgumentListOpt |
cf7d4c69 | 903 | : ArgumentList { $$ = $1; } |
691e4717 | 904 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
905 | ; |
906 | ||
36cd3cb9 JF |
907 | ArgumentList |
908 | : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); } | |
1dbba6cc JF |
909 | ; |
910 | ||
911 | Arguments | |
36cd3cb9 | 912 | : "(" ArgumentListOpt ")" { $$ = $2; } |
1dbba6cc JF |
913 | ; |
914 | ||
36cd3cb9 | 915 | LeftHandSideExpression |
cf7d4c69 JF |
916 | : NewExpression { $$ = $1; } |
917 | | CallExpression { $$ = $1; } | |
693d501b JF |
918 | ; |
919 | ||
920 | LeftHandSideExpressionNoBF | |
921 | : NewExpressionNoBF { $$ = $1; } | |
922 | | CallExpressionNoBF { $$ = $1; } | |
1dbba6cc | 923 | ; |
561ac418 | 924 | |
b1589845 JF |
925 | LeftHandSideExpressionNoRE |
926 | : NewExpressionNoRE { $$ = $1; } | |
927 | | CallExpressionNoRE { $$ = $1; } | |
928 | ; | |
929 | ||
b5dd57dc | 930 | @begin ObjectiveC |
561ac418 JF |
931 | LeftHandSideExpressionNoWC |
932 | : NewExpressionNoWC { $$ = $1; } | |
933 | | CallExpression { $$ = $1; } | |
934 | ; | |
b5dd57dc | 935 | @end |
63cd45c9 JF |
936 | /* }}} */ |
937 | /* 11.3 Postfix Expressions {{{ */ | |
36cd3cb9 | 938 | PostfixExpression |
9b5527f0 | 939 | : AssigneeExpression { $$ = $1; } |
b1ff2d78 JF |
940 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } |
941 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
1dbba6cc JF |
942 | ; |
943 | ||
693d501b | 944 | PostfixExpressionNoBF |
9b5527f0 | 945 | : AssigneeExpressionNoBF { $$ = $1; } |
693d501b JF |
946 | | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); } |
947 | | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
948 | ; | |
561ac418 | 949 | |
b1589845 JF |
950 | PostfixExpressionNoRE |
951 | : AssigneeExpressionNoRE { $$ = $1; } | |
952 | | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
953 | | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
954 | ; | |
955 | ||
b5dd57dc | 956 | @begin ObjectiveC |
561ac418 JF |
957 | PostfixExpressionNoWC |
958 | : AssigneeExpressionNoWC { $$ = $1; } | |
959 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
960 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
961 | ; | |
b5dd57dc | 962 | @end |
63cd45c9 JF |
963 | /* }}} */ |
964 | /* 11.4 Unary Operators {{{ */ | |
693d501b JF |
965 | UnaryExpression_ |
966 | : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); } | |
36cd3cb9 JF |
967 | | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); } |
968 | | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); } | |
969 | | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
970 | | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
971 | | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
972 | | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
c0bc320e | 973 | | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); } |
36cd3cb9 JF |
974 | | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); } |
975 | | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); } | |
976 | | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); } | |
693d501b JF |
977 | ; |
978 | ||
979 | UnaryExpression | |
980 | : PostfixExpression { $$ = $1; } | |
691e4717 | 981 | | LexSetRegExp UnaryExpression_ { $$ = $2; } |
693d501b JF |
982 | ; |
983 | ||
984 | UnaryExpressionNoBF | |
985 | : PostfixExpressionNoBF { $$ = $1; } | |
986 | | UnaryExpression_ { $$ = $1; } | |
1dbba6cc | 987 | ; |
561ac418 | 988 | |
b1589845 JF |
989 | UnaryExpressionNoRE |
990 | : PostfixExpressionNoRE { $$ = $1; } | |
991 | | UnaryExpression_ { $$ = $1; } | |
992 | ; | |
993 | ||
b5dd57dc | 994 | @begin ObjectiveC |
561ac418 JF |
995 | UnaryExpressionNoWC |
996 | : PostfixExpressionNoWC { $$ = $1; } | |
997 | | LexSetRegExp UnaryExpression_ { $$ = $2; } | |
998 | ; | |
b5dd57dc | 999 | @end |
63cd45c9 JF |
1000 | /* }}} */ |
1001 | /* 11.5 Multiplicative Operators {{{ */ | |
36cd3cb9 | 1002 | MultiplicativeExpression |
cf7d4c69 | 1003 | : UnaryExpression { $$ = $1; } |
36cd3cb9 JF |
1004 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } |
1005 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1006 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1dbba6cc JF |
1007 | ; |
1008 | ||
693d501b JF |
1009 | MultiplicativeExpressionNoBF |
1010 | : UnaryExpressionNoBF { $$ = $1; } | |
1011 | | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
1012 | | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1013 | | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1014 | ; | |
561ac418 | 1015 | |
b5dd57dc | 1016 | @begin ObjectiveC |
561ac418 JF |
1017 | MultiplicativeExpressionNoWC |
1018 | : UnaryExpressionNoWC { $$ = $1; } | |
1019 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
1020 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
1021 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
1022 | ; | |
b5dd57dc | 1023 | @end |
63cd45c9 JF |
1024 | /* }}} */ |
1025 | /* 11.6 Additive Operators {{{ */ | |
36cd3cb9 | 1026 | AdditiveExpression |
cf7d4c69 | 1027 | : MultiplicativeExpression { $$ = $1; } |
36cd3cb9 JF |
1028 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } |
1029 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1dbba6cc JF |
1030 | ; |
1031 | ||
693d501b JF |
1032 | AdditiveExpressionNoBF |
1033 | : MultiplicativeExpressionNoBF { $$ = $1; } | |
1034 | | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
1035 | | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1036 | ; | |
561ac418 | 1037 | |
b5dd57dc | 1038 | @begin ObjectiveC |
561ac418 | 1039 | AdditiveExpressionNoWC |
b92ceddb | 1040 | : MultiplicativeExpressionNoWC { $$ = $1; } |
561ac418 JF |
1041 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } |
1042 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
1043 | ; | |
b5dd57dc | 1044 | @end |
63cd45c9 JF |
1045 | /* }}} */ |
1046 | /* 11.7 Bitwise Shift Operators {{{ */ | |
36cd3cb9 | 1047 | ShiftExpression |
cf7d4c69 | 1048 | : AdditiveExpression { $$ = $1; } |
36cd3cb9 JF |
1049 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } |
1050 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1051 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1dbba6cc JF |
1052 | ; |
1053 | ||
693d501b JF |
1054 | ShiftExpressionNoBF |
1055 | : AdditiveExpressionNoBF { $$ = $1; } | |
1056 | | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
1057 | | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1058 | | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1059 | ; | |
561ac418 | 1060 | |
b5dd57dc | 1061 | @begin ObjectiveC |
561ac418 JF |
1062 | ShiftExpressionNoWC |
1063 | : AdditiveExpressionNoWC { $$ = $1; } | |
1064 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
1065 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
1066 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
1067 | ; | |
b5dd57dc | 1068 | @end |
63cd45c9 JF |
1069 | /* }}} */ |
1070 | /* 11.8 Relational Operators {{{ */ | |
0ff9f149 JF |
1071 | RelationalExpressionNoIn_ |
1072 | : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); } | |
1073 | | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); } | |
1074 | | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); } | |
1075 | | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); } | |
1076 | | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); } | |
1077 | ; | |
1078 | ||
1079 | RelationalExpression_ | |
1080 | : RelationalExpressionNoIn_ { $$ = $1; } | |
1081 | | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); } | |
1082 | ; | |
1083 | ||
36cd3cb9 | 1084 | RelationalExpression |
cf7d4c69 | 1085 | : ShiftExpression { $$ = $1; } |
0ff9f149 | 1086 | | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } |
1dbba6cc JF |
1087 | ; |
1088 | ||
693d501b JF |
1089 | RelationalExpressionNoIn |
1090 | : ShiftExpression { $$ = $1; } | |
0ff9f149 | 1091 | | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; } |
693d501b JF |
1092 | ; |
1093 | ||
1094 | RelationalExpressionNoBF | |
1095 | : ShiftExpressionNoBF { $$ = $1; } | |
0ff9f149 | 1096 | | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; } |
693d501b | 1097 | ; |
561ac418 | 1098 | |
b5dd57dc | 1099 | @begin ObjectiveC |
561ac418 JF |
1100 | RelationalExpressionNoWC |
1101 | : ShiftExpressionNoWC { $$ = $1; } | |
1102 | | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
1103 | ; | |
b5dd57dc | 1104 | @end |
63cd45c9 JF |
1105 | /* }}} */ |
1106 | /* 11.9 Equality Operators {{{ */ | |
36cd3cb9 | 1107 | EqualityExpression |
cf7d4c69 | 1108 | : RelationalExpression { $$ = $1; } |
36cd3cb9 JF |
1109 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } |
1110 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1111 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1112 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1dbba6cc JF |
1113 | ; |
1114 | ||
693d501b JF |
1115 | EqualityExpressionNoIn |
1116 | : RelationalExpressionNoIn { $$ = $1; } | |
1117 | | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1118 | | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1119 | | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1120 | | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1121 | ; | |
1122 | ||
1123 | EqualityExpressionNoBF | |
1124 | : RelationalExpressionNoBF { $$ = $1; } | |
1125 | | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1126 | | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1127 | | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1128 | | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1129 | ; | |
561ac418 | 1130 | |
b5dd57dc | 1131 | @begin ObjectiveC |
561ac418 JF |
1132 | EqualityExpressionNoWC |
1133 | : RelationalExpressionNoWC { $$ = $1; } | |
1134 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1135 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1136 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1137 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1138 | ; | |
b5dd57dc | 1139 | @end |
63cd45c9 JF |
1140 | /* }}} */ |
1141 | /* 11.10 Binary Bitwise Operators {{{ */ | |
36cd3cb9 | 1142 | BitwiseANDExpression |
cf7d4c69 | 1143 | : EqualityExpression { $$ = $1; } |
36cd3cb9 | 1144 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } |
1dbba6cc JF |
1145 | ; |
1146 | ||
693d501b JF |
1147 | BitwiseANDExpressionNoIn |
1148 | : EqualityExpressionNoIn { $$ = $1; } | |
1149 | | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1150 | ; | |
1151 | ||
1152 | BitwiseANDExpressionNoBF | |
1153 | : EqualityExpressionNoBF { $$ = $1; } | |
1154 | | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1155 | ; | |
1156 | ||
b5dd57dc | 1157 | @begin ObjectiveC |
561ac418 JF |
1158 | BitwiseANDExpressionNoWC |
1159 | : EqualityExpressionNoWC { $$ = $1; } | |
1160 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1161 | ; | |
b5dd57dc | 1162 | @end |
561ac418 | 1163 | |
36cd3cb9 | 1164 | BitwiseXORExpression |
cf7d4c69 | 1165 | : BitwiseANDExpression { $$ = $1; } |
36cd3cb9 | 1166 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } |
1dbba6cc JF |
1167 | ; |
1168 | ||
693d501b JF |
1169 | BitwiseXORExpressionNoIn |
1170 | : BitwiseANDExpressionNoIn { $$ = $1; } | |
1171 | | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1172 | ; | |
1173 | ||
1174 | BitwiseXORExpressionNoBF | |
1175 | : BitwiseANDExpressionNoBF { $$ = $1; } | |
1176 | | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1177 | ; | |
1178 | ||
b5dd57dc | 1179 | @begin ObjectiveC |
561ac418 JF |
1180 | BitwiseXORExpressionNoWC |
1181 | : BitwiseANDExpressionNoWC { $$ = $1; } | |
1182 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1183 | ; | |
b5dd57dc | 1184 | @end |
561ac418 | 1185 | |
36cd3cb9 | 1186 | BitwiseORExpression |
cf7d4c69 | 1187 | : BitwiseXORExpression { $$ = $1; } |
36cd3cb9 | 1188 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } |
1dbba6cc JF |
1189 | ; |
1190 | ||
693d501b JF |
1191 | BitwiseORExpressionNoIn |
1192 | : BitwiseXORExpressionNoIn { $$ = $1; } | |
1193 | | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1194 | ; | |
1195 | ||
1196 | BitwiseORExpressionNoBF | |
1197 | : BitwiseXORExpressionNoBF { $$ = $1; } | |
1198 | | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1199 | ; | |
561ac418 | 1200 | |
b5dd57dc | 1201 | @begin ObjectiveC |
561ac418 JF |
1202 | BitwiseORExpressionNoWC |
1203 | : BitwiseXORExpressionNoWC { $$ = $1; } | |
1204 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1205 | ; | |
b5dd57dc | 1206 | @end |
63cd45c9 JF |
1207 | /* }}} */ |
1208 | /* 11.11 Binary Logical Operators {{{ */ | |
36cd3cb9 | 1209 | LogicalANDExpression |
cf7d4c69 | 1210 | : BitwiseORExpression { $$ = $1; } |
36cd3cb9 | 1211 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } |
1dbba6cc JF |
1212 | ; |
1213 | ||
693d501b JF |
1214 | LogicalANDExpressionNoIn |
1215 | : BitwiseORExpressionNoIn { $$ = $1; } | |
1216 | | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1217 | ; | |
1218 | ||
1219 | LogicalANDExpressionNoBF | |
1220 | : BitwiseORExpressionNoBF { $$ = $1; } | |
1221 | | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1222 | ; | |
1223 | ||
b5dd57dc | 1224 | @begin ObjectiveC |
561ac418 JF |
1225 | LogicalANDExpressionNoWC |
1226 | : BitwiseORExpressionNoWC { $$ = $1; } | |
1227 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1228 | ; | |
b5dd57dc | 1229 | @end |
561ac418 | 1230 | |
36cd3cb9 | 1231 | LogicalORExpression |
cf7d4c69 | 1232 | : LogicalANDExpression { $$ = $1; } |
36cd3cb9 | 1233 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } |
1dbba6cc JF |
1234 | ; |
1235 | ||
693d501b JF |
1236 | LogicalORExpressionNoIn |
1237 | : LogicalANDExpressionNoIn { $$ = $1; } | |
1238 | | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1239 | ; | |
1240 | ||
1241 | LogicalORExpressionNoBF | |
1242 | : LogicalANDExpressionNoBF { $$ = $1; } | |
1243 | | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1244 | ; | |
561ac418 | 1245 | |
b5dd57dc | 1246 | @begin ObjectiveC |
561ac418 JF |
1247 | LogicalORExpressionNoWC |
1248 | : LogicalANDExpressionNoWC { $$ = $1; } | |
1249 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1250 | ; | |
b5dd57dc | 1251 | @end |
63cd45c9 JF |
1252 | /* }}} */ |
1253 | /* 11.12 Conditional Operator ( ? : ) {{{ */ | |
36cd3cb9 | 1254 | ConditionalExpression |
cf7d4c69 | 1255 | : LogicalORExpression { $$ = $1; } |
36cd3cb9 | 1256 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } |
1dbba6cc JF |
1257 | ; |
1258 | ||
693d501b JF |
1259 | ConditionalExpressionNoIn |
1260 | : LogicalORExpressionNoIn { $$ = $1; } | |
1261 | | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1262 | ; | |
1263 | ||
1264 | ConditionalExpressionNoBF | |
1265 | : LogicalORExpressionNoBF { $$ = $1; } | |
1266 | | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1267 | ; | |
561ac418 | 1268 | |
b5dd57dc | 1269 | @begin ObjectiveC |
561ac418 JF |
1270 | ConditionalExpressionNoWC |
1271 | : LogicalORExpressionNoWC { $$ = $1; } | |
1272 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1273 | ; | |
b5dd57dc | 1274 | @end |
63cd45c9 JF |
1275 | /* }}} */ |
1276 | /* 11.13 Assignment Operators {{{ */ | |
0ff9f149 JF |
1277 | AssignmentExpression_ |
1278 | : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); } | |
1279 | | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); } | |
1280 | | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); } | |
1281 | | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); } | |
1282 | | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); } | |
1283 | | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); } | |
1284 | | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); } | |
1285 | | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); } | |
1286 | | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); } | |
1287 | | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); } | |
1288 | | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); } | |
1289 | | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); } | |
1290 | ; | |
1291 | ||
9b5527f0 JF |
1292 | AssigneeExpression |
1293 | : LeftHandSideExpression { $$ = $1; } | |
691e4717 | 1294 | | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } |
9b5527f0 JF |
1295 | ; |
1296 | ||
1297 | AssigneeExpressionNoBF | |
1298 | : LeftHandSideExpressionNoBF { $$ = $1; } | |
697d6fd2 | 1299 | | UnaryAssigneeExpression { $$ = $1; } |
9b5527f0 JF |
1300 | ; |
1301 | ||
b1589845 JF |
1302 | AssigneeExpressionNoRE |
1303 | : LeftHandSideExpressionNoRE { $$ = $1; } | |
1304 | | UnaryAssigneeExpression { $$ = $1; } | |
1305 | ; | |
1306 | ||
b5dd57dc | 1307 | @begin ObjectiveC |
561ac418 JF |
1308 | AssigneeExpressionNoWC |
1309 | : LeftHandSideExpressionNoWC { $$ = $1; } | |
1310 | | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } | |
1311 | ; | |
b5dd57dc | 1312 | @end |
561ac418 | 1313 | |
36cd3cb9 | 1314 | AssignmentExpression |
cf7d4c69 | 1315 | : ConditionalExpression { $$ = $1; } |
9b5527f0 | 1316 | | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } |
36cd3cb9 JF |
1317 | ; |
1318 | ||
693d501b JF |
1319 | AssignmentExpressionNoIn |
1320 | : ConditionalExpressionNoIn { $$ = $1; } | |
9b5527f0 JF |
1321 | | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); } |
1322 | | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
1323 | | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
1324 | | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
1325 | | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
1326 | | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
1327 | | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
1328 | | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
1329 | | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
1330 | | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
1331 | | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
1332 | | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
693d501b JF |
1333 | ; |
1334 | ||
1335 | AssignmentExpressionNoBF | |
1336 | : ConditionalExpressionNoBF { $$ = $1; } | |
9b5527f0 | 1337 | | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } |
693d501b | 1338 | ; |
561ac418 | 1339 | |
b5dd57dc | 1340 | @begin ObjectiveC |
561ac418 JF |
1341 | AssignmentExpressionNoWC |
1342 | : ConditionalExpressionNoWC { $$ = $1; } | |
1343 | | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1344 | ; | |
b5dd57dc | 1345 | @end |
63cd45c9 JF |
1346 | /* }}} */ |
1347 | /* 11.14 Comma Operator {{{ */ | |
36cd3cb9 | 1348 | Expression_ |
d35a3b07 | 1349 | : "," Expression { $$ = new(driver.pool_) CYCompound($2); } |
cf7d4c69 | 1350 | | { $$ = NULL; } |
1dbba6cc JF |
1351 | ; |
1352 | ||
693d501b | 1353 | ExpressionNoIn_ |
d35a3b07 | 1354 | : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); } |
693d501b JF |
1355 | | { $$ = NULL; } |
1356 | ; | |
1357 | ||
36cd3cb9 | 1358 | ExpressionOpt |
cf7d4c69 | 1359 | : Expression { $$ = $1; } |
691e4717 | 1360 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
1361 | ; |
1362 | ||
693d501b JF |
1363 | ExpressionNoInOpt |
1364 | : ExpressionNoIn { $$ = $1; } | |
691e4717 | 1365 | | LexSetRegExp { $$ = NULL; } |
693d501b JF |
1366 | ; |
1367 | ||
36cd3cb9 | 1368 | Expression |
d35a3b07 | 1369 | : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } |
1dbba6cc JF |
1370 | ; |
1371 | ||
693d501b | 1372 | ExpressionNoIn |
d35a3b07 | 1373 | : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } |
693d501b JF |
1374 | ; |
1375 | ||
1376 | ExpressionNoBF | |
d35a3b07 | 1377 | : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } |
693d501b | 1378 | ; |
63cd45c9 | 1379 | /* }}} */ |
693d501b | 1380 | |
63cd45c9 | 1381 | /* 12 Statements {{{ */ |
b10bd496 | 1382 | Statement_ |
36cd3cb9 JF |
1383 | : Block { $$ = $1; } |
1384 | | VariableStatement { $$ = $1; } | |
1385 | | EmptyStatement { $$ = $1; } | |
1386 | | ExpressionStatement { $$ = $1; } | |
cf7d4c69 JF |
1387 | | IfStatement { $$ = $1; } |
1388 | | IterationStatement { $$ = $1; } | |
36cd3cb9 JF |
1389 | | ContinueStatement { $$ = $1; } |
1390 | | BreakStatement { $$ = $1; } | |
1391 | | ReturnStatement { $$ = $1; } | |
cf7d4c69 JF |
1392 | | WithStatement { $$ = $1; } |
1393 | | LabelledStatement { $$ = $1; } | |
36cd3cb9 JF |
1394 | | SwitchStatement { $$ = $1; } |
1395 | | ThrowStatement { $$ = $1; } | |
1396 | | TryStatement { $$ = $1; } | |
1dbba6cc | 1397 | ; |
b10bd496 JF |
1398 | |
1399 | Statement | |
691e4717 | 1400 | : LexSetRegExp Statement_ { $$ = $2; } |
b10bd496 | 1401 | ; |
63cd45c9 JF |
1402 | /* }}} */ |
1403 | /* 12.1 Block {{{ */ | |
cac61857 JF |
1404 | Block_ |
1405 | : "{" StatementListOpt "}" { $$ = $2; } | |
1406 | ; | |
1407 | ||
36cd3cb9 | 1408 | Block |
cac61857 | 1409 | : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); } |
1dbba6cc JF |
1410 | ; |
1411 | ||
693d501b | 1412 | StatementList |
cf7d4c69 | 1413 | : Statement StatementListOpt { $1->SetNext($2); $$ = $1; } |
693d501b JF |
1414 | ; |
1415 | ||
1416 | StatementListOpt | |
1417 | : StatementList { $$ = $1; } | |
691e4717 | 1418 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc | 1419 | ; |
63cd45c9 JF |
1420 | /* }}} */ |
1421 | /* 12.2 Variable Statement {{{ */ | |
36cd3cb9 | 1422 | VariableStatement |
cac61857 | 1423 | : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); } |
1dbba6cc JF |
1424 | ; |
1425 | ||
36cd3cb9 | 1426 | VariableDeclarationList_ |
cf7d4c69 JF |
1427 | : "," VariableDeclarationList { $$ = $2; } |
1428 | | { $$ = NULL; } | |
1dbba6cc JF |
1429 | ; |
1430 | ||
693d501b JF |
1431 | VariableDeclarationListNoIn_ |
1432 | : "," VariableDeclarationListNoIn { $$ = $2; } | |
1433 | | { $$ = NULL; } | |
1434 | ; | |
1435 | ||
36cd3cb9 | 1436 | VariableDeclarationList |
b1ff2d78 | 1437 | : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } |
1dbba6cc JF |
1438 | ; |
1439 | ||
693d501b JF |
1440 | VariableDeclarationListNoIn |
1441 | : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
1442 | ; | |
1443 | ||
36cd3cb9 JF |
1444 | VariableDeclaration |
1445 | : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1dbba6cc JF |
1446 | ; |
1447 | ||
693d501b JF |
1448 | VariableDeclarationNoIn |
1449 | : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1450 | ; | |
1451 | ||
36cd3cb9 | 1452 | InitialiserOpt |
cf7d4c69 | 1453 | : Initialiser { $$ = $1; } |
36cd3cb9 | 1454 | | { $$ = NULL; } |
1dbba6cc JF |
1455 | ; |
1456 | ||
693d501b JF |
1457 | InitialiserNoInOpt |
1458 | : InitialiserNoIn { $$ = $1; } | |
1459 | | { $$ = NULL; } | |
1460 | ; | |
1461 | ||
36cd3cb9 JF |
1462 | Initialiser |
1463 | : "=" AssignmentExpression { $$ = $2; } | |
1dbba6cc JF |
1464 | ; |
1465 | ||
693d501b JF |
1466 | InitialiserNoIn |
1467 | : "=" AssignmentExpressionNoIn { $$ = $2; } | |
1468 | ; | |
63cd45c9 JF |
1469 | /* }}} */ |
1470 | /* 12.3 Empty Statement {{{ */ | |
36cd3cb9 | 1471 | EmptyStatement |
b1ff2d78 | 1472 | : ";" { $$ = new(driver.pool_) CYEmpty(); } |
1dbba6cc | 1473 | ; |
63cd45c9 JF |
1474 | /* }}} */ |
1475 | /* 12.4 Expression Statement {{{ */ | |
36cd3cb9 | 1476 | ExpressionStatement |
693d501b | 1477 | : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); } |
1dbba6cc | 1478 | ; |
63cd45c9 JF |
1479 | /* }}} */ |
1480 | /* 12.5 The if Statement {{{ */ | |
36cd3cb9 JF |
1481 | ElseStatementOpt |
1482 | : "else" Statement { $$ = $2; } | |
c3c20102 | 1483 | | %prec "if" { $$ = NULL; } |
1dbba6cc JF |
1484 | ; |
1485 | ||
36cd3cb9 JF |
1486 | IfStatement |
1487 | : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); } | |
1dbba6cc | 1488 | ; |
63cd45c9 | 1489 | /* }}} */ |
1dbba6cc | 1490 | |
63cd45c9 | 1491 | /* 12.6 Iteration Statements {{{ */ |
36cd3cb9 JF |
1492 | IterationStatement |
1493 | : DoWhileStatement { $$ = $1; } | |
cf7d4c69 JF |
1494 | | WhileStatement { $$ = $1; } |
1495 | | ForStatement { $$ = $1; } | |
1496 | | ForInStatement { $$ = $1; } | |
1dbba6cc | 1497 | ; |
63cd45c9 JF |
1498 | /* }}} */ |
1499 | /* 12.6.1 The do-while Statement {{{ */ | |
36cd3cb9 JF |
1500 | DoWhileStatement |
1501 | : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); } | |
1dbba6cc | 1502 | ; |
63cd45c9 JF |
1503 | /* }}} */ |
1504 | /* 12.6.2 The while Statement {{{ */ | |
36cd3cb9 JF |
1505 | WhileStatement |
1506 | : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); } | |
1dbba6cc | 1507 | ; |
63cd45c9 JF |
1508 | /* }}} */ |
1509 | /* 12.6.3 The for Statement {{{ */ | |
36cd3cb9 JF |
1510 | ForStatement |
1511 | : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); } | |
1dbba6cc JF |
1512 | ; |
1513 | ||
36cd3cb9 | 1514 | ForStatementInitialiser |
693d501b | 1515 | : ExpressionNoInOpt { $$ = $1; } |
691e4717 | 1516 | | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; } |
1dbba6cc | 1517 | ; |
63cd45c9 JF |
1518 | /* }}} */ |
1519 | /* 12.6.4 The for-in Statement {{{ */ | |
36cd3cb9 JF |
1520 | ForInStatement |
1521 | : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); } | |
1dbba6cc JF |
1522 | ; |
1523 | ||
36cd3cb9 JF |
1524 | ForInStatementInitialiser |
1525 | : LeftHandSideExpression { $$ = $1; } | |
691e4717 | 1526 | | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; } |
1dbba6cc | 1527 | ; |
63cd45c9 | 1528 | /* }}} */ |
1dbba6cc | 1529 | |
63cd45c9 | 1530 | /* 12.7 The continue Statement {{{ */ |
36cd3cb9 JF |
1531 | ContinueStatement |
1532 | : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); } | |
1dbba6cc | 1533 | ; |
63cd45c9 JF |
1534 | /* }}} */ |
1535 | /* 12.8 The break Statement {{{ */ | |
36cd3cb9 JF |
1536 | BreakStatement |
1537 | : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); } | |
1dbba6cc | 1538 | ; |
63cd45c9 JF |
1539 | /* }}} */ |
1540 | /* 12.9 The return Statement {{{ */ | |
36cd3cb9 | 1541 | ReturnStatement |
c3c20102 | 1542 | : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); } |
1dbba6cc | 1543 | ; |
63cd45c9 JF |
1544 | /* }}} */ |
1545 | /* 12.10 The with Statement {{{ */ | |
36cd3cb9 JF |
1546 | WithStatement |
1547 | : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); } | |
1dbba6cc | 1548 | ; |
63cd45c9 | 1549 | /* }}} */ |
1dbba6cc | 1550 | |
63cd45c9 | 1551 | /* 12.11 The switch Statement {{{ */ |
36cd3cb9 JF |
1552 | SwitchStatement |
1553 | : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); } | |
1dbba6cc JF |
1554 | ; |
1555 | ||
1556 | CaseBlock | |
36cd3cb9 | 1557 | : "{" CaseClausesOpt "}" { $$ = $2; } |
1dbba6cc JF |
1558 | ; |
1559 | ||
36cd3cb9 | 1560 | CaseClausesOpt |
cf7d4c69 JF |
1561 | : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } |
1562 | | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1563 | | { $$ = NULL; } | |
1dbba6cc JF |
1564 | ; |
1565 | ||
36cd3cb9 JF |
1566 | CaseClause |
1567 | : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); } | |
1dbba6cc JF |
1568 | ; |
1569 | ||
36cd3cb9 JF |
1570 | DefaultClause |
1571 | : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); } | |
1dbba6cc | 1572 | ; |
63cd45c9 JF |
1573 | /* }}} */ |
1574 | /* 12.12 Labelled Statements {{{ */ | |
36cd3cb9 | 1575 | LabelledStatement |
3b52fd1a | 1576 | : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); } |
1dbba6cc | 1577 | ; |
63cd45c9 JF |
1578 | /* }}} */ |
1579 | /* 12.13 The throw Statement {{{ */ | |
36cd3cb9 | 1580 | ThrowStatement |
37954781 | 1581 | : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); } |
1dbba6cc | 1582 | ; |
63cd45c9 JF |
1583 | /* }}} */ |
1584 | /* 12.14 The try Statement {{{ */ | |
36cd3cb9 | 1585 | TryStatement |
37954781 | 1586 | : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); } |
1dbba6cc JF |
1587 | ; |
1588 | ||
1589 | CatchOpt | |
37954781 | 1590 | : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); } |
cf7d4c69 | 1591 | | { $$ = NULL; } |
1dbba6cc JF |
1592 | ; |
1593 | ||
1594 | FinallyOpt | |
b10bd496 | 1595 | : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); } |
cf7d4c69 | 1596 | | { $$ = NULL; } |
1dbba6cc | 1597 | ; |
63cd45c9 | 1598 | /* }}} */ |
1dbba6cc | 1599 | |
63cd45c9 | 1600 | /* 13 Function Definition {{{ */ |
36cd3cb9 | 1601 | FunctionDeclaration |
fb98ac0c | 1602 | : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); } |
1dbba6cc JF |
1603 | ; |
1604 | ||
36cd3cb9 | 1605 | FunctionExpression |
b1589845 | 1606 | : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } |
1dbba6cc JF |
1607 | ; |
1608 | ||
1609 | FormalParameterList_ | |
36cd3cb9 | 1610 | : "," FormalParameterList { $$ = $2; } |
cf7d4c69 | 1611 | | { $$ = NULL; } |
1dbba6cc JF |
1612 | ; |
1613 | ||
1614 | FormalParameterList | |
b09da87b | 1615 | : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); } |
cf7d4c69 | 1616 | | { $$ = NULL; } |
1dbba6cc JF |
1617 | ; |
1618 | ||
36cd3cb9 JF |
1619 | FunctionBody |
1620 | : SourceElements { $$ = $1; } | |
1dbba6cc | 1621 | ; |
63cd45c9 JF |
1622 | /* }}} */ |
1623 | /* 14 Program {{{ */ | |
1dbba6cc | 1624 | Program |
3b52fd1a | 1625 | : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); } |
1dbba6cc JF |
1626 | ; |
1627 | ||
36cd3cb9 JF |
1628 | SourceElements |
1629 | : SourceElement SourceElements { $1->SetNext($2); $$ = $1; } | |
691e4717 | 1630 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
1631 | ; |
1632 | ||
697d6fd2 | 1633 | SourceElement_ |
b10bd496 | 1634 | : Statement_ { $$ = $1; } |
36cd3cb9 | 1635 | | FunctionDeclaration { $$ = $1; } |
1dbba6cc | 1636 | ; |
697d6fd2 JF |
1637 | |
1638 | SourceElement | |
691e4717 | 1639 | : LexSetRegExp SourceElement_ { $$ = $2; } |
697d6fd2 | 1640 | ; |
63cd45c9 | 1641 | /* }}} */ |
e5332278 | 1642 | |
cbaa5f0f | 1643 | @begin ObjectiveC |
4de0686f | 1644 | /* Cycript (Objective-C): @class Declaration {{{ */ |
b09da87b | 1645 | ClassSuperOpt |
697d6fd2 | 1646 | /* XXX: why the hell did I choose MemberExpressionNoBF? */ |
691e4717 | 1647 | : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; } |
b09da87b JF |
1648 | | { $$ = NULL; } |
1649 | ; | |
1650 | ||
1651 | ClassFieldList | |
1652 | : "{" "}" { $$ = NULL; } | |
1653 | ; | |
1654 | ||
1655 | MessageScope | |
1656 | : "+" { $$ = false; } | |
1657 | | "-" { $$ = true; } | |
1658 | ; | |
1659 | ||
1660 | TypeOpt | |
1661 | : "(" Expression ")" { $$ = $2; } | |
1662 | | { $$ = NULL; } | |
1663 | ; | |
1664 | ||
1665 | MessageParameter | |
75b0a457 | 1666 | : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); } |
b09da87b JF |
1667 | ; |
1668 | ||
1669 | MessageParameterListOpt | |
1670 | : MessageParameterList { $$ = $1; } | |
1671 | | { $$ = NULL; } | |
1672 | ; | |
1673 | ||
1674 | MessageParameterList | |
1675 | : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; } | |
1676 | ; | |
1677 | ||
1678 | MessageParameters | |
1679 | : MessageParameterList { $$ = $1; } | |
75b0a457 | 1680 | | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); } |
b09da87b JF |
1681 | ; |
1682 | ||
1683 | ClassMessageDeclaration | |
75b0a457 | 1684 | : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); } |
b09da87b JF |
1685 | ; |
1686 | ||
1687 | ClassMessageDeclarationListOpt | |
4e8c99fb | 1688 | : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; } |
b09da87b JF |
1689 | | { $$ = NULL; } |
1690 | ; | |
1691 | ||
e5bc40db JF |
1692 | ClassName |
1693 | : Identifier { $$ = $1; } | |
1694 | | "(" AssignmentExpression ")" { $$ = $2; } | |
1695 | ; | |
1696 | ||
367eebb1 JF |
1697 | ClassNameOpt |
1698 | : ClassName { $$ = $1; } | |
1699 | | { $$ = NULL; } | |
b09da87b JF |
1700 | ; |
1701 | ||
fb98ac0c JF |
1702 | ClassExpression |
1703 | : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); } | |
1704 | ; | |
1705 | ||
1706 | ClassStatement | |
1707 | : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); } | |
367eebb1 JF |
1708 | ; |
1709 | ||
1710 | CategoryStatement | |
75b0a457 | 1711 | : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); } |
367eebb1 JF |
1712 | ; |
1713 | ||
561ac418 | 1714 | PrimaryExpressionBF |
fb98ac0c | 1715 | : ClassExpression { $$ = $1; } |
367eebb1 JF |
1716 | ; |
1717 | ||
b10bd496 | 1718 | Statement_ |
fb98ac0c | 1719 | : ClassStatement { $$ = $1; } |
365abb0a | 1720 | | CategoryStatement { $$ = $1; } |
b09da87b | 1721 | ; |
cac61857 | 1722 | /* }}} */ |
4de0686f | 1723 | /* Cycript (Objective-C): Send Message {{{ */ |
693d501b JF |
1724 | VariadicCall |
1725 | : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); } | |
1726 | | { $$ = NULL; } | |
1727 | ; | |
1728 | ||
1729 | SelectorCall_ | |
1730 | : SelectorCall { $$ = $1; } | |
1731 | | VariadicCall { $$ = $1; } | |
1732 | ; | |
1733 | ||
1734 | SelectorCall | |
1735 | : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); } | |
1736 | ; | |
1737 | ||
1738 | SelectorList | |
1739 | : SelectorCall { $$ = $1; } | |
1740 | | Word { $$ = new(driver.pool_) CYArgument($1, NULL); } | |
1741 | ; | |
1742 | ||
1743 | MessageExpression | |
561ac418 | 1744 | : "[" AssignmentExpressionNoWC SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); } |
691e4717 | 1745 | | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); } |
693d501b JF |
1746 | ; |
1747 | ||
e7ed5354 JF |
1748 | SelectorExpressionOpt |
1749 | : SelectorExpression_ { $$ = $1; } | |
1750 | | { $$ = NULL; } | |
1751 | ; | |
1752 | ||
1753 | SelectorExpression_ | |
62014ea9 | 1754 | : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); } |
e7ed5354 JF |
1755 | ; |
1756 | ||
1757 | SelectorExpression | |
1758 | : SelectorExpression_ { $$ = $1; } | |
62014ea9 | 1759 | | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); } |
e7ed5354 JF |
1760 | ; |
1761 | ||
561ac418 | 1762 | PrimaryExpressionNo |
693d501b | 1763 | : MessageExpression { $$ = $1; } |
75b0a457 | 1764 | | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); } |
693d501b JF |
1765 | ; |
1766 | /* }}} */ | |
4de0686f JF |
1767 | @end |
1768 | ||
1769 | @begin C | |
1770 | /* Cycript (C): Pointer Indirection/Addressing {{{ */ | |
697d6fd2 | 1771 | UnaryAssigneeExpression |
b1589845 | 1772 | : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); } |
693d501b JF |
1773 | ; |
1774 | ||
1775 | UnaryExpression_ | |
1776 | : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); } | |
1777 | ; | |
1778 | ||
9b5527f0 | 1779 | MemberAccess |
3b52fd1a JF |
1780 | : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); } |
1781 | | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); } | |
9b5527f0 | 1782 | ; |
cac61857 | 1783 | /* }}} */ |
4de0686f JF |
1784 | @end |
1785 | ||
cb02f8ae | 1786 | @begin E4X |
691e4717 JF |
1787 | /* Lexer State {{{ */ |
1788 | LexPushRegExp | |
1789 | : { driver.PushCondition(CYDriver::RegExpCondition); } | |
1790 | ; | |
1791 | ||
1792 | LexPushXMLContent | |
1793 | : { driver.PushCondition(CYDriver::XMLContentCondition); } | |
1794 | ; | |
1795 | ||
1796 | LexPushXMLTag | |
1797 | : { driver.PushCondition(CYDriver::XMLTagCondition); } | |
1798 | ; | |
1799 | ||
1800 | LexPop | |
1801 | : { driver.PopCondition(); } | |
1802 | ; | |
1803 | ||
1804 | LexSetXMLContent | |
1805 | : { driver.SetCondition(CYDriver::XMLContentCondition); } | |
1806 | ; | |
1807 | ||
1808 | LexSetXMLTag | |
1809 | : { driver.SetCondition(CYDriver::XMLTagCondition); } | |
1810 | ; | |
1811 | /* }}} */ | |
1812 | ||
1813 | XMLWhitespaceOpt | |
1814 | : XMLWhitespace | |
1815 | | | |
1816 | ; | |
1817 | ||
1818 | /* 8.1 Context Keywords {{{ */ | |
1819 | Identifier | |
1820 | : "namespace" { $$ = $1; } | |
1821 | | "xml" { $$ = $1; } | |
1822 | ; | |
1823 | /* }}} */ | |
cb02f8ae JF |
1824 | /* 8.3 XML Initialiser Input Elements {{{ */ |
1825 | XMLMarkup | |
691e4717 JF |
1826 | : XMLComment { $$ = $1; } |
1827 | | XMLCDATA { $$ = $1; } | |
1828 | | XMLPI { $$ = $1; } | |
cb02f8ae JF |
1829 | ; |
1830 | /* }}} */ | |
1831 | /* 11.1 Primary Expressions {{{ */ | |
561ac418 | 1832 | PrimaryExpressionWC |
b92ceddb | 1833 | : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } |
691e4717 JF |
1834 | | XMLInitialiser { $$ = $1; } |
1835 | | XMLListInitialiser { $$ = $1; } | |
cb02f8ae JF |
1836 | ; |
1837 | ||
1838 | PropertyIdentifier | |
691e4717 JF |
1839 | : AttributeIdentifier { $$ = $1; } |
1840 | | QualifiedIdentifier { $$ = $1; } | |
1841 | | WildcardIdentifier { $$ = $1; } | |
cb02f8ae JF |
1842 | ; |
1843 | /* }}} */ | |
1844 | /* 11.1.1 Attribute Identifiers {{{ */ | |
1845 | AttributeIdentifier | |
691e4717 JF |
1846 | : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); } |
1847 | ; | |
1848 | ||
1849 | PropertySelector_ | |
b92ceddb JF |
1850 | : PropertySelector { $$ = $1; } |
1851 | | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); } | |
cb02f8ae JF |
1852 | ; |
1853 | ||
1854 | PropertySelector | |
b92ceddb | 1855 | : Identifier { $$ = new(driver.pool_) CYSelector($1); } |
691e4717 | 1856 | | WildcardIdentifier { $$ = $1; } |
cb02f8ae JF |
1857 | ; |
1858 | /* }}} */ | |
1859 | /* 11.1.2 Qualified Identifiers {{{ */ | |
691e4717 | 1860 | QualifiedIdentifier_ |
b92ceddb | 1861 | : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); } |
691e4717 JF |
1862 | | QualifiedIdentifier { $$ = $1; } |
1863 | ; | |
1864 | ||
cb02f8ae | 1865 | QualifiedIdentifier |
b92ceddb | 1866 | : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); } |
cb02f8ae JF |
1867 | ; |
1868 | /* }}} */ | |
1869 | /* 11.1.3 Wildcard Identifiers {{{ */ | |
1870 | WildcardIdentifier | |
691e4717 | 1871 | : "*" { $$ = new(driver.pool_) CYWildcard(); } |
cb02f8ae JF |
1872 | ; |
1873 | /* }}} */ | |
1874 | /* 11.1.4 XML Initialiser {{{ */ | |
1875 | XMLInitialiser | |
691e4717 JF |
1876 | : XMLMarkup { $$ = $1; } |
1877 | | XMLElement { $$ = $1; } | |
cb02f8ae JF |
1878 | ; |
1879 | ||
1880 | XMLElement | |
0347fadf JF |
1881 | : "<" XMLTagContent "/>" LexPop |
1882 | | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop | |
cb02f8ae JF |
1883 | ; |
1884 | ||
1885 | XMLTagContent | |
0347fadf | 1886 | : LexPushXMLTag XMLTagName XMLAttributes |
cb02f8ae JF |
1887 | ; |
1888 | ||
691e4717 JF |
1889 | XMLExpression |
1890 | : "{" LexPushRegExp Expression "}" LexPop | |
1891 | ; | |
1892 | ||
cb02f8ae | 1893 | XMLTagName |
691e4717 | 1894 | : XMLExpression |
cb02f8ae JF |
1895 | | XMLName |
1896 | ; | |
1897 | ||
0347fadf JF |
1898 | XMLAttributes_ |
1899 | : XMLAttributes_ XMLAttribute | |
1900 | | | |
cb02f8ae JF |
1901 | ; |
1902 | ||
0347fadf JF |
1903 | XMLAttributes |
1904 | : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt | |
1905 | | XMLAttributes_ XMLWhitespaceOpt | |
cb02f8ae JF |
1906 | ; |
1907 | ||
691e4717 JF |
1908 | XMLAttributeValue_ |
1909 | : XMLExpression | |
1910 | | XMLAttributeValue | |
1911 | ; | |
1912 | ||
cb02f8ae | 1913 | XMLAttribute |
691e4717 | 1914 | : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_ |
cb02f8ae JF |
1915 | ; |
1916 | ||
cb02f8ae | 1917 | XMLElementContent |
691e4717 | 1918 | : XMLExpression XMLElementContentOpt |
cb02f8ae JF |
1919 | | XMLMarkup XMLElementContentOpt |
1920 | | XMLText XMLElementContentOpt | |
1921 | | XMLElement XMLElementContentOpt | |
1922 | ; | |
1923 | ||
1924 | XMLElementContentOpt | |
1925 | : XMLElementContent | |
1926 | | | |
1927 | ; | |
1928 | /* }}} */ | |
1929 | /* 11.1.5 XMLList Initialiser {{{ */ | |
1930 | XMLListInitialiser | |
691e4717 JF |
1931 | : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); } |
1932 | ; | |
1933 | /* }}} */ | |
1934 | /* 11.2 Left-Hand-Side Expressions {{{ */ | |
1935 | PropertyIdentifier_ | |
0347fadf | 1936 | : Identifier { $$ = $1; } |
691e4717 JF |
1937 | | PropertyIdentifier { $$ = $1; } |
1938 | ; | |
1939 | ||
1940 | MemberAccess | |
1941 | : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); } | |
1942 | | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); } | |
1943 | | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); } | |
1944 | ; | |
1945 | /* }}} */ | |
1946 | /* 12.1 The default xml namespace Statement {{{ */ | |
b92ceddb | 1947 | /* XXX: DefaultXMLNamespaceStatement |
691e4717 JF |
1948 | : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); } |
1949 | ; | |
1950 | ||
1951 | Statement_ | |
1952 | : DefaultXMLNamespaceStatement { $$ = $1; } | |
b92ceddb | 1953 | ; */ |
cb02f8ae JF |
1954 | /* }}} */ |
1955 | @end | |
1956 | ||
cac61857 JF |
1957 | /* ECMAScript5: Object Literal Trailing Comma {{{ */ |
1958 | PropertyNameAndValueList_ | |
1959 | : "," { $$ = NULL; } | |
1960 | ; | |
1961 | /* }}} */ | |
1962 | /* JavaScript 1.7: Array Comprehensions {{{ */ | |
367eebb1 | 1963 | IfComprehension |
75b0a457 | 1964 | : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); } |
367eebb1 JF |
1965 | ; |
1966 | ||
1967 | ForComprehension | |
75b0a457 JF |
1968 | : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); } |
1969 | | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); } | |
367eebb1 JF |
1970 | ; |
1971 | ||
1972 | ComprehensionListOpt | |
75b0a457 JF |
1973 | : ComprehensionList { $$ = $1; } |
1974 | | IfComprehension { $$ = $1; } | |
1975 | | { $$ = NULL; } | |
367eebb1 JF |
1976 | ; |
1977 | ||
1978 | ComprehensionList | |
75b0a457 | 1979 | : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; } |
367eebb1 JF |
1980 | ; |
1981 | ||
561ac418 | 1982 | PrimaryExpressionNo |
75b0a457 | 1983 | : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); } |
367eebb1 | 1984 | ; |
cac61857 JF |
1985 | /* }}} */ |
1986 | /* JavaScript 1.7: for each {{{ */ | |
1987 | ForInStatement | |
1988 | : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); } | |
1989 | ; | |
1990 | /* }}} */ | |
b10bd496 | 1991 | /* JavaScript 1.7: let Statements {{{ *//* |
cac61857 JF |
1992 | LetStatement |
1993 | : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); } | |
1994 | ; | |
1995 | ||
697d6fd2 | 1996 | Statement_ |
cac61857 JF |
1997 | : LetStatement |
1998 | ; | |
534fb6da | 1999 | *//* }}} */ |
b10bd496 JF |
2000 | /* JavaScript FTW: Function Statements {{{ */ |
2001 | Statement | |
691e4717 | 2002 | : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; } |
b10bd496 JF |
2003 | ; |
2004 | /* }}} */ | |
367eebb1 | 2005 | |
e5332278 | 2006 | %% |