d60554792b4f6383fa43014466ee1d93a350b4a8
[WebKit.git] / JavaScriptCore / kjs / 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 #define kjsyydebug 0 // Set to 1 to debug a parse error.
47 #if !PLATFORM(DARWIN)
48     // avoid triggering warnings in older bison
49 #define YYERROR_VERBOSE
50 #endif
51
52 int kjsyylex(void* lvalp, void* llocp, void* globalPtr);
53 int kjsyyerror(const char*);
54 static inline bool allowAutomaticSemicolon(JSC::Lexer&, int);
55
56 #define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr)
57 #define LEXER (GLOBAL_DATA->lexer)
58
59 #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0)
60 #define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceRange((divot), (divot) - (start), (end) - (divot))
61 #define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line)
62
63 using namespace JSC;
64 using namespace std;
65
66 static ExpressionNode* makeAssignNode(void*, ExpressionNode* loc, Operator, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end);
67 static ExpressionNode* makePrefixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end);
68 static ExpressionNode* makePostfixNode(void*, ExpressionNode* expr, Operator, int start, int divot, int end);
69 static PropertyNode* makeGetterOrSetterPropertyNode(void*, const Identifier &getOrSet, const Identifier& name, ParameterNode*, FunctionBodyNode*, const SourceCode&);
70 static ExpressionNodeInfo makeFunctionCallNode(void*, ExpressionNodeInfo func, ArgumentsNodeInfo, int start, int divot, int end);
71 static ExpressionNode* makeTypeOfNode(void*, ExpressionNode*);
72 static ExpressionNode* makeDeleteNode(void*, ExpressionNode*, int start, int divot, int end);
73 static ExpressionNode* makeNegateNode(void*, ExpressionNode*);
74 static NumberNode* makeNumberNode(void*, double);
75 static ExpressionNode* makeBitwiseNotNode(void*, ExpressionNode*);
76 static ExpressionNode* makeMultNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
77 static ExpressionNode* makeDivNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
78 static ExpressionNode* makeAddNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
79 static ExpressionNode* makeSubNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
80 static ExpressionNode* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
81 static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
82 static StatementNode* makeVarStatementNode(void*, ExpressionNode*);
83 static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init);
84
85 #if COMPILER(MSVC)
86
87 #pragma warning(disable: 4065)
88 #pragma warning(disable: 4244)
89 #pragma warning(disable: 4702)
90
91 // At least some of the time, the declarations of malloc and free that bison
92 // generates are causing warnings. A way to avoid this is to explicitly define
93 // the macros so that bison doesn't try to declare malloc and free.
94 #define YYMALLOC malloc
95 #define YYFREE free
96
97 #endif
98
99 #define YYPARSE_PARAM globalPtr
100 #define YYLEX_PARAM globalPtr
101
102 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls, 
103                                                                        ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls,
104                                                                        CodeFeatures info,
105                                                                        int numConstants) 
106 {
107     ASSERT((info & ~AllFeatures) == 0);
108     NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants};
109     return result;
110 }
111
112 template <typename T> NodeInfo<T> createNodeInfo(T node, CodeFeatures info, int numConstants)
113 {
114     ASSERT((info & ~AllFeatures) == 0);
115     NodeInfo<T> result = {node, info, numConstants};
116     return result;
117 }
118
119 template <typename T> T mergeDeclarationLists(T decls1, T decls2) 
120 {
121     // decls1 or both are null
122     if (!decls1)
123         return decls2;
124     // only decls1 is non-null
125     if (!decls2)
126         return decls1;
127
128     // Both are non-null
129     decls1->data.append(decls2->data);
130     
131     // We manually release the declaration lists to avoid accumulating many many
132     // unused heap allocated vectors
133     decls2->ref();
134     decls2->deref();
135     return decls1;
136 }
137
138 static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, const Identifier& ident, unsigned attrs)
139 {
140     if (!varDecls)
141         varDecls = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
142
143     varDecls->data.append(make_pair(ident, attrs));
144
145 }
146
147 static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, ConstDeclNode* decl)
148 {
149     unsigned attrs = DeclarationStacks::IsConstant;
150     if (decl->m_init)
151         attrs |= DeclarationStacks::HasInitializer;        
152     appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs);
153 }
154
155 %}
156
157 %union {
158     int                 intValue;
159     double              doubleValue;
160     Identifier*         ident;
161
162     // expression subtrees
163     ExpressionNodeInfo  expressionNode;
164     FuncDeclNodeInfo    funcDeclNode;
165     PropertyNodeInfo    propertyNode;
166     ArgumentsNodeInfo   argumentsNode;
167     ConstDeclNodeInfo   constDeclNode;
168     CaseBlockNodeInfo   caseBlockNode;
169     CaseClauseNodeInfo  caseClauseNode;
170     FuncExprNodeInfo    funcExprNode;
171
172     // statement nodes
173     StatementNodeInfo   statementNode;
174     FunctionBodyNode*   functionBodyNode;
175     ProgramNode*        programNode;
176
177     SourceElementsInfo  sourceElements;
178     PropertyListInfo    propertyList;
179     ArgumentListInfo    argumentList;
180     VarDeclListInfo     varDeclList;
181     ConstDeclListInfo   constDeclList;
182     ClauseListInfo      clauseList;
183     ElementListInfo     elementList;
184     ParameterListInfo   parameterList;
185
186     Operator            op;
187 }
188
189 %start Program
190
191 /* literals */
192 %token NULLTOKEN TRUETOKEN FALSETOKEN
193
194 /* keywords */
195 %token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE
196 %token FUNCTION RETURN VOIDTOKEN DELETETOKEN
197 %token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF
198 %token SWITCH WITH RESERVED
199 %token THROW TRY CATCH FINALLY
200 %token DEBUGGER
201
202 /* give an if without an else higher precedence than an else to resolve the ambiguity */
203 %nonassoc IF_WITHOUT_ELSE
204 %nonassoc ELSE
205
206 /* punctuators */
207 %token EQEQ NE                     /* == and != */
208 %token STREQ STRNEQ                /* === and !== */
209 %token LE GE                       /* < and > */
210 %token OR AND                      /* || and && */
211 %token PLUSPLUS MINUSMINUS         /* ++ and --  */
212 %token LSHIFT                      /* << */
213 %token RSHIFT URSHIFT              /* >> and >>> */
214 %token PLUSEQUAL MINUSEQUAL        /* += and -= */
215 %token MULTEQUAL DIVEQUAL          /* *= and /= */
216 %token LSHIFTEQUAL                 /* <<= */
217 %token RSHIFTEQUAL URSHIFTEQUAL    /* >>= and >>>= */
218 %token ANDEQUAL MODEQUAL           /* &= and %= */
219 %token XOREQUAL OREQUAL            /* ^= and |= */
220 %token <intValue> OPENBRACE        /* { (with char offset) */
221 %token <intValue> CLOSEBRACE        /* { (with char offset) */
222
223 /* terminal types */
224 %token <doubleValue> NUMBER
225 %token <ident> IDENT STRING
226
227 /* automatically inserted semicolon */
228 %token AUTOPLUSPLUS AUTOMINUSMINUS
229
230 /* non-terminal types */
231 %type <expressionNode>  Literal ArrayLiteral
232
233 %type <expressionNode>  PrimaryExpr PrimaryExprNoBrace
234 %type <expressionNode>  MemberExpr MemberExprNoBF /* BF => brace or function */
235 %type <expressionNode>  NewExpr NewExprNoBF
236 %type <expressionNode>  CallExpr CallExprNoBF
237 %type <expressionNode>  LeftHandSideExpr LeftHandSideExprNoBF
238 %type <expressionNode>  PostfixExpr PostfixExprNoBF
239 %type <expressionNode>  UnaryExpr UnaryExprNoBF UnaryExprCommon
240 %type <expressionNode>  MultiplicativeExpr MultiplicativeExprNoBF
241 %type <expressionNode>  AdditiveExpr AdditiveExprNoBF
242 %type <expressionNode>  ShiftExpr ShiftExprNoBF
243 %type <expressionNode>  RelationalExpr RelationalExprNoIn RelationalExprNoBF
244 %type <expressionNode>  EqualityExpr EqualityExprNoIn EqualityExprNoBF
245 %type <expressionNode>  BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF
246 %type <expressionNode>  BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF
247 %type <expressionNode>  BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF
248 %type <expressionNode>  LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF
249 %type <expressionNode>  LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF
250 %type <expressionNode>  ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF
251 %type <expressionNode>  AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF
252 %type <expressionNode>  Expr ExprNoIn ExprNoBF
253
254 %type <expressionNode>  ExprOpt ExprNoInOpt
255
256 %type <statementNode>   Statement Block
257 %type <statementNode>   VariableStatement ConstStatement EmptyStatement ExprStatement
258 %type <statementNode>   IfStatement IterationStatement ContinueStatement
259 %type <statementNode>   BreakStatement ReturnStatement WithStatement
260 %type <statementNode>   SwitchStatement LabelledStatement
261 %type <statementNode>   ThrowStatement TryStatement
262 %type <statementNode>   DebuggerStatement
263 %type <statementNode>   SourceElement
264
265 %type <expressionNode>  Initializer InitializerNoIn
266 %type <funcDeclNode>    FunctionDeclaration
267 %type <funcExprNode>    FunctionExpr
268 %type <functionBodyNode>  FunctionBody
269 %type <sourceElements>  SourceElements
270 %type <parameterList>   FormalParameterList
271 %type <op>              AssignmentOperator
272 %type <argumentsNode>   Arguments
273 %type <argumentList>    ArgumentList
274 %type <varDeclList>     VariableDeclarationList VariableDeclarationListNoIn
275 %type <constDeclList>   ConstDeclarationList
276 %type <constDeclNode>   ConstDeclaration
277 %type <caseBlockNode>   CaseBlock
278 %type <caseClauseNode>  CaseClause DefaultClause
279 %type <clauseList>      CaseClauses CaseClausesOpt
280 %type <intValue>        Elision ElisionOpt
281 %type <elementList>     ElementList
282 %type <propertyNode>    Property
283 %type <propertyList>    PropertyList
284 %%
285
286 Literal:
287     NULLTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); }
288   | TRUETOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); }
289   | FALSETOKEN                          { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); }
290   | NUMBER                              { $$ = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, $1), 0, 1); }
291   | STRING                              { $$ = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *$1), 0, 1); }
292   | '/' /* regexp */                    {
293                                             Lexer& l = *LEXER;
294                                             if (!l.scanRegExp())
295                                                 YYABORT;
296                                             RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags());
297                                             int size = l.pattern().size() + 2; // + 2 for the two /'s
298                                             SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
299                                             $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
300                                         }
301   | DIVEQUAL /* regexp with /= */       {
302                                             Lexer& l = *LEXER;
303                                             if (!l.scanRegExp())
304                                                 YYABORT;
305                                             RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags());
306                                             int size = l.pattern().size() + 2; // + 2 for the two /'s
307                                             SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
308                                             $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
309                                         }
310 ;
311
312 Property:
313     IDENT ':' AssignmentExpr            { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
314   | STRING ':' AssignmentExpr           { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
315   | 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); }
316   | 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; }
317   | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
318                                                              {
319                                                                  $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0); 
320                                                                  if ($4.m_features & ArgumentsFeature)
321                                                                      $7->setUsesArguments(); 
322                                                                  DBG($7, @6, @8); 
323                                                                  if (!$$.m_node) 
324                                                                      YYABORT; 
325                                                              }
326 ;
327
328 PropertyList:
329     Property                            { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node); 
330                                           $$.m_node.tail = $$.m_node.head;
331                                           $$.m_features = $1.m_features;
332                                           $$.m_numConstants = $1.m_numConstants; }
333   | PropertyList ',' Property           { $$.m_node.head = $1.m_node.head;
334                                           $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail);
335                                           $$.m_features = $1.m_features | $3.m_features;
336                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
337 ;
338
339 PrimaryExpr:
340     PrimaryExprNoBrace
341   | OPENBRACE CLOSEBRACE                             { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); }
342   | OPENBRACE PropertyList CLOSEBRACE                { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
343   /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */
344   | OPENBRACE PropertyList ',' CLOSEBRACE            { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
345 ;
346
347 PrimaryExprNoBrace:
348     THISTOKEN                           { $$ = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }
349   | Literal
350   | ArrayLiteral
351   | IDENT                               { $$ = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
352   | '(' Expr ')'                        { $$ = $2; }
353 ;
354
355 ArrayLiteral:
356     '[' ElisionOpt ']'                  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); }
357   | '[' ElementList ']'                 { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
358   | '[' ElementList ',' ElisionOpt ']'  { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); }
359 ;
360
361 ElementList:
362     ElisionOpt AssignmentExpr           { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node);
363                                           $$.m_node.tail = $$.m_node.head;
364                                           $$.m_features = $2.m_features;
365                                           $$.m_numConstants = $2.m_numConstants; }
366   | ElementList ',' ElisionOpt AssignmentExpr
367                                         { $$.m_node.head = $1.m_node.head;
368                                           $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node);
369                                           $$.m_features = $1.m_features | $4.m_features;
370                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; }
371 ;
372
373 ElisionOpt:
374     /* nothing */                       { $$ = 0; }
375   | Elision
376 ;
377
378 Elision:
379     ','                                 { $$ = 1; }
380   | Elision ','                         { $$ = $1 + 1; }
381 ;
382
383 MemberExpr:
384     PrimaryExpr
385   | FunctionExpr                        { $$ = createNodeInfo<ExpressionNode*>($1.m_node, $1.m_features, $1.m_numConstants); }
386   | MemberExpr '[' Expr ']'             { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
387                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
388                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
389                                         }
390   | MemberExpr '.' IDENT                { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
391                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
392                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
393                                         }
394   | NEW MemberExpr Arguments            { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
395                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
396                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
397                                         }
398 ;
399
400 MemberExprNoBF:
401     PrimaryExprNoBrace
402   | MemberExprNoBF '[' Expr ']'         { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
403                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
404                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
405                                         }
406   | MemberExprNoBF '.' IDENT            { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
407                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
408                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
409                                         }
410   | NEW MemberExpr Arguments            { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
411                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
412                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
413                                         }
414 ;
415
416 NewExpr:
417     MemberExpr
418   | NEW NewExpr                         { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
419                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
420                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants); 
421                                         }
422 ;
423
424 NewExprNoBF:
425     MemberExprNoBF
426   | NEW NewExpr                         { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
427                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
428                                           $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
429                                         }
430 ;
431
432 CallExpr:
433     MemberExpr Arguments                { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
434   | CallExpr Arguments                  { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
435   | CallExpr '[' Expr ']'               { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
436                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
437                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
438                                         }
439   | CallExpr '.' IDENT                  { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
440                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
441                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); }
442 ;
443
444 CallExprNoBF:
445     MemberExprNoBF Arguments            { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
446   | CallExprNoBF Arguments              { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
447   | CallExprNoBF '[' Expr ']'           { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
448                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
449                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); 
450                                         }
451   | CallExprNoBF '.' IDENT              { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
452                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
453                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); 
454                                         }
455 ;
456
457 Arguments:
458     '(' ')'                             { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA), 0, 0); }
459   | '(' ArgumentList ')'                { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
460 ;
461
462 ArgumentList:
463     AssignmentExpr                      { $$.m_node.head = new ArgumentListNode(GLOBAL_DATA, $1.m_node);
464                                           $$.m_node.tail = $$.m_node.head;
465                                           $$.m_features = $1.m_features;
466                                           $$.m_numConstants = $1.m_numConstants; }
467   | ArgumentList ',' AssignmentExpr     { $$.m_node.head = $1.m_node.head;
468                                           $$.m_node.tail = new ArgumentListNode(GLOBAL_DATA, $1.m_node.tail, $3.m_node);
469                                           $$.m_features = $1.m_features | $3.m_features;
470                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
471 ;
472
473 LeftHandSideExpr:
474     NewExpr
475   | CallExpr
476 ;
477
478 LeftHandSideExprNoBF:
479     NewExprNoBF
480   | CallExprNoBF
481 ;
482
483 PostfixExpr:
484     LeftHandSideExpr
485   | 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); }
486   | 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); }
487 ;
488
489 PostfixExprNoBF:
490     LeftHandSideExprNoBF
491   | 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); }
492   | 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); }
493 ;
494
495 UnaryExprCommon:
496     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); }
497   | VOIDTOKEN UnaryExpr                 { $$ = createNodeInfo<ExpressionNode*>(new VoidNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants + 1); }
498   | TYPEOF UnaryExpr                    { $$ = createNodeInfo<ExpressionNode*>(makeTypeOfNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
499   | 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); }
500   | 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); }
501   | 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); }
502   | 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); }
503   | '+' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(new UnaryPlusNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
504   | '-' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(makeNegateNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
505   | '~' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(makeBitwiseNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
506   | '!' UnaryExpr                       { $$ = createNodeInfo<ExpressionNode*>(new LogicalNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
507
508 UnaryExpr:
509     PostfixExpr
510   | UnaryExprCommon
511 ;
512
513 UnaryExprNoBF:
514     PostfixExprNoBF
515   | UnaryExprCommon
516 ;
517
518 MultiplicativeExpr:
519     UnaryExpr
520   | 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); }
521   | 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); }
522   | 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); }
523 ;
524
525 MultiplicativeExprNoBF:
526     UnaryExprNoBF
527   | MultiplicativeExprNoBF '*' UnaryExpr
528                                         { $$ = 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); }
529   | MultiplicativeExprNoBF '/' UnaryExpr
530                                         { $$ = 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); }
531   | MultiplicativeExprNoBF '%' UnaryExpr
532                                         { $$ = 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); }
533 ;
534
535 AdditiveExpr:
536     MultiplicativeExpr
537   | 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); }
538   | 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); }
539 ;
540
541 AdditiveExprNoBF:
542     MultiplicativeExprNoBF
543   | AdditiveExprNoBF '+' MultiplicativeExpr
544                                         { $$ = 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); }
545   | AdditiveExprNoBF '-' MultiplicativeExpr
546                                         { $$ = 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); }
547 ;
548
549 ShiftExpr:
550     AdditiveExpr
551   | 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); }
552   | 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); }
553   | 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); }
554 ;
555
556 ShiftExprNoBF:
557     AdditiveExprNoBF
558   | 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); }
559   | 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); }
560   | 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); }
561 ;
562
563 RelationalExpr:
564     ShiftExpr
565   | 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); }
566   | 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); }
567   | 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); }
568   | 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); }
569   | RelationalExpr INSTANCEOF ShiftExpr { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
570                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
571                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
572   | RelationalExpr INTOKEN ShiftExpr    { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
573                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
574                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
575 ;
576
577 RelationalExprNoIn:
578     ShiftExpr
579   | 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); }
580   | 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); }
581   | 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); }
582   | 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); }
583   | RelationalExprNoIn INSTANCEOF ShiftExpr
584                                         { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
585                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
586                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
587 ;
588
589 RelationalExprNoBF:
590     ShiftExprNoBF
591   | 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); }
592   | 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); }
593   | 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); }
594   | 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); }
595   | RelationalExprNoBF INSTANCEOF ShiftExpr
596                                         { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
597                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
598                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
599   | RelationalExprNoBF INTOKEN ShiftExpr 
600                                         { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
601                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);  
602                                           $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
603 ;
604
605 EqualityExpr:
606     RelationalExpr
607   | 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); }
608   | 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); }
609   | 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); }
610   | 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); }
611 ;
612
613 EqualityExprNoIn:
614     RelationalExprNoIn
615   | EqualityExprNoIn EQEQ RelationalExprNoIn
616                                         { $$ = 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); }
617   | EqualityExprNoIn NE RelationalExprNoIn
618                                         { $$ = 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); }
619   | EqualityExprNoIn STREQ RelationalExprNoIn
620                                         { $$ = 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); }
621   | EqualityExprNoIn STRNEQ RelationalExprNoIn
622                                         { $$ = 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); }
623 ;
624
625 EqualityExprNoBF:
626     RelationalExprNoBF
627   | EqualityExprNoBF EQEQ RelationalExpr
628                                         { $$ = 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); }
629   | 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); }
630   | EqualityExprNoBF STREQ RelationalExpr
631                                         { $$ = 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); }
632   | EqualityExprNoBF STRNEQ RelationalExpr
633                                         { $$ = 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); }
634 ;
635
636 BitwiseANDExpr:
637     EqualityExpr
638   | 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); }
639 ;
640
641 BitwiseANDExprNoIn:
642     EqualityExprNoIn
643   | BitwiseANDExprNoIn '&' EqualityExprNoIn
644                                         { $$ = 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); }
645 ;
646
647 BitwiseANDExprNoBF:
648     EqualityExprNoBF
649   | 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); }
650 ;
651
652 BitwiseXORExpr:
653     BitwiseANDExpr
654   | 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); }
655 ;
656
657 BitwiseXORExprNoIn:
658     BitwiseANDExprNoIn
659   | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn
660                                         { $$ = 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); }
661 ;
662
663 BitwiseXORExprNoBF:
664     BitwiseANDExprNoBF
665   | BitwiseXORExprNoBF '^' BitwiseANDExpr
666                                         { $$ = 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); }
667 ;
668
669 BitwiseORExpr:
670     BitwiseXORExpr
671   | 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); }
672 ;
673
674 BitwiseORExprNoIn:
675     BitwiseXORExprNoIn
676   | BitwiseORExprNoIn '|' BitwiseXORExprNoIn
677                                         { $$ = 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); }
678 ;
679
680 BitwiseORExprNoBF:
681     BitwiseXORExprNoBF
682   | BitwiseORExprNoBF '|' BitwiseXORExpr
683                                         { $$ = 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); }
684 ;
685
686 LogicalANDExpr:
687     BitwiseORExpr
688   | 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); }
689 ;
690
691 LogicalANDExprNoIn:
692     BitwiseORExprNoIn
693   | LogicalANDExprNoIn AND BitwiseORExprNoIn
694                                         { $$ = 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); }
695 ;
696
697 LogicalANDExprNoBF:
698     BitwiseORExprNoBF
699   | LogicalANDExprNoBF AND BitwiseORExpr
700                                         { $$ = 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); }
701 ;
702
703 LogicalORExpr:
704     LogicalANDExpr
705   | 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); }
706 ;
707
708 LogicalORExprNoIn:
709     LogicalANDExprNoIn
710   | LogicalORExprNoIn OR LogicalANDExprNoIn
711                                         { $$ = 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); }
712 ;
713
714 LogicalORExprNoBF:
715     LogicalANDExprNoBF
716   | 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); }
717 ;
718
719 ConditionalExpr:
720     LogicalORExpr
721   | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr
722                                         { $$ = 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); }
723 ;
724
725 ConditionalExprNoIn:
726     LogicalORExprNoIn
727   | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn
728                                         { $$ = 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); }
729 ;
730
731 ConditionalExprNoBF:
732     LogicalORExprNoBF
733   | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr
734                                         { $$ = 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); }
735 ;
736
737 AssignmentExpr:
738     ConditionalExpr
739   | LeftHandSideExpr AssignmentOperator AssignmentExpr
740                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, 
741                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); 
742                                         }
743 ;
744
745 AssignmentExprNoIn:
746     ConditionalExprNoIn
747   | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn
748                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature, 
749                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
750                                         }
751 ;
752
753 AssignmentExprNoBF:
754     ConditionalExprNoBF
755   | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr
756                                         { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
757                                                                                                      @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants); 
758                                         }
759 ;
760
761 AssignmentOperator:
762     '='                                 { $$ = OpEqual; }
763   | PLUSEQUAL                           { $$ = OpPlusEq; }
764   | MINUSEQUAL                          { $$ = OpMinusEq; }
765   | MULTEQUAL                           { $$ = OpMultEq; }
766   | DIVEQUAL                            { $$ = OpDivEq; }
767   | LSHIFTEQUAL                         { $$ = OpLShift; }
768   | RSHIFTEQUAL                         { $$ = OpRShift; }
769   | URSHIFTEQUAL                        { $$ = OpURShift; }
770   | ANDEQUAL                            { $$ = OpAndEq; }
771   | XOREQUAL                            { $$ = OpXOrEq; }
772   | OREQUAL                             { $$ = OpOrEq; }
773   | MODEQUAL                            { $$ = OpModEq; }
774 ;
775
776 Expr:
777     AssignmentExpr
778   | 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); }
779 ;
780
781 ExprNoIn:
782     AssignmentExprNoIn
783   | 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); }
784 ;
785
786 ExprNoBF:
787     AssignmentExprNoBF
788   | 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); }
789 ;
790
791 Statement:
792     Block
793   | VariableStatement
794   | ConstStatement
795   | EmptyStatement
796   | ExprStatement
797   | IfStatement
798   | IterationStatement
799   | ContinueStatement
800   | BreakStatement
801   | ReturnStatement
802   | WithStatement
803   | SwitchStatement
804   | LabelledStatement
805   | ThrowStatement
806   | TryStatement
807   | DebuggerStatement
808 ;
809
810 Block:
811     OPENBRACE CLOSEBRACE                             { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0);
812                                           DBG($$.m_node, @1, @2); }
813   | OPENBRACE SourceElements CLOSEBRACE              { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
814                                           DBG($$.m_node, @1, @3); }
815 ;
816
817 VariableStatement:
818     VAR VariableDeclarationList ';'     { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
819                                           DBG($$.m_node, @1, @3); }
820   | VAR VariableDeclarationList error   { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
821                                           DBG($$.m_node, @1, @2);
822                                           AUTO_SEMICOLON; }
823 ;
824
825 VariableDeclarationList:
826     IDENT                               { $$.m_node = 0;
827                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
828                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
829                                           $$.m_funcDeclarations = 0;
830                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
831                                           $$.m_numConstants = 0;
832                                         }
833   | IDENT Initializer                   { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
834                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
835                                           $$.m_node = node;
836                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
837                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
838                                           $$.m_funcDeclarations = 0;
839                                           $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
840                                           $$.m_numConstants = $2.m_numConstants;
841                                         }
842   | VariableDeclarationList ',' IDENT
843                                         { $$.m_node = $1.m_node;
844                                           $$.m_varDeclarations = $1.m_varDeclarations;
845                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
846                                           $$.m_funcDeclarations = 0;
847                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
848                                           $$.m_numConstants = $1.m_numConstants;
849                                         }
850   | VariableDeclarationList ',' IDENT Initializer
851                                         { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
852                                           SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
853                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
854                                           $$.m_varDeclarations = $1.m_varDeclarations;
855                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
856                                           $$.m_funcDeclarations = 0;
857                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
858                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
859                                         }
860 ;
861
862 VariableDeclarationListNoIn:
863     IDENT                               { $$.m_node = 0;
864                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
865                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
866                                           $$.m_funcDeclarations = 0;
867                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
868                                           $$.m_numConstants = 0;
869                                         }
870   | IDENT InitializerNoIn               { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
871                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
872                                           $$.m_node = node;
873                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
874                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
875                                           $$.m_funcDeclarations = 0;
876                                           $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
877                                           $$.m_numConstants = $2.m_numConstants;
878                                         }
879   | VariableDeclarationListNoIn ',' IDENT
880                                         { $$.m_node = $1.m_node;
881                                           $$.m_varDeclarations = $1.m_varDeclarations;
882                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
883                                           $$.m_funcDeclarations = 0;
884                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
885                                           $$.m_numConstants = $1.m_numConstants;
886                                         }
887   | VariableDeclarationListNoIn ',' IDENT InitializerNoIn
888                                         { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
889                                           SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
890                                           $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
891                                           $$.m_varDeclarations = $1.m_varDeclarations;
892                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
893                                           $$.m_funcDeclarations = 0;
894                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
895                                           $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
896                                         }
897 ;
898
899 ConstStatement:
900     CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
901                                           DBG($$.m_node, @1, @3); }
902   | CONSTTOKEN ConstDeclarationList error
903                                         { $$ = 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, @2); AUTO_SEMICOLON; }
905 ;
906
907 ConstDeclarationList:
908     ConstDeclaration                    { $$.m_node.head = $1.m_node;
909                                           $$.m_node.tail = $$.m_node.head;
910                                           $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
911                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $1.m_node);
912                                           $$.m_funcDeclarations = 0; 
913                                           $$.m_features = $1.m_features;
914                                           $$.m_numConstants = $1.m_numConstants;
915     }
916   | ConstDeclarationList ',' ConstDeclaration
917                                         {  $$.m_node.head = $1.m_node.head;
918                                           $1.m_node.tail->m_next = $3.m_node;
919                                           $$.m_node.tail = $3.m_node;
920                                           $$.m_varDeclarations = $1.m_varDeclarations;
921                                           appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $3.m_node);
922                                           $$.m_funcDeclarations = 0;
923                                           $$.m_features = $1.m_features | $3.m_features;
924                                           $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
925 ;
926
927 ConstDeclaration:
928     IDENT                               { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, 0), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
929   | 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); }
930 ;
931
932 Initializer:
933     '=' AssignmentExpr                  { $$ = $2; }
934 ;
935
936 InitializerNoIn:
937     '=' AssignmentExprNoIn              { $$ = $2; }
938 ;
939
940 EmptyStatement:
941     ';'                                 { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); }
942 ;
943
944 ExprStatement:
945     ExprNoBF ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
946                                           DBG($$.m_node, @1, @2); }
947   | ExprNoBF error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
948                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
949 ;
950
951 IfStatement:
952     IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE
953                                         { $$ = 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);
954                                           DBG($$.m_node, @1, @4); }
955   | IF '(' Expr ')' Statement ELSE Statement
956                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new IfElseNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node), 
957                                                                                          mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations),
958                                                                                          $3.m_features | $5.m_features | $7.m_features,
959                                                                                          $3.m_numConstants + $5.m_numConstants + $7.m_numConstants); 
960                                           DBG($$.m_node, @1, @4); }
961 ;
962
963 IterationStatement:
964     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);
965                                              DBG($$.m_node, @1, @3); }
966   | 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);
967                                              DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion.
968   | 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);
969                                           DBG($$.m_node, @1, @4); }
970   | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement
971                                         { $$ = 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, 
972                                                                                          $3.m_features | $5.m_features | $7.m_features | $9.m_features,
973                                                                                          $3.m_numConstants + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
974                                           DBG($$.m_node, @1, @8); 
975                                         }
976   | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement
977                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $4.m_node, $6.m_node, $8.m_node, $10.m_node, true),
978                                                                                          mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations),
979                                                                                          mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations),
980                                                                                          $4.m_features | $6.m_features | $8.m_features | $10.m_features,
981                                                                                          $4.m_numConstants + $6.m_numConstants + $8.m_numConstants + $10.m_numConstants);
982                                           DBG($$.m_node, @1, @9); }
983   | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement
984                                         {
985                                             ForInNode* node = new ForInNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node);
986                                             SET_EXCEPTION_LOCATION(node, @3.first_column, @3.last_column, @5.last_column);
987                                             $$ = createNodeDeclarationInfo<StatementNode*>(node, $7.m_varDeclarations, $7.m_funcDeclarations,
988                                                                                            $3.m_features | $5.m_features | $7.m_features,
989                                                                                            $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
990                                             DBG($$.m_node, @1, @6);
991                                         }
992   | FOR '(' VAR IDENT INTOKEN Expr ')' Statement
993                                         { 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);
994                                           SET_EXCEPTION_LOCATION(forIn, @4.first_column, @5.first_column + 1, @6.last_column);
995                                           appendToVarDeclarationList(GLOBAL_DATA, $8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
996                                           $$ = 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);
997                                           DBG($$.m_node, @1, @7); }
998   | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement
999                                         { 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);
1000                                           SET_EXCEPTION_LOCATION(forIn, @4.first_column, @6.first_column + 1, @7.last_column);
1001                                           appendToVarDeclarationList(GLOBAL_DATA, $9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
1002                                           $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $9.m_varDeclarations, $9.m_funcDeclarations,
1003                                                                                          ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $5.m_features | $7.m_features | $9.m_features,
1004                                                                                          $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1005                                           DBG($$.m_node, @1, @8); }
1006 ;
1007
1008 ExprOpt:
1009     /* nothing */                       { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1010   | Expr
1011 ;
1012
1013 ExprNoInOpt:
1014     /* nothing */                       { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1015   | ExprNoIn
1016 ;
1017
1018 ContinueStatement:
1019     CONTINUE ';'                        { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1020                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1021                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1022                                           DBG($$.m_node, @1, @2); }
1023   | CONTINUE error                      { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1024                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1025                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1026                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1027   | CONTINUE IDENT ';'                  { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1028                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); 
1029                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1030                                           DBG($$.m_node, @1, @3); }
1031   | CONTINUE IDENT error                { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1032                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column); 
1033                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1034                                           DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1035 ;
1036
1037 BreakStatement:
1038     BREAK ';'                           { BreakNode* node = new BreakNode(GLOBAL_DATA);
1039                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1040                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1041   | BREAK error                         { BreakNode* node = new BreakNode(GLOBAL_DATA);
1042                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1043                                           $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1044   | BREAK IDENT ';'                     { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1045                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1046                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @3); }
1047   | BREAK IDENT error                   { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1048                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1049                                           $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA, *$2), 0, 0, 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1050 ;
1051
1052 ReturnStatement:
1053     RETURN ';'                          { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0); 
1054                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column); 
1055                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1056   | RETURN error                        { 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, @1); AUTO_SEMICOLON; }
1059   | RETURN Expr ';'                     { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node); 
1060                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1061                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @3); }
1062   | RETURN Expr error                   { 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, @2); AUTO_SEMICOLON; }
1065 ;
1066
1067 WithStatement:
1068     WITH '(' Expr ')' Statement         { $$ = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column),
1069                                                                                          $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features | WithFeature, $3.m_numConstants + $5.m_numConstants);
1070                                           DBG($$.m_node, @1, @4); }
1071 ;
1072
1073 SwitchStatement:
1074     SWITCH '(' Expr ')' CaseBlock       { $$ = createNodeDeclarationInfo<StatementNode*>(new SwitchNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations,
1075                                                                                          $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
1076                                           DBG($$.m_node, @1, @4); }
1077 ;
1078
1079 CaseBlock:
1080     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); }
1081   | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE
1082                                         { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, $3.m_node, $4.m_node.head),
1083                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations),
1084                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations),
1085                                                                                          $2.m_features | $3.m_features | $4.m_features,
1086                                                                                          $2.m_numConstants + $3.m_numConstants + $4.m_numConstants); }
1087 ;
1088
1089 CaseClausesOpt:
1090 /* nothing */                       { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; $$.m_features = 0; $$.m_numConstants = 0; }
1091   | CaseClauses
1092 ;
1093
1094 CaseClauses:
1095     CaseClause                          { $$.m_node.head = new ClauseListNode(GLOBAL_DATA, $1.m_node);
1096                                           $$.m_node.tail = $$.m_node.head;
1097                                           $$.m_varDeclarations = $1.m_varDeclarations;
1098                                           $$.m_funcDeclarations = $1.m_funcDeclarations; 
1099                                           $$.m_features = $1.m_features;
1100                                           $$.m_numConstants = $1.m_numConstants; }
1101   | CaseClauses CaseClause              { $$.m_node.head = $1.m_node.head;
1102                                           $$.m_node.tail = new ClauseListNode(GLOBAL_DATA, $1.m_node.tail, $2.m_node);
1103                                           $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1104                                           $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1105                                           $$.m_features = $1.m_features | $2.m_features;
1106                                           $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1107                                         }
1108 ;
1109
1110 CaseClause:
1111     CASE Expr ':'                       { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node), 0, 0, $2.m_features, $2.m_numConstants); }
1112   | 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); }
1113 ;
1114
1115 DefaultClause:
1116     DEFAULT ':'                         { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); }
1117   | DEFAULT ':' SourceElements          { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1118 ;
1119
1120 LabelledStatement:
1121     IDENT ':' Statement                 { $3.m_node->pushLabel(*$1);
1122                                           LabelNode* node = new LabelNode(GLOBAL_DATA, *$1, $3.m_node);
1123                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1124                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1125 ;
1126
1127 ThrowStatement:
1128     THROW Expr ';'                      { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1129                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1130                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2);
1131                                         }
1132   | THROW Expr error                    { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1133                                           SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1134                                           $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; 
1135                                         }
1136 ;
1137
1138 TryStatement:
1139     TRY Block FINALLY Block             { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node),
1140                                                                                          mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
1141                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
1142                                                                                          $2.m_features | $4.m_features,
1143                                                                                          $2.m_numConstants + $4.m_numConstants);
1144                                           DBG($$.m_node, @1, @2); }
1145   | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, 0),
1146                                                                                          mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations),
1147                                                                                          mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations),
1148                                                                                          $2.m_features | $7.m_features | CatchFeature,
1149                                                                                          $2.m_numConstants + $7.m_numConstants);
1150                                           DBG($$.m_node, @1, @2); }
1151   | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
1152                                         { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, $9.m_node),
1153                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations),
1154                                                                                          mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations),
1155                                                                                          $2.m_features | $7.m_features | $9.m_features | CatchFeature,
1156                                                                                          $2.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1157                                           DBG($$.m_node, @1, @2); }
1158 ;
1159
1160 DebuggerStatement:
1161     DEBUGGER ';'                        { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1162                                           DBG($$.m_node, @1, @2); }
1163   | DEBUGGER error                      { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1164                                           DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1165 ;
1166
1167 FunctionDeclaration:
1168     FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); }
1169   | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1170       { 
1171           $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0); 
1172           if ($4.m_features & ArgumentsFeature)
1173               $7->setUsesArguments(); 
1174           DBG($7, @6, @8); 
1175       }
1176 ;
1177
1178 FunctionExpr:
1179     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); }
1180     | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 
1181       { 
1182           $$ = 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); 
1183           if ($3.m_features & ArgumentsFeature) 
1184               $6->setUsesArguments();
1185           DBG($6, @5, @7); 
1186       }
1187   | 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); }
1188   | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE 
1189       { 
1190           $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), $4.m_features | ClosureFeature, 0); 
1191           if ($4.m_features & ArgumentsFeature)
1192               $7->setUsesArguments();
1193           DBG($7, @6, @8); 
1194       }
1195 ;
1196
1197 FormalParameterList:
1198     IDENT                               { $$.m_node.head = new ParameterNode(GLOBAL_DATA, *$1);
1199                                           $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
1200                                           $$.m_node.tail = $$.m_node.head; }
1201   | FormalParameterList ',' IDENT       { $$.m_node.head = $1.m_node.head;
1202                                           $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
1203                                           $$.m_node.tail = new ParameterNode(GLOBAL_DATA, $1.m_node.tail, *$3);  }
1204 ;
1205
1206 FunctionBody:
1207     /* not in spec */           { $$ = FunctionBodyNode::create(GLOBAL_DATA, 0, 0, 0, NoFeatures, 0); }
1208   | SourceElements              { $$ = FunctionBodyNode::create(GLOBAL_DATA, $1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0, 
1209                                                                 $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0,
1210                                                                 $1.m_features, $1.m_numConstants);
1211                                   // As in mergeDeclarationLists() we have to ref/deref to safely get rid of
1212                                   // the declaration lists.
1213                                   if ($1.m_varDeclarations) {
1214                                       $1.m_varDeclarations->ref();
1215                                       $1.m_varDeclarations->deref();
1216                                   }
1217                                   if ($1.m_funcDeclarations) {
1218                                       $1.m_funcDeclarations->ref();
1219                                       $1.m_funcDeclarations->deref();
1220                                   }
1221                                 }
1222 ;
1223
1224 Program:
1225     /* not in spec */                   { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, @0.last_line, 0); }
1226     | SourceElements                    { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, $1.m_features, 
1227                                                                                 @1.last_line, $1.m_numConstants); }
1228 ;
1229
1230 SourceElements:
1231     SourceElement                       { $$.m_node = new SourceElements(GLOBAL_DATA);
1232                                           $$.m_node->append($1.m_node);
1233                                           $$.m_varDeclarations = $1.m_varDeclarations;
1234                                           $$.m_funcDeclarations = $1.m_funcDeclarations;
1235                                           $$.m_features = $1.m_features;
1236                                           $$.m_numConstants = $1.m_numConstants;
1237                                         }
1238   | SourceElements SourceElement        { $$.m_node->append($2.m_node);
1239                                           $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1240                                           $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1241                                           $$.m_features = $1.m_features | $2.m_features;
1242                                           $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1243                                         }
1244 ;
1245
1246 SourceElement:
1247     FunctionDeclaration                 { $$ = createNodeDeclarationInfo<StatementNode*>($1.m_node, 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), $1.m_features, 0); $$.m_funcDeclarations->data.append($1.m_node); }
1248   | Statement                           { $$ = $1; }
1249 ;
1250  
1251 %%
1252
1253 static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end)
1254 {
1255     if (!loc->isLocation())
1256         return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot);
1257
1258     if (loc->isResolveNode()) {
1259         ResolveNode* resolve = static_cast<ResolveNode*>(loc);
1260         if (op == OpEqual) {
1261             AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments);
1262             SET_EXCEPTION_LOCATION(node, start, divot, end);
1263             return node;
1264         } else
1265             return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1266     }
1267     if (loc->isBracketAccessorNode()) {
1268         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc);
1269         if (op == OpEqual)
1270             return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot());
1271         else {
1272             ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot);
1273             node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1274             return node;
1275         }
1276     }
1277     ASSERT(loc->isDotAccessorNode());
1278     DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
1279     if (op == OpEqual)
1280         return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
1281
1282     ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1283     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1284     return node;
1285 }
1286
1287 static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1288 {
1289     if (!expr->isLocation())
1290         return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1291     
1292     if (expr->isResolveNode()) {
1293         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1294         return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1295     }
1296     if (expr->isBracketAccessorNode()) {
1297         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1298         PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1299         node->setSubexpressionInfo(bracket->divot(), bracket->startOffset());
1300         return node;
1301     }
1302     ASSERT(expr->isDotAccessorNode());
1303     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1304     PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1305     node->setSubexpressionInfo(dot->divot(), dot->startOffset());
1306     return node;
1307 }
1308
1309 static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1310
1311     if (!expr->isLocation())
1312         return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1313     
1314     if (expr->isResolveNode()) {
1315         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1316         return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1317     }
1318     if (expr->isBracketAccessorNode()) {
1319         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1320         PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1321         node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1322         return node;
1323         
1324     }
1325     ASSERT(expr->isDotAccessorNode());
1326     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1327     PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1328     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1329     return node;
1330 }
1331
1332 static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end)
1333 {
1334     CodeFeatures features = func.m_features | args.m_features;
1335     int numConstants = func.m_numConstants + args.m_numConstants;
1336     if (!func.m_node->isLocation())
1337         return createNodeInfo<ExpressionNode*>(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants);
1338     if (func.m_node->isResolveNode()) {
1339         ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node);
1340         const Identifier& identifier = resolve->identifier();
1341         if (identifier == GLOBAL_DATA->propertyNames->eval)
1342             return createNodeInfo<ExpressionNode*>(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants);
1343         return createNodeInfo<ExpressionNode*>(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants);
1344     }
1345     if (func.m_node->isBracketAccessorNode()) {
1346         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func.m_node);
1347         FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot);
1348         node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1349         return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1350     }
1351     ASSERT(func.m_node->isDotAccessorNode());
1352     DotAccessorNode* dot = static_cast<DotAccessorNode*>(func.m_node);
1353     FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot);
1354     node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1355     return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1356 }
1357
1358 static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr)
1359 {
1360     if (expr->isResolveNode()) {
1361         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1362         return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier());
1363     }
1364     return new TypeOfValueNode(GLOBAL_DATA, expr);
1365 }
1366
1367 static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end)
1368 {
1369     if (!expr->isLocation())
1370         return new DeleteValueNode(GLOBAL_DATA, expr);
1371     if (expr->isResolveNode()) {
1372         ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1373         return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot);
1374     }
1375     if (expr->isBracketAccessorNode()) {
1376         BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1377         return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot);
1378     }
1379     ASSERT(expr->isDotAccessorNode());
1380     DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1381     return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot);
1382 }
1383
1384 static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source)
1385 {
1386     PropertyNode::Type type;
1387     if (getOrSet == "get")
1388         type = PropertyNode::Getter;
1389     else if (getOrSet == "set")
1390         type = PropertyNode::Setter;
1391     else
1392         return 0;
1393     return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type);
1394 }
1395
1396 static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n)
1397 {
1398     if (n->isNumber()) {
1399         NumberNode* number = static_cast<NumberNode*>(n);
1400
1401         if (number->value() > 0.0) {
1402             number->setValue(-number->value());
1403             return number;
1404         }
1405     }
1406
1407     return new NegateNode(GLOBAL_DATA, n);
1408 }
1409
1410 static NumberNode* makeNumberNode(void* globalPtr, double d)
1411 {
1412     JSValue* value = JSImmediate::from(d);
1413     if (value)
1414         return new ImmediateNumberNode(GLOBAL_DATA, value, d);
1415     return new NumberNode(GLOBAL_DATA, d);
1416 }
1417
1418 static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr)
1419 {
1420     if (expr->isNumber())
1421         return makeNumberNode(globalPtr, ~JSValue::toInt32(static_cast<NumberNode*>(expr)->value()));
1422     return new BitwiseNotNode(GLOBAL_DATA, expr);
1423 }
1424
1425 static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1426 {
1427     expr1 = expr1->stripUnaryPlus();
1428     expr2 = expr2->stripUnaryPlus();
1429
1430     if (expr1->isNumber() && expr2->isNumber())
1431         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
1432
1433     if (expr1->isNumber() && static_cast<NumberNode*>(expr1)->value() == 1)
1434         return new UnaryPlusNode(GLOBAL_DATA, expr2);
1435
1436     if (expr2->isNumber() && static_cast<NumberNode*>(expr2)->value() == 1)
1437         return new UnaryPlusNode(GLOBAL_DATA, expr1);
1438
1439     return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1440 }
1441
1442 static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1443 {
1444     expr1 = expr1->stripUnaryPlus();
1445     expr2 = expr2->stripUnaryPlus();
1446
1447     if (expr1->isNumber() && expr2->isNumber())
1448         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
1449     return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1450 }
1451
1452 static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1453 {
1454     if (expr1->isNumber() && expr2->isNumber())
1455         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
1456     return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1457 }
1458
1459 static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1460 {
1461     expr1 = expr1->stripUnaryPlus();
1462     expr2 = expr2->stripUnaryPlus();
1463
1464     if (expr1->isNumber() && expr2->isNumber())
1465         return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value());
1466     return new SubNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1467 }
1468
1469 static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1470 {
1471     if (expr1->isNumber() && expr2->isNumber())
1472         return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) << (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1473     return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1474 }
1475
1476 static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1477 {
1478     if (expr1->isNumber() && expr2->isNumber())
1479         return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) >> (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1480     return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1481 }
1482
1483 /* called by yyparse on error */
1484 int yyerror(const char *)
1485 {
1486     return 1;
1487 }
1488
1489 /* may we automatically insert a semicolon ? */
1490 static bool allowAutomaticSemicolon(Lexer& lexer, int yychar)
1491 {
1492     return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator();
1493 }
1494
1495 static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init)
1496 {
1497     if (!list)
1498         return init;
1499     return new VarDeclCommaNode(GLOBAL_DATA, list, init);
1500 }
1501
1502 // We turn variable declarations into either assignments or empty
1503 // statements (which later get stripped out), because the actual
1504 // declaration work is hoisted up to the start of the function body
1505 static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr)
1506 {
1507     if (!expr)
1508         return new EmptyStatementNode(GLOBAL_DATA);
1509     return new VarStatementNode(GLOBAL_DATA, expr);
1510 }
1511
1512 #undef GLOBAL_DATA