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