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