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