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