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