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