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