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