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