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