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