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