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