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