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