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