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