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