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