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