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