]>
Commit | Line | Data |
---|---|---|
b3378a02 | 1 | /* Cycript - Optimizing JavaScript Compiler/Runtime |
c15969fd | 2 | * Copyright (C) 2009-2013 Jay Freeman (saurik) |
b4aa79af JF |
3 | */ |
4 | ||
c15969fd | 5 | /* GNU General Public License, Version 3 {{{ */ |
b4aa79af | 6 | /* |
c15969fd JF |
7 | * Cycript is free software: you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation, either version 3 of the License, | |
10 | * or (at your option) any later version. | |
b4aa79af | 11 | * |
c15969fd JF |
12 | * Cycript is distributed in the hope that it will be useful, but |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
b4aa79af | 16 | * |
c15969fd | 17 | * You should have received a copy of the GNU General Public License |
b3378a02 JF |
18 | * along with Cycript. If not, see <http://www.gnu.org/licenses/>. |
19 | **/ | |
b4aa79af JF |
20 | /* }}} */ |
21 | ||
be36c292 JF |
22 | @if Bison23 %{ |
23 | ||
24 | @if Bison24 %code top { | |
4e869640 | 25 | #define cyscanner driver.scanner_ |
693d501b | 26 | #define YYSTACKEXPANDABLE 1 |
7198f003 | 27 | @if Bison23 #define yyerrok (yyerrstatus_ = 0) |
be36c292 | 28 | @if Bison24 } |
1dbba6cc | 29 | |
be36c292 | 30 | @if Bison24 %code requires { |
b12a9965 | 31 | #include "Driver.hpp" |
63b4c5a8 | 32 | #include "Parser.hpp" |
2eb8215d | 33 | #define CYNew new($pool) |
63b4c5a8 | 34 | |
cbaa5f0f | 35 | @begin ObjectiveC |
3c1c3635 | 36 | #include "ObjectiveC/Syntax.hpp" |
4de0686f JF |
37 | @end |
38 | ||
691e4717 | 39 | @begin E4X |
b92ceddb | 40 | #include "E4X/Syntax.hpp" |
691e4717 JF |
41 | @end |
42 | ||
82a02ede JF |
43 | #include "Highlight.hpp" |
44 | ||
c3c20102 JF |
45 | typedef struct { |
46 | bool newline_; | |
82a02ede | 47 | hi::Value highlight_; |
c3c20102 JF |
48 | |
49 | union { | |
b09da87b JF |
50 | bool bool_; |
51 | ||
63cd45c9 JF |
52 | CYDriver::Condition condition_; |
53 | ||
c3c20102 | 54 | CYArgument *argument_; |
0ff9f149 | 55 | CYAssignment *assignment_; |
c3c20102 JF |
56 | CYBoolean *boolean_; |
57 | CYClause *clause_; | |
37954781 | 58 | cy::Syntax::Catch *catch_; |
320ce753 | 59 | CYComment *comment_; |
75b0a457 | 60 | CYComprehension *comprehension_; |
d35a3b07 | 61 | CYCompound *compound_; |
c3c20102 JF |
62 | CYDeclaration *declaration_; |
63 | CYDeclarations *declarations_; | |
64 | CYElement *element_; | |
65 | CYExpression *expression_; | |
66 | CYFalse *false_; | |
b10bd496 | 67 | CYFinally *finally_; |
c3c20102 JF |
68 | CYForInitialiser *for_; |
69 | CYForInInitialiser *forin_; | |
b09da87b | 70 | CYFunctionParameter *functionParameter_; |
c3c20102 | 71 | CYIdentifier *identifier_; |
0ff9f149 | 72 | CYInfix *infix_; |
c3c20102 | 73 | CYLiteral *literal_; |
9b5527f0 | 74 | CYMember *member_; |
417dcc12 | 75 | CYModule *module_; |
c3c20102 JF |
76 | CYNull *null_; |
77 | CYNumber *number_; | |
3b52fd1a | 78 | CYProgram *program_; |
c3c20102 | 79 | CYProperty *property_; |
e5bc40db | 80 | CYPropertyName *propertyName_; |
6c093cce | 81 | CYRubyProc *rubyProc_; |
c3c20102 JF |
82 | CYStatement *statement_; |
83 | CYString *string_; | |
84 | CYThis *this_; | |
85 | CYTrue *true_; | |
86 | CYWord *word_; | |
4de0686f | 87 | |
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 |
be36c292 | 113 | @if Bison24 } |
63b4c5a8 | 114 | |
be36c292 | 115 | @if Bison24 %code provides { |
4e869640 | 116 | int cylex(YYSTYPE *, cy::location *, void *); |
be36c292 JF |
117 | @if Bison24 } |
118 | ||
119 | @if Bison23 %} | |
e5332278 | 120 | |
4e869640 JF |
121 | %name-prefix="cy" |
122 | ||
be36c292 JF |
123 | @if Bison23 %skeleton "lalr1.cc" |
124 | @if Bison24 %language "C++" | |
1dbba6cc | 125 | |
5999c315 JF |
126 | %initial-action { |
127 | @$.begin.filename = @$.end.filename = &driver.filename_; | |
128 | }; | |
129 | ||
be36c292 | 130 | %locations |
e5332278 | 131 | %defines |
1dbba6cc | 132 | |
534fb6da JF |
133 | //%glr-parser |
134 | //%expect 1 | |
cac61857 | 135 | |
e5332278 JF |
136 | %error-verbose |
137 | ||
5999c315 | 138 | %parse-param { CYDriver &driver } |
4e869640 | 139 | %lex-param { void *cyscanner } |
e5332278 | 140 | |
c3b144b8 | 141 | /* Token Declarations {{{ */ |
cb02f8ae | 142 | @begin E4X |
cb02f8ae JF |
143 | %token XMLCDATA |
144 | %token XMLComment | |
145 | %token XMLPI | |
691e4717 JF |
146 | |
147 | %token XMLAttributeValue | |
148 | %token XMLName | |
149 | %token XMLTagCharacters | |
150 | %token XMLText | |
151 | %token XMLWhitespace | |
152 | @end | |
153 | ||
154 | @begin E4X | |
155 | %token LeftRight "<>" | |
156 | %token LeftSlashRight "</>" | |
157 | ||
158 | %token SlashRight "/>" | |
159 | %token LeftSlash "</" | |
160 | ||
691e4717 JF |
161 | %token ColonColon "::" |
162 | %token PeriodPeriod ".." | |
cb02f8ae | 163 | @end |
ac9a5ce1 | 164 | |
b1589845 JF |
165 | @begin E4X ObjectiveC |
166 | %token At "@" | |
ac9d4181 | 167 | %token Pound "#" |
b1589845 JF |
168 | @end |
169 | ||
63b4c5a8 JF |
170 | %token Ampersand "&" |
171 | %token AmpersandAmpersand "&&" | |
172 | %token AmpersandEqual "&=" | |
173 | %token Carrot "^" | |
174 | %token CarrotEqual "^=" | |
175 | %token Equal "=" | |
176 | %token EqualEqual "==" | |
177 | %token EqualEqualEqual "===" | |
4b2fd91c | 178 | %token EqualRight "=>" |
63b4c5a8 JF |
179 | %token Exclamation "!" |
180 | %token ExclamationEqual "!=" | |
181 | %token ExclamationEqualEqual "!==" | |
182 | %token Hyphen "-" | |
183 | %token HyphenEqual "-=" | |
184 | %token HyphenHyphen "--" | |
c3c20102 | 185 | %token HyphenHyphen_ "\n--" |
63b4c5a8 JF |
186 | %token HyphenRight "->" |
187 | %token Left "<" | |
188 | %token LeftEqual "<=" | |
189 | %token LeftLeft "<<" | |
190 | %token LeftLeftEqual "<<=" | |
191 | %token Percent "%" | |
192 | %token PercentEqual "%=" | |
193 | %token Period "." | |
c8a0500b | 194 | %token PeriodPeriodPeriod "..." |
63b4c5a8 JF |
195 | %token Pipe "|" |
196 | %token PipeEqual "|=" | |
197 | %token PipePipe "||" | |
198 | %token Plus "+" | |
199 | %token PlusEqual "+=" | |
200 | %token PlusPlus "++" | |
c3c20102 | 201 | %token PlusPlus_ "\n++" |
63b4c5a8 JF |
202 | %token Right ">" |
203 | %token RightEqual ">=" | |
204 | %token RightRight ">>" | |
205 | %token RightRightEqual ">>=" | |
206 | %token RightRightRight ">>>" | |
207 | %token RightRightRightEqual ">>>=" | |
208 | %token Slash "/" | |
209 | %token SlashEqual "/=" | |
210 | %token Star "*" | |
211 | %token StarEqual "*=" | |
212 | %token Tilde "~" | |
213 | ||
214 | %token Colon ":" | |
215 | %token Comma "," | |
216 | %token Question "?" | |
217 | %token SemiColon ";" | |
c3c20102 | 218 | %token NewLine "\n" |
63b4c5a8 | 219 | |
320ce753 JF |
220 | %token <comment_> Comment |
221 | ||
63b4c5a8 JF |
222 | %token OpenParen "(" |
223 | %token CloseParen ")" | |
924f67b2 | 224 | |
63b4c5a8 | 225 | %token OpenBrace "{" |
6c093cce | 226 | %token OpenBrace_ "\n{" |
3ea7eed0 | 227 | %token OpenBrace__ ";{" |
63b4c5a8 | 228 | %token CloseBrace "}" |
924f67b2 | 229 | |
63b4c5a8 JF |
230 | %token OpenBracket "[" |
231 | %token CloseBracket "]" | |
232 | ||
dc5d7cf4 JF |
233 | %token AtError "@error" |
234 | ||
1ba6903e | 235 | @begin Java |
b09da87b | 236 | %token AtClass "@class" |
1ba6903e JF |
237 | @end |
238 | ||
60097023 JF |
239 | @begin C |
240 | %token <identifier_> Typedef "typedef" | |
3fe283c5 JF |
241 | %token <identifier_> Unsigned "unsigned" |
242 | %token <identifier_> Signed "signed" | |
60097023 JF |
243 | @end |
244 | ||
8a2eb1be JF |
245 | @begin C |
246 | %token AtEncode "@encode" | |
247 | @end | |
248 | ||
1ba6903e JF |
249 | @begin ObjectiveC |
250 | %token AtImplementation "@implementation" | |
3ea7eed0 | 251 | %token AtImplementation_ ";@implementation" |
1ba6903e | 252 | %token AtImport "@import" |
d35a3b07 | 253 | %token AtEnd "@end" |
1ba6903e | 254 | %token AtSelector "@selector" |
60496dd5 JF |
255 | %token <identifier_> Yes "YES" |
256 | %token <identifier_> No "NO" | |
1ba6903e | 257 | @end |
e7ed5354 | 258 | |
534fb6da JF |
259 | %token <false_> False "false" |
260 | %token <null_> Null "null" | |
261 | %token <true_> True "true" | |
262 | ||
263 | // ES3/ES5/WIE/JSC Reserved | |
a87d7060 | 264 | %token <word_> Auto "auto" |
cf7d4c69 JF |
265 | %token <word_> Break "break" |
266 | %token <word_> Case "case" | |
267 | %token <word_> Catch "catch" | |
268 | %token <word_> Continue "continue" | |
269 | %token <word_> Default "default" | |
270 | %token <word_> Delete "delete" | |
271 | %token <word_> Do "do" | |
272 | %token <word_> Else "else" | |
cf7d4c69 JF |
273 | %token <word_> Finally "finally" |
274 | %token <word_> For "for" | |
275 | %token <word_> Function "function" | |
3ea7eed0 | 276 | %token <word_> Function_ ";function" |
cf7d4c69 JF |
277 | %token <word_> If "if" |
278 | %token <word_> In "in" | |
3ea7eed0 | 279 | %token <word_> In_ "!in" |
cf7d4c69 JF |
280 | %token <word_> InstanceOf "instanceof" |
281 | %token <word_> New "new" | |
cf7d4c69 JF |
282 | %token <word_> Return "return" |
283 | %token <word_> Switch "switch" | |
284 | %token <this_> This "this" | |
285 | %token <word_> Throw "throw" | |
cf7d4c69 JF |
286 | %token <word_> Try "try" |
287 | %token <word_> TypeOf "typeof" | |
288 | %token <word_> Var "var" | |
289 | %token <word_> Void "void" | |
290 | %token <word_> While "while" | |
291 | %token <word_> With "with" | |
63b4c5a8 | 292 | |
534fb6da | 293 | // ES3/IE6 Future, ES5/JSC Reserved |
d35a3b07 | 294 | %token <word_> Debugger "debugger" |
534fb6da JF |
295 | |
296 | // ES3/ES5/IE6 Future, JSC Reserved | |
297 | %token <word_> Const "const" | |
298 | ||
299 | // ES3/ES5/IE6/JSC Future | |
300 | %token <word_> Class "class" | |
d35a3b07 JF |
301 | %token <word_> Enum "enum" |
302 | %token <word_> Export "export" | |
303 | %token <word_> Extends "extends" | |
d35a3b07 | 304 | %token <word_> Import "import" |
d35a3b07 | 305 | %token <word_> Super "super" |
d35a3b07 | 306 | |
534fb6da JF |
307 | // ES3 Future, ES5 Strict Future |
308 | %token <identifier_> Implements "implements" | |
309 | %token <identifier_> Interface "interface" | |
310 | %token <identifier_> Package "package" | |
311 | %token <identifier_> Private "private" | |
312 | %token <identifier_> Protected "protected" | |
313 | %token <identifier_> Public "public" | |
314 | %token <identifier_> Static "static" | |
315 | ||
316 | // ES3 Future | |
317 | %token <identifier_> Abstract "abstract" | |
318 | %token <identifier_> Boolean "boolean" | |
319 | %token <identifier_> Byte "byte" | |
320 | %token <identifier_> Char "char" | |
321 | %token <identifier_> Double "double" | |
322 | %token <identifier_> Final "final" | |
323 | %token <identifier_> Float "float" | |
324 | %token <identifier_> Goto "goto" | |
325 | %token <identifier_> Int "int" | |
326 | %token <identifier_> Long "long" | |
327 | %token <identifier_> Native "native" | |
328 | %token <identifier_> Short "short" | |
329 | %token <identifier_> Synchronized "synchronized" | |
330 | %token <identifier_> Throws "throws" | |
331 | %token <identifier_> Transient "transient" | |
332 | %token <identifier_> Volatile "volatile" | |
333 | ||
334 | // ES5 Strict | |
cac61857 | 335 | %token <identifier_> Let "let" |
534fb6da JF |
336 | %token <identifier_> Yield "yield" |
337 | ||
338 | // Woah?! | |
339 | %token <identifier_> Each "each" | |
480c8834 | 340 | %token <identifier_> Of "of" |
75b0a457 | 341 | |
691e4717 JF |
342 | @begin E4X |
343 | // E4X Conditional | |
344 | %token <identifier_> Namespace "namespace" | |
345 | %token <identifier_> XML "xml" | |
346 | @end | |
347 | ||
7e5391fd JF |
348 | %token AutoComplete |
349 | ||
75b0a457 | 350 | %token <identifier_> Identifier_ |
63b4c5a8 JF |
351 | %token <number_> NumericLiteral |
352 | %token <string_> StringLiteral | |
63cd45c9 | 353 | %token <literal_> RegularExpressionLiteral |
1dbba6cc | 354 | |
cf7d4c69 | 355 | %type <expression_> AdditiveExpression |
cf7d4c69 | 356 | %type <argument_> ArgumentList_ |
55fc1817 | 357 | %type <argument_> ArgumentList |
cf7d4c69 JF |
358 | %type <argument_> ArgumentListOpt |
359 | %type <argument_> Arguments | |
b3aa25d8 JF |
360 | %type <expression_> ArrayComprehension |
361 | %type <expression_> ArrayInitialiser | |
cf7d4c69 | 362 | %type <literal_> ArrayLiteral |
4b2fd91c JF |
363 | %type <expression_> ArrowFunction |
364 | %type <functionParameter_> ArrowParameters | |
55fc1817 | 365 | %type <expression_> AssignmentExpression |
c2529502 | 366 | %type <identifier_> Binding |
c8a0500b | 367 | %type <identifier_> BindingIdentifier |
cf7d4c69 | 368 | %type <expression_> BitwiseANDExpression |
cac61857 | 369 | %type <statement_> Block_ |
55fc1817 | 370 | %type <statement_> Block |
cf7d4c69 | 371 | %type <boolean_> BooleanLiteral |
c8a0500b | 372 | %type <declaration_> BindingElement |
cf7d4c69 JF |
373 | %type <expression_> BitwiseORExpression |
374 | %type <expression_> BitwiseXORExpression | |
375 | %type <statement_> BreakStatement | |
c8a0500b | 376 | %type <statement_> BreakableStatement |
3ea7eed0 | 377 | %type <expression_> CallExpression_ |
cf7d4c69 JF |
378 | %type <expression_> CallExpression |
379 | %type <clause_> CaseBlock | |
380 | %type <clause_> CaseClause | |
381 | %type <clause_> CaseClausesOpt | |
382 | %type <catch_> CatchOpt | |
b3aa25d8 JF |
383 | %type <expression_> Comprehension |
384 | %type <comprehension_> ComprehensionFor | |
385 | %type <comprehension_> ComprehensionIf | |
386 | %type <comprehension_> ComprehensionTail | |
cf7d4c69 JF |
387 | %type <expression_> ConditionalExpression |
388 | %type <statement_> ContinueStatement | |
4b2fd91c | 389 | %type <statement_> ConciseBody |
c8a0500b | 390 | %type <statement_> DebuggerStatement |
3ea7eed0 JF |
391 | %type <statement_> Declaration__ |
392 | %type <statement_> Declaration_ | |
c8a0500b | 393 | %type <statement_> Declaration |
cf7d4c69 | 394 | %type <clause_> DefaultClause |
cf7d4c69 | 395 | %type <expression_> Element |
5befe15e | 396 | %type <expression_> ElementOpt |
cf7d4c69 | 397 | %type <element_> ElementList |
5befe15e | 398 | %type <element_> ElementListOpt |
cf7d4c69 JF |
399 | %type <statement_> ElseStatementOpt |
400 | %type <statement_> EmptyStatement | |
401 | %type <expression_> EqualityExpression | |
55fc1817 | 402 | %type <compound_> Expression_ |
e7797a66 | 403 | %type <compound_> Expression |
cf7d4c69 JF |
404 | %type <expression_> ExpressionOpt |
405 | %type <statement_> ExpressionStatement | |
b10bd496 | 406 | %type <finally_> FinallyOpt |
cf7d4c69 | 407 | %type <for_> ForStatementInitialiser |
cf7d4c69 | 408 | %type <forin_> ForInStatementInitialiser |
c8a0500b | 409 | %type <declaration_> FormalParameter |
b09da87b | 410 | %type <functionParameter_> FormalParameterList_ |
55fc1817 | 411 | %type <functionParameter_> FormalParameterList |
c8a0500b | 412 | %type <functionParameter_> FormalParameterListOpt |
b10bd496 JF |
413 | %type <statement_> FunctionBody |
414 | %type <statement_> FunctionDeclaration | |
cf7d4c69 | 415 | %type <expression_> FunctionExpression |
75b0a457 | 416 | %type <identifier_> Identifier |
cf7d4c69 | 417 | %type <identifier_> IdentifierOpt |
3fe283c5 | 418 | %type <identifier_> IdentifierType |
4492c19c | 419 | %type <word_> IdentifierName |
cf7d4c69 JF |
420 | %type <statement_> IfStatement |
421 | %type <expression_> Initialiser | |
422 | %type <expression_> InitialiserOpt | |
423 | %type <statement_> IterationStatement | |
424 | %type <statement_> LabelledStatement | |
425 | %type <expression_> LeftHandSideExpression | |
15b88a33 | 426 | %type <statement_> LetStatement |
c8a0500b | 427 | %type <statement_> LexicalDeclaration |
cf7d4c69 | 428 | %type <literal_> Literal |
c3b144b8 | 429 | %type <literal_> ValueLiteral |
cf7d4c69 JF |
430 | %type <expression_> LogicalANDExpression |
431 | %type <expression_> LogicalORExpression | |
9b5527f0 | 432 | %type <member_> MemberAccess |
693d501b | 433 | %type <expression_> MemberExpression_ |
55fc1817 | 434 | %type <expression_> MemberExpression |
7b750785 | 435 | %type <module_> Module |
cf7d4c69 | 436 | %type <expression_> MultiplicativeExpression |
55fc1817 | 437 | %type <expression_> NewExpression |
cf7d4c69 JF |
438 | %type <null_> NullLiteral |
439 | %type <literal_> ObjectLiteral | |
4b2fd91c JF |
440 | %type <compound_> Parenthetical |
441 | %type <compound_> ParentheticalOpt | |
cf7d4c69 JF |
442 | %type <expression_> PostfixExpression |
443 | %type <expression_> PrimaryExpression | |
b10bd496 | 444 | %type <statement_> Program |
c8a0500b JF |
445 | %type <statement_> ProgramBody |
446 | %type <statement_> ProgramBodyOpt | |
b92ceddb | 447 | %type <propertyName_> PropertyName_ |
55fc1817 | 448 | %type <propertyName_> PropertyName |
aea76473 JF |
449 | %type <property_> PropertyDefinition |
450 | %type <property_> PropertyDefinitionList_ | |
451 | %type <property_> PropertyDefinitionList | |
452 | %type <property_> PropertyDefinitionListOpt | |
55fc1817 | 453 | %type <expression_> RelationalExpression |
cf7d4c69 | 454 | %type <statement_> ReturnStatement |
6c093cce | 455 | %type <rubyProc_> RubyProcExpression |
6c093cce | 456 | %type <functionParameter_> RubyProcParameterList_ |
55fc1817 | 457 | %type <functionParameter_> RubyProcParameterList |
d7205a63 | 458 | %type <functionParameter_> RubyProcParameters |
6c093cce | 459 | %type <functionParameter_> RubyProcParametersOpt |
cf7d4c69 | 460 | %type <expression_> ShiftExpression |
c8a0500b | 461 | %type <declaration_> SingleNameBinding |
3ea7eed0 | 462 | %type <statement_> Statement__ |
b10bd496 | 463 | %type <statement_> Statement_ |
55fc1817 | 464 | %type <statement_> Statement |
693d501b | 465 | %type <statement_> StatementList |
cf7d4c69 | 466 | %type <statement_> StatementListOpt |
c8a0500b | 467 | %type <statement_> StatementListItem |
cf7d4c69 JF |
468 | %type <statement_> SwitchStatement |
469 | %type <statement_> ThrowStatement | |
470 | %type <statement_> TryStatement | |
693d501b | 471 | %type <expression_> UnaryExpression_ |
55fc1817 | 472 | %type <expression_> UnaryExpression |
cf7d4c69 | 473 | %type <declaration_> VariableDeclaration |
cf7d4c69 | 474 | %type <declarations_> VariableDeclarationList_ |
55fc1817 | 475 | %type <declarations_> VariableDeclarationList |
cf7d4c69 | 476 | %type <statement_> VariableStatement |
cf7d4c69 | 477 | %type <statement_> WithStatement |
4492c19c JF |
478 | %type <word_> Word |
479 | %type <word_> WordOpt | |
46f4f308 | 480 | %type <expression_> Variable |
cf7d4c69 | 481 | |
7b750785 | 482 | @begin C |
663c538f | 483 | %type <typedIdentifier_> ArrayedType |
7b750785 JF |
484 | %type <expression_> EncodedType |
485 | %type <modifier_> FunctionedType | |
486 | %type <specifier_> IntegerType | |
487 | %type <specifier_> IntegerTypeOpt | |
488 | %type <typedIdentifier_> PrefixedType | |
489 | %type <specifier_> PrimitiveType | |
490 | %type <typedIdentifier_> TypeParenthetical | |
491 | %type <typedIdentifier_> TypeSignifier | |
492 | %type <typedIdentifier_> SuffixedType | |
493 | %type <modifier_> TypeQualifierLeft | |
494 | %type <typedIdentifier_> TypeQualifierRight | |
495 | %type <typedIdentifier_> TypedIdentifier | |
496 | %type <typedParameter_> TypedParameterList_ | |
497 | %type <typedParameter_> TypedParameterList | |
498 | %type <typedParameter_> TypedParameterListOpt | |
499 | @end | |
500 | ||
501 | @begin ObjectiveC | |
c3b144b8 | 502 | %type <expression_> BoxableExpression |
328ad766 JF |
503 | %type <statement_> CategoryStatement |
504 | %type <expression_> ClassExpression | |
cfd73c6d JF |
505 | %type <field_> ClassFieldListOpt |
506 | %type <field_> ClassFields | |
328ad766 JF |
507 | %type <statement_> ClassStatement |
508 | %type <expression_> ClassSuperOpt | |
328ad766 JF |
509 | %type <message_> ClassMessageDeclaration |
510 | %type <message_> ClassMessageDeclarationListOpt | |
511 | %type <className_> ClassName | |
512 | %type <className_> ClassNameOpt | |
64b8d29f JF |
513 | %type <protocol_> ClassProtocolListOpt |
514 | %type <protocol_> ClassProtocols | |
515 | %type <protocol_> ClassProtocolsOpt | |
693d501b | 516 | %type <expression_> MessageExpression |
328ad766 JF |
517 | %type <messageParameter_> MessageParameter |
518 | %type <messageParameter_> MessageParameters | |
519 | %type <messageParameter_> MessageParameterList | |
520 | %type <messageParameter_> MessageParameterListOpt | |
521 | %type <bool_> MessageScope | |
9a39f705 | 522 | %type <typedIdentifier_> ModifiedType |
693d501b | 523 | %type <argument_> SelectorCall_ |
55fc1817 | 524 | %type <argument_> SelectorCall |
328ad766 | 525 | %type <selector_> SelectorExpression_ |
55fc1817 | 526 | %type <selector_> SelectorExpression |
328ad766 | 527 | %type <selector_> SelectorExpressionOpt |
693d501b | 528 | %type <argument_> SelectorList |
7e5391fd | 529 | %type <word_> SelectorWordOpt |
328ad766 | 530 | %type <expression_> TypeOpt |
693d501b | 531 | %type <argument_> VariadicCall |
328ad766 | 532 | @end |
693d501b | 533 | |
691e4717 | 534 | @begin E4X |
b92ceddb | 535 | %type <propertyIdentifier_> PropertyIdentifier_ |
b92ceddb | 536 | %type <selector_> PropertySelector_ |
55fc1817 | 537 | %type <selector_> PropertySelector |
691e4717 | 538 | %type <identifier_> QualifiedIdentifier_ |
55fc1817 | 539 | %type <identifier_> QualifiedIdentifier |
691e4717 JF |
540 | %type <identifier_> WildcardIdentifier |
541 | %type <identifier_> XMLComment | |
542 | %type <identifier_> XMLCDATA | |
543 | %type <identifier_> XMLElement | |
544 | %type <identifier_> XMLElementContent | |
545 | %type <identifier_> XMLMarkup | |
546 | %type <identifier_> XMLPI | |
547 | ||
548 | %type <attribute_> AttributeIdentifier | |
b92ceddb | 549 | /* XXX: %type <statement_> DefaultXMLNamespaceStatement */ |
691e4717 JF |
550 | %type <expression_> PropertyIdentifier |
551 | %type <expression_> XMLListInitialiser | |
552 | %type <expression_> XMLInitialiser | |
553 | @end | |
c3b144b8 JF |
554 | /* }}} */ |
555 | /* Token Priorities {{{ */ | |
3ea7eed0 JF |
556 | %nonassoc "" |
557 | %left "++" "--" | |
b92ceddb JF |
558 | |
559 | %nonassoc "if" | |
560 | %nonassoc "else" | |
c3b144b8 | 561 | /* }}} */ |
b92ceddb | 562 | |
693d501b | 563 | %start Program |
e5332278 | 564 | |
693d501b | 565 | %% |
c3c20102 | 566 | |
691e4717 | 567 | /* Lexer State {{{ */ |
3ea7eed0 JF |
568 | LexPushInOn |
569 | : { driver.in_.push(true); } | |
570 | ; | |
571 | ||
572 | LexPushInOff | |
573 | : { driver.in_.push(false); } | |
574 | ; | |
575 | ||
576 | LexPopIn | |
577 | : { driver.in_.pop(); } | |
578 | ; | |
579 | ||
691e4717 JF |
580 | LexSetRegExp |
581 | : { driver.SetCondition(CYDriver::RegExpCondition); } | |
582 | ; | |
3ea7eed0 | 583 | |
4b2fd91c | 584 | LexNoBrace |
5602b1ee | 585 | : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; } |
4b2fd91c | 586 | ; |
066da9f6 | 587 | |
4b2fd91c | 588 | LexNoFunction |
9417a638 | 589 | : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; } |
4b2fd91c JF |
590 | ; |
591 | ||
39ed6a51 JF |
592 | LexNoAtImplementation : |
593 | @begin ObjectiveC | |
594 | { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; } | |
595 | @end | |
507848cd JF |
596 | ; |
597 | ||
4b2fd91c | 598 | LexSetStatement |
507848cd | 599 | : LexNoBrace LexNoFunction LexNoAtImplementation |
3ea7eed0 | 600 | ; |
691e4717 | 601 | /* }}} */ |
c3b144b8 | 602 | /* Virtual Tokens {{{ */ |
3ea7eed0 | 603 | BRACE |
6c093cce JF |
604 | : "{" |
605 | | "\n{" | |
606 | ; | |
a87d7060 JF |
607 | |
608 | Var_ | |
609 | : "var" | |
610 | ; | |
c3b144b8 | 611 | /* }}} */ |
6c093cce | 612 | |
c3b144b8 JF |
613 | /* 7.6 Identifier Names and Identifiers {{{ */ |
614 | IdentifierName | |
615 | : Word { $$ = $1; } | |
c3c20102 JF |
616 | ; |
617 | ||
618 | NewLineOpt | |
693d501b | 619 | : "\n" |
c3c20102 JF |
620 | | |
621 | ; | |
1dbba6cc | 622 | |
36cd3cb9 | 623 | Word |
cf7d4c69 | 624 | : Identifier { $$ = $1; } |
a87d7060 | 625 | | "auto" { $$ = $1; } |
c3c20102 | 626 | | "break" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
627 | | "case" { $$ = $1; } |
628 | | "catch" { $$ = $1; } | |
d35a3b07 JF |
629 | | "class" { $$ = $1; } |
630 | | "const" { $$ = $1; } | |
c3c20102 | 631 | | "continue" NewLineOpt { $$ = $1; } |
d35a3b07 | 632 | | "debugger" { $$ = $1; } |
cf7d4c69 JF |
633 | | "default" { $$ = $1; } |
634 | | "delete" { $$ = $1; } | |
635 | | "do" { $$ = $1; } | |
636 | | "else" { $$ = $1; } | |
d35a3b07 JF |
637 | | "enum" { $$ = $1; } |
638 | | "export" { $$ = $1; } | |
639 | | "extends" { $$ = $1; } | |
cf7d4c69 JF |
640 | | "false" { $$ = $1; } |
641 | | "finally" { $$ = $1; } | |
561ac418 | 642 | /* XXX: | "for" { $$ = $1; } */ |
cf7d4c69 JF |
643 | | "function" { $$ = $1; } |
644 | | "if" { $$ = $1; } | |
d35a3b07 | 645 | | "import" { $$ = $1; } |
693d501b | 646 | /* XXX: | "in" { $$ = $1; } */ |
4492c19c | 647 | | "!in" { $$ = $1; } |
693d501b | 648 | /* XXX: | "instanceof" { $$ = $1; } */ |
dd983804 JF |
649 | |
650 | // XXX: as it currently is not an Identifier | |
651 | | "let" { $$ = $1; } | |
652 | ||
cf7d4c69 JF |
653 | | "new" { $$ = $1; } |
654 | | "null" { $$ = $1; } | |
c3c20102 | 655 | | "return" NewLineOpt { $$ = $1; } |
d35a3b07 | 656 | | "super" { $$ = $1; } |
cf7d4c69 JF |
657 | | "switch" { $$ = $1; } |
658 | | "this" { $$ = $1; } | |
c3c20102 | 659 | | "throw" NewLineOpt { $$ = $1; } |
cf7d4c69 JF |
660 | | "true" { $$ = $1; } |
661 | | "try" { $$ = $1; } | |
662 | | "typeof" { $$ = $1; } | |
663 | | "var" { $$ = $1; } | |
664 | | "void" { $$ = $1; } | |
665 | | "while" { $$ = $1; } | |
666 | | "with" { $$ = $1; } | |
2bf24581 | 667 | ; |
f2f0d1d1 | 668 | |
55fc1817 JF |
669 | WordOpt |
670 | : Word { $$ = $1; } | |
671 | | { $$ = NULL; } | |
672 | ; | |
673 | ||
3fe283c5 | 674 | IdentifierType |
75b0a457 | 675 | : Identifier_ { $$ = $1; } |
534fb6da JF |
676 | |
677 | | "implements" { $$ = $1; } | |
678 | | "interface" { $$ = $1; } | |
679 | | "package" { $$ = $1; } | |
680 | | "private" { $$ = $1; } | |
681 | | "protected" { $$ = $1; } | |
682 | | "public" { $$ = $1; } | |
683 | | "static" { $$ = $1; } | |
684 | ||
685 | | "abstract" { $$ = $1; } | |
686 | | "boolean" { $$ = $1; } | |
687 | | "byte" { $$ = $1; } | |
534fb6da JF |
688 | | "double" { $$ = $1; } |
689 | | "final" { $$ = $1; } | |
690 | | "float" { $$ = $1; } | |
691 | | "goto" { $$ = $1; } | |
534fb6da | 692 | | "native" { $$ = $1; } |
534fb6da JF |
693 | | "synchronized" { $$ = $1; } |
694 | | "throws" { $$ = $1; } | |
695 | | "transient" { $$ = $1; } | |
534fb6da | 696 | |
dd983804 JF |
697 | // XXX: currently I only have this as Word |
698 | // | "let" { $$ = $1; } | |
699 | ||
534fb6da JF |
700 | | "yield" { $$ = $1; } |
701 | ||
702 | | "each" { $$ = $1; } | |
480c8834 | 703 | | "of" { $$ = $1; } |
75b0a457 JF |
704 | ; |
705 | ||
3fe283c5 JF |
706 | Identifier |
707 | : IdentifierType | |
708 | | "char" { $$ = $1; } | |
709 | | "int" { $$ = $1; } | |
710 | | "long" { $$ = $1; } | |
711 | | "short" { $$ = $1; } | |
712 | | "volatile" { $$ = $1; } | |
713 | @begin C | |
714 | | "typedef" { $$ = $1; } | |
715 | | "unsigned" { $$ = $1; } | |
716 | | "signed" { $$ = $1; } | |
7b750785 JF |
717 | @end |
718 | @begin ObjectiveC | |
3fe283c5 JF |
719 | | "YES" { $$ = $1; } |
720 | | "NO" { $$ = $1; } | |
721 | @end | |
722 | ; | |
723 | ||
36cd3cb9 | 724 | IdentifierOpt |
cf7d4c69 JF |
725 | : Identifier { $$ = $1; } |
726 | | { $$ = NULL; } | |
1dbba6cc | 727 | ; |
c3b144b8 | 728 | /* }}} */ |
1dbba6cc | 729 | |
c3b144b8 JF |
730 | /* 7.8 Literals {{{ */ |
731 | Literal | |
cf7d4c69 | 732 | : NullLiteral { $$ = $1; } |
c3b144b8 | 733 | | ValueLiteral { $$ = $1; } |
561ac418 JF |
734 | ; |
735 | ||
c3b144b8 JF |
736 | ValueLiteral |
737 | : BooleanLiteral { $$ = $1; } | |
738 | | NumericLiteral { $$ = $1; } | |
739 | | StringLiteral { $$ = $1; } | |
3ea7eed0 | 740 | | RegularExpressionLiteral { $$ = $1; } |
1dbba6cc | 741 | ; |
c3b144b8 JF |
742 | /* }}} */ |
743 | /* 7.8.1 Null Literals {{{ */ | |
36cd3cb9 | 744 | NullLiteral |
cf7d4c69 | 745 | : "null" { $$ = $1; } |
1dbba6cc | 746 | ; |
c3b144b8 JF |
747 | /* }}} */ |
748 | /* 7.8.2 Boolean Literals {{{ */ | |
36cd3cb9 | 749 | BooleanLiteral |
cf7d4c69 JF |
750 | : "true" { $$ = $1; } |
751 | | "false" { $$ = $1; } | |
1dbba6cc | 752 | ; |
c3b144b8 JF |
753 | /* }}} */ |
754 | ||
755 | /* 7.9 Automatic Semicolon Insertion {{{ */ | |
756 | StrictSemi | |
757 | : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } | |
758 | ; | |
759 | ||
760 | Terminator | |
761 | : ";" | |
762 | | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi | |
763 | ; | |
764 | ||
765 | TerminatorOpt | |
766 | : ";" | |
767 | | error { yyerrok; driver.errors_.pop_back(); } StrictSemi | |
768 | ; | |
769 | /* }}} */ | |
1dbba6cc | 770 | |
1dbba6cc | 771 | /* 11.1 Primary Expressions {{{ */ |
3ea7eed0 | 772 | Parenthetical |
440424e2 | 773 | : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; } |
561ac418 JF |
774 | ; |
775 | ||
4b2fd91c JF |
776 | ParentheticalOpt |
777 | : Parenthetical { $$ = $1; } | |
778 | | { $$ = NULL; } | |
779 | ; | |
780 | ||
46f4f308 JF |
781 | Variable |
782 | : Identifier { $$ = CYNew CYVariable($1); } | |
783 | ; | |
784 | ||
3ea7eed0 | 785 | PrimaryExpression |
cf7d4c69 | 786 | : "this" { $$ = $1; } |
46f4f308 | 787 | | Variable { $$ = $1; } |
cf7d4c69 | 788 | | Literal { $$ = $1; } |
b3aa25d8 | 789 | | ArrayInitialiser { $$ = $1; } |
3ea7eed0 | 790 | | ObjectLiteral { $$ = $1; } |
3ea7eed0 JF |
791 | | Parenthetical { $$ = $1; } |
792 | | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; } | |
1dbba6cc JF |
793 | ; |
794 | /* }}} */ | |
b3aa25d8 JF |
795 | /* 11.1.4 Array Initializer {{{ */ |
796 | ArrayInitialiser | |
797 | : ArrayLiteral { $$ = $1; } | |
798 | | ArrayComprehension { $$ = $1; } | |
799 | ; | |
800 | /* }}} */ | |
801 | /* 11.1.4.1 Array Literal {{{ */ | |
36cd3cb9 | 802 | ArrayLiteral |
440424e2 | 803 | : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); } |
1dbba6cc JF |
804 | ; |
805 | ||
36cd3cb9 | 806 | Element |
cf7d4c69 | 807 | : AssignmentExpression { $$ = $1; } |
5befe15e JF |
808 | ; |
809 | ||
810 | ElementOpt | |
811 | : Element { $$ = $1; } | |
691e4717 | 812 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
813 | ; |
814 | ||
36cd3cb9 | 815 | ElementList |
2eb8215d JF |
816 | : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); } |
817 | | Element { $$ = CYNew CYElement($1, NULL); } | |
1dbba6cc | 818 | ; |
55fc1817 JF |
819 | |
820 | ElementListOpt | |
821 | : ElementList { $$ = $1; } | |
822 | | LexSetRegExp { $$ = NULL; } | |
823 | ; | |
1dbba6cc | 824 | /* }}} */ |
c2529502 | 825 | /* 11.1.4.2 Array Comprehension {{{ */ |
b3aa25d8 JF |
826 | ArrayComprehension |
827 | : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; } | |
c2529502 JF |
828 | ; |
829 | ||
b3aa25d8 JF |
830 | Comprehension |
831 | : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); } | |
c2529502 JF |
832 | ; |
833 | ||
b3aa25d8 JF |
834 | ComprehensionTail |
835 | : { $$ = NULL; } | |
836 | | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); } | |
837 | | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); } | |
838 | ; | |
839 | ||
840 | ComprehensionFor | |
841 | : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); } | |
842 | ; | |
843 | ||
844 | ComprehensionIf | |
845 | : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); } | |
c2529502 JF |
846 | ; |
847 | /* }}} */ | |
1dbba6cc | 848 | /* 11.1.5 Object Initialiser {{{ */ |
36cd3cb9 | 849 | ObjectLiteral |
440424e2 | 850 | : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); } |
1dbba6cc JF |
851 | ; |
852 | ||
aea76473 JF |
853 | PropertyDefinitionList_ |
854 | : "," PropertyDefinitionList { $$ = $2; } | |
70234143 | 855 | | "," LexSetRegExp { $$ = NULL; } |
cac61857 | 856 | | { $$ = NULL; } |
1dbba6cc JF |
857 | ; |
858 | ||
aea76473 JF |
859 | PropertyDefinitionList |
860 | : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; } | |
55fc1817 JF |
861 | ; |
862 | ||
aea76473 JF |
863 | PropertyDefinitionListOpt |
864 | : PropertyDefinitionList { $$ = $1; } | |
70234143 | 865 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
866 | ; |
867 | ||
aea76473 | 868 | PropertyDefinition |
797cb0e5 JF |
869 | // XXX: this should be IdentifierName |
870 | : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); } | |
871 | | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); } | |
aea76473 JF |
872 | //| MethodDefinition |
873 | ; | |
874 | ||
b92ceddb | 875 | PropertyName_ |
4492c19c | 876 | : IdentifierName { $$ = $1; } |
36cd3cb9 JF |
877 | | StringLiteral { $$ = $1; } |
878 | | NumericLiteral { $$ = $1; } | |
1dbba6cc | 879 | ; |
b92ceddb JF |
880 | |
881 | PropertyName | |
882 | : LexSetRegExp PropertyName_ { $$ = $2; } | |
883 | ; | |
1dbba6cc JF |
884 | /* }}} */ |
885 | ||
63cd45c9 | 886 | /* 11.2 Left-Hand-Side Expressions {{{ */ |
9b5527f0 | 887 | MemberAccess |
440424e2 | 888 | : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); } |
5ccfc586 | 889 | | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); } |
7e5391fd | 890 | | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; } |
9b5527f0 JF |
891 | ; |
892 | ||
55fc1817 | 893 | MemberExpression_ |
3ea7eed0 JF |
894 | : MemberExpression { $$ = $1; } |
895 | //| "super" { $$ = $1; } | |
55fc1817 JF |
896 | ; |
897 | ||
36cd3cb9 | 898 | MemberExpression |
3ea7eed0 | 899 | : LexSetRegExp PrimaryExpression { $$ = $2; } |
afbff131 | 900 | | LexSetRegExp FunctionExpression { $$ = $2; } |
3ea7eed0 JF |
901 | | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; } |
902 | | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); } | |
1dbba6cc JF |
903 | ; |
904 | ||
36cd3cb9 | 905 | NewExpression |
cf7d4c69 | 906 | : MemberExpression { $$ = $1; } |
3ea7eed0 | 907 | | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); } |
1dbba6cc JF |
908 | ; |
909 | ||
3ea7eed0 JF |
910 | CallExpression_ |
911 | : MemberExpression_ | |
912 | | CallExpression | |
b1589845 JF |
913 | ; |
914 | ||
36cd3cb9 | 915 | CallExpression |
3ea7eed0 | 916 | : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); } |
7e5391fd | 917 | | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; } |
1dbba6cc JF |
918 | ; |
919 | ||
3ea7eed0 | 920 | Arguments |
440424e2 | 921 | : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; } |
b1589845 JF |
922 | ; |
923 | ||
36cd3cb9 | 924 | ArgumentList_ |
cf7d4c69 JF |
925 | : "," ArgumentList { $$ = $2; } |
926 | | { $$ = NULL; } | |
1dbba6cc JF |
927 | ; |
928 | ||
55fc1817 JF |
929 | ArgumentList |
930 | : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); } | |
931 | ; | |
932 | ||
36cd3cb9 | 933 | ArgumentListOpt |
cf7d4c69 | 934 | : ArgumentList { $$ = $1; } |
691e4717 | 935 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc JF |
936 | ; |
937 | ||
36cd3cb9 | 938 | LeftHandSideExpression |
cf7d4c69 JF |
939 | : NewExpression { $$ = $1; } |
940 | | CallExpression { $$ = $1; } | |
693d501b | 941 | ; |
63cd45c9 JF |
942 | /* }}} */ |
943 | /* 11.3 Postfix Expressions {{{ */ | |
36cd3cb9 | 944 | PostfixExpression |
3ea7eed0 | 945 | : %prec "" LeftHandSideExpression { $$ = $1; } |
2eb8215d JF |
946 | | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); } |
947 | | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); } | |
1dbba6cc | 948 | ; |
63cd45c9 JF |
949 | /* }}} */ |
950 | /* 11.4 Unary Operators {{{ */ | |
693d501b | 951 | UnaryExpression_ |
2eb8215d JF |
952 | : "delete" UnaryExpression { $$ = CYNew CYDelete($2); } |
953 | | "void" UnaryExpression { $$ = CYNew CYVoid($2); } | |
954 | | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); } | |
955 | | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); } | |
956 | | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); } | |
957 | | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); } | |
958 | | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); } | |
959 | | "+" UnaryExpression { $$ = CYNew CYAffirm($2); } | |
960 | | "-" UnaryExpression { $$ = CYNew CYNegate($2); } | |
961 | | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); } | |
962 | | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); } | |
693d501b JF |
963 | ; |
964 | ||
965 | UnaryExpression | |
966 | : PostfixExpression { $$ = $1; } | |
691e4717 | 967 | | LexSetRegExp UnaryExpression_ { $$ = $2; } |
693d501b | 968 | ; |
63cd45c9 JF |
969 | /* }}} */ |
970 | /* 11.5 Multiplicative Operators {{{ */ | |
36cd3cb9 | 971 | MultiplicativeExpression |
cf7d4c69 | 972 | : UnaryExpression { $$ = $1; } |
2eb8215d JF |
973 | | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); } |
974 | | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); } | |
975 | | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); } | |
1dbba6cc | 976 | ; |
63cd45c9 JF |
977 | /* }}} */ |
978 | /* 11.6 Additive Operators {{{ */ | |
36cd3cb9 | 979 | AdditiveExpression |
cf7d4c69 | 980 | : MultiplicativeExpression { $$ = $1; } |
2eb8215d JF |
981 | | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); } |
982 | | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); } | |
1dbba6cc | 983 | ; |
63cd45c9 JF |
984 | /* }}} */ |
985 | /* 11.7 Bitwise Shift Operators {{{ */ | |
36cd3cb9 | 986 | ShiftExpression |
cf7d4c69 | 987 | : AdditiveExpression { $$ = $1; } |
2eb8215d JF |
988 | | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); } |
989 | | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); } | |
990 | | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); } | |
1dbba6cc | 991 | ; |
63cd45c9 JF |
992 | /* }}} */ |
993 | /* 11.8 Relational Operators {{{ */ | |
3ea7eed0 | 994 | RelationalExpression |
05089169 JF |
995 | : ShiftExpression { $$ = $1; } |
996 | | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); } | |
997 | | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); } | |
998 | | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); } | |
999 | | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); } | |
1000 | | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); } | |
1001 | | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); } | |
693d501b | 1002 | ; |
63cd45c9 JF |
1003 | /* }}} */ |
1004 | /* 11.9 Equality Operators {{{ */ | |
36cd3cb9 | 1005 | EqualityExpression |
cf7d4c69 | 1006 | : RelationalExpression { $$ = $1; } |
2eb8215d JF |
1007 | | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); } |
1008 | | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); } | |
1009 | | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); } | |
1010 | | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); } | |
1dbba6cc | 1011 | ; |
63cd45c9 JF |
1012 | /* }}} */ |
1013 | /* 11.10 Binary Bitwise Operators {{{ */ | |
36cd3cb9 | 1014 | BitwiseANDExpression |
cf7d4c69 | 1015 | : EqualityExpression { $$ = $1; } |
2eb8215d | 1016 | | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); } |
1dbba6cc JF |
1017 | ; |
1018 | ||
36cd3cb9 | 1019 | BitwiseXORExpression |
cf7d4c69 | 1020 | : BitwiseANDExpression { $$ = $1; } |
2eb8215d | 1021 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); } |
1dbba6cc JF |
1022 | ; |
1023 | ||
36cd3cb9 | 1024 | BitwiseORExpression |
cf7d4c69 | 1025 | : BitwiseXORExpression { $$ = $1; } |
2eb8215d | 1026 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); } |
1dbba6cc | 1027 | ; |
63cd45c9 JF |
1028 | /* }}} */ |
1029 | /* 11.11 Binary Logical Operators {{{ */ | |
36cd3cb9 | 1030 | LogicalANDExpression |
cf7d4c69 | 1031 | : BitwiseORExpression { $$ = $1; } |
2eb8215d | 1032 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); } |
1dbba6cc JF |
1033 | ; |
1034 | ||
36cd3cb9 | 1035 | LogicalORExpression |
cf7d4c69 | 1036 | : LogicalANDExpression { $$ = $1; } |
2eb8215d | 1037 | | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); } |
1dbba6cc | 1038 | ; |
63cd45c9 JF |
1039 | /* }}} */ |
1040 | /* 11.12 Conditional Operator ( ? : ) {{{ */ | |
36cd3cb9 | 1041 | ConditionalExpression |
cf7d4c69 | 1042 | : LogicalORExpression { $$ = $1; } |
440424e2 | 1043 | | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); } |
c2faf0d3 | 1044 | | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); } |
693d501b | 1045 | ; |
63cd45c9 JF |
1046 | /* }}} */ |
1047 | /* 11.13 Assignment Operators {{{ */ | |
36cd3cb9 | 1048 | AssignmentExpression |
cf7d4c69 | 1049 | : ConditionalExpression { $$ = $1; } |
4b2fd91c | 1050 | | ArrowFunction { $$ = $1; } |
005a0939 JF |
1051 | | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); } |
1052 | | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); } | |
1053 | | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); } | |
1054 | | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); } | |
1055 | | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); } | |
1056 | | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); } | |
1057 | | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); } | |
1058 | | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); } | |
1059 | | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); } | |
1060 | | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); } | |
1061 | | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); } | |
1062 | | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); } | |
693d501b | 1063 | ; |
63cd45c9 JF |
1064 | /* }}} */ |
1065 | /* 11.14 Comma Operator {{{ */ | |
36cd3cb9 | 1066 | Expression_ |
e7797a66 | 1067 | : "," Expression { $$ = $2; } |
fd5cdf97 | 1068 | | { $$ = NULL; } |
1dbba6cc JF |
1069 | ; |
1070 | ||
55fc1817 | 1071 | Expression |
fd5cdf97 | 1072 | : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); } |
693d501b JF |
1073 | ; |
1074 | ||
36cd3cb9 | 1075 | ExpressionOpt |
cf7d4c69 | 1076 | : Expression { $$ = $1; } |
691e4717 | 1077 | | LexSetRegExp { $$ = NULL; } |
1dbba6cc | 1078 | ; |
63cd45c9 | 1079 | /* }}} */ |
693d501b | 1080 | |
63cd45c9 | 1081 | /* 12 Statements {{{ */ |
3ea7eed0 | 1082 | Statement__ |
36cd3cb9 JF |
1083 | : Block { $$ = $1; } |
1084 | | VariableStatement { $$ = $1; } | |
1085 | | EmptyStatement { $$ = $1; } | |
cf7d4c69 | 1086 | | IfStatement { $$ = $1; } |
c8a0500b | 1087 | | BreakableStatement { $$ = $1; } |
36cd3cb9 JF |
1088 | | ContinueStatement { $$ = $1; } |
1089 | | BreakStatement { $$ = $1; } | |
1090 | | ReturnStatement { $$ = $1; } | |
cf7d4c69 JF |
1091 | | WithStatement { $$ = $1; } |
1092 | | LabelledStatement { $$ = $1; } | |
36cd3cb9 JF |
1093 | | ThrowStatement { $$ = $1; } |
1094 | | TryStatement { $$ = $1; } | |
c8a0500b | 1095 | | DebuggerStatement { $$ = $1; } |
1dbba6cc | 1096 | ; |
b10bd496 | 1097 | |
3ea7eed0 JF |
1098 | Statement_ |
1099 | : LexSetRegExp Statement__ { $$ = $2; } | |
1100 | | ExpressionStatement { $$ = $1; } | |
1101 | ; | |
1102 | ||
b10bd496 | 1103 | Statement |
3ea7eed0 | 1104 | : LexSetStatement Statement_ { $$ = $2; } |
b10bd496 | 1105 | ; |
c8a0500b | 1106 | |
3ea7eed0 | 1107 | Declaration__ |
c8a0500b JF |
1108 | : FunctionDeclaration { $$ = $1; } |
1109 | | LexicalDeclaration { $$ = $1; } | |
1110 | ; | |
1111 | ||
3ea7eed0 JF |
1112 | Declaration_ |
1113 | : LexSetRegExp Declaration__ { $$ = $2; } | |
1114 | ; | |
1115 | ||
1116 | Declaration | |
1117 | : LexSetStatement Declaration_ { $$ = $2; } | |
1118 | ; | |
1119 | ||
c8a0500b JF |
1120 | BreakableStatement |
1121 | : IterationStatement { $$ = $1; } | |
1122 | | SwitchStatement { $$ = $1; } | |
1123 | ; | |
63cd45c9 JF |
1124 | /* }}} */ |
1125 | /* 12.1 Block {{{ */ | |
cac61857 | 1126 | Block_ |
3ea7eed0 | 1127 | : BRACE StatementListOpt "}" { $$ = $2; } |
cac61857 JF |
1128 | ; |
1129 | ||
36cd3cb9 | 1130 | Block |
3ea7eed0 | 1131 | : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); } |
1dbba6cc JF |
1132 | ; |
1133 | ||
693d501b | 1134 | StatementList |
c8a0500b | 1135 | : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; } |
693d501b JF |
1136 | ; |
1137 | ||
1138 | StatementListOpt | |
1139 | : StatementList { $$ = $1; } | |
5d660bed | 1140 | | LexSetStatement LexSetRegExp { $$ = NULL; } |
1dbba6cc | 1141 | ; |
c8a0500b JF |
1142 | |
1143 | StatementListItem | |
1144 | : Statement { $$ = $1; } | |
3ea7eed0 | 1145 | | Declaration { $$ = $1; } |
c8a0500b JF |
1146 | ; |
1147 | /* }}} */ | |
c3b144b8 | 1148 | |
c8a0500b JF |
1149 | /* 12.2 Declarations {{{ */ |
1150 | BindingIdentifier | |
1151 | : Identifier { $$ = $1; } | |
1152 | ; | |
1153 | ||
c2529502 JF |
1154 | Binding |
1155 | : BindingIdentifier | |
1156 | ; | |
1157 | ||
c8a0500b JF |
1158 | // XXX: BindingPattern |
1159 | /* }}} */ | |
1160 | /* 12.2.1 Let and Const Declarations {{{ */ | |
1161 | LexicalDeclaration | |
1162 | : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); } | |
1163 | ; | |
1164 | ||
1165 | LetOrConst | |
1166 | : "let" | |
1167 | | "const" | |
1168 | ; | |
63cd45c9 | 1169 | /* }}} */ |
c8a0500b | 1170 | /* 12.2.2 Variable Statement {{{ */ |
36cd3cb9 | 1171 | VariableStatement |
a87d7060 | 1172 | : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); } |
1dbba6cc JF |
1173 | ; |
1174 | ||
36cd3cb9 | 1175 | VariableDeclarationList_ |
cf7d4c69 JF |
1176 | : "," VariableDeclarationList { $$ = $2; } |
1177 | | { $$ = NULL; } | |
1dbba6cc JF |
1178 | ; |
1179 | ||
55fc1817 JF |
1180 | VariableDeclarationList |
1181 | : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); } | |
1182 | ; | |
1183 | ||
36cd3cb9 | 1184 | VariableDeclaration |
c8a0500b JF |
1185 | : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); } |
1186 | // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); } | |
1dbba6cc JF |
1187 | ; |
1188 | ||
55fc1817 JF |
1189 | Initialiser |
1190 | : "=" AssignmentExpression { $$ = $2; } | |
1191 | ; | |
1192 | ||
36cd3cb9 | 1193 | InitialiserOpt |
cf7d4c69 | 1194 | : Initialiser { $$ = $1; } |
36cd3cb9 | 1195 | | { $$ = NULL; } |
1dbba6cc | 1196 | ; |
63cd45c9 | 1197 | /* }}} */ |
c8a0500b JF |
1198 | /* 12.2.4 Destructuring Binding Patterns {{{ */ |
1199 | // XXX: * | |
1200 | ||
1201 | BindingElement | |
1202 | : SingleNameBinding { $$ = $1; } | |
1203 | ; | |
1204 | ||
1205 | SingleNameBinding | |
1206 | : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); } | |
1207 | ; | |
1208 | /* }}} */ | |
c3b144b8 | 1209 | |
63cd45c9 | 1210 | /* 12.3 Empty Statement {{{ */ |
36cd3cb9 | 1211 | EmptyStatement |
2eb8215d | 1212 | : ";" { $$ = CYNew CYEmpty(); } |
1dbba6cc | 1213 | ; |
63cd45c9 JF |
1214 | /* }}} */ |
1215 | /* 12.4 Expression Statement {{{ */ | |
36cd3cb9 | 1216 | ExpressionStatement |
3ea7eed0 | 1217 | : Expression Terminator { $$ = CYNew CYExpress($1); } |
1dbba6cc | 1218 | ; |
63cd45c9 JF |
1219 | /* }}} */ |
1220 | /* 12.5 The if Statement {{{ */ | |
36cd3cb9 JF |
1221 | ElseStatementOpt |
1222 | : "else" Statement { $$ = $2; } | |
c3c20102 | 1223 | | %prec "if" { $$ = NULL; } |
1dbba6cc JF |
1224 | ; |
1225 | ||
36cd3cb9 | 1226 | IfStatement |
2eb8215d | 1227 | : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); } |
1dbba6cc | 1228 | ; |
63cd45c9 | 1229 | /* }}} */ |
1dbba6cc | 1230 | |
63cd45c9 | 1231 | /* 12.6.1 The do-while Statement {{{ */ |
d5618df7 | 1232 | IterationStatement |
2eb8215d | 1233 | : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); } |
1dbba6cc | 1234 | ; |
63cd45c9 JF |
1235 | /* }}} */ |
1236 | /* 12.6.2 The while Statement {{{ */ | |
d5618df7 | 1237 | IterationStatement |
2eb8215d | 1238 | : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); } |
1dbba6cc | 1239 | ; |
63cd45c9 JF |
1240 | /* }}} */ |
1241 | /* 12.6.3 The for Statement {{{ */ | |
d5618df7 | 1242 | IterationStatement |
440424e2 | 1243 | : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); } |
1dbba6cc JF |
1244 | ; |
1245 | ||
36cd3cb9 | 1246 | ForStatementInitialiser |
3ea7eed0 | 1247 | : ExpressionOpt { $$ = $1; } |
a87d7060 | 1248 | | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); } |
1dbba6cc | 1249 | ; |
63cd45c9 | 1250 | /* }}} */ |
0d56ef32 | 1251 | /* 12.6.4 The for-in and for-of Statements {{{ */ |
d5618df7 | 1252 | IterationStatement |
440424e2 JF |
1253 | : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); } |
1254 | | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); } | |
1dbba6cc JF |
1255 | ; |
1256 | ||
36cd3cb9 JF |
1257 | ForInStatementInitialiser |
1258 | : LeftHandSideExpression { $$ = $1; } | |
a87d7060 | 1259 | | LexSetRegExp Var_ VariableDeclaration { $$ = $3; } |
1dbba6cc | 1260 | ; |
63cd45c9 | 1261 | /* }}} */ |
1dbba6cc | 1262 | |
63cd45c9 | 1263 | /* 12.7 The continue Statement {{{ */ |
36cd3cb9 | 1264 | ContinueStatement |
5ccfc586 JF |
1265 | : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); } |
1266 | | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); } | |
1dbba6cc | 1267 | ; |
63cd45c9 JF |
1268 | /* }}} */ |
1269 | /* 12.8 The break Statement {{{ */ | |
36cd3cb9 | 1270 | BreakStatement |
5ccfc586 JF |
1271 | : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); } |
1272 | | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); } | |
1dbba6cc | 1273 | ; |
63cd45c9 JF |
1274 | /* }}} */ |
1275 | /* 12.9 The return Statement {{{ */ | |
36cd3cb9 | 1276 | ReturnStatement |
e0815d86 | 1277 | : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); } |
5ccfc586 | 1278 | | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); } |
1dbba6cc | 1279 | ; |
63cd45c9 JF |
1280 | /* }}} */ |
1281 | /* 12.10 The with Statement {{{ */ | |
36cd3cb9 | 1282 | WithStatement |
2eb8215d | 1283 | : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); } |
1dbba6cc | 1284 | ; |
63cd45c9 | 1285 | /* }}} */ |
1dbba6cc | 1286 | |
63cd45c9 | 1287 | /* 12.11 The switch Statement {{{ */ |
36cd3cb9 | 1288 | SwitchStatement |
2eb8215d | 1289 | : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); } |
1dbba6cc JF |
1290 | ; |
1291 | ||
1292 | CaseBlock | |
3ea7eed0 | 1293 | : BRACE CaseClausesOpt "}" { $$ = $2; } |
1dbba6cc JF |
1294 | ; |
1295 | ||
55fc1817 JF |
1296 | CaseClause |
1297 | : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); } | |
1298 | ; | |
1299 | ||
36cd3cb9 | 1300 | CaseClausesOpt |
cf7d4c69 JF |
1301 | : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } |
1302 | | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1303 | | { $$ = NULL; } | |
1dbba6cc JF |
1304 | ; |
1305 | ||
36cd3cb9 | 1306 | DefaultClause |
2eb8215d | 1307 | : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); } |
1dbba6cc | 1308 | ; |
63cd45c9 JF |
1309 | /* }}} */ |
1310 | /* 12.12 Labelled Statements {{{ */ | |
36cd3cb9 | 1311 | LabelledStatement |
2eb8215d | 1312 | : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); } |
1dbba6cc | 1313 | ; |
63cd45c9 JF |
1314 | /* }}} */ |
1315 | /* 12.13 The throw Statement {{{ */ | |
36cd3cb9 | 1316 | ThrowStatement |
e0815d86 | 1317 | : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; } |
5ccfc586 | 1318 | | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); } |
1dbba6cc | 1319 | ; |
63cd45c9 JF |
1320 | /* }}} */ |
1321 | /* 12.14 The try Statement {{{ */ | |
36cd3cb9 | 1322 | TryStatement |
2eb8215d | 1323 | : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); } |
1dbba6cc JF |
1324 | ; |
1325 | ||
1326 | CatchOpt | |
2eb8215d | 1327 | : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); } |
cf7d4c69 | 1328 | | { $$ = NULL; } |
1dbba6cc JF |
1329 | ; |
1330 | ||
1331 | FinallyOpt | |
2eb8215d | 1332 | : "finally" Block_ { $$ = CYNew CYFinally($2); } |
cf7d4c69 | 1333 | | { $$ = NULL; } |
1dbba6cc | 1334 | ; |
63cd45c9 | 1335 | /* }}} */ |
c8a0500b JF |
1336 | /* 12.14 The debugger Statement {{{ */ |
1337 | DebuggerStatement | |
1338 | : "debugger" Terminator { $$ = CYNew CYDebugger(); } | |
1339 | ; | |
1340 | /* }}} */ | |
1dbba6cc | 1341 | |
4b2fd91c | 1342 | /* 13.1 Function Definitions {{{ */ |
36cd3cb9 | 1343 | FunctionDeclaration |
3ea7eed0 | 1344 | : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); } |
1dbba6cc JF |
1345 | ; |
1346 | ||
36cd3cb9 | 1347 | FunctionExpression |
440424e2 | 1348 | : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); } |
1dbba6cc JF |
1349 | ; |
1350 | ||
1351 | FormalParameterList_ | |
36cd3cb9 | 1352 | : "," FormalParameterList { $$ = $2; } |
cf7d4c69 | 1353 | | { $$ = NULL; } |
1dbba6cc JF |
1354 | ; |
1355 | ||
c8a0500b JF |
1356 | FormalParameterList |
1357 | // XXX: : FunctionRestParameter { $$ = $1; } | |
1358 | : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); } | |
1359 | ; | |
1360 | ||
55fc1817 JF |
1361 | FormalParameterListOpt |
1362 | : FormalParameterList | |
1363 | | { $$ = NULL; } | |
1364 | ; | |
1365 | ||
c8a0500b JF |
1366 | /* XXX: FunctionRestParameter |
1367 | : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); } | |
1368 | ;*/ | |
1369 | ||
1370 | FormalParameter | |
1371 | : BindingElement { $$ = $1; } | |
1372 | ; | |
1373 | ||
36cd3cb9 | 1374 | FunctionBody |
c8a0500b | 1375 | : StatementListOpt { $$ = $1; } |
1dbba6cc | 1376 | ; |
63cd45c9 | 1377 | /* }}} */ |
4b2fd91c JF |
1378 | /* 13.2 Arrow Function Definitions {{{ */ |
1379 | ArrowFunction | |
a0be43fc | 1380 | : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); } |
4b2fd91c JF |
1381 | ; |
1382 | ||
1383 | ArrowParameters | |
1384 | : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); } | |
1385 | //| ParentheticalOpt { $$ = $1; } | |
1386 | ; | |
1387 | ||
1388 | ConciseBody | |
1389 | : AssignmentExpression { $$ = CYNew CYReturn($1); } | |
440424e2 | 1390 | | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; } |
4b2fd91c JF |
1391 | ; |
1392 | /* }}} */ | |
63cd45c9 | 1393 | /* 14 Program {{{ */ |
1dbba6cc | 1394 | Program |
c8a0500b | 1395 | : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); } |
1dbba6cc JF |
1396 | ; |
1397 | ||
55fc1817 JF |
1398 | ProgramBody |
1399 | : StatementList { $$ = $1; } | |
1400 | ; | |
1401 | ||
c8a0500b JF |
1402 | ProgramBodyOpt |
1403 | : ProgramBody { $$ = $1; } | |
5d660bed | 1404 | | LexSetStatement LexSetRegExp { $$ = NULL; } |
1dbba6cc | 1405 | ; |
63cd45c9 | 1406 | /* }}} */ |
e5332278 | 1407 | |
7b750785 JF |
1408 | @begin C |
1409 | /* Cycript (C): Type Encoding {{{ */ | |
663c538f | 1410 | TypeParenthetical |
9a39f705 | 1411 | : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; } |
663c538f JF |
1412 | ; |
1413 | ||
1414 | TypeSignifier | |
3fe283c5 | 1415 | : IdentifierType { $$ = CYNew CYTypedIdentifier($1); } |
9a39f705 | 1416 | | TypeParenthetical { $$ = $1; } |
663c538f JF |
1417 | ; |
1418 | ||
1419 | ArrayedType | |
9a39f705 | 1420 | : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); } |
663c538f | 1421 | | TypeSignifier { $$ = $1; } |
9a39f705 JF |
1422 | | { $$ = CYNew CYTypedIdentifier(); } |
1423 | ; | |
1424 | ||
1425 | FunctionedType | |
1426 | : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); } | |
663c538f JF |
1427 | ; |
1428 | ||
46f4f308 | 1429 | SuffixedType |
663c538f | 1430 | : ArrayedType { $$ = $1; } |
3fe16be7 | 1431 | | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); } |
9a39f705 JF |
1432 | | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; } |
1433 | | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; } | |
46f4f308 JF |
1434 | ; |
1435 | ||
1436 | PrefixedType | |
9a39f705 | 1437 | : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); } |
46f4f308 JF |
1438 | ; |
1439 | ||
663c538f | 1440 | TypeQualifierLeft |
3fe283c5 JF |
1441 | : { $$ = NULL; } |
1442 | | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); } | |
1443 | | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); } | |
663c538f JF |
1444 | ; |
1445 | ||
1446 | TypeQualifierRight | |
3fe283c5 | 1447 | : PrefixedType { $$ = $1; } |
9a39f705 | 1448 | | SuffixedType { $$ = $1; } |
3fe283c5 JF |
1449 | | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); } |
1450 | | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); } | |
1451 | ; | |
1452 | ||
1453 | IntegerType | |
1454 | : "int" { $$ = CYNew CYTypeVariable("int"); } | |
1455 | | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); } | |
1456 | | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); } | |
1457 | | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); } | |
1458 | | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); } | |
1459 | ; | |
1460 | ||
1461 | IntegerTypeOpt | |
1462 | : IntegerType { $$ = $1; } | |
22e0b32a | 1463 | | { $$ = CYNew CYTypeVariable("int"); } |
56e02e5b JF |
1464 | ; |
1465 | ||
663c538f | 1466 | PrimitiveType |
3fe283c5 JF |
1467 | : IdentifierType { $$ = CYNew CYTypeVariable($1); } |
1468 | | IntegerType { $$ = $1; } | |
1469 | | "void" { $$ = CYNew CYTypeVoid(); } | |
1470 | | "char" { $$ = CYNew CYTypeVariable("char"); } | |
1471 | | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); } | |
1472 | | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); } | |
46f4f308 JF |
1473 | ; |
1474 | ||
1475 | TypedIdentifier | |
3fe283c5 | 1476 | : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; } |
561e7f1c JF |
1477 | ; |
1478 | ||
1479 | EncodedType | |
9a39f705 | 1480 | : TypedIdentifier { $$ = CYNew CYEncodedType($1); } |
663c538f JF |
1481 | ; |
1482 | ||
46f4f308 | 1483 | PrimaryExpression |
3fc53550 | 1484 | : "@encode" "(" EncodedType ")" { $$ = $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 | |
56e02e5b | 1512 | : "(" LexSetRegExp EncodedType ")" { $$ = $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 | %% |