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