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