]>
Commit | Line | Data |
---|---|---|
1 | /* Cycript - Inlining/Optimizing JavaScript Compiler | |
2 | * Copyright (C) 2009 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* Modified BSD License {{{ */ | |
6 | /* | |
7 | * Redistribution and use in source and binary | |
8 | * forms, with or without modification, are permitted | |
9 | * provided that the following conditions are met: | |
10 | * | |
11 | * 1. Redistributions of source code must retain the | |
12 | * above copyright notice, this list of conditions | |
13 | * and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the | |
15 | * above copyright notice, this list of conditions | |
16 | * and the following disclaimer in the documentation | |
17 | * and/or other materials provided with the | |
18 | * distribution. | |
19 | * 3. The name of the author may not be used to endorse | |
20 | * or promote products derived from this software | |
21 | * without specific prior written permission. | |
22 | * | |
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' | |
24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
25 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
26 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE | |
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
30 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
34 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
35 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
36 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | |
38 | /* }}} */ | |
39 | ||
40 | %code top { | |
41 | #include "Cycript.tab.hh" | |
42 | #define scanner driver.scanner_ | |
43 | #define YYSTACKEXPANDABLE 1 | |
44 | } | |
45 | ||
46 | %code requires { | |
47 | #include "Parser.hpp" | |
48 | ||
49 | @begin ObjectiveC | |
50 | #include "ObjectiveC/Syntax.hpp" | |
51 | @end | |
52 | ||
53 | @begin E4X | |
54 | #include "E4X/Syntax.hpp" | |
55 | @end | |
56 | ||
57 | typedef struct { | |
58 | bool newline_; | |
59 | ||
60 | union { | |
61 | bool bool_; | |
62 | ||
63 | CYDriver::Condition condition_; | |
64 | ||
65 | CYArgument *argument_; | |
66 | CYAssignment *assignment_; | |
67 | CYBoolean *boolean_; | |
68 | CYClause *clause_; | |
69 | cy::Syntax::Catch *catch_; | |
70 | CYComment *comment_; | |
71 | CYComprehension *comprehension_; | |
72 | CYCompound *compound_; | |
73 | CYDeclaration *declaration_; | |
74 | CYDeclarations *declarations_; | |
75 | CYElement *element_; | |
76 | CYExpression *expression_; | |
77 | CYFalse *false_; | |
78 | CYFinally *finally_; | |
79 | CYForInitialiser *for_; | |
80 | CYForInInitialiser *forin_; | |
81 | CYFunctionParameter *functionParameter_; | |
82 | CYIdentifier *identifier_; | |
83 | CYInfix *infix_; | |
84 | CYLiteral *literal_; | |
85 | CYMember *member_; | |
86 | CYNull *null_; | |
87 | CYNumber *number_; | |
88 | CYProgram *program_; | |
89 | CYProperty *property_; | |
90 | CYPropertyName *propertyName_; | |
91 | CYStatement *statement_; | |
92 | CYString *string_; | |
93 | CYThis *this_; | |
94 | CYTrue *true_; | |
95 | CYWord *word_; | |
96 | ||
97 | @begin ObjectiveC | |
98 | CYClassName *className_; | |
99 | CYField *field_; | |
100 | CYMessage *message_; | |
101 | CYMessageParameter *messageParameter_; | |
102 | CYSelectorPart *selector_; | |
103 | @end | |
104 | ||
105 | @begin E4X | |
106 | CYAttribute *attribute_; | |
107 | CYPropertyIdentifier *propertyIdentifier_; | |
108 | CYSelector *selector_; | |
109 | @end | |
110 | }; | |
111 | } YYSTYPE; | |
112 | ||
113 | } | |
114 | ||
115 | %code provides { | |
116 | int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner); | |
117 | } | |
118 | ||
119 | %name-prefix "cy" | |
120 | ||
121 | %language "C++" | |
122 | %locations | |
123 | ||
124 | %initial-action { | |
125 | @$.begin.filename = @$.end.filename = &driver.filename_; | |
126 | }; | |
127 | ||
128 | %defines | |
129 | ||
130 | //%glr-parser | |
131 | //%expect 1 | |
132 | ||
133 | %error-verbose | |
134 | ||
135 | %parse-param { CYDriver &driver } | |
136 | %lex-param { void *scanner } | |
137 | ||
138 | @begin E4X | |
139 | %token XMLCDATA | |
140 | %token XMLComment | |
141 | %token XMLPI | |
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 | ||
157 | %token ColonColon "::" | |
158 | %token PeriodPeriod ".." | |
159 | @end | |
160 | ||
161 | @begin E4X ObjectiveC | |
162 | %token At "@" | |
163 | @end | |
164 | ||
165 | %token Ampersand "&" | |
166 | %token AmpersandAmpersand "&&" | |
167 | %token AmpersandEqual "&=" | |
168 | %token Carrot "^" | |
169 | %token CarrotEqual "^=" | |
170 | %token Equal "=" | |
171 | %token EqualEqual "==" | |
172 | %token EqualEqualEqual "===" | |
173 | %token Exclamation "!" | |
174 | %token ExclamationEqual "!=" | |
175 | %token ExclamationEqualEqual "!==" | |
176 | %token Hyphen "-" | |
177 | %token HyphenEqual "-=" | |
178 | %token HyphenHyphen "--" | |
179 | %token HyphenHyphen_ "\n--" | |
180 | %token HyphenRight "->" | |
181 | %token Left "<" | |
182 | %token LeftEqual "<=" | |
183 | %token LeftLeft "<<" | |
184 | %token LeftLeftEqual "<<=" | |
185 | %token Percent "%" | |
186 | %token PercentEqual "%=" | |
187 | %token Period "." | |
188 | %token Pipe "|" | |
189 | %token PipeEqual "|=" | |
190 | %token PipePipe "||" | |
191 | %token Plus "+" | |
192 | %token PlusEqual "+=" | |
193 | %token PlusPlus "++" | |
194 | %token PlusPlus_ "\n++" | |
195 | %token Right ">" | |
196 | %token RightEqual ">=" | |
197 | %token RightRight ">>" | |
198 | %token RightRightEqual ">>=" | |
199 | %token RightRightRight ">>>" | |
200 | %token RightRightRightEqual ">>>=" | |
201 | %token Slash "/" | |
202 | %token SlashEqual "/=" | |
203 | %token Star "*" | |
204 | %token StarEqual "*=" | |
205 | %token Tilde "~" | |
206 | ||
207 | %token Colon ":" | |
208 | %token Comma "," | |
209 | %token Question "?" | |
210 | %token SemiColon ";" | |
211 | %token NewLine "\n" | |
212 | ||
213 | %token <comment_> Comment | |
214 | ||
215 | %token OpenParen "(" | |
216 | %token CloseParen ")" | |
217 | ||
218 | %token OpenBrace "{" | |
219 | %token CloseBrace "}" | |
220 | ||
221 | %token OpenBracket "[" | |
222 | %token CloseBracket "]" | |
223 | ||
224 | %token AtClass "@class" | |
225 | %token AtSelector "@selector" | |
226 | %token AtEnd "@end" | |
227 | ||
228 | %token <false_> False "false" | |
229 | %token <null_> Null "null" | |
230 | %token <true_> True "true" | |
231 | ||
232 | // ES3/ES5/WIE/JSC Reserved | |
233 | %token <word_> Break "break" | |
234 | %token <word_> Case "case" | |
235 | %token <word_> Catch "catch" | |
236 | %token <word_> Continue "continue" | |
237 | %token <word_> Default "default" | |
238 | %token <word_> Delete "delete" | |
239 | %token <word_> Do "do" | |
240 | %token <word_> Else "else" | |
241 | %token <word_> Finally "finally" | |
242 | %token <word_> For "for" | |
243 | %token <word_> Function "function" | |
244 | %token <word_> If "if" | |
245 | %token <word_> In "in" | |
246 | %token <word_> InstanceOf "instanceof" | |
247 | %token <word_> New "new" | |
248 | %token <word_> Return "return" | |
249 | %token <word_> Switch "switch" | |
250 | %token <this_> This "this" | |
251 | %token <word_> Throw "throw" | |
252 | %token <word_> Try "try" | |
253 | %token <word_> TypeOf "typeof" | |
254 | %token <word_> Var "var" | |
255 | %token <word_> Void "void" | |
256 | %token <word_> While "while" | |
257 | %token <word_> With "with" | |
258 | ||
259 | // ES3/IE6 Future, ES5/JSC Reserved | |
260 | %token <word_> Debugger "debugger" | |
261 | ||
262 | // ES3/ES5/IE6 Future, JSC Reserved | |
263 | %token <word_> Const "const" | |
264 | ||
265 | // ES3/ES5/IE6/JSC Future | |
266 | %token <word_> Class "class" | |
267 | %token <word_> Enum "enum" | |
268 | %token <word_> Export "export" | |
269 | %token <word_> Extends "extends" | |
270 | %token <word_> Import "import" | |
271 | %token <word_> Super "super" | |
272 | ||
273 | // ES3 Future, ES5 Strict Future | |
274 | %token <identifier_> Implements "implements" | |
275 | %token <identifier_> Interface "interface" | |
276 | %token <identifier_> Package "package" | |
277 | %token <identifier_> Private "private" | |
278 | %token <identifier_> Protected "protected" | |
279 | %token <identifier_> Public "public" | |
280 | %token <identifier_> Static "static" | |
281 | ||
282 | // ES3 Future | |
283 | %token <identifier_> Abstract "abstract" | |
284 | %token <identifier_> Boolean "boolean" | |
285 | %token <identifier_> Byte "byte" | |
286 | %token <identifier_> Char "char" | |
287 | %token <identifier_> Double "double" | |
288 | %token <identifier_> Final "final" | |
289 | %token <identifier_> Float "float" | |
290 | %token <identifier_> Goto "goto" | |
291 | %token <identifier_> Int "int" | |
292 | %token <identifier_> Long "long" | |
293 | %token <identifier_> Native "native" | |
294 | %token <identifier_> Short "short" | |
295 | %token <identifier_> Synchronized "synchronized" | |
296 | %token <identifier_> Throws "throws" | |
297 | %token <identifier_> Transient "transient" | |
298 | %token <identifier_> Volatile "volatile" | |
299 | ||
300 | // ES5 Strict | |
301 | %token <identifier_> Let "let" | |
302 | %token <identifier_> Yield "yield" | |
303 | ||
304 | // Woah?! | |
305 | %token <identifier_> Each "each" | |
306 | ||
307 | @begin E4X | |
308 | // E4X Conditional | |
309 | %token <identifier_> Namespace "namespace" | |
310 | %token <identifier_> XML "xml" | |
311 | @end | |
312 | ||
313 | %token <identifier_> Identifier_ | |
314 | %token <number_> NumericLiteral | |
315 | %token <string_> StringLiteral | |
316 | %token <literal_> RegularExpressionLiteral | |
317 | ||
318 | %type <expression_> AdditiveExpression | |
319 | %type <expression_> AdditiveExpressionNoBF | |
320 | %type <argument_> ArgumentList | |
321 | %type <argument_> ArgumentList_ | |
322 | %type <argument_> ArgumentListOpt | |
323 | %type <argument_> Arguments | |
324 | %type <literal_> ArrayLiteral | |
325 | %type <expression_> AssigneeExpression | |
326 | %type <expression_> AssigneeExpressionNoBF | |
327 | %type <expression_> AssigneeExpressionNoRE | |
328 | %type <expression_> AssignmentExpression | |
329 | %type <assignment_> AssignmentExpression_ | |
330 | %type <expression_> AssignmentExpressionNoBF | |
331 | %type <expression_> AssignmentExpressionNoIn | |
332 | %type <expression_> BitwiseANDExpression | |
333 | %type <expression_> BitwiseANDExpressionNoBF | |
334 | %type <expression_> BitwiseANDExpressionNoIn | |
335 | %type <statement_> Block | |
336 | %type <statement_> Block_ | |
337 | %type <boolean_> BooleanLiteral | |
338 | %type <expression_> BitwiseORExpression | |
339 | %type <expression_> BitwiseORExpressionNoBF | |
340 | %type <expression_> BitwiseORExpressionNoIn | |
341 | %type <expression_> BitwiseXORExpression | |
342 | %type <expression_> BitwiseXORExpressionNoBF | |
343 | %type <expression_> BitwiseXORExpressionNoIn | |
344 | %type <statement_> BreakStatement | |
345 | %type <expression_> CallExpression | |
346 | %type <expression_> CallExpressionNoBF | |
347 | %type <expression_> CallExpressionNoRE | |
348 | %type <clause_> CaseBlock | |
349 | %type <clause_> CaseClause | |
350 | %type <clause_> CaseClausesOpt | |
351 | %type <catch_> CatchOpt | |
352 | %type <comprehension_> ComprehensionList | |
353 | %type <comprehension_> ComprehensionListOpt | |
354 | %type <expression_> ConditionalExpression | |
355 | %type <expression_> ConditionalExpressionNoBF | |
356 | %type <expression_> ConditionalExpressionNoIn | |
357 | %type <statement_> ContinueStatement | |
358 | %type <clause_> DefaultClause | |
359 | %type <statement_> DoWhileStatement | |
360 | %type <expression_> Element | |
361 | %type <expression_> ElementOpt | |
362 | %type <element_> ElementList | |
363 | %type <element_> ElementListOpt | |
364 | %type <statement_> ElseStatementOpt | |
365 | %type <statement_> EmptyStatement | |
366 | %type <expression_> EqualityExpression | |
367 | %type <expression_> EqualityExpressionNoBF | |
368 | %type <expression_> EqualityExpressionNoIn | |
369 | %type <expression_> Expression | |
370 | %type <expression_> ExpressionOpt | |
371 | %type <compound_> Expression_ | |
372 | %type <expression_> ExpressionNoBF | |
373 | %type <expression_> ExpressionNoIn | |
374 | %type <compound_> ExpressionNoIn_ | |
375 | %type <expression_> ExpressionNoInOpt | |
376 | %type <statement_> ExpressionStatement | |
377 | %type <finally_> FinallyOpt | |
378 | %type <comprehension_> ForComprehension | |
379 | %type <statement_> ForStatement | |
380 | %type <for_> ForStatementInitialiser | |
381 | %type <statement_> ForInStatement | |
382 | %type <forin_> ForInStatementInitialiser | |
383 | %type <functionParameter_> FormalParameterList | |
384 | %type <functionParameter_> FormalParameterList_ | |
385 | %type <statement_> FunctionBody | |
386 | %type <statement_> FunctionDeclaration | |
387 | %type <expression_> FunctionExpression | |
388 | %type <identifier_> Identifier | |
389 | %type <identifier_> IdentifierOpt | |
390 | %type <comprehension_> IfComprehension | |
391 | %type <statement_> IfStatement | |
392 | %type <expression_> Initialiser | |
393 | %type <expression_> InitialiserOpt | |
394 | %type <expression_> InitialiserNoIn | |
395 | %type <expression_> InitialiserNoInOpt | |
396 | %type <statement_> IterationStatement | |
397 | %type <statement_> LabelledStatement | |
398 | %type <expression_> LeftHandSideExpression | |
399 | %type <expression_> LeftHandSideExpressionNoBF | |
400 | %type <expression_> LeftHandSideExpressionNoRE | |
401 | //%type <statement_> LetStatement | |
402 | %type <literal_> Literal | |
403 | %type <literal_> LiteralNoRE | |
404 | %type <literal_> LiteralRE | |
405 | %type <expression_> LogicalANDExpression | |
406 | %type <expression_> LogicalANDExpressionNoBF | |
407 | %type <expression_> LogicalANDExpressionNoIn | |
408 | %type <expression_> LogicalORExpression | |
409 | %type <expression_> LogicalORExpressionNoBF | |
410 | %type <expression_> LogicalORExpressionNoIn | |
411 | %type <member_> MemberAccess | |
412 | %type <expression_> MemberExpression | |
413 | %type <expression_> MemberExpression_ | |
414 | %type <expression_> MemberExpressionNoBF | |
415 | %type <expression_> MemberExpressionNoRE | |
416 | %type <expression_> MultiplicativeExpression | |
417 | %type <expression_> MultiplicativeExpressionNoBF | |
418 | %type <expression_> NewExpression | |
419 | %type <expression_> NewExpression_ | |
420 | %type <expression_> NewExpressionNoBF | |
421 | %type <expression_> NewExpressionNoRE | |
422 | %type <null_> NullLiteral | |
423 | %type <literal_> ObjectLiteral | |
424 | %type <expression_> PostfixExpression | |
425 | %type <expression_> PostfixExpressionNoBF | |
426 | %type <expression_> PostfixExpressionNoRE | |
427 | %type <expression_> PrimaryExpression | |
428 | %type <expression_> PrimaryExpressionNo | |
429 | %type <expression_> PrimaryExpressionNoBF | |
430 | %type <expression_> PrimaryExpressionNoRE | |
431 | %type <expression_> PrimaryExpressionBF | |
432 | %type <statement_> Program | |
433 | %type <propertyName_> PropertyName | |
434 | %type <propertyName_> PropertyName_ | |
435 | %type <property_> PropertyNameAndValueList | |
436 | %type <property_> PropertyNameAndValueList_ | |
437 | %type <property_> PropertyNameAndValueListOpt | |
438 | %type <expression_> RelationalExpression | |
439 | %type <infix_> RelationalExpression_ | |
440 | %type <expression_> RelationalExpressionNoBF | |
441 | %type <expression_> RelationalExpressionNoIn | |
442 | %type <infix_> RelationalExpressionNoIn_ | |
443 | %type <statement_> ReturnStatement | |
444 | %type <expression_> ShiftExpression | |
445 | %type <expression_> ShiftExpressionNoBF | |
446 | %type <statement_> SourceElement | |
447 | %type <statement_> SourceElement_ | |
448 | %type <statement_> SourceElements | |
449 | %type <statement_> Statement | |
450 | %type <statement_> Statement_ | |
451 | %type <statement_> StatementList | |
452 | %type <statement_> StatementListOpt | |
453 | %type <statement_> SwitchStatement | |
454 | %type <statement_> ThrowStatement | |
455 | %type <statement_> TryStatement | |
456 | %type <expression_> UnaryAssigneeExpression | |
457 | %type <expression_> UnaryExpression | |
458 | %type <expression_> UnaryExpression_ | |
459 | %type <expression_> UnaryExpressionNoBF | |
460 | %type <expression_> UnaryExpressionNoRE | |
461 | %type <declaration_> VariableDeclaration | |
462 | %type <declaration_> VariableDeclarationNoIn | |
463 | %type <declarations_> VariableDeclarationList | |
464 | %type <declarations_> VariableDeclarationList_ | |
465 | %type <declarations_> VariableDeclarationListNoIn | |
466 | %type <declarations_> VariableDeclarationListNoIn_ | |
467 | %type <statement_> VariableStatement | |
468 | %type <statement_> WhileStatement | |
469 | %type <statement_> WithStatement | |
470 | ||
471 | @begin ObjectiveC | |
472 | %type <statement_> CategoryStatement | |
473 | %type <expression_> ClassExpression | |
474 | %type <statement_> ClassStatement | |
475 | %type <expression_> ClassSuperOpt | |
476 | %type <field_> ClassFieldList | |
477 | %type <message_> ClassMessageDeclaration | |
478 | %type <message_> ClassMessageDeclarationListOpt | |
479 | %type <className_> ClassName | |
480 | %type <className_> ClassNameOpt | |
481 | %type <expression_> MessageExpression | |
482 | %type <messageParameter_> MessageParameter | |
483 | %type <messageParameter_> MessageParameters | |
484 | %type <messageParameter_> MessageParameterList | |
485 | %type <messageParameter_> MessageParameterListOpt | |
486 | %type <bool_> MessageScope | |
487 | %type <argument_> SelectorCall | |
488 | %type <argument_> SelectorCall_ | |
489 | %type <selector_> SelectorExpression | |
490 | %type <selector_> SelectorExpression_ | |
491 | %type <selector_> SelectorExpressionOpt | |
492 | %type <argument_> SelectorList | |
493 | %type <expression_> TypeOpt | |
494 | %type <argument_> VariadicCall | |
495 | %type <word_> Word | |
496 | %type <word_> WordOpt | |
497 | @end | |
498 | ||
499 | @begin E4X | |
500 | %type <propertyIdentifier_> PropertyIdentifier_ | |
501 | %type <selector_> PropertySelector | |
502 | %type <selector_> PropertySelector_ | |
503 | %type <identifier_> QualifiedIdentifier | |
504 | %type <identifier_> QualifiedIdentifier_ | |
505 | %type <identifier_> WildcardIdentifier | |
506 | %type <identifier_> XMLComment | |
507 | %type <identifier_> XMLCDATA | |
508 | %type <identifier_> XMLElement | |
509 | %type <identifier_> XMLElementContent | |
510 | %type <identifier_> XMLMarkup | |
511 | %type <identifier_> XMLPI | |
512 | ||
513 | %type <attribute_> AttributeIdentifier | |
514 | /* XXX: %type <statement_> DefaultXMLNamespaceStatement */ | |
515 | %type <expression_> PropertyIdentifier | |
516 | %type <expression_> XMLListInitialiser | |
517 | %type <expression_> XMLInitialiser | |
518 | @end | |
519 | ||
520 | %nonassoc Identifier_ "abstract" "boolean" "break" "byte" "case" "catch" "char" "class" "const" "continue" "debugger" "default" "delete" "do" "double" "each" "enum" "export" "extends" "false" "final" "finally" "float" /*"for"*/ "function" "goto" "implements" "import" /*"in"*/ /*"instanceof"*/ "int" "interface" "let" "long" "namespace" "native" "new" "null" "package" "private" "protected" "public" "return" "short" "super" "static" "switch" "synchronized" "this" "throw" "throws" "transient" "true" "try" "typeof" "var" "void" "volatile" "while" "with" "xml" "yield" | |
521 | ||
522 | %nonassoc "if" | |
523 | %nonassoc "else" | |
524 | ||
525 | %nonassoc "++" "--" | |
526 | %nonassoc "(" "[" | |
527 | ||
528 | %left "*" "/" "%" | |
529 | %left "+" "-" | |
530 | %left "<<" ">>" ">>>" | |
531 | %left "<" ">" "<=" ">=" "instanceof" "in" | |
532 | %left "==" "!=" "===" "!==" | |
533 | %left "&" | |
534 | %left "^" | |
535 | %left "|" | |
536 | %left "&&" | |
537 | %left "||" | |
538 | ||
539 | %right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|=" | |
540 | ||
541 | %start Program | |
542 | ||
543 | %% | |
544 | ||
545 | /* Lexer State {{{ */ | |
546 | LexSetRegExp | |
547 | : { driver.SetCondition(CYDriver::RegExpCondition); } | |
548 | ; | |
549 | /* }}} */ | |
550 | ||
551 | StrictSemi | |
552 | : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); } | |
553 | ; | |
554 | ||
555 | Terminator_ | |
556 | : ";" | |
557 | | "\n" StrictSemi | |
558 | ; | |
559 | ||
560 | TerminatorOpt | |
561 | : Terminator_ | |
562 | | error { yyerrok; driver.errors_.pop_back(); } StrictSemi | |
563 | ; | |
564 | ||
565 | Terminator | |
566 | : Terminator_ | |
567 | | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi | |
568 | ; | |
569 | ||
570 | /*CommaOpt | |
571 | : "," | |
572 | | | |
573 | ;*/ | |
574 | ||
575 | @begin ObjectiveC | |
576 | NewLineOpt | |
577 | : "\n" | |
578 | | | |
579 | ; | |
580 | ||
581 | WordOpt | |
582 | : Word { $$ = $1; } | |
583 | | { $$ = NULL; } | |
584 | ; | |
585 | ||
586 | Word | |
587 | : Identifier { $$ = $1; } | |
588 | | "break" NewLineOpt { $$ = $1; } | |
589 | | "case" { $$ = $1; } | |
590 | | "catch" { $$ = $1; } | |
591 | | "class" { $$ = $1; } | |
592 | | "const" { $$ = $1; } | |
593 | | "continue" NewLineOpt { $$ = $1; } | |
594 | | "debugger" { $$ = $1; } | |
595 | | "default" { $$ = $1; } | |
596 | | "delete" { $$ = $1; } | |
597 | | "do" { $$ = $1; } | |
598 | | "else" { $$ = $1; } | |
599 | | "enum" { $$ = $1; } | |
600 | | "export" { $$ = $1; } | |
601 | | "extends" { $$ = $1; } | |
602 | | "false" { $$ = $1; } | |
603 | | "finally" { $$ = $1; } | |
604 | /* XXX: | "for" { $$ = $1; } */ | |
605 | | "function" { $$ = $1; } | |
606 | | "if" { $$ = $1; } | |
607 | | "import" { $$ = $1; } | |
608 | /* XXX: | "in" { $$ = $1; } */ | |
609 | /* XXX: | "instanceof" { $$ = $1; } */ | |
610 | | "new" { $$ = $1; } | |
611 | | "null" { $$ = $1; } | |
612 | | "return" NewLineOpt { $$ = $1; } | |
613 | | "super" { $$ = $1; } | |
614 | | "switch" { $$ = $1; } | |
615 | | "this" { $$ = $1; } | |
616 | | "throw" NewLineOpt { $$ = $1; } | |
617 | | "true" { $$ = $1; } | |
618 | | "try" { $$ = $1; } | |
619 | | "typeof" { $$ = $1; } | |
620 | | "var" { $$ = $1; } | |
621 | | "void" { $$ = $1; } | |
622 | | "while" { $$ = $1; } | |
623 | | "with" { $$ = $1; } | |
624 | ; | |
625 | @end | |
626 | ||
627 | Identifier | |
628 | : Identifier_ { $$ = $1; } | |
629 | ||
630 | | "implements" { $$ = $1; } | |
631 | | "interface" { $$ = $1; } | |
632 | | "package" { $$ = $1; } | |
633 | | "private" { $$ = $1; } | |
634 | | "protected" { $$ = $1; } | |
635 | | "public" { $$ = $1; } | |
636 | | "static" { $$ = $1; } | |
637 | ||
638 | | "abstract" { $$ = $1; } | |
639 | | "boolean" { $$ = $1; } | |
640 | | "byte" { $$ = $1; } | |
641 | | "char" { $$ = $1; } | |
642 | | "double" { $$ = $1; } | |
643 | | "final" { $$ = $1; } | |
644 | | "float" { $$ = $1; } | |
645 | | "goto" { $$ = $1; } | |
646 | | "int" { $$ = $1; } | |
647 | | "long" { $$ = $1; } | |
648 | | "native" { $$ = $1; } | |
649 | | "short" { $$ = $1; } | |
650 | | "synchronized" { $$ = $1; } | |
651 | | "throws" { $$ = $1; } | |
652 | | "transient" { $$ = $1; } | |
653 | | "volatile" { $$ = $1; } | |
654 | ||
655 | | "let" { $$ = $1; } | |
656 | | "yield" { $$ = $1; } | |
657 | ||
658 | | "each" { $$ = $1; } | |
659 | ; | |
660 | ||
661 | IdentifierOpt | |
662 | : Identifier { $$ = $1; } | |
663 | | { $$ = NULL; } | |
664 | ; | |
665 | ||
666 | LiteralNoRE | |
667 | : NullLiteral { $$ = $1; } | |
668 | | BooleanLiteral { $$ = $1; } | |
669 | | NumericLiteral { $$ = $1; } | |
670 | | StringLiteral { $$ = $1; } | |
671 | | "@" StringLiteral { $$ = $2; } | |
672 | ; | |
673 | ||
674 | LiteralRE | |
675 | : RegularExpressionLiteral { $$ = $1; } | |
676 | ; | |
677 | ||
678 | Literal | |
679 | : LiteralNoRE { $$ = $1; } | |
680 | | LiteralRE { $$ = $1; } | |
681 | ; | |
682 | ||
683 | NullLiteral | |
684 | : "null" { $$ = $1; } | |
685 | ; | |
686 | ||
687 | BooleanLiteral | |
688 | : "true" { $$ = $1; } | |
689 | | "false" { $$ = $1; } | |
690 | ; | |
691 | ||
692 | /* 11.1 Primary Expressions {{{ */ | |
693 | PrimaryExpression | |
694 | : LexSetRegExp PrimaryExpressionNoRE { $$ = $2; } | |
695 | ; | |
696 | ||
697 | PrimaryExpressionNoBF | |
698 | : PrimaryExpressionNo { $$ = $1; } | |
699 | ; | |
700 | ||
701 | PrimaryExpressionNoRE | |
702 | : PrimaryExpressionBF { $$ = $1; } | |
703 | | PrimaryExpressionNo { $$ = $1; } | |
704 | ; | |
705 | ||
706 | PrimaryExpressionNo | |
707 | : "this" { $$ = $1; } | |
708 | | Identifier { $$ = new(driver.pool_) CYVariable($1); } | |
709 | | Literal { $$ = $1; } | |
710 | | ArrayLiteral { $$ = $1; } | |
711 | | "(" Expression ")" { $$ = $2; } | |
712 | ; | |
713 | ||
714 | PrimaryExpressionBF | |
715 | : ObjectLiteral { $$ = $1; } | |
716 | ; | |
717 | /* }}} */ | |
718 | /* 11.1.4 Array Initialiser {{{ */ | |
719 | ArrayLiteral | |
720 | : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); } | |
721 | ; | |
722 | ||
723 | Element | |
724 | : AssignmentExpression { $$ = $1; } | |
725 | ; | |
726 | ||
727 | ElementOpt | |
728 | : Element { $$ = $1; } | |
729 | | LexSetRegExp { $$ = NULL; } | |
730 | ; | |
731 | ||
732 | ElementListOpt | |
733 | : ElementList { $$ = $1; } | |
734 | | LexSetRegExp { $$ = NULL; } | |
735 | ; | |
736 | ||
737 | ElementList | |
738 | : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); } | |
739 | | Element { $$ = new(driver.pool_) CYElement($1, NULL); } | |
740 | ; | |
741 | /* }}} */ | |
742 | /* 11.1.5 Object Initialiser {{{ */ | |
743 | ObjectLiteral | |
744 | : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); } | |
745 | ; | |
746 | ||
747 | PropertyNameAndValueList_ | |
748 | : "," PropertyNameAndValueList { $$ = $2; } | |
749 | | { $$ = NULL; } | |
750 | ; | |
751 | ||
752 | PropertyNameAndValueListOpt | |
753 | : PropertyNameAndValueList { $$ = $1; } | |
754 | | { $$ = NULL; } | |
755 | ; | |
756 | ||
757 | PropertyNameAndValueList | |
758 | : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); } | |
759 | ; | |
760 | ||
761 | PropertyName_ | |
762 | : Identifier { $$ = $1; } | |
763 | | StringLiteral { $$ = $1; } | |
764 | | NumericLiteral { $$ = $1; } | |
765 | ; | |
766 | ||
767 | PropertyName | |
768 | : LexSetRegExp PropertyName_ { $$ = $2; } | |
769 | ; | |
770 | /* }}} */ | |
771 | ||
772 | /* 11.2 Left-Hand-Side Expressions {{{ */ | |
773 | MemberExpression_ | |
774 | : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); } | |
775 | ; | |
776 | ||
777 | MemberAccess | |
778 | : "[" Expression "]" { $$ = new(driver.pool_) CYDirectMember(NULL, $2); } | |
779 | | "." Identifier { $$ = new(driver.pool_) CYDirectMember(NULL, new(driver.pool_) CYString($2)); } | |
780 | ; | |
781 | ||
782 | MemberExpression | |
783 | : PrimaryExpression { $$ = $1; } | |
784 | | LexSetRegExp FunctionExpression { $$ = $2; } | |
785 | | MemberExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | |
786 | | LexSetRegExp MemberExpression_ { $$ = $2; } | |
787 | ; | |
788 | ||
789 | MemberExpressionNoBF | |
790 | : PrimaryExpressionNoBF { $$ = $1; } | |
791 | | MemberExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } | |
792 | | MemberExpression_ { $$ = $1; } | |
793 | ; | |
794 | ||
795 | MemberExpressionNoRE | |
796 | : PrimaryExpressionNoRE { $$ = $1; } | |
797 | | FunctionExpression { $$ = $1; } | |
798 | | MemberExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
799 | | MemberExpression_ { $$ = $1; } | |
800 | ; | |
801 | ||
802 | NewExpression_ | |
803 | : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); } | |
804 | ; | |
805 | ||
806 | NewExpression | |
807 | : MemberExpression { $$ = $1; } | |
808 | | LexSetRegExp NewExpression_ { $$ = $2; } | |
809 | ; | |
810 | ||
811 | NewExpressionNoBF | |
812 | : MemberExpressionNoBF { $$ = $1; } | |
813 | | NewExpression_ { $$ = $1; } | |
814 | ; | |
815 | ||
816 | NewExpressionNoRE | |
817 | : MemberExpressionNoRE { $$ = $1; } | |
818 | | NewExpression_ { $$ = $1; } | |
819 | ; | |
820 | ||
821 | CallExpression | |
822 | : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
823 | | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
824 | | CallExpression MemberAccess { $2->SetLeft($1); $$ = $2; } | |
825 | ; | |
826 | ||
827 | CallExpressionNoBF | |
828 | : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
829 | | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
830 | | CallExpressionNoBF MemberAccess { $2->SetLeft($1); $$ = $2; } | |
831 | ; | |
832 | ||
833 | CallExpressionNoRE | |
834 | : MemberExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
835 | | CallExpressionNoRE Arguments { $$ = new(driver.pool_) CYCall($1, $2); } | |
836 | | CallExpressionNoRE MemberAccess { $2->SetLeft($1); $$ = $2; } | |
837 | ; | |
838 | ||
839 | ArgumentList_ | |
840 | : "," ArgumentList { $$ = $2; } | |
841 | | { $$ = NULL; } | |
842 | ; | |
843 | ||
844 | ArgumentListOpt | |
845 | : ArgumentList { $$ = $1; } | |
846 | | LexSetRegExp { $$ = NULL; } | |
847 | ; | |
848 | ||
849 | ArgumentList | |
850 | : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); } | |
851 | ; | |
852 | ||
853 | Arguments | |
854 | : "(" ArgumentListOpt ")" { $$ = $2; } | |
855 | ; | |
856 | ||
857 | LeftHandSideExpression | |
858 | : NewExpression { $$ = $1; } | |
859 | | CallExpression { $$ = $1; } | |
860 | ; | |
861 | ||
862 | LeftHandSideExpressionNoBF | |
863 | : NewExpressionNoBF { $$ = $1; } | |
864 | | CallExpressionNoBF { $$ = $1; } | |
865 | ; | |
866 | ||
867 | LeftHandSideExpressionNoRE | |
868 | : NewExpressionNoRE { $$ = $1; } | |
869 | | CallExpressionNoRE { $$ = $1; } | |
870 | ; | |
871 | /* }}} */ | |
872 | /* 11.3 Postfix Expressions {{{ */ | |
873 | PostfixExpression | |
874 | : AssigneeExpression { $$ = $1; } | |
875 | | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
876 | | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
877 | ; | |
878 | ||
879 | PostfixExpressionNoBF | |
880 | : AssigneeExpressionNoBF { $$ = $1; } | |
881 | | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
882 | | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
883 | ; | |
884 | ||
885 | PostfixExpressionNoRE | |
886 | : AssigneeExpressionNoRE { $$ = $1; } | |
887 | | LeftHandSideExpressionNoRE "++" { $$ = new(driver.pool_) CYPostIncrement($1); } | |
888 | | LeftHandSideExpressionNoRE "--" { $$ = new(driver.pool_) CYPostDecrement($1); } | |
889 | ; | |
890 | /* }}} */ | |
891 | /* 11.4 Unary Operators {{{ */ | |
892 | UnaryExpression_ | |
893 | : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); } | |
894 | | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); } | |
895 | | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); } | |
896 | | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
897 | | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); } | |
898 | | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
899 | | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); } | |
900 | | "+" UnaryExpression { $$ = new(driver.pool_) CYAffirm($2); } | |
901 | | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); } | |
902 | | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); } | |
903 | | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); } | |
904 | ; | |
905 | ||
906 | UnaryExpression | |
907 | : PostfixExpression { $$ = $1; } | |
908 | | LexSetRegExp UnaryExpression_ { $$ = $2; } | |
909 | ; | |
910 | ||
911 | UnaryExpressionNoBF | |
912 | : PostfixExpressionNoBF { $$ = $1; } | |
913 | | UnaryExpression_ { $$ = $1; } | |
914 | ; | |
915 | ||
916 | UnaryExpressionNoRE | |
917 | : PostfixExpressionNoRE { $$ = $1; } | |
918 | | UnaryExpression_ { $$ = $1; } | |
919 | ; | |
920 | /* }}} */ | |
921 | /* 11.5 Multiplicative Operators {{{ */ | |
922 | MultiplicativeExpression | |
923 | : UnaryExpression { $$ = $1; } | |
924 | | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
925 | | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
926 | | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
927 | ; | |
928 | ||
929 | MultiplicativeExpressionNoBF | |
930 | : UnaryExpressionNoBF { $$ = $1; } | |
931 | | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); } | |
932 | | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); } | |
933 | | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); } | |
934 | ; | |
935 | /* }}} */ | |
936 | /* 11.6 Additive Operators {{{ */ | |
937 | AdditiveExpression | |
938 | : MultiplicativeExpression { $$ = $1; } | |
939 | | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
940 | | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
941 | ; | |
942 | ||
943 | AdditiveExpressionNoBF | |
944 | : MultiplicativeExpressionNoBF { $$ = $1; } | |
945 | | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); } | |
946 | | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); } | |
947 | ; | |
948 | /* }}} */ | |
949 | /* 11.7 Bitwise Shift Operators {{{ */ | |
950 | ShiftExpression | |
951 | : AdditiveExpression { $$ = $1; } | |
952 | | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
953 | | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
954 | | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
955 | ; | |
956 | ||
957 | ShiftExpressionNoBF | |
958 | : AdditiveExpressionNoBF { $$ = $1; } | |
959 | | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); } | |
960 | | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); } | |
961 | | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); } | |
962 | ; | |
963 | /* }}} */ | |
964 | /* 11.8 Relational Operators {{{ */ | |
965 | RelationalExpressionNoIn_ | |
966 | : "<" ShiftExpression { $$ = new(driver.pool_) CYLess(NULL, $2); } | |
967 | | ">" ShiftExpression { $$ = new(driver.pool_) CYGreater(NULL, $2); } | |
968 | | "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual(NULL, $2); } | |
969 | | ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual(NULL, $2); } | |
970 | | "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf(NULL, $2); } | |
971 | ; | |
972 | ||
973 | RelationalExpression_ | |
974 | : RelationalExpressionNoIn_ { $$ = $1; } | |
975 | | "in" ShiftExpression { $$ = new(driver.pool_) CYIn(NULL, $2); } | |
976 | ; | |
977 | ||
978 | RelationalExpression | |
979 | : ShiftExpression { $$ = $1; } | |
980 | | RelationalExpression RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
981 | ; | |
982 | ||
983 | RelationalExpressionNoIn | |
984 | : ShiftExpression { $$ = $1; } | |
985 | | RelationalExpressionNoIn RelationalExpressionNoIn_ { $2->SetLeft($1); $$ = $2; } | |
986 | ; | |
987 | ||
988 | RelationalExpressionNoBF | |
989 | : ShiftExpressionNoBF { $$ = $1; } | |
990 | | RelationalExpressionNoBF RelationalExpression_ { $2->SetLeft($1); $$ = $2; } | |
991 | ; | |
992 | /* }}} */ | |
993 | /* 11.9 Equality Operators {{{ */ | |
994 | EqualityExpression | |
995 | : RelationalExpression { $$ = $1; } | |
996 | | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
997 | | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
998 | | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
999 | | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1000 | ; | |
1001 | ||
1002 | EqualityExpressionNoIn | |
1003 | : RelationalExpressionNoIn { $$ = $1; } | |
1004 | | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1005 | | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1006 | | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1007 | | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1008 | ; | |
1009 | ||
1010 | EqualityExpressionNoBF | |
1011 | : RelationalExpressionNoBF { $$ = $1; } | |
1012 | | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); } | |
1013 | | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); } | |
1014 | | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); } | |
1015 | | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); } | |
1016 | ; | |
1017 | /* }}} */ | |
1018 | /* 11.10 Binary Bitwise Operators {{{ */ | |
1019 | BitwiseANDExpression | |
1020 | : EqualityExpression { $$ = $1; } | |
1021 | | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1022 | ; | |
1023 | ||
1024 | BitwiseANDExpressionNoIn | |
1025 | : EqualityExpressionNoIn { $$ = $1; } | |
1026 | | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1027 | ; | |
1028 | ||
1029 | BitwiseANDExpressionNoBF | |
1030 | : EqualityExpressionNoBF { $$ = $1; } | |
1031 | | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); } | |
1032 | ; | |
1033 | ||
1034 | BitwiseXORExpression | |
1035 | : BitwiseANDExpression { $$ = $1; } | |
1036 | | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1037 | ; | |
1038 | ||
1039 | BitwiseXORExpressionNoIn | |
1040 | : BitwiseANDExpressionNoIn { $$ = $1; } | |
1041 | | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1042 | ; | |
1043 | ||
1044 | BitwiseXORExpressionNoBF | |
1045 | : BitwiseANDExpressionNoBF { $$ = $1; } | |
1046 | | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); } | |
1047 | ; | |
1048 | ||
1049 | BitwiseORExpression | |
1050 | : BitwiseXORExpression { $$ = $1; } | |
1051 | | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1052 | ; | |
1053 | ||
1054 | BitwiseORExpressionNoIn | |
1055 | : BitwiseXORExpressionNoIn { $$ = $1; } | |
1056 | | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1057 | ; | |
1058 | ||
1059 | BitwiseORExpressionNoBF | |
1060 | : BitwiseXORExpressionNoBF { $$ = $1; } | |
1061 | | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); } | |
1062 | ; | |
1063 | /* }}} */ | |
1064 | /* 11.11 Binary Logical Operators {{{ */ | |
1065 | LogicalANDExpression | |
1066 | : BitwiseORExpression { $$ = $1; } | |
1067 | | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1068 | ; | |
1069 | ||
1070 | LogicalANDExpressionNoIn | |
1071 | : BitwiseORExpressionNoIn { $$ = $1; } | |
1072 | | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1073 | ; | |
1074 | ||
1075 | LogicalANDExpressionNoBF | |
1076 | : BitwiseORExpressionNoBF { $$ = $1; } | |
1077 | | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); } | |
1078 | ; | |
1079 | ||
1080 | LogicalORExpression | |
1081 | : LogicalANDExpression { $$ = $1; } | |
1082 | | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1083 | ; | |
1084 | ||
1085 | LogicalORExpressionNoIn | |
1086 | : LogicalANDExpressionNoIn { $$ = $1; } | |
1087 | | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1088 | ; | |
1089 | ||
1090 | LogicalORExpressionNoBF | |
1091 | : LogicalANDExpressionNoBF { $$ = $1; } | |
1092 | | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); } | |
1093 | ; | |
1094 | /* }}} */ | |
1095 | /* 11.12 Conditional Operator ( ? : ) {{{ */ | |
1096 | ConditionalExpression | |
1097 | : LogicalORExpression { $$ = $1; } | |
1098 | | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1099 | ; | |
1100 | ||
1101 | ConditionalExpressionNoIn | |
1102 | : LogicalORExpressionNoIn { $$ = $1; } | |
1103 | | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1104 | ; | |
1105 | ||
1106 | ConditionalExpressionNoBF | |
1107 | : LogicalORExpressionNoBF { $$ = $1; } | |
1108 | | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); } | |
1109 | ; | |
1110 | /* }}} */ | |
1111 | /* 11.13 Assignment Operators {{{ */ | |
1112 | AssignmentExpression_ | |
1113 | : "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign(NULL, $2); } | |
1114 | | "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign(NULL, $2); } | |
1115 | | "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign(NULL, $2); } | |
1116 | | "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign(NULL, $2); } | |
1117 | | "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign(NULL, $2); } | |
1118 | | "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign(NULL, $2); } | |
1119 | | "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign(NULL, $2); } | |
1120 | | ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign(NULL, $2); } | |
1121 | | ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign(NULL, $2); } | |
1122 | | "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign(NULL, $2); } | |
1123 | | "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign(NULL, $2); } | |
1124 | | "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign(NULL, $2); } | |
1125 | ; | |
1126 | ||
1127 | AssigneeExpression | |
1128 | : LeftHandSideExpression { $$ = $1; } | |
1129 | | LexSetRegExp UnaryAssigneeExpression { $$ = $2; } | |
1130 | ; | |
1131 | ||
1132 | AssigneeExpressionNoBF | |
1133 | : LeftHandSideExpressionNoBF { $$ = $1; } | |
1134 | | UnaryAssigneeExpression { $$ = $1; } | |
1135 | ; | |
1136 | ||
1137 | AssigneeExpressionNoRE | |
1138 | : LeftHandSideExpressionNoRE { $$ = $1; } | |
1139 | | UnaryAssigneeExpression { $$ = $1; } | |
1140 | ; | |
1141 | ||
1142 | AssignmentExpression | |
1143 | : ConditionalExpression { $$ = $1; } | |
1144 | | AssigneeExpression AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1145 | ; | |
1146 | ||
1147 | AssignmentExpressionNoIn | |
1148 | : ConditionalExpressionNoIn { $$ = $1; } | |
1149 | | AssigneeExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); } | |
1150 | | AssigneeExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); } | |
1151 | | AssigneeExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); } | |
1152 | | AssigneeExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); } | |
1153 | | AssigneeExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); } | |
1154 | | AssigneeExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); } | |
1155 | | AssigneeExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); } | |
1156 | | AssigneeExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); } | |
1157 | | AssigneeExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); } | |
1158 | | AssigneeExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); } | |
1159 | | AssigneeExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); } | |
1160 | | AssigneeExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); } | |
1161 | ; | |
1162 | ||
1163 | AssignmentExpressionNoBF | |
1164 | : ConditionalExpressionNoBF { $$ = $1; } | |
1165 | | AssigneeExpressionNoBF AssignmentExpression_ { $2->SetLeft($1); $$ = $2; } | |
1166 | ; | |
1167 | /* }}} */ | |
1168 | /* 11.14 Comma Operator {{{ */ | |
1169 | Expression_ | |
1170 | : "," Expression { $$ = new(driver.pool_) CYCompound($2); } | |
1171 | | { $$ = NULL; } | |
1172 | ; | |
1173 | ||
1174 | ExpressionNoIn_ | |
1175 | : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); } | |
1176 | | { $$ = NULL; } | |
1177 | ; | |
1178 | ||
1179 | ExpressionOpt | |
1180 | : Expression { $$ = $1; } | |
1181 | | LexSetRegExp { $$ = NULL; } | |
1182 | ; | |
1183 | ||
1184 | ExpressionNoInOpt | |
1185 | : ExpressionNoIn { $$ = $1; } | |
1186 | | LexSetRegExp { $$ = NULL; } | |
1187 | ; | |
1188 | ||
1189 | Expression | |
1190 | : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1191 | ; | |
1192 | ||
1193 | ExpressionNoIn | |
1194 | : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1195 | ; | |
1196 | ||
1197 | ExpressionNoBF | |
1198 | : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; } | |
1199 | ; | |
1200 | /* }}} */ | |
1201 | ||
1202 | /* 12 Statements {{{ */ | |
1203 | Statement_ | |
1204 | : Block { $$ = $1; } | |
1205 | | VariableStatement { $$ = $1; } | |
1206 | | EmptyStatement { $$ = $1; } | |
1207 | | ExpressionStatement { $$ = $1; } | |
1208 | | IfStatement { $$ = $1; } | |
1209 | | IterationStatement { $$ = $1; } | |
1210 | | ContinueStatement { $$ = $1; } | |
1211 | | BreakStatement { $$ = $1; } | |
1212 | | ReturnStatement { $$ = $1; } | |
1213 | | WithStatement { $$ = $1; } | |
1214 | | LabelledStatement { $$ = $1; } | |
1215 | | SwitchStatement { $$ = $1; } | |
1216 | | ThrowStatement { $$ = $1; } | |
1217 | | TryStatement { $$ = $1; } | |
1218 | ; | |
1219 | ||
1220 | Statement | |
1221 | : LexSetRegExp Statement_ { $$ = $2; } | |
1222 | ; | |
1223 | /* }}} */ | |
1224 | /* 12.1 Block {{{ */ | |
1225 | Block_ | |
1226 | : "{" StatementListOpt "}" { $$ = $2; } | |
1227 | ; | |
1228 | ||
1229 | Block | |
1230 | : Block_ { if ($1) $$ = new(driver.pool_) CYBlock($1); else $$ = new(driver.pool_) CYEmpty(); } | |
1231 | ; | |
1232 | ||
1233 | StatementList | |
1234 | : Statement StatementListOpt { $1->SetNext($2); $$ = $1; } | |
1235 | ; | |
1236 | ||
1237 | StatementListOpt | |
1238 | : StatementList { $$ = $1; } | |
1239 | | LexSetRegExp { $$ = NULL; } | |
1240 | ; | |
1241 | /* }}} */ | |
1242 | /* 12.2 Variable Statement {{{ */ | |
1243 | VariableStatement | |
1244 | : "var" VariableDeclarationList Terminator { $$ = new(driver.pool_) CYVar($2); } | |
1245 | ; | |
1246 | ||
1247 | VariableDeclarationList_ | |
1248 | : "," VariableDeclarationList { $$ = $2; } | |
1249 | | { $$ = NULL; } | |
1250 | ; | |
1251 | ||
1252 | VariableDeclarationListNoIn_ | |
1253 | : "," VariableDeclarationListNoIn { $$ = $2; } | |
1254 | | { $$ = NULL; } | |
1255 | ; | |
1256 | ||
1257 | VariableDeclarationList | |
1258 | : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
1259 | ; | |
1260 | ||
1261 | VariableDeclarationListNoIn | |
1262 | : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); } | |
1263 | ; | |
1264 | ||
1265 | VariableDeclaration | |
1266 | : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1267 | ; | |
1268 | ||
1269 | VariableDeclarationNoIn | |
1270 | : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); } | |
1271 | ; | |
1272 | ||
1273 | InitialiserOpt | |
1274 | : Initialiser { $$ = $1; } | |
1275 | | { $$ = NULL; } | |
1276 | ; | |
1277 | ||
1278 | InitialiserNoInOpt | |
1279 | : InitialiserNoIn { $$ = $1; } | |
1280 | | { $$ = NULL; } | |
1281 | ; | |
1282 | ||
1283 | Initialiser | |
1284 | : "=" AssignmentExpression { $$ = $2; } | |
1285 | ; | |
1286 | ||
1287 | InitialiserNoIn | |
1288 | : "=" AssignmentExpressionNoIn { $$ = $2; } | |
1289 | ; | |
1290 | /* }}} */ | |
1291 | /* 12.3 Empty Statement {{{ */ | |
1292 | EmptyStatement | |
1293 | : ";" { $$ = new(driver.pool_) CYEmpty(); } | |
1294 | ; | |
1295 | /* }}} */ | |
1296 | /* 12.4 Expression Statement {{{ */ | |
1297 | ExpressionStatement | |
1298 | : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); } | |
1299 | ; | |
1300 | /* }}} */ | |
1301 | /* 12.5 The if Statement {{{ */ | |
1302 | ElseStatementOpt | |
1303 | : "else" Statement { $$ = $2; } | |
1304 | | %prec "if" { $$ = NULL; } | |
1305 | ; | |
1306 | ||
1307 | IfStatement | |
1308 | : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); } | |
1309 | ; | |
1310 | /* }}} */ | |
1311 | ||
1312 | /* 12.6 Iteration Statements {{{ */ | |
1313 | IterationStatement | |
1314 | : DoWhileStatement { $$ = $1; } | |
1315 | | WhileStatement { $$ = $1; } | |
1316 | | ForStatement { $$ = $1; } | |
1317 | | ForInStatement { $$ = $1; } | |
1318 | ; | |
1319 | /* }}} */ | |
1320 | /* 12.6.1 The do-while Statement {{{ */ | |
1321 | DoWhileStatement | |
1322 | : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); } | |
1323 | ; | |
1324 | /* }}} */ | |
1325 | /* 12.6.2 The while Statement {{{ */ | |
1326 | WhileStatement | |
1327 | : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); } | |
1328 | ; | |
1329 | /* }}} */ | |
1330 | /* 12.6.3 The for Statement {{{ */ | |
1331 | ForStatement | |
1332 | : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); } | |
1333 | ; | |
1334 | ||
1335 | ForStatementInitialiser | |
1336 | : ExpressionNoInOpt { $$ = $1; } | |
1337 | | LexSetRegExp "var" VariableDeclarationListNoIn { $$ = $3; } | |
1338 | ; | |
1339 | /* }}} */ | |
1340 | /* 12.6.4 The for-in Statement {{{ */ | |
1341 | ForInStatement | |
1342 | : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); } | |
1343 | ; | |
1344 | ||
1345 | ForInStatementInitialiser | |
1346 | : LeftHandSideExpression { $$ = $1; } | |
1347 | | LexSetRegExp "var" VariableDeclarationNoIn { $$ = $3; } | |
1348 | ; | |
1349 | /* }}} */ | |
1350 | ||
1351 | /* 12.7 The continue Statement {{{ */ | |
1352 | ContinueStatement | |
1353 | : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); } | |
1354 | ; | |
1355 | /* }}} */ | |
1356 | /* 12.8 The break Statement {{{ */ | |
1357 | BreakStatement | |
1358 | : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); } | |
1359 | ; | |
1360 | /* }}} */ | |
1361 | /* 12.9 The return Statement {{{ */ | |
1362 | ReturnStatement | |
1363 | : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); } | |
1364 | ; | |
1365 | /* }}} */ | |
1366 | /* 12.10 The with Statement {{{ */ | |
1367 | WithStatement | |
1368 | : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); } | |
1369 | ; | |
1370 | /* }}} */ | |
1371 | ||
1372 | /* 12.11 The switch Statement {{{ */ | |
1373 | SwitchStatement | |
1374 | : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); } | |
1375 | ; | |
1376 | ||
1377 | CaseBlock | |
1378 | : "{" CaseClausesOpt "}" { $$ = $2; } | |
1379 | ; | |
1380 | ||
1381 | CaseClausesOpt | |
1382 | : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1383 | | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; } | |
1384 | | { $$ = NULL; } | |
1385 | ; | |
1386 | ||
1387 | CaseClause | |
1388 | : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); } | |
1389 | ; | |
1390 | ||
1391 | DefaultClause | |
1392 | : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); } | |
1393 | ; | |
1394 | /* }}} */ | |
1395 | /* 12.12 Labelled Statements {{{ */ | |
1396 | LabelledStatement | |
1397 | : Identifier ":" Statement { $$ = new(driver.pool_) CYLabel($1, $3); } | |
1398 | ; | |
1399 | /* }}} */ | |
1400 | /* 12.13 The throw Statement {{{ */ | |
1401 | ThrowStatement | |
1402 | : "throw" Expression Terminator { $$ = new(driver.pool_) cy::Syntax::Throw($2); } | |
1403 | ; | |
1404 | /* }}} */ | |
1405 | /* 12.14 The try Statement {{{ */ | |
1406 | TryStatement | |
1407 | : "try" Block_ CatchOpt FinallyOpt { $$ = new(driver.pool_) cy::Syntax::Try($2, $3, $4); } | |
1408 | ; | |
1409 | ||
1410 | CatchOpt | |
1411 | : "catch" "(" Identifier ")" Block_ { $$ = new(driver.pool_) cy::Syntax::Catch($3, $5); } | |
1412 | | { $$ = NULL; } | |
1413 | ; | |
1414 | ||
1415 | FinallyOpt | |
1416 | : "finally" Block_ { $$ = new(driver.pool_) CYFinally($2); } | |
1417 | | { $$ = NULL; } | |
1418 | ; | |
1419 | /* }}} */ | |
1420 | ||
1421 | /* 13 Function Definition {{{ */ | |
1422 | FunctionDeclaration | |
1423 | : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionStatement($2, $4, $7); } | |
1424 | ; | |
1425 | ||
1426 | FunctionExpression | |
1427 | : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunctionExpression($2, $4, $7); } | |
1428 | ; | |
1429 | ||
1430 | FormalParameterList_ | |
1431 | : "," FormalParameterList { $$ = $2; } | |
1432 | | { $$ = NULL; } | |
1433 | ; | |
1434 | ||
1435 | FormalParameterList | |
1436 | : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); } | |
1437 | | { $$ = NULL; } | |
1438 | ; | |
1439 | ||
1440 | FunctionBody | |
1441 | : SourceElements { $$ = $1; } | |
1442 | ; | |
1443 | /* }}} */ | |
1444 | /* 14 Program {{{ */ | |
1445 | Program | |
1446 | : SourceElements { driver.program_ = new(driver.pool_) CYProgram($1); } | |
1447 | ; | |
1448 | ||
1449 | SourceElements | |
1450 | : SourceElement SourceElements { $1->SetNext($2); $$ = $1; } | |
1451 | | LexSetRegExp { $$ = NULL; } | |
1452 | ; | |
1453 | ||
1454 | SourceElement_ | |
1455 | : Statement_ { $$ = $1; } | |
1456 | | FunctionDeclaration { $$ = $1; } | |
1457 | ; | |
1458 | ||
1459 | SourceElement | |
1460 | : LexSetRegExp SourceElement_ { $$ = $2; } | |
1461 | ; | |
1462 | /* }}} */ | |
1463 | ||
1464 | @begin ObjectiveC | |
1465 | /* Cycript (Objective-C): @class Declaration {{{ */ | |
1466 | ClassSuperOpt | |
1467 | /* XXX: why the hell did I choose MemberExpressionNoBF? */ | |
1468 | : ":" LexSetRegExp MemberExpressionNoBF { $$ = $3; } | |
1469 | | { $$ = NULL; } | |
1470 | ; | |
1471 | ||
1472 | ClassFieldList | |
1473 | : "{" "}" { $$ = NULL; } | |
1474 | ; | |
1475 | ||
1476 | MessageScope | |
1477 | : "+" { $$ = false; } | |
1478 | | "-" { $$ = true; } | |
1479 | ; | |
1480 | ||
1481 | TypeOpt | |
1482 | : "(" Expression ")" { $$ = $2; } | |
1483 | | { $$ = NULL; } | |
1484 | ; | |
1485 | ||
1486 | MessageParameter | |
1487 | : Word ":" TypeOpt Identifier { $$ = new(driver.pool_) CYMessageParameter($1, $3, $4); } | |
1488 | ; | |
1489 | ||
1490 | MessageParameterListOpt | |
1491 | : MessageParameterList { $$ = $1; } | |
1492 | | { $$ = NULL; } | |
1493 | ; | |
1494 | ||
1495 | MessageParameterList | |
1496 | : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; } | |
1497 | ; | |
1498 | ||
1499 | MessageParameters | |
1500 | : MessageParameterList { $$ = $1; } | |
1501 | | Word { $$ = new(driver.pool_) CYMessageParameter($1, NULL, NULL); } | |
1502 | ; | |
1503 | ||
1504 | ClassMessageDeclaration | |
1505 | : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new(driver.pool_) CYMessage($1, $2, $3, $5); } | |
1506 | ; | |
1507 | ||
1508 | ClassMessageDeclarationListOpt | |
1509 | : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; } | |
1510 | | { $$ = NULL; } | |
1511 | ; | |
1512 | ||
1513 | ClassName | |
1514 | : Identifier { $$ = $1; } | |
1515 | | "(" AssignmentExpression ")" { $$ = $2; } | |
1516 | ; | |
1517 | ||
1518 | ClassNameOpt | |
1519 | : ClassName { $$ = $1; } | |
1520 | | { $$ = NULL; } | |
1521 | ; | |
1522 | ||
1523 | ClassExpression | |
1524 | : "@class" ClassNameOpt ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassExpression($2, $3, $4, $5); } | |
1525 | ; | |
1526 | ||
1527 | ClassStatement | |
1528 | : "@class" ClassName ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYClassStatement($2, $3, $4, $5); } | |
1529 | ; | |
1530 | ||
1531 | CategoryStatement | |
1532 | : "@class" ClassName ClassMessageDeclarationListOpt "@end" { $$ = new(driver.pool_) CYCategory($2, $3); } | |
1533 | ; | |
1534 | ||
1535 | PrimaryExpressionBF | |
1536 | : ClassExpression { $$ = $1; } | |
1537 | ; | |
1538 | ||
1539 | Statement_ | |
1540 | : ClassStatement { $$ = $1; } | |
1541 | | CategoryStatement { $$ = $1; } | |
1542 | ; | |
1543 | /* }}} */ | |
1544 | /* Cycript (Objective-C): Send Message {{{ */ | |
1545 | VariadicCall | |
1546 | : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); } | |
1547 | | { $$ = NULL; } | |
1548 | ; | |
1549 | ||
1550 | SelectorCall_ | |
1551 | : SelectorCall { $$ = $1; } | |
1552 | | VariadicCall { $$ = $1; } | |
1553 | ; | |
1554 | ||
1555 | SelectorCall | |
1556 | : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); } | |
1557 | ; | |
1558 | ||
1559 | SelectorList | |
1560 | : SelectorCall { $$ = $1; } | |
1561 | | Word { $$ = new(driver.pool_) CYArgument($1, NULL); } | |
1562 | ; | |
1563 | ||
1564 | MessageExpression | |
1565 | : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSendDirect($2, $3); } | |
1566 | | "[" LexSetRegExp "super" SelectorList "]" { $$ = new(driver.pool_) CYSendSuper($4); } | |
1567 | ; | |
1568 | ||
1569 | SelectorExpressionOpt | |
1570 | : SelectorExpression_ { $$ = $1; } | |
1571 | | { $$ = NULL; } | |
1572 | ; | |
1573 | ||
1574 | SelectorExpression_ | |
1575 | : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); } | |
1576 | ; | |
1577 | ||
1578 | SelectorExpression | |
1579 | : SelectorExpression_ { $$ = $1; } | |
1580 | | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); } | |
1581 | ; | |
1582 | ||
1583 | PrimaryExpressionNo | |
1584 | : MessageExpression { $$ = $1; } | |
1585 | | "@selector" "(" SelectorExpression ")" { $$ = new(driver.pool_) CYSelector($3); } | |
1586 | ; | |
1587 | /* }}} */ | |
1588 | @end | |
1589 | ||
1590 | @begin C | |
1591 | /* Cycript (C): Pointer Indirection/Addressing {{{ */ | |
1592 | UnaryAssigneeExpression | |
1593 | : "*" UnaryExpressionNoRE { $$ = new(driver.pool_) CYIndirect($2); } | |
1594 | ; | |
1595 | ||
1596 | UnaryExpression_ | |
1597 | : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); } | |
1598 | ; | |
1599 | ||
1600 | MemberAccess | |
1601 | : "->" "[" Expression "]" { $$ = new(driver.pool_) CYIndirectMember(NULL, $3); } | |
1602 | | "->" Identifier { $$ = new(driver.pool_) CYIndirectMember(NULL, new(driver.pool_) CYString($2)); } | |
1603 | ; | |
1604 | /* }}} */ | |
1605 | @end | |
1606 | ||
1607 | /* YUI: Documentation Comments {{{ */ | |
1608 | Statement_ | |
1609 | : Comment { $$ = $1; } | |
1610 | ; | |
1611 | /* }}} */ | |
1612 | ||
1613 | @begin E4X | |
1614 | /* Lexer State {{{ */ | |
1615 | LexPushRegExp | |
1616 | : { driver.PushCondition(CYDriver::RegExpCondition); } | |
1617 | ; | |
1618 | ||
1619 | LexPushXMLContent | |
1620 | : { driver.PushCondition(CYDriver::XMLContentCondition); } | |
1621 | ; | |
1622 | ||
1623 | LexPushXMLTag | |
1624 | : { driver.PushCondition(CYDriver::XMLTagCondition); } | |
1625 | ; | |
1626 | ||
1627 | LexPop | |
1628 | : { driver.PopCondition(); } | |
1629 | ; | |
1630 | ||
1631 | LexSetXMLContent | |
1632 | : { driver.SetCondition(CYDriver::XMLContentCondition); } | |
1633 | ; | |
1634 | ||
1635 | LexSetXMLTag | |
1636 | : { driver.SetCondition(CYDriver::XMLTagCondition); } | |
1637 | ; | |
1638 | /* }}} */ | |
1639 | ||
1640 | XMLWhitespaceOpt | |
1641 | : XMLWhitespace | |
1642 | | | |
1643 | ; | |
1644 | ||
1645 | /* 8.1 Context Keywords {{{ */ | |
1646 | Identifier | |
1647 | : "namespace" { $$ = $1; } | |
1648 | | "xml" { $$ = $1; } | |
1649 | ; | |
1650 | /* }}} */ | |
1651 | /* 8.3 XML Initialiser Input Elements {{{ */ | |
1652 | XMLMarkup | |
1653 | : XMLComment { $$ = $1; } | |
1654 | | XMLCDATA { $$ = $1; } | |
1655 | | XMLPI { $$ = $1; } | |
1656 | ; | |
1657 | /* }}} */ | |
1658 | /* 11.1 Primary Expressions {{{ */ | |
1659 | PrimaryExpressionNo | |
1660 | : PropertyIdentifier { $$ = new(driver.pool_) CYPropertyVariable($1); } | |
1661 | | XMLInitialiser { $$ = $1; } | |
1662 | | XMLListInitialiser { $$ = $1; } | |
1663 | ; | |
1664 | ||
1665 | PropertyIdentifier | |
1666 | : AttributeIdentifier { $$ = $1; } | |
1667 | | QualifiedIdentifier { $$ = $1; } | |
1668 | | WildcardIdentifier { $$ = $1; } | |
1669 | ; | |
1670 | /* }}} */ | |
1671 | /* 11.1.1 Attribute Identifiers {{{ */ | |
1672 | AttributeIdentifier | |
1673 | : "@" QualifiedIdentifier_ { $$ = new(driver.pool_) CYAttribute($2); } | |
1674 | ; | |
1675 | ||
1676 | PropertySelector_ | |
1677 | : PropertySelector { $$ = $1; } | |
1678 | | "[" Expression "]" { $$ = new(driver.pool_) CYSelector($2); } | |
1679 | ; | |
1680 | ||
1681 | PropertySelector | |
1682 | : Identifier { $$ = new(driver.pool_) CYSelector($1); } | |
1683 | | WildcardIdentifier { $$ = $1; } | |
1684 | ; | |
1685 | /* }}} */ | |
1686 | /* 11.1.2 Qualified Identifiers {{{ */ | |
1687 | QualifiedIdentifier_ | |
1688 | : PropertySelector_ { $$ = new(driver.pool_) CYQualified(NULL, $1); } | |
1689 | | QualifiedIdentifier { $$ = $1; } | |
1690 | ; | |
1691 | ||
1692 | QualifiedIdentifier | |
1693 | : PropertySelector "::" PropertySelector_ { $$ = new(driver.pool_) CYQualified($1, $3); } | |
1694 | ; | |
1695 | /* }}} */ | |
1696 | /* 11.1.3 Wildcard Identifiers {{{ */ | |
1697 | WildcardIdentifier | |
1698 | : "*" { $$ = new(driver.pool_) CYWildcard(); } | |
1699 | ; | |
1700 | /* }}} */ | |
1701 | /* 11.1.4 XML Initialiser {{{ */ | |
1702 | XMLInitialiser | |
1703 | : XMLMarkup { $$ = $1; } | |
1704 | | XMLElement { $$ = $1; } | |
1705 | ; | |
1706 | ||
1707 | XMLElement | |
1708 | : "<" XMLTagContent "/>" LexPop | |
1709 | | "<" XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt ">" LexPop | |
1710 | ; | |
1711 | ||
1712 | XMLTagContent | |
1713 | : LexPushXMLTag XMLTagName XMLAttributes | |
1714 | ; | |
1715 | ||
1716 | XMLExpression | |
1717 | : "{" LexPushRegExp Expression "}" LexPop | |
1718 | ; | |
1719 | ||
1720 | XMLTagName | |
1721 | : XMLExpression | |
1722 | | XMLName | |
1723 | ; | |
1724 | ||
1725 | XMLAttributes_ | |
1726 | : XMLAttributes_ XMLAttribute | |
1727 | | | |
1728 | ; | |
1729 | ||
1730 | XMLAttributes | |
1731 | : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt | |
1732 | | XMLAttributes_ XMLWhitespaceOpt | |
1733 | ; | |
1734 | ||
1735 | XMLAttributeValue_ | |
1736 | : XMLExpression | |
1737 | | XMLAttributeValue | |
1738 | ; | |
1739 | ||
1740 | XMLAttribute | |
1741 | : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_ | |
1742 | ; | |
1743 | ||
1744 | XMLElementContent | |
1745 | : XMLExpression XMLElementContentOpt | |
1746 | | XMLMarkup XMLElementContentOpt | |
1747 | | XMLText XMLElementContentOpt | |
1748 | | XMLElement XMLElementContentOpt | |
1749 | ; | |
1750 | ||
1751 | XMLElementContentOpt | |
1752 | : XMLElementContent | |
1753 | | | |
1754 | ; | |
1755 | /* }}} */ | |
1756 | /* 11.1.5 XMLList Initialiser {{{ */ | |
1757 | XMLListInitialiser | |
1758 | : "<>" LexPushXMLContent XMLElementContent "</>" LexPop { $$ = new(driver.pool_) CYXMLList($3); } | |
1759 | ; | |
1760 | /* }}} */ | |
1761 | /* 11.2 Left-Hand-Side Expressions {{{ */ | |
1762 | PropertyIdentifier_ | |
1763 | : Identifier { $$ = $1; } | |
1764 | | PropertyIdentifier { $$ = $1; } | |
1765 | ; | |
1766 | ||
1767 | MemberAccess | |
1768 | : "." PropertyIdentifier { $$ = new(driver.pool_) CYPropertyMember(NULL, $2); } | |
1769 | | ".." PropertyIdentifier_ { $$ = new(driver.pool_) CYDescendantMember(NULL, $2); } | |
1770 | | "." "(" Expression ")" { $$ = new(driver.pool_) CYFilteringPredicate(NULL, $3); } | |
1771 | ; | |
1772 | /* }}} */ | |
1773 | /* 12.1 The default xml namespace Statement {{{ */ | |
1774 | /* XXX: DefaultXMLNamespaceStatement | |
1775 | : "default" "xml" "namespace" "=" Expression Terminator { $$ = new(driver.pool_) CYDefaultXMLNamespace($5); } | |
1776 | ; | |
1777 | ||
1778 | Statement_ | |
1779 | : DefaultXMLNamespaceStatement { $$ = $1; } | |
1780 | ; */ | |
1781 | /* }}} */ | |
1782 | @end | |
1783 | ||
1784 | /* ECMAScript5: Object Literal Trailing Comma {{{ */ | |
1785 | PropertyNameAndValueList_ | |
1786 | : "," { $$ = NULL; } | |
1787 | ; | |
1788 | /* }}} */ | |
1789 | /* JavaScript 1.7: Array Comprehensions {{{ */ | |
1790 | IfComprehension | |
1791 | : "if" "(" Expression ")" { $$ = new(driver.pool_) CYIfComprehension($3); } | |
1792 | ; | |
1793 | ||
1794 | ForComprehension | |
1795 | : "for" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForInComprehension($3, $5); } | |
1796 | | "for" "each" "(" Identifier "in" Expression ")" { $$ = new(driver.pool_) CYForEachInComprehension($4, $6); } | |
1797 | ; | |
1798 | ||
1799 | ComprehensionListOpt | |
1800 | : ComprehensionList { $$ = $1; } | |
1801 | | IfComprehension { $$ = $1; } | |
1802 | | { $$ = NULL; } | |
1803 | ; | |
1804 | ||
1805 | ComprehensionList | |
1806 | : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; } | |
1807 | ; | |
1808 | ||
1809 | PrimaryExpressionNo | |
1810 | : "[" AssignmentExpression ComprehensionList "]" { $$ = new(driver.pool_) CYArrayComprehension($2, $3); } | |
1811 | ; | |
1812 | /* }}} */ | |
1813 | /* JavaScript 1.7: for each {{{ */ | |
1814 | ForInStatement | |
1815 | : "for" "each" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForEachIn($4, $6, $8); } | |
1816 | ; | |
1817 | /* }}} */ | |
1818 | /* JavaScript 1.7: let Statements {{{ *//* | |
1819 | LetStatement | |
1820 | : "let" "(" VariableDeclarationList ")" Block_ { $$ = new(driver.pool_) CYLet($3, $5); } | |
1821 | ; | |
1822 | ||
1823 | Statement_ | |
1824 | : LetStatement | |
1825 | ; | |
1826 | *//* }}} */ | |
1827 | /* JavaScript FTW: Function Statements {{{ */ | |
1828 | Statement | |
1829 | : LexSetRegExp FunctionDeclaration { driver.Warning(yylloc, "warning, FunctionDeclaration is a SourceElement, not a Statement"); } { $$ = $2; } | |
1830 | ; | |
1831 | /* }}} */ | |
1832 | ||
1833 | %% |