2008-12-29 Cameron Zwarich <cwzwarich@uwaterloo.ca>
[WebKit-https.git] / JavaScriptCore / parser / Grammar.y
1 %pure_parser
2
3 %{
4
5 /*
6  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
7  *  Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
8  *  Copyright (C) 2007 Eric Seidel <eric@webkit.org>
9  *
10  *  This library is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU Lesser General Public
12  *  License as published by the Free Software Foundation; either
13  *  version 2 of the License, or (at your option) any later version.
14  *
15  *  This library is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  Lesser General Public License for more details.
19  *
20  *  You should have received a copy of the GNU Lesser General Public
21  *  License along with this library; if not, write to the Free Software
22  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23  *
24  */
25
26 #include "config.h"
27
28 #include <string.h>
29 #include <stdlib.h>
30 #include "JSValue.h"
31 #include "JSObject.h"
32 #include "Nodes.h"
33 #include "Lexer.h"
34 #include "JSString.h"
35 #include "JSGlobalData.h"
36 #include "CommonIdentifiers.h"
37 #include "NodeInfo.h"
38 #include "Parser.h"
39 #include <wtf/MathExtras.h>
40
41 #define YYMAXDEPTH 10000
42 #define YYENABLE_NLS 0
43
44 /* default values for bison */
45 #define YYDEBUG 0 // Set to 1 to debug a parse error.
46 #if !PLATFORM(DARWIN)
47     // avoid triggering warnings in older bison
48 #define YYERROR_VERBOSE
49 #endif
50
51 int kjsyylex(void* lvalp, void* llocp, void* globalPtr);
52 int kjsyyerror(const char*);
53 static inline bool allowAutomaticSemicolon(JSC::Lexer&, int);
54
55 #define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr)
56 #define LEXER (GLOBAL_DATA->lexer)
57
58 #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0)
59 #define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceCode((divot), (divot) - (start), (end) - (divot))
60 #define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line)
61
62 using namespace JSC;
63 using namespace std;
64
65 static ExpressionNode* makeAssignNode(void*, ExpressionNode* loc, Operator, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end);
66 static ExpressionNode* makePrefixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end);
67 static ExpressionNode* makePostfixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end);
68 static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceCode&);
69 static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo, int start, int divot, int end);
70 static ExpressionNode* makeTypeOfNode(void*, ExpressionNode*);
71 static ExpressionNode* makeDeleteNode(void*, ExpressionNode*, int start, int divot, int end);
72 static ExpressionNode* makeNegateNode(void*, ExpressionNode*);
73 static NumberNode* makeNumberNode(void*, double);
74 static ExpressionNode* makeBitwiseNotNode(void*, ExpressionNode*);
75 static ExpressionNode* makeMultNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
76 static ExpressionNode* makeDivNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
77 static ExpressionNode* makeAddNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
78 static ExpressionNode* makeSubNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
79 static ExpressionNode* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
80 static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
81 static StatementNode* makeVarStatementNode(void*, ExpressionNode*);
82 static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init);
83
84 #if COMPILER(MSVC)
85
86 #pragma warning(disable: 4065)
87 #pragma warning(disable: 4244)
88 #pragma warning(disable: 4702)
89
90 // At least some of the time, the declarations of malloc and free that bison
91 // generates are causing warnings. A way to avoid this is to explicitly define
92 // the macros so that bison doesn't try to declare malloc and free.
93 #define YYMALLOC malloc
94 #define YYFREE free
95
96 #endif
97
98 #define YYPARSE_PARAM globalPtr
99 #define YYLEX_PARAM globalPtr
100
101 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls, 
102                                                                        ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls,
103                                                                        CodeFeatures info,
104                                                                        int numConstants) 
105 {
106     ASSERT((info & ~AllFeatures) == 0);
107     NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants};
108     return result;
109 }
110
111 template <typename T> NodeInfo<T> createNodeInfo(T node, CodeFeatures info, int numConstants)
112 {
113     ASSERT((info & ~AllFeatures) == 0);
114     NodeInfo<T> result = {node, info, numConstants};
115     return result;
116 }
117
118 template <typename T> T mergeDeclarationLists(T decls1, T decls2) 
119 {
120     // decls1 or both are null
121     if (!decls1)
122         return decls2;
123     // only decls1 is non-null
124     if (!decls2)
125         return decls1;
126
127     // Both are non-null
128     decls1->data.append(decls2->data);
129     
130     // We manually release the declaration lists to avoid accumulating many many
131     // unused heap allocated vectors
132     decls2->ref();
133     decls2->deref();
134     return decls1;
135 }
136
137 static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, const Identifier& ident, unsigned attrs)
138 {
139     if (!varDecls)
140         varDecls = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
141
142     varDecls->data.append(make_pair(ident, attrs));
143
144 }
145
146 static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, ConstDeclNode* decl)
147 {
148     unsigned attrs = DeclarationStacks::IsConstant;
149     if (decl->m_init)
150         attrs |= DeclarationStacks::HasInitializer;        
151     appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs);
152 }
153
154 %}
155
156 %union {
157     int                 intValue;
158     double              doubleValue;
159     Identifier*         ident;
160
161     // expression subtrees
162     ExpressionNodeInfo  expressionNode;
163     FuncDeclNodeInfo    funcDeclNode;
164     PropertyNodeInfo    propertyNode;
165     ArgumentsNodeInfo   argumentsNode;
166     ConstDeclNodeInfo   constDeclNode;
167     CaseBlockNodeInfo   caseBlockNode;
168     CaseClauseNodeInfo  caseClauseNode;
169     FuncExprNodeInfo    funcExprNode;
170
171     // statement nodes
172     StatementNodeInfo   statementNode;
173     FunctionBodyNode*   functionBodyNode;
174     ProgramNode*        programNode;
175
176     SourceElementsInfo  sourceElements;
177     PropertyListInfo    propertyList;
178     ArgumentListInfo    argumentList;
179     VarDeclListInfo     varDeclList;
180     ConstDeclListInfo   constDeclList;
181     ClauseListInfo      clauseList;
182     ElementListInfo     elementList;
183     ParameterListInfo   parameterList;
184
185     Operator            op;
186 }
187
188 %start Program
189
190 /* literals */
191 %token NULLTOKEN TRUETOKEN FALSETOKEN
192
193 /* keywords */
194 %token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE
195 %token FUNCTION RETURN VOIDTOKEN DELETETOKEN
196 %token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF
197 %token SWITCH WITH RESERVED
198 %token THROW TRY CATCH FINALLY
199 %token DEBUGGER
200
201 /* give an if without an else higher precedence than an else to resolve the ambiguity */
202 %nonassoc IF_WITHOUT_ELSE
203 %nonassoc ELSE
204
205 /* punctuators */
206 %token EQEQ NE                     /* == and != */
207 %token STREQ STRNEQ                /* === and !== */
208 %token LE GE                       /* < and > */
209 %token OR AND                      /* || and && */
210 %token PLUSPLUS MINUSMINUS         /* ++ and --  */
211 %token LSHIFT                      /* << */
212 %token RSHIFT URSHIFT              /* >> and >>> */
213 %token PLUSEQUAL MINUSEQUAL        /* += and -= */
214 %token MULTEQUAL DIVEQUAL          /* *= and /= */
215 %token LSHIFTEQUAL                 /* <<= */
216 %token RSHIFTEQUAL URSHIFTEQUAL    /* >>= and >>>= */
217 %token ANDEQUAL MODEQUAL           /* &= and %= */
218 %token XOREQUAL OREQUAL            /* ^= and |= */
219 %token <intValue> OPENBRACE        /* { (with char offset) */
220 %token <intValue> CLOSEBRACE        /* { (with char offset) */
221
222 /* terminal types */
223 %token <doubleValue> NUMBER
224 %token <ident> IDENT STRING
225
226 /* automatically inserted semicolon */
227 %token AUTOPLUSPLUS AUTOMINUSMINUS
228
229 /* non-terminal types */
230 %type <expressionNode>  Literal ArrayLiteral
231
232 %type <expressionNode>  PrimaryExpr PrimaryExprNoBrace
233 %type <expressionNode>  MemberExpr MemberExprNoBF /* BF => brace or function */
234 %type <expressionNode>  NewExpr NewExprNoBF
235 %type <expressionNode>  CallExpr CallExprNoBF
236 %type <expressionNode>  LeftHandSideExpr LeftHandSideExprNoBF
237 %type <expressionNode>  PostfixExpr PostfixExprNoBF
238 %type <expressionNode>  UnaryExpr UnaryExprNoBF UnaryExprCommon
239 %type <expressionNode>  MultiplicativeExpr MultiplicativeExprNoBF
240 %type <expressionNode>  AdditiveExpr AdditiveExprNoBF
241 %type <expressionNode>  ShiftExpr ShiftExprNoBF
242 %type <expressionNode>  RelationalExpr RelationalExprNoIn RelationalExprNoBF
243 %type <expressionNode>  EqualityExpr EqualityExprNoIn EqualityExprNoBF
244 %type <expressionNode>  BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF
245 %type <expressionNode>  BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF
246 %type <expressionNode>  BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF
247 %type <expressionNode>  LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF
248 %type <expressionNode>  LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF
249 %type <expressionNode>  ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF
250 %type <expressionNode>  AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF
251 %type <expressionNode>  Expr ExprNoIn ExprNoBF
252
253 %type <expressionNode>  ExprOpt ExprNoInOpt
254
255 %type <statementNode>   Statement Block
256 %type <statementNode>   VariableStatement ConstStatement EmptyStatement ExprStatement
257 %type <statementNode>   IfStatement IterationStatement ContinueStatement
258 %type <statementNode>   BreakStatement ReturnStatement WithStatement
259 %type <statementNode>   SwitchStatement LabelledStatement
260 %type <statementNode>   ThrowStatement TryStatement
261 %type <statementNode>   DebuggerStatement
262
263 %type <expressionNode>  Initializer InitializerNoIn
264 %type <statementNode>   FunctionDeclaration
265 %type <funcExprNode>    FunctionExpr
266 %type <functionBodyNode>  FunctionBody
267 %type <sourceElements>  SourceElements
268 %type <parameterList>   FormalParameterList
269 %type <op>              AssignmentOperator
270 %type <argumentsNode>   Arguments
271 %type <argumentList>    ArgumentList
272 %type <varDeclList>     VariableDeclarationList VariableDeclarationListNoIn
273 %type <constDeclList>   ConstDeclarationList
274 %type <constDeclNode>   ConstDeclaration
275 %type <caseBlockNode>   CaseBlock
276 %type <caseClauseNode>  CaseClause DefaultClause
277 %type <clauseList>      CaseClauses CaseClausesOpt
278 %type <intValue>        Elision ElisionOpt
279 %type <elementList>     ElementList
280 %type <propertyNode>    Property
281 %type <propertyList>    PropertyList
282 %%
283
284 // FIXME: There are currently two versions of the grammar in this file, the normal one, and the NoNodes version used for
285 // lazy recompilation of FunctionBodyNodes.  We should move to generating the two versions from a script to avoid bugs.
286 // In the mean time, make sure to make any changes to the grammar in both versions.
287
288 Literal:
289     NULLTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); }
290   | TRUETOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); }
291   | FALSETOKEN                          { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); }
292   | NUMBER                              { $$ = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, $1), 0, 1); }
293   | STRING                              { $$ = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *$1), 0, 1); }
294   | '/' /* regexp */                    {
295                                             Lexer& l = *LEXER;
296                                             if (!l.scanRegExp())
297                                                 YYABORT;
298                                             RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags());
299                                             int size = l.pattern().size() + 2; // + 2 for the two /'s
300                                             SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
301                                             $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
302                                         }
303   | DIVEQUAL /* regexp with /= */       {
304                                             Lexer& l = *LEXER;
305                                             if (!l.scanRegExp())
306                                                 YYABORT;
307                                             RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags());
308                                             int size = l.pattern().size() + 2; // + 2 for the two /'s
309                                             SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
310                                             $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
311                                         }
312 ;
313
314 Property:
315     IDENT ':' AssignmentExpr            { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
316   | STRING ':' AssignmentExpr           { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
317   | NUMBER ':' AssignmentExpr           { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
318   | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE    { $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, 0, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); if (!$$.m_node) YYABORT; }
319   | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
320                                                              {
321                                                                  $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0); 
322                                                                  if ($4.m_features & ArgumentsFeature)
323                                                                      $7->setUsesArguments(); 
324                                                                  DBG($7, @6, @8); 
325                                                                  if (!$$.m_node) 
326                                                                      YYABORT; 
327                                                              }
328 ;
329
330 PropertyList:
331     Property                            { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node); 
332                                           $$.m_node.tail = $$.m_node.head;
333                                           $$.m_features = $1.m_features;
334                                           $$.m_numConstants = $1.m_numConstants; }
335   | PropertyList ',' Property           { $$.m_node.head = $1.m_node.head;
336                                           $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail);
337                                           $$.m_features = $1.m_features | $3.m_features;
338                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
339 ;
340
341 PrimaryExpr:
342     PrimaryExprNoBrace
343   | OPENBRACE CLOSEBRACE                             { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); }
344   | OPENBRACE PropertyList CLOSEBRACE                { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
345   /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */
346   | OPENBRACE PropertyList ',' CLOSEBRACE            { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
347 ;
348
349 PrimaryExprNoBrace:
350     THISTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }
351   | Literal
352   | ArrayLiteral
353   | IDENT                               { $$ = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
354   | '(' Expr ')'                        { $$ = $2; }
355 ;
356
357 ArrayLiteral:
358     '[' ElisionOpt ']'                  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); }
359   | '[' ElementList ']'                 { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
360   | '[' ElementList ',' ElisionOpt ']'  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); }
361 ;
362
363 ElementList:
364     ElisionOpt AssignmentExpr           { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node);
365                                           $$.m_node.tail = $$.m_node.head;
366                                           $$.m_features = $2.m_features;
367                                           $$.m_numConstants = $2.m_numConstants; }
368   | ElementList ',' ElisionOpt AssignmentExpr
369                                         { $$.m_node.head = $1.m_node.head;
370                                           $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node);
371                                           $$.m_features = $1.m_features | $4.m_features;
372                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; }
373 ;
374
375 ElisionOpt:
376     /* nothing */                       { $$ = 0; }
377   | Elision
378 ;
379
380 Elision:
381     ','                                 { $$ = 1; }
382   | Elision ','                         { $$ = $1 + 1; }
383 ;
384
385 MemberExpr:
386     PrimaryExpr
387   | FunctionExpr                        { $$ = createNodeInfo<ExpressionNode*>($1.m_node, $1.m_features, $1.m_numConstants); }
388   | MemberExpr '[' Expr ']'             { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
389                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
390                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
391                                         }
392   | MemberExpr '.' IDENT                { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
393                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
394                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
395                                         }
396   | NEW MemberExpr Arguments            { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
397                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
398                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
399                                         }
400 ;
401
402 MemberExprNoBF:
403     PrimaryExprNoBrace
404   | MemberExprNoBF '[' Expr ']'         { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
405                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
406                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
407                                         }
408   | MemberExprNoBF '.' IDENT            { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
409                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
410                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
411                                         }
412   | NEW MemberExpr Arguments            { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
413                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
414                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
415                                         }
416 ;
417
418 NewExpr:
419     MemberExpr
420   | NEW NewExpr                         { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
421                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
422                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants); 
423                                         }
424 ;
425
426 NewExprNoBF:
427     MemberExprNoBF
428   | NEW NewExpr                         { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
429                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
430                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
431                                         }
432 ;
433
434 CallExpr:
435     MemberExpr Arguments                { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
436   | CallExpr Arguments                  { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
437   | CallExpr '[' Expr ']'               { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
438                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
439                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
440                                         }
441   | CallExpr '.' IDENT                  { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
442                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
443                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); }
444 ;
445
446 CallExprNoBF:
447     MemberExprNoBF Arguments            { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
448   | CallExprNoBF Arguments              { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
449   | CallExprNoBF '[' Expr ']'           { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
450                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
451                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
452                                         }
453   | CallExprNoBF '.' IDENT              { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
454                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
455                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); 
456                                         }
457 ;
458
459 Arguments:
460     '(' ')'                             { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA), 0, 0); }
461   | '(' ArgumentList ')'                { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
462 ;
463
464 ArgumentList:
465     AssignmentExpr                      { $$.m_node.head = new ArgumentListNode(GLOBAL_DATA, $1.m_node);
466                                           $$.m_node.tail = $$.m_node.head;
467                                           $$.m_features = $1.m_features;
468                                           $$.m_numConstants = $1.m_numConstants; }
469   | ArgumentList ',' AssignmentExpr     { $$.m_node.head = $1.m_node.head;
470                                           $$.m_node.tail = new ArgumentListNode(GLOBAL_DATA, $1.m_node.tail, $3.m_node);
471                                           $$.m_features = $1.m_features | $3.m_features;
472                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
473 ;
474
475 LeftHandSideExpr:
476     NewExpr
477   | CallExpr
478 ;
479
480 LeftHandSideExprNoBF:
481     NewExprNoBF
482   | CallExprNoBF
483 ;
484
485 PostfixExpr:
486     LeftHandSideExpr
487   | LeftHandSideExpr PLUSPLUS           { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
488   | LeftHandSideExpr MINUSMINUS         { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
489 ;
490
491 PostfixExprNoBF:
492     LeftHandSideExprNoBF
493   | LeftHandSideExprNoBF PLUSPLUS       { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
494   | LeftHandSideExprNoBF MINUSMINUS     { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
495 ;
496
497 UnaryExprCommon:
498     DELETETOKEN UnaryExpr               { $$ = createNodeInfo<ExpressionNode*>(makeDeleteNode(GLOBAL_DATA, $2.m_node, @1.first_column, @2.last_column, @2.last_column), $2.m_features, $2.m_numConstants); }
499   | VOIDTOKEN UnaryExpr                 { $$ = createNodeInfo<ExpressionNode*>(new VoidNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants + 1); }
500   | TYPEOF UnaryExpr                    { $$ = createNodeInfo<ExpressionNode*>(makeTypeOfNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
501   | PLUSPLUS UnaryExpr                  { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
502   | AUTOPLUSPLUS UnaryExpr              { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
503   | MINUSMINUS UnaryExpr                { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
504   | AUTOMINUSMINUS UnaryExpr            { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
505   | '+' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(new UnaryPlusNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
506   | '-' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(makeNegateNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
507   | '~' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(makeBitwiseNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
508   | '!' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(new LogicalNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
509
510 UnaryExpr:
511     PostfixExpr
512   | UnaryExprCommon
513 ;
514
515 UnaryExprNoBF:
516     PostfixExprNoBF
517   | UnaryExprCommon
518 ;
519
520 MultiplicativeExpr:
521     UnaryExpr
522   | MultiplicativeExpr '*' UnaryExpr    { $$ = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
523   | MultiplicativeExpr '/' UnaryExpr    { $$ = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
524   | MultiplicativeExpr '%' UnaryExpr    { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
525 ;
526
527 MultiplicativeExprNoBF:
528     UnaryExprNoBF
529   | MultiplicativeExprNoBF '*' UnaryExpr
530                                         { $$ = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
531   | MultiplicativeExprNoBF '/' UnaryExpr
532                                         { $$ = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
533   | MultiplicativeExprNoBF '%' UnaryExpr
534                                         { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
535 ;
536
537 AdditiveExpr:
538     MultiplicativeExpr
539   | AdditiveExpr '+' MultiplicativeExpr { $$ = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
540   | AdditiveExpr '-' MultiplicativeExpr { $$ = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
541 ;
542
543 AdditiveExprNoBF:
544     MultiplicativeExprNoBF
545   | AdditiveExprNoBF '+' MultiplicativeExpr
546                                         { $$ = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
547   | AdditiveExprNoBF '-' MultiplicativeExpr
548                                         { $$ = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
549 ;
550
551 ShiftExpr:
552     AdditiveExpr
553   | ShiftExpr LSHIFT AdditiveExpr       { $$ = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
554   | ShiftExpr RSHIFT AdditiveExpr       { $$ = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
555   | ShiftExpr URSHIFT AdditiveExpr      { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
556 ;
557
558 ShiftExprNoBF:
559     AdditiveExprNoBF
560   | ShiftExprNoBF LSHIFT AdditiveExpr   { $$ = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
561   | ShiftExprNoBF RSHIFT AdditiveExpr   { $$ = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
562   | ShiftExprNoBF URSHIFT AdditiveExpr  { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
563 ;
564
565 RelationalExpr:
566     ShiftExpr
567   | RelationalExpr '<' ShiftExpr        { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
568   | RelationalExpr '>' ShiftExpr        { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
569   | RelationalExpr LE ShiftExpr         { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
570   | RelationalExpr GE ShiftExpr         { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
571   | RelationalExpr INSTANCEOF ShiftExpr { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
572                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
573                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
574   | RelationalExpr INTOKEN ShiftExpr    { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
575                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
576                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
577 ;
578
579 RelationalExprNoIn:
580     ShiftExpr
581   | RelationalExprNoIn '<' ShiftExpr    { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
582   | RelationalExprNoIn '>' ShiftExpr    { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
583   | RelationalExprNoIn LE ShiftExpr     { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
584   | RelationalExprNoIn GE ShiftExpr     { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
585   | RelationalExprNoIn INSTANCEOF ShiftExpr
586                                         { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
587                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
588                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
589 ;
590
591 RelationalExprNoBF:
592     ShiftExprNoBF
593   | RelationalExprNoBF '<' ShiftExpr    { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
594   | RelationalExprNoBF '>' ShiftExpr    { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
595   | RelationalExprNoBF LE ShiftExpr     { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
596   | RelationalExprNoBF GE ShiftExpr     { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
597   | RelationalExprNoBF INSTANCEOF ShiftExpr
598                                         { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
599                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
600                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
601   | RelationalExprNoBF INTOKEN ShiftExpr 
602                                         { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
603                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
604                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
605 ;
606
607 EqualityExpr:
608     RelationalExpr
609   | EqualityExpr EQEQ RelationalExpr    { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
610   | EqualityExpr NE RelationalExpr      { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
611   | EqualityExpr STREQ RelationalExpr   { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
612   | EqualityExpr STRNEQ RelationalExpr  { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
613 ;
614
615 EqualityExprNoIn:
616     RelationalExprNoIn
617   | EqualityExprNoIn EQEQ RelationalExprNoIn
618                                         { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
619   | EqualityExprNoIn NE RelationalExprNoIn
620                                         { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
621   | EqualityExprNoIn STREQ RelationalExprNoIn
622                                         { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
623   | EqualityExprNoIn STRNEQ RelationalExprNoIn
624                                         { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
625 ;
626
627 EqualityExprNoBF:
628     RelationalExprNoBF
629   | EqualityExprNoBF EQEQ RelationalExpr
630                                         { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
631   | EqualityExprNoBF NE RelationalExpr  { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
632   | EqualityExprNoBF STREQ RelationalExpr
633                                         { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
634   | EqualityExprNoBF STRNEQ RelationalExpr
635                                         { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
636 ;
637
638 BitwiseANDExpr:
639     EqualityExpr
640   | BitwiseANDExpr '&' EqualityExpr     { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
641 ;
642
643 BitwiseANDExprNoIn:
644     EqualityExprNoIn
645   | BitwiseANDExprNoIn '&' EqualityExprNoIn
646                                         { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
647 ;
648
649 BitwiseANDExprNoBF:
650     EqualityExprNoBF
651   | BitwiseANDExprNoBF '&' EqualityExpr { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
652 ;
653
654 BitwiseXORExpr:
655     BitwiseANDExpr
656   | BitwiseXORExpr '^' BitwiseANDExpr   { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
657 ;
658
659 BitwiseXORExprNoIn:
660     BitwiseANDExprNoIn
661   | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn
662                                         { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
663 ;
664
665 BitwiseXORExprNoBF:
666     BitwiseANDExprNoBF
667   | BitwiseXORExprNoBF '^' BitwiseANDExpr
668                                         { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
669 ;
670
671 BitwiseORExpr:
672     BitwiseXORExpr
673   | BitwiseORExpr '|' BitwiseXORExpr    { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
674 ;
675
676 BitwiseORExprNoIn:
677     BitwiseXORExprNoIn
678   | BitwiseORExprNoIn '|' BitwiseXORExprNoIn
679                                         { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
680 ;
681
682 BitwiseORExprNoBF:
683     BitwiseXORExprNoBF
684   | BitwiseORExprNoBF '|' BitwiseXORExpr
685                                         { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
686 ;
687
688 LogicalANDExpr:
689     BitwiseORExpr
690   | LogicalANDExpr AND BitwiseORExpr    { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
691 ;
692
693 LogicalANDExprNoIn:
694     BitwiseORExprNoIn
695   | LogicalANDExprNoIn AND BitwiseORExprNoIn
696                                         { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
697 ;
698
699 LogicalANDExprNoBF:
700     BitwiseORExprNoBF
701   | LogicalANDExprNoBF AND BitwiseORExpr
702                                         { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
703 ;
704
705 LogicalORExpr:
706     LogicalANDExpr
707   | LogicalORExpr OR LogicalANDExpr     { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
708 ;
709
710 LogicalORExprNoIn:
711     LogicalANDExprNoIn
712   | LogicalORExprNoIn OR LogicalANDExprNoIn
713                                         { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
714 ;
715
716 LogicalORExprNoBF:
717     LogicalANDExprNoBF
718   | LogicalORExprNoBF OR LogicalANDExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
719 ;
720
721 ConditionalExpr:
722     LogicalORExpr
723   | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr
724                                         { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
725 ;
726
727 ConditionalExprNoIn:
728     LogicalORExprNoIn
729   | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn
730                                         { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
731 ;
732
733 ConditionalExprNoBF:
734     LogicalORExprNoBF
735   | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr
736                                         { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
737 ;
738
739 AssignmentExpr:
740     ConditionalExpr
741   | LeftHandSideExpr AssignmentOperator AssignmentExpr
742                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, 
743                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); 
744                                         }
745 ;
746
747 AssignmentExprNoIn:
748     ConditionalExprNoIn
749   | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn
750                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, 
751                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
752                                         }
753 ;
754
755 AssignmentExprNoBF:
756     ConditionalExprNoBF
757   | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr
758                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
759                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); 
760                                         }
761 ;
762
763 AssignmentOperator:
764     '='                                 { $$ = OpEqual; }
765   | PLUSEQUAL                           { $$ = OpPlusEq; }
766   | MINUSEQUAL                          { $$ = OpMinusEq; }
767   | MULTEQUAL                           { $$ = OpMultEq; }
768   | DIVEQUAL                            { $$ = OpDivEq; }
769   | LSHIFTEQUAL                         { $$ = OpLShift; }
770   | RSHIFTEQUAL                         { $$ = OpRShift; }
771   | URSHIFTEQUAL                        { $$ = OpURShift; }
772   | ANDEQUAL                            { $$ = OpAndEq; }
773   | XOREQUAL                            { $$ = OpXOrEq; }
774   | OREQUAL                             { $$ = OpOrEq; }
775   | MODEQUAL                            { $$ = OpModEq; }
776 ;
777
778 Expr:
779     AssignmentExpr
780   | Expr ',' AssignmentExpr             { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
781 ;
782
783 ExprNoIn:
784     AssignmentExprNoIn
785   | ExprNoIn ',' AssignmentExprNoIn     { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
786 ;
787
788 ExprNoBF:
789     AssignmentExprNoBF
790   | ExprNoBF ',' AssignmentExpr         { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
791 ;
792
793 Statement:
794     Block
795   | VariableStatement
796   | ConstStatement
797   | FunctionDeclaration
798   | EmptyStatement
799   | ExprStatement
800   | IfStatement
801   | IterationStatement
802   | ContinueStatement
803   | BreakStatement
804   | ReturnStatement
805   | WithStatement
806   | SwitchStatement
807   | LabelledStatement
808   | ThrowStatement
809   | TryStatement
810   | DebuggerStatement
811 ;
812
813 Block:
814     OPENBRACE CLOSEBRACE                             { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0);
815                                           DBG($$.m_node, @1, @2); }
816   | OPENBRACE SourceElements CLOSEBRACE              { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
817                                           DBG($$.m_node, @1, @3); }
818 ;
819
820 VariableStatement:
821     VAR VariableDeclarationList ';'     { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
822                                           DBG($$.m_node, @1, @3); }
823   | VAR VariableDeclarationList error   { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
824                                           DBG($$.m_node, @1, @2);
825                                           AUTO_SEMICOLON; }
826 ;
827
828 VariableDeclarationList:
829     IDENT                               { $$.m_node = 0;
830                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
831                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
832                                           $$.m_funcDeclarations = 0;
833                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
834                                           $$.m_numConstants = 0;
835                                         }
836   | IDENT Initializer                   { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
837                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
838                                           $$.m_node = node;
839                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
840                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
841                                           $$.m_funcDeclarations = 0;
842                                           $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
843                                           $$.m_numConstants = $2.m_numConstants;
844                                         }
845   | VariableDeclarationList ',' IDENT
846                                         { $$.m_node = $1.m_node;
847                                           $$.m_varDeclarations = $1.m_varDeclarations;
848                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
849                                           $$.m_funcDeclarations = 0;
850                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
851                                           $$.m_numConstants = $1.m_numConstants;
852                                         }
853   | VariableDeclarationList ',' IDENT Initializer
854                                         { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
855                                           SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
856                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
857                                           $$.m_varDeclarations = $1.m_varDeclarations;
858                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
859                                           $$.m_funcDeclarations = 0;
860                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
861                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
862                                         }
863 ;
864
865 VariableDeclarationListNoIn:
866     IDENT                               { $$.m_node = 0;
867                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
868                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
869                                           $$.m_funcDeclarations = 0;
870                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
871                                           $$.m_numConstants = 0;
872                                         }
873   | IDENT InitializerNoIn               { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
874                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
875                                           $$.m_node = node;
876                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
877                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
878                                           $$.m_funcDeclarations = 0;
879                                           $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
880                                           $$.m_numConstants = $2.m_numConstants;
881                                         }
882   | VariableDeclarationListNoIn ',' IDENT
883                                         { $$.m_node = $1.m_node;
884                                           $$.m_varDeclarations = $1.m_varDeclarations;
885                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
886                                           $$.m_funcDeclarations = 0;
887                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
888                                           $$.m_numConstants = $1.m_numConstants;
889                                         }
890   | VariableDeclarationListNoIn ',' IDENT InitializerNoIn
891                                         { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
892                                           SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
893                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
894                                           $$.m_varDeclarations = $1.m_varDeclarations;
895                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
896                                           $$.m_funcDeclarations = 0;
897                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
898                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
899                                         }
900 ;
901
902 ConstStatement:
903     CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
904                                           DBG($$.m_node, @1, @3); }
905   | CONSTTOKEN ConstDeclarationList error
906                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
907                                           DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
908 ;
909
910 ConstDeclarationList:
911     ConstDeclaration                    { $$.m_node.head = $1.m_node;
912                                           $$.m_node.tail = $$.m_node.head;
913                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
914                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $1.m_node);
915                                           $$.m_funcDeclarations = 0; 
916                                           $$.m_features = $1.m_features;
917                                           $$.m_numConstants = $1.m_numConstants;
918     }
919   | ConstDeclarationList ',' ConstDeclaration
920                                         {  $$.m_node.head = $1.m_node.head;
921                                           $1.m_node.tail->m_next = $3.m_node;
922                                           $$.m_node.tail = $3.m_node;
923                                           $$.m_varDeclarations = $1.m_varDeclarations;
924                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $3.m_node);
925                                           $$.m_funcDeclarations = 0;
926                                           $$.m_features = $1.m_features | $3.m_features;
927                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
928 ;
929
930 ConstDeclaration:
931     IDENT                               { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, 0), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
932   | IDENT Initializer                   { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, $2.m_node), ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features, $2.m_numConstants); }
933 ;
934
935 Initializer:
936     '=' AssignmentExpr                  { $$ = $2; }
937 ;
938
939 InitializerNoIn:
940     '=' AssignmentExprNoIn              { $$ = $2; }
941 ;
942
943 EmptyStatement:
944     ';'                                 { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); }
945 ;
946
947 ExprStatement:
948     ExprNoBF ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
949                                           DBG($$.m_node, @1, @2); }
950   | ExprNoBF error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
951                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
952 ;
953
954 IfStatement:
955     IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE
956                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new IfNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
957                                           DBG($$.m_node, @1, @4); }
958   | IF '(' Expr ')' Statement ELSE Statement
959                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new IfElseNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node), 
960                                                                                          mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations),
961                                                                                          $3.m_features | $5.m_features | $7.m_features,
962                                                                                          $3.m_numConstants + $5.m_numConstants + $7.m_numConstants); 
963                                           DBG($$.m_node, @1, @4); }
964 ;
965
966 IterationStatement:
967     DO Statement WHILE '(' Expr ')' ';'    { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
968                                              DBG($$.m_node, @1, @3); }
969   | DO Statement WHILE '(' Expr ')' error  { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
970                                              DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion.
971   | WHILE '(' Expr ')' Statement        { $$ = createNodeDeclarationInfo<StatementNode*>(new WhileNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
972                                           DBG($$.m_node, @1, @4); }
973   | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement
974                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations, 
975                                                                                          $3.m_features | $5.m_features | $7.m_features | $9.m_features,
976                                                                                          $3.m_numConstants + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
977                                           DBG($$.m_node, @1, @8); 
978                                         }
979   | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement
980                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $4.m_node, $6.m_node, $8.m_node, $10.m_node, true),
981                                                                                          mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations),
982                                                                                          mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations),
983                                                                                          $4.m_features | $6.m_features | $8.m_features | $10.m_features,
984                                                                                          $4.m_numConstants + $6.m_numConstants + $8.m_numConstants + $10.m_numConstants);
985                                           DBG($$.m_node, @1, @9); }
986   | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement
987                                         {
988                                             ForInNode* node = new ForInNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node);
989                                             SET_EXCEPTION_LOCATION(node, @3.first_column, @3.last_column, @5.last_column);
990                                             $$ = createNodeDeclarationInfo<StatementNode*>(node, $7.m_varDeclarations, $7.m_funcDeclarations,
991                                                                                            $3.m_features | $5.m_features | $7.m_features,
992                                                                                            $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
993                                             DBG($$.m_node, @1, @6);
994                                         }
995   | FOR '(' VAR IDENT INTOKEN Expr ')' Statement
996                                         { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, 0, $6.m_node, $8.m_node, @5.first_column, @5.first_column - @4.first_column, @6.last_column - @5.first_column);
997                                           SET_EXCEPTION_LOCATION(forIn, @4.first_column, @5.first_column + 1, @6.last_column);
998                                           appendToVarDeclarationList(GLOBAL_DATA, $8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
999                                           $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $8.m_varDeclarations, $8.m_funcDeclarations, ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $6.m_features | $8.m_features, $6.m_numConstants + $8.m_numConstants);
1000                                           DBG($$.m_node, @1, @7); }
1001   | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement
1002                                         { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, $5.m_node, $7.m_node, $9.m_node, @5.first_column, @5.first_column - @4.first_column, @5.last_column - @5.first_column);
1003                                           SET_EXCEPTION_LOCATION(forIn, @4.first_column, @6.first_column + 1, @7.last_column);
1004                                           appendToVarDeclarationList(GLOBAL_DATA, $9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
1005                                           $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $9.m_varDeclarations, $9.m_funcDeclarations,
1006                                                                                          ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $5.m_features | $7.m_features | $9.m_features,
1007                                                                                          $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1008                                           DBG($$.m_node, @1, @8); }
1009 ;
1010
1011 ExprOpt:
1012     /* nothing */                       { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1013   | Expr
1014 ;
1015
1016 ExprNoInOpt:
1017     /* nothing */                       { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1018   | ExprNoIn
1019 ;
1020
1021 ContinueStatement:
1022     CONTINUE ';'                        { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1023                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1024                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1025                                           DBG($$.m_node, @1, @2); }
1026   | CONTINUE error                      { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1027                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1028                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1029                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1030   | CONTINUE IDENT ';'                  { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1031                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); 
1032                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1033                                           DBG($$.m_node, @1, @3); }
1034   | CONTINUE IDENT error                { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1035                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); 
1036                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1037                                           DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1038 ;
1039
1040 BreakStatement:
1041     BREAK ';'                           { BreakNode* node = new BreakNode(GLOBAL_DATA);
1042                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1043                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1044   | BREAK error                         { BreakNode* node = new BreakNode(GLOBAL_DATA);
1045                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1046                                           $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1047   | BREAK IDENT ';'                     { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1048                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1049                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @3); }
1050   | BREAK IDENT error                   { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1051                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1052                                           $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA, *$2), 0, 0, 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1053 ;
1054
1055 ReturnStatement:
1056     RETURN ';'                          { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); 
1057                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1058                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1059   | RETURN error                        { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); 
1060                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1061                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1062   | RETURN Expr ';'                     { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node); 
1063                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1064                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @3); }
1065   | RETURN Expr error                   { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node); 
1066                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); 
1067                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1068 ;
1069
1070 WithStatement:
1071     WITH '(' Expr ')' Statement         { $$ = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column),
1072                                                                                          $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features | WithFeature, $3.m_numConstants + $5.m_numConstants);
1073                                           DBG($$.m_node, @1, @4); }
1074 ;
1075
1076 SwitchStatement:
1077     SWITCH '(' Expr ')' CaseBlock       { $$ = createNodeDeclarationInfo<StatementNode*>(new SwitchNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations,
1078                                                                                          $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
1079                                           DBG($$.m_node, @1, @4); }
1080 ;
1081
1082 CaseBlock:
1083     OPENBRACE CaseClausesOpt CLOSEBRACE              { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); }
1084   | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE
1085                                         { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, $3.m_node, $4.m_node.head),
1086                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations),
1087                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations),
1088                                                                                          $2.m_features | $3.m_features | $4.m_features,
1089                                                                                          $2.m_numConstants + $3.m_numConstants + $4.m_numConstants); }
1090 ;
1091
1092 CaseClausesOpt:
1093 /* nothing */                       { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; $$.m_features = 0; $$.m_numConstants = 0; }
1094   | CaseClauses
1095 ;
1096
1097 CaseClauses:
1098     CaseClause                          { $$.m_node.head = new ClauseListNode(GLOBAL_DATA, $1.m_node);
1099                                           $$.m_node.tail = $$.m_node.head;
1100                                           $$.m_varDeclarations = $1.m_varDeclarations;
1101                                           $$.m_funcDeclarations = $1.m_funcDeclarations; 
1102                                           $$.m_features = $1.m_features;
1103                                           $$.m_numConstants = $1.m_numConstants; }
1104   | CaseClauses CaseClause              { $$.m_node.head = $1.m_node.head;
1105                                           $$.m_node.tail = new ClauseListNode(GLOBAL_DATA, $1.m_node.tail, $2.m_node);
1106                                           $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1107                                           $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1108                                           $$.m_features = $1.m_features | $2.m_features;
1109                                           $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1110                                         }
1111 ;
1112
1113 CaseClause:
1114     CASE Expr ':'                       { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node), 0, 0, $2.m_features, $2.m_numConstants); }
1115   | CASE Expr ':' SourceElements        { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations, $2.m_features | $4.m_features, $2.m_numConstants + $4.m_numConstants); }
1116 ;
1117
1118 DefaultClause:
1119     DEFAULT ':'                         { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); }
1120   | DEFAULT ':' SourceElements          { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1121 ;
1122
1123 LabelledStatement:
1124     IDENT ':' Statement                 { LabelNode* node = new LabelNode(GLOBAL_DATA, *$1, $3.m_node);
1125                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1126                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1127 ;
1128
1129 ThrowStatement:
1130     THROW Expr ';'                      { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1131                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1132                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2);
1133                                         }
1134   | THROW Expr error                    { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1135                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1136                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; 
1137                                         }
1138 ;
1139
1140 TryStatement:
1141     TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node),
1142                                                                                          mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
1143                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
1144                                                                                          $2.m_features | $4.m_features,
1145                                                                                          $2.m_numConstants + $4.m_numConstants);
1146                                           DBG($$.m_node, @1, @2); }
1147   | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, 0),
1148                                                                                          mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations),
1149                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations),
1150                                                                                          $2.m_features | $7.m_features | CatchFeature,
1151                                                                                          $2.m_numConstants + $7.m_numConstants);
1152                                           DBG($$.m_node, @1, @2); }
1153   | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
1154                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, $9.m_node),
1155                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations),
1156                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations),
1157                                                                                          $2.m_features | $7.m_features | $9.m_features | CatchFeature,
1158                                                                                          $2.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1159                                           DBG($$.m_node, @1, @2); }
1160 ;
1161
1162 DebuggerStatement:
1163     DEBUGGER ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1164                                           DBG($$.m_node, @1, @2); }
1165   | DEBUGGER error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1166                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1167 ;
1168
1169 FunctionDeclaration:
1170     FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node)); }
1171   | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1172       { 
1173           $$ = createNodeDeclarationInfo<StatementNode*>(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0); 
1174           if ($4.m_features & ArgumentsFeature)
1175               $7->setUsesArguments(); 
1176           DBG($7, @6, @8);
1177           $$.m_funcDeclarations->data.append(static_cast<FuncDeclNode*>($$.m_node));
1178       }
1179 ;
1180
1181 FunctionExpr:
1182     FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $5, LEXER->sourceCode($4, $6, @4.first_line)), ClosureFeature, 0); DBG($5, @4, @6); }
1183     | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 
1184       { 
1185           $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $6, LEXER->sourceCode($5, $7, @5.first_line), $3.m_node.head), $3.m_features | ClosureFeature, 0); 
1186           if ($3.m_features & ArgumentsFeature) 
1187               $6->setUsesArguments();
1188           DBG($6, @5, @7); 
1189       }
1190   | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); }
1191   | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 
1192       { 
1193           $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), $4.m_features | ClosureFeature, 0); 
1194           if ($4.m_features & ArgumentsFeature)
1195               $7->setUsesArguments();
1196           DBG($7, @6, @8); 
1197       }
1198 ;
1199
1200 FormalParameterList:
1201     IDENT                               { $$.m_node.head = new ParameterNode(GLOBAL_DATA, *$1);
1202                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
1203                                           $$.m_node.tail = $$.m_node.head; }
1204   | FormalParameterList ',' IDENT       { $$.m_node.head = $1.m_node.head;
1205                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
1206                                           $$.m_node.tail = new ParameterNode(GLOBAL_DATA, $1.m_node.tail, *$3);  }
1207 ;
1208
1209 FunctionBody:
1210     /* not in spec */                   { $$ = FunctionBodyNode::create(GLOBAL_DATA); }
1211   | SourceElements_NoNode               { $$ = FunctionBodyNode::create(GLOBAL_DATA); }
1212 ;
1213
1214 Program:
1215     /* not in spec */                   { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, @0.last_line, 0); }
1216     | SourceElements                    { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, $1.m_features, 
1217                                                                                 @1.last_line, $1.m_numConstants); }
1218 ;
1219
1220 SourceElements:
1221     Statement                           { $$.m_node = new SourceElements(GLOBAL_DATA);
1222                                           $$.m_node->append($1.m_node);
1223                                           $$.m_varDeclarations = $1.m_varDeclarations;
1224                                           $$.m_funcDeclarations = $1.m_funcDeclarations;
1225                                           $$.m_features = $1.m_features;
1226                                           $$.m_numConstants = $1.m_numConstants;
1227                                         }
1228   | SourceElements Statement            { $$.m_node->append($2.m_node);
1229                                           $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1230                                           $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1231                                           $$.m_features = $1.m_features | $2.m_features;
1232                                           $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1233                                         }
1234 ;
1235  
1236 // Start NoNodes
1237
1238 Literal_NoNode:
1239     NULLTOKEN
1240   | TRUETOKEN
1241   | FALSETOKEN
1242   | NUMBER { }
1243   | STRING { }
1244   | '/' /* regexp */ { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; }
1245   | DIVEQUAL /* regexp with /= */ { Lexer& l = *LEXER; if (!l.scanRegExp()) YYABORT; }
1246 ;
1247
1248 Property_NoNode:
1249     IDENT ':' AssignmentExpr_NoNode { }
1250   | STRING ':' AssignmentExpr_NoNode { }
1251   | NUMBER ':' AssignmentExpr_NoNode { }
1252   | IDENT IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; }
1253   | IDENT IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE { if (*$1 != "get" && *$1 != "set") YYABORT; }
1254 ;
1255
1256 PropertyList_NoNode:
1257     Property_NoNode
1258   | PropertyList_NoNode ',' Property_NoNode
1259 ;
1260
1261 PrimaryExpr_NoNode:
1262     PrimaryExprNoBrace_NoNode
1263   | OPENBRACE CLOSEBRACE { }
1264   | OPENBRACE PropertyList_NoNode CLOSEBRACE { }
1265   /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */
1266   | OPENBRACE PropertyList_NoNode ',' CLOSEBRACE { }
1267 ;
1268
1269 PrimaryExprNoBrace_NoNode:
1270     THISTOKEN
1271   | Literal_NoNode
1272   | ArrayLiteral_NoNode
1273   | IDENT { }
1274   | '(' Expr_NoNode ')'
1275 ;
1276
1277 ArrayLiteral_NoNode:
1278     '[' ElisionOpt_NoNode ']'
1279   | '[' ElementList_NoNode ']'
1280   | '[' ElementList_NoNode ',' ElisionOpt_NoNode ']'
1281 ;
1282
1283 ElementList_NoNode:
1284     ElisionOpt_NoNode AssignmentExpr_NoNode
1285   | ElementList_NoNode ',' ElisionOpt_NoNode AssignmentExpr_NoNode
1286 ;
1287
1288 ElisionOpt_NoNode:
1289     /* nothing */
1290   | Elision_NoNode
1291 ;
1292
1293 Elision_NoNode:
1294     ','
1295   | Elision_NoNode ','
1296 ;
1297
1298 MemberExpr_NoNode:
1299     PrimaryExpr_NoNode
1300   | FunctionExpr_NoNode
1301   | MemberExpr_NoNode '[' Expr_NoNode ']'
1302   | MemberExpr_NoNode '.' IDENT
1303   | NEW MemberExpr_NoNode Arguments_NoNode
1304 ;
1305
1306 MemberExprNoBF_NoNode:
1307     PrimaryExprNoBrace_NoNode
1308   | MemberExprNoBF_NoNode '[' Expr_NoNode ']'
1309   | MemberExprNoBF_NoNode '.' IDENT
1310   | NEW MemberExpr_NoNode Arguments_NoNode
1311 ;
1312
1313 NewExpr_NoNode:
1314     MemberExpr_NoNode
1315   | NEW NewExpr_NoNode
1316 ;
1317
1318 NewExprNoBF_NoNode:
1319     MemberExprNoBF_NoNode
1320   | NEW NewExpr_NoNode
1321 ;
1322
1323 CallExpr_NoNode:
1324     MemberExpr_NoNode Arguments_NoNode
1325   | CallExpr_NoNode Arguments_NoNode
1326   | CallExpr_NoNode '[' Expr_NoNode ']'
1327   | CallExpr_NoNode '.' IDENT
1328 ;
1329
1330 CallExprNoBF_NoNode:
1331     MemberExprNoBF_NoNode Arguments_NoNode
1332   | CallExprNoBF_NoNode Arguments_NoNode
1333   | CallExprNoBF_NoNode '[' Expr_NoNode ']'
1334   | CallExprNoBF_NoNode '.' IDENT
1335 ;
1336
1337 Arguments_NoNode:
1338     '(' ')'
1339   | '(' ArgumentList_NoNode ')'
1340 ;
1341
1342 ArgumentList_NoNode:
1343     AssignmentExpr_NoNode
1344   | ArgumentList_NoNode ',' AssignmentExpr_NoNode
1345 ;
1346
1347 LeftHandSideExpr_NoNode:
1348     NewExpr_NoNode
1349   | CallExpr_NoNode
1350 ;
1351
1352 LeftHandSideExprNoBF_NoNode:
1353     NewExprNoBF_NoNode
1354   | CallExprNoBF_NoNode
1355 ;
1356
1357 PostfixExpr_NoNode:
1358     LeftHandSideExpr_NoNode
1359   | LeftHandSideExpr_NoNode PLUSPLUS
1360   | LeftHandSideExpr_NoNode MINUSMINUS
1361 ;
1362
1363 PostfixExprNoBF_NoNode:
1364     LeftHandSideExprNoBF_NoNode
1365   | LeftHandSideExprNoBF_NoNode PLUSPLUS
1366   | LeftHandSideExprNoBF_NoNode MINUSMINUS
1367 ;
1368
1369 UnaryExprCommon_NoNode:
1370     DELETETOKEN UnaryExpr_NoNode
1371   | VOIDTOKEN UnaryExpr_NoNode
1372   | TYPEOF UnaryExpr_NoNode
1373   | PLUSPLUS UnaryExpr_NoNode
1374   | AUTOPLUSPLUS UnaryExpr_NoNode
1375   | MINUSMINUS UnaryExpr_NoNode
1376   | AUTOMINUSMINUS UnaryExpr_NoNode
1377   | '+' UnaryExpr_NoNode
1378   | '-' UnaryExpr_NoNode
1379   | '~' UnaryExpr_NoNode
1380   | '!' UnaryExpr_NoNode
1381
1382 UnaryExpr_NoNode:
1383     PostfixExpr_NoNode
1384   | UnaryExprCommon_NoNode
1385 ;
1386
1387 UnaryExprNoBF_NoNode:
1388     PostfixExprNoBF_NoNode
1389   | UnaryExprCommon_NoNode
1390 ;
1391
1392 MultiplicativeExpr_NoNode:
1393     UnaryExpr_NoNode
1394   | MultiplicativeExpr_NoNode '*' UnaryExpr_NoNode
1395   | MultiplicativeExpr_NoNode '/' UnaryExpr_NoNode
1396   | MultiplicativeExpr_NoNode '%' UnaryExpr_NoNode
1397 ;
1398
1399 MultiplicativeExprNoBF_NoNode:
1400     UnaryExprNoBF_NoNode
1401   | MultiplicativeExprNoBF_NoNode '*' UnaryExpr_NoNode
1402   | MultiplicativeExprNoBF_NoNode '/' UnaryExpr_NoNode
1403   | MultiplicativeExprNoBF_NoNode '%' UnaryExpr_NoNode
1404 ;
1405
1406 AdditiveExpr_NoNode:
1407     MultiplicativeExpr_NoNode
1408   | AdditiveExpr_NoNode '+' MultiplicativeExpr_NoNode
1409   | AdditiveExpr_NoNode '-' MultiplicativeExpr_NoNode
1410 ;
1411
1412 AdditiveExprNoBF_NoNode:
1413     MultiplicativeExprNoBF_NoNode
1414   | AdditiveExprNoBF_NoNode '+' MultiplicativeExpr_NoNode
1415   | AdditiveExprNoBF_NoNode '-' MultiplicativeExpr_NoNode
1416 ;
1417
1418 ShiftExpr_NoNode:
1419     AdditiveExpr_NoNode
1420   | ShiftExpr_NoNode LSHIFT AdditiveExpr_NoNode
1421   | ShiftExpr_NoNode RSHIFT AdditiveExpr_NoNode
1422   | ShiftExpr_NoNode URSHIFT AdditiveExpr_NoNode
1423 ;
1424
1425 ShiftExprNoBF_NoNode:
1426     AdditiveExprNoBF_NoNode
1427   | ShiftExprNoBF_NoNode LSHIFT AdditiveExpr_NoNode
1428   | ShiftExprNoBF_NoNode RSHIFT AdditiveExpr_NoNode
1429   | ShiftExprNoBF_NoNode URSHIFT AdditiveExpr_NoNode
1430 ;
1431
1432 RelationalExpr_NoNode:
1433     ShiftExpr_NoNode
1434   | RelationalExpr_NoNode '<' ShiftExpr_NoNode
1435   | RelationalExpr_NoNode '>' ShiftExpr_NoNode
1436   | RelationalExpr_NoNode LE ShiftExpr_NoNode
1437   | RelationalExpr_NoNode GE ShiftExpr_NoNode
1438   | RelationalExpr_NoNode INSTANCEOF ShiftExpr_NoNode
1439   | RelationalExpr_NoNode INTOKEN ShiftExpr_NoNode
1440 ;
1441
1442 RelationalExprNoIn_NoNode:
1443     ShiftExpr_NoNode
1444   | RelationalExprNoIn_NoNode '<' ShiftExpr_NoNode
1445   | RelationalExprNoIn_NoNode '>' ShiftExpr_NoNode
1446   | RelationalExprNoIn_NoNode LE ShiftExpr_NoNode
1447   | RelationalExprNoIn_NoNode GE ShiftExpr_NoNode
1448   | RelationalExprNoIn_NoNode INSTANCEOF ShiftExpr_NoNode
1449 ;
1450
1451 RelationalExprNoBF_NoNode:
1452     ShiftExprNoBF_NoNode
1453   | RelationalExprNoBF_NoNode '<' ShiftExpr_NoNode
1454   | RelationalExprNoBF_NoNode '>' ShiftExpr_NoNode
1455   | RelationalExprNoBF_NoNode LE ShiftExpr_NoNode
1456   | RelationalExprNoBF_NoNode GE ShiftExpr_NoNode
1457   | RelationalExprNoBF_NoNode INSTANCEOF ShiftExpr_NoNode
1458   | RelationalExprNoBF_NoNode INTOKEN ShiftExpr_NoNode
1459 ;
1460
1461 EqualityExpr_NoNode:
1462     RelationalExpr_NoNode
1463   | EqualityExpr_NoNode EQEQ RelationalExpr_NoNode
1464   | EqualityExpr_NoNode NE RelationalExpr_NoNode
1465   | EqualityExpr_NoNode STREQ RelationalExpr_NoNode
1466   | EqualityExpr_NoNode STRNEQ RelationalExpr_NoNode
1467 ;
1468
1469 EqualityExprNoIn_NoNode:
1470     RelationalExprNoIn_NoNode
1471   | EqualityExprNoIn_NoNode EQEQ RelationalExprNoIn_NoNode
1472   | EqualityExprNoIn_NoNode NE RelationalExprNoIn_NoNode
1473   | EqualityExprNoIn_NoNode STREQ RelationalExprNoIn_NoNode
1474   | EqualityExprNoIn_NoNode STRNEQ RelationalExprNoIn_NoNode
1475 ;
1476
1477 EqualityExprNoBF_NoNode:
1478     RelationalExprNoBF_NoNode
1479   | EqualityExprNoBF_NoNode EQEQ RelationalExpr_NoNode
1480   | EqualityExprNoBF_NoNode NE RelationalExpr_NoNode
1481   | EqualityExprNoBF_NoNode STREQ RelationalExpr_NoNode
1482   | EqualityExprNoBF_NoNode STRNEQ RelationalExpr_NoNode
1483 ;
1484
1485 BitwiseANDExpr_NoNode:
1486     EqualityExpr_NoNode
1487   | BitwiseANDExpr_NoNode '&' EqualityExpr_NoNode
1488 ;
1489
1490 BitwiseANDExprNoIn_NoNode:
1491     EqualityExprNoIn_NoNode
1492   | BitwiseANDExprNoIn_NoNode '&' EqualityExprNoIn_NoNode
1493 ;
1494
1495 BitwiseANDExprNoBF_NoNode:
1496     EqualityExprNoBF_NoNode
1497   | BitwiseANDExprNoBF_NoNode '&' EqualityExpr_NoNode
1498 ;
1499
1500 BitwiseXORExpr_NoNode:
1501     BitwiseANDExpr_NoNode
1502   | BitwiseXORExpr_NoNode '^' BitwiseANDExpr_NoNode
1503 ;
1504
1505 BitwiseXORExprNoIn_NoNode:
1506     BitwiseANDExprNoIn_NoNode
1507   | BitwiseXORExprNoIn_NoNode '^' BitwiseANDExprNoIn_NoNode
1508 ;
1509
1510 BitwiseXORExprNoBF_NoNode:
1511     BitwiseANDExprNoBF_NoNode
1512   | BitwiseXORExprNoBF_NoNode '^' BitwiseANDExpr_NoNode
1513 ;
1514
1515 BitwiseORExpr_NoNode:
1516     BitwiseXORExpr_NoNode
1517   | BitwiseORExpr_NoNode '|' BitwiseXORExpr_NoNode
1518 ;
1519
1520 BitwiseORExprNoIn_NoNode:
1521     BitwiseXORExprNoIn_NoNode
1522   | BitwiseORExprNoIn_NoNode '|' BitwiseXORExprNoIn_NoNode
1523 ;
1524
1525 BitwiseORExprNoBF_NoNode:
1526     BitwiseXORExprNoBF_NoNode
1527   | BitwiseORExprNoBF_NoNode '|' BitwiseXORExpr_NoNode
1528 ;
1529
1530 LogicalANDExpr_NoNode:
1531     BitwiseORExpr_NoNode
1532   | LogicalANDExpr_NoNode AND BitwiseORExpr_NoNode
1533 ;
1534
1535 LogicalANDExprNoIn_NoNode:
1536     BitwiseORExprNoIn_NoNode
1537   | LogicalANDExprNoIn_NoNode AND BitwiseORExprNoIn_NoNode
1538 ;
1539
1540 LogicalANDExprNoBF_NoNode:
1541     BitwiseORExprNoBF_NoNode
1542   | LogicalANDExprNoBF_NoNode AND BitwiseORExpr_NoNode
1543 ;
1544
1545 LogicalORExpr_NoNode:
1546     LogicalANDExpr_NoNode
1547   | LogicalORExpr_NoNode OR LogicalANDExpr_NoNode
1548 ;
1549
1550 LogicalORExprNoIn_NoNode:
1551     LogicalANDExprNoIn_NoNode
1552   | LogicalORExprNoIn_NoNode OR LogicalANDExprNoIn_NoNode
1553 ;
1554
1555 LogicalORExprNoBF_NoNode:
1556     LogicalANDExprNoBF_NoNode
1557   | LogicalORExprNoBF_NoNode OR LogicalANDExpr_NoNode
1558 ;
1559
1560 ConditionalExpr_NoNode:
1561     LogicalORExpr_NoNode
1562   | LogicalORExpr_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode
1563 ;
1564
1565 ConditionalExprNoIn_NoNode:
1566     LogicalORExprNoIn_NoNode
1567   | LogicalORExprNoIn_NoNode '?' AssignmentExprNoIn_NoNode ':' AssignmentExprNoIn_NoNode
1568 ;
1569
1570 ConditionalExprNoBF_NoNode:
1571     LogicalORExprNoBF_NoNode
1572   | LogicalORExprNoBF_NoNode '?' AssignmentExpr_NoNode ':' AssignmentExpr_NoNode
1573 ;
1574
1575 AssignmentExpr_NoNode:
1576     ConditionalExpr_NoNode
1577   | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode
1578 ;
1579
1580 AssignmentExprNoIn_NoNode:
1581     ConditionalExprNoIn_NoNode
1582   | LeftHandSideExpr_NoNode AssignmentOperator_NoNode AssignmentExprNoIn_NoNode
1583 ;
1584
1585 AssignmentExprNoBF_NoNode:
1586     ConditionalExprNoBF_NoNode
1587   | LeftHandSideExprNoBF_NoNode AssignmentOperator_NoNode AssignmentExpr_NoNode
1588 ;
1589
1590 AssignmentOperator_NoNode:
1591     '='
1592   | PLUSEQUAL
1593   | MINUSEQUAL
1594   | MULTEQUAL
1595   | DIVEQUAL
1596   | LSHIFTEQUAL
1597   | RSHIFTEQUAL
1598   | URSHIFTEQUAL
1599   | ANDEQUAL
1600   | XOREQUAL
1601   | OREQUAL
1602   | MODEQUAL
1603 ;
1604
1605 Expr_NoNode:
1606     AssignmentExpr_NoNode
1607   | Expr_NoNode ',' AssignmentExpr_NoNode
1608 ;
1609
1610 ExprNoIn_NoNode:
1611     AssignmentExprNoIn_NoNode
1612   | ExprNoIn_NoNode ',' AssignmentExprNoIn_NoNode
1613 ;
1614
1615 ExprNoBF_NoNode:
1616     AssignmentExprNoBF_NoNode
1617   | ExprNoBF_NoNode ',' AssignmentExpr_NoNode
1618 ;
1619
1620 Statement_NoNode:
1621     Block_NoNode
1622   | VariableStatement_NoNode
1623   | ConstStatement_NoNode
1624   | FunctionDeclaration_NoNode
1625   | EmptyStatement_NoNode
1626   | ExprStatement_NoNode
1627   | IfStatement_NoNode
1628   | IterationStatement_NoNode
1629   | ContinueStatement_NoNode
1630   | BreakStatement_NoNode
1631   | ReturnStatement_NoNode
1632   | WithStatement_NoNode
1633   | SwitchStatement_NoNode
1634   | LabelledStatement_NoNode
1635   | ThrowStatement_NoNode
1636   | TryStatement_NoNode
1637   | DebuggerStatement_NoNode
1638 ;
1639
1640 Block_NoNode:
1641     OPENBRACE CLOSEBRACE { }
1642   | OPENBRACE SourceElements_NoNode CLOSEBRACE { }
1643 ;
1644
1645 VariableStatement_NoNode:
1646     VAR VariableDeclarationList_NoNode ';'
1647   | VAR VariableDeclarationList_NoNode error { AUTO_SEMICOLON; }
1648 ;
1649
1650 VariableDeclarationList_NoNode:
1651     IDENT { }
1652   | IDENT Initializer_NoNode { }
1653   | VariableDeclarationList_NoNode ',' IDENT
1654   | VariableDeclarationList_NoNode ',' IDENT Initializer_NoNode
1655 ;
1656
1657 VariableDeclarationListNoIn_NoNode:
1658     IDENT { }
1659   | IDENT InitializerNoIn_NoNode { }
1660   | VariableDeclarationListNoIn_NoNode ',' IDENT
1661   | VariableDeclarationListNoIn_NoNode ',' IDENT InitializerNoIn_NoNode
1662 ;
1663
1664 ConstStatement_NoNode:
1665     CONSTTOKEN ConstDeclarationList_NoNode ';'
1666   | CONSTTOKEN ConstDeclarationList_NoNode error { AUTO_SEMICOLON; }
1667 ;
1668
1669 ConstDeclarationList_NoNode:
1670     ConstDeclaration_NoNode
1671   | ConstDeclarationList_NoNode ',' ConstDeclaration_NoNode
1672 ;
1673
1674 ConstDeclaration_NoNode:
1675     IDENT { }
1676   | IDENT Initializer_NoNode { }
1677 ;
1678
1679 Initializer_NoNode:
1680     '=' AssignmentExpr_NoNode
1681 ;
1682
1683 InitializerNoIn_NoNode:
1684     '=' AssignmentExprNoIn_NoNode
1685 ;
1686
1687 EmptyStatement_NoNode:
1688     ';'
1689 ;
1690
1691 ExprStatement_NoNode:
1692     ExprNoBF_NoNode ';'
1693   | ExprNoBF_NoNode error { AUTO_SEMICOLON; }
1694 ;
1695
1696 IfStatement_NoNode:
1697     IF '(' Expr_NoNode ')' Statement_NoNode %prec IF_WITHOUT_ELSE
1698   | IF '(' Expr_NoNode ')' Statement_NoNode ELSE Statement_NoNode
1699 ;
1700
1701 IterationStatement_NoNode:
1702     DO Statement_NoNode WHILE '(' Expr_NoNode ')' ';'
1703   | DO Statement_NoNode WHILE '(' Expr_NoNode ')' error // Always performs automatic semicolon insertion
1704   | WHILE '(' Expr_NoNode ')' Statement_NoNode
1705   | FOR '(' ExprNoInOpt_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode
1706   | FOR '(' VAR VariableDeclarationListNoIn_NoNode ';' ExprOpt_NoNode ';' ExprOpt_NoNode ')' Statement_NoNode
1707   | FOR '(' LeftHandSideExpr_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode
1708   | FOR '(' VAR IDENT INTOKEN Expr_NoNode ')' Statement_NoNode
1709   | FOR '(' VAR IDENT InitializerNoIn_NoNode INTOKEN Expr_NoNode ')' Statement_NoNode
1710 ;
1711
1712 ExprOpt_NoNode:
1713     /* nothing */
1714   | Expr_NoNode
1715 ;
1716
1717 ExprNoInOpt_NoNode:
1718     /* nothing */
1719   | ExprNoIn_NoNode
1720 ;
1721
1722 ContinueStatement_NoNode:
1723     CONTINUE ';'
1724   | CONTINUE error { AUTO_SEMICOLON; }
1725   | CONTINUE IDENT ';'
1726   | CONTINUE IDENT error { AUTO_SEMICOLON; }
1727 ;
1728
1729 BreakStatement_NoNode:
1730     BREAK ';'
1731   | BREAK error { AUTO_SEMICOLON; }
1732   | BREAK IDENT ';'
1733   | BREAK IDENT error { AUTO_SEMICOLON; }
1734 ;
1735
1736 ReturnStatement_NoNode:
1737     RETURN ';'
1738   | RETURN error { AUTO_SEMICOLON; }
1739   | RETURN Expr_NoNode ';'
1740   | RETURN Expr_NoNode error { AUTO_SEMICOLON; }
1741 ;
1742
1743 WithStatement_NoNode:
1744     WITH '(' Expr_NoNode ')' Statement_NoNode
1745 ;
1746
1747 SwitchStatement_NoNode:
1748     SWITCH '(' Expr_NoNode ')' CaseBlock_NoNode
1749 ;
1750
1751 CaseBlock_NoNode:
1752     OPENBRACE CaseClausesOpt_NoNode CLOSEBRACE { }
1753   | OPENBRACE CaseClausesOpt_NoNode DefaultClause_NoNode CaseClausesOpt_NoNode CLOSEBRACE { }
1754 ;
1755
1756 CaseClausesOpt_NoNode:
1757     /* nothing */
1758   | CaseClauses_NoNode
1759 ;
1760
1761 CaseClauses_NoNode:
1762     CaseClause_NoNode
1763   | CaseClauses_NoNode CaseClause_NoNode
1764 ;
1765
1766 CaseClause_NoNode:
1767     CASE Expr_NoNode ':'
1768   | CASE Expr_NoNode ':' SourceElements_NoNode
1769 ;
1770
1771 DefaultClause_NoNode:
1772     DEFAULT ':'
1773   | DEFAULT ':' SourceElements_NoNode
1774 ;
1775
1776 LabelledStatement_NoNode:
1777     IDENT ':' Statement_NoNode { }
1778 ;
1779
1780 ThrowStatement_NoNode:
1781     THROW Expr_NoNode ';'
1782   | THROW Expr_NoNode error { AUTO_SEMICOLON; }
1783 ;
1784
1785 TryStatement_NoNode:
1786     TRY Block_NoNode FINALLY Block_NoNode
1787   | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode
1788   | TRY Block_NoNode CATCH '(' IDENT ')' Block_NoNode FINALLY Block_NoNode
1789 ;
1790
1791 DebuggerStatement_NoNode:
1792     DEBUGGER ';'
1793   | DEBUGGER error { AUTO_SEMICOLON; }
1794 ;
1795
1796 FunctionDeclaration_NoNode:
1797     FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1798   | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1799 ;
1800
1801 FunctionExpr_NoNode:
1802     FUNCTION '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1803   | FUNCTION '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1804   | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1805   | FUNCTION IDENT '(' FormalParameterList_NoNode ')' OPENBRACE FunctionBody_NoNode CLOSEBRACE
1806 ;
1807
1808 FormalParameterList_NoNode:
1809     IDENT { }
1810   | FormalParameterList_NoNode ',' IDENT
1811 ;
1812
1813 FunctionBody_NoNode:
1814     /* not in spec */
1815   | SourceElements_NoNode
1816 ;
1817
1818 SourceElements_NoNode:
1819     Statement_NoNode
1820   | SourceElements_NoNode Statement_NoNode
1821 ;
1822
1823 // End NoNodes
1824
1825 %%
1826
1827 static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end)
1828 {
1829     if (!loc->isLocation())
1830         return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot);
1831
1832     if (loc->isResolveNode()) {
1833         ResolveNode* resolve = static_cast<ResolveNode*>(loc);
1834         if (op == OpEqual) {
1835             AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments);
1836             SET_EXCEPTION_LOCATION(node, start, divot, end);
1837             return node;
1838         } else
1839             return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1840     }
1841     if (loc->isBracketAccessorNode()) {
1842         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc);
1843         if (op == OpEqual)
1844             return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot());
1845         else {
1846             ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot);
1847             node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1848             return node;
1849         }
1850     }
1851     ASSERT(loc->isDotAccessorNode());
1852     DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
1853     if (op == OpEqual)
1854         return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
1855
1856     ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1857     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1858     return node;
1859 }
1860
1861 static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1862 {
1863     if (!expr->isLocation())
1864         return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1865     
1866     if (expr->isResolveNode()) {
1867         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1868         return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1869     }
1870     if (expr->isBracketAccessorNode()) {
1871         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1872         PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1873         node->setSubexpressionInfo(bracket->divot(), bracket->startOffset());
1874         return node;
1875     }
1876     ASSERT(expr->isDotAccessorNode());
1877     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1878     PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1879     node->setSubexpressionInfo(dot->divot(), dot->startOffset());
1880     return node;
1881 }
1882
1883 static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1884
1885     if (!expr->isLocation())
1886         return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1887     
1888     if (expr->isResolveNode()) {
1889         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1890         return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1891     }
1892     if (expr->isBracketAccessorNode()) {
1893         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1894         PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1895         node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1896         return node;
1897         
1898     }
1899     ASSERT(expr->isDotAccessorNode());
1900     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1901     PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1902     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1903     return node;
1904 }
1905
1906 static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end)
1907 {
1908     CodeFeatures features = func.m_features | args.m_features;
1909     int numConstants = func.m_numConstants + args.m_numConstants;
1910     if (!func.m_node->isLocation())
1911         return createNodeInfo<ExpressionNode*>(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants);
1912     if (func.m_node->isResolveNode()) {
1913         ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node);
1914         const Identifier& identifier = resolve->identifier();
1915         if (identifier == GLOBAL_DATA->propertyNames->eval)
1916             return createNodeInfo<ExpressionNode*>(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants);
1917         return createNodeInfo<ExpressionNode*>(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants);
1918     }
1919     if (func.m_node->isBracketAccessorNode()) {
1920         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func.m_node);
1921         FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot);
1922         node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1923         return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1924     }
1925     ASSERT(func.m_node->isDotAccessorNode());
1926     DotAccessorNode* dot = static_cast<DotAccessorNode*>(func.m_node);
1927     FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot);
1928     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1929     return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1930 }
1931
1932 static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr)
1933 {
1934     if (expr->isResolveNode()) {
1935         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1936         return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier());
1937     }
1938     return new TypeOfValueNode(GLOBAL_DATA, expr);
1939 }
1940
1941 static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end)
1942 {
1943     if (!expr->isLocation())
1944         return new DeleteValueNode(GLOBAL_DATA, expr);
1945     if (expr->isResolveNode()) {
1946         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1947         return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot);
1948     }
1949     if (expr->isBracketAccessorNode()) {
1950         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1951         return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot);
1952     }
1953     ASSERT(expr->isDotAccessorNode());
1954     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1955     return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot);
1956 }
1957
1958 static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source)
1959 {
1960     PropertyNode::Type type;
1961     if (getOrSet == "get")
1962         type = PropertyNode::Getter;
1963     else if (getOrSet == "set")
1964         type = PropertyNode::Setter;
1965     else
1966         return 0;
1967     return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type);
1968 }
1969
1970 static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n)
1971 {
1972     if (n->isNumber()) {
1973         NumberNode* number = static_cast<NumberNode*>(n);
1974
1975         if (number->value() > 0.0) {
1976             number->setValue(-number->value());
1977             return number;
1978         }
1979     }
1980
1981     return new NegateNode(GLOBAL_DATA, n);
1982 }
1983
1984 static NumberNode* makeNumberNode(void* globalPtr, double d)
1985 {
1986     return new NumberNode(GLOBAL_DATA, d);
1987 }
1988
1989 static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr)
1990 {
1991     if (expr->isNumber())
1992         return makeNumberNode(globalPtr, ~toInt32(static_cast<NumberNode*>(expr)->value()));
1993     return new BitwiseNotNode(GLOBAL_DATA, expr);
1994 }
1995
1996 static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1997 {
1998     expr1 = expr1->stripUnaryPlus();
1999     expr2 = expr2->stripUnaryPlus();
2000
2001     if (expr1->isNumber() && expr2->isNumber())
2002         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
2003
2004     if (expr1->isNumber() && static_cast<NumberNode*>(expr1)->value() == 1)
2005         return new UnaryPlusNode(GLOBAL_DATA, expr2);
2006
2007     if (expr2->isNumber() && static_cast<NumberNode*>(expr2)->value() == 1)
2008         return new UnaryPlusNode(GLOBAL_DATA, expr1);
2009
2010     return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2011 }
2012
2013 static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
2014 {
2015     expr1 = expr1->stripUnaryPlus();
2016     expr2 = expr2->stripUnaryPlus();
2017
2018     if (expr1->isNumber() && expr2->isNumber())
2019         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
2020     return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2021 }
2022
2023 static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
2024 {
2025     if (expr1->isNumber() && expr2->isNumber())
2026         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
2027     return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2028 }
2029
2030 static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
2031 {
2032     expr1 = expr1->stripUnaryPlus();
2033     expr2 = expr2->stripUnaryPlus();
2034
2035     if (expr1->isNumber() && expr2->isNumber())
2036         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value());
2037     return new SubNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2038 }
2039
2040 static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
2041 {
2042     if (expr1->isNumber() && expr2->isNumber())
2043         return makeNumberNode(globalPtr, toInt32(static_cast<NumberNode*>(expr1)->value()) << (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
2044     return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2045 }
2046
2047 static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
2048 {
2049     if (expr1->isNumber() && expr2->isNumber())
2050         return makeNumberNode(globalPtr, toInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
2051     return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
2052 }
2053
2054 /* called by yyparse on error */
2055 int yyerror(const char *)
2056 {
2057     return 1;
2058 }
2059
2060 /* may we automatically insert a semicolon ? */
2061 static bool allowAutomaticSemicolon(Lexer& lexer, int yychar)
2062 {
2063     return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator();
2064 }
2065
2066 static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init)
2067 {
2068     if (!list)
2069         return init;
2070     return new VarDeclCommaNode(GLOBAL_DATA, list, init);
2071 }
2072
2073 // We turn variable declarations into either assignments or empty
2074 // statements (which later get stripped out), because the actual
2075 // declaration work is hoisted up to the start of the function body
2076 static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr)
2077 {
2078     if (!expr)
2079         return new EmptyStatementNode(GLOBAL_DATA);
2080     return new VarStatementNode(GLOBAL_DATA, expr);
2081 }
2082
2083 #undef GLOBAL_DATA