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