6 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
7 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
8 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
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.
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.
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
35 #include "JSGlobalData.h"
36 #include "CommonIdentifiers.h"
39 #include <wtf/MathExtras.h>
41 #define YYMAXDEPTH 10000
42 #define YYENABLE_NLS 0
44 /* default values for bison */
45 #define YYDEBUG 0 // Set to 1 to debug a parse error.
46 #define kjsyydebug 0 // Set to 1 to debug a parse error.
48 // avoid triggering warnings in older bison
49 #define YYERROR_VERBOSE
52 int kjsyylex(void* lvalp, void* llocp, void* globalPtr);
53 int kjsyyerror(const char*);
54 static inline bool allowAutomaticSemicolon(JSC::Lexer&, int);
56 #define GLOBAL_DATA static_cast<JSGlobalData*>(globalPtr)
57 #define LEXER (GLOBAL_DATA->lexer)
59 #define AUTO_SEMICOLON do { if (!allowAutomaticSemicolon(*LEXER, yychar)) YYABORT; } while (0)
60 #define SET_EXCEPTION_LOCATION(node, start, divot, end) node->setExceptionSourceRange((divot), (divot) - (start), (end) - (divot))
61 #define DBG(l, s, e) (l)->setLoc((s).first_line, (e).last_line)
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* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
80 static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
81 static StatementNode* makeVarStatementNode(void*, ExpressionNode*);
82 static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init);
86 #pragma warning(disable: 4065)
87 #pragma warning(disable: 4244)
88 #pragma warning(disable: 4702)
90 // At least some of the time, the declarations of malloc and free that bison
91 // generates are causing warnings. A way to avoid this is to explicitly define
92 // the macros so that bison doesn't try to declare malloc and free.
93 #define YYMALLOC malloc
98 #define YYPARSE_PARAM globalPtr
99 #define YYLEX_PARAM globalPtr
101 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls,
102 ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls,
106 ASSERT((info & ~AllFeatures) == 0);
107 NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants};
111 template <typename T> NodeInfo<T> createNodeInfo(T node, CodeFeatures info, int numConstants)
113 ASSERT((info & ~AllFeatures) == 0);
114 NodeInfo<T> result = {node, info, numConstants};
118 template <typename T> T mergeDeclarationLists(T decls1, T decls2)
120 // decls1 or both are null
123 // only decls1 is non-null
128 decls1->data.append(decls2->data);
130 // We manually release the declaration lists to avoid accumulating many many
131 // unused heap allocated vectors
137 static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, const Identifier& ident, unsigned attrs)
140 varDecls = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
142 varDecls->data.append(make_pair(ident, attrs));
146 static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, ConstDeclNode* decl)
148 unsigned attrs = DeclarationStacks::IsConstant;
150 attrs |= DeclarationStacks::HasInitializer;
151 appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs);
161 // expression subtrees
162 ExpressionNodeInfo expressionNode;
163 FuncDeclNodeInfo funcDeclNode;
164 PropertyNodeInfo propertyNode;
165 ArgumentsNodeInfo argumentsNode;
166 ConstDeclNodeInfo constDeclNode;
167 CaseBlockNodeInfo caseBlockNode;
168 CaseClauseNodeInfo caseClauseNode;
169 FuncExprNodeInfo funcExprNode;
172 StatementNodeInfo statementNode;
173 FunctionBodyNode* functionBodyNode;
174 ProgramNode* programNode;
176 SourceElementsInfo sourceElements;
177 PropertyListInfo propertyList;
178 ArgumentListInfo argumentList;
179 VarDeclListInfo varDeclList;
180 ConstDeclListInfo constDeclList;
181 ClauseListInfo clauseList;
182 ElementListInfo elementList;
183 ParameterListInfo parameterList;
191 %token NULLTOKEN TRUETOKEN FALSETOKEN
194 %token BREAK CASE DEFAULT FOR NEW VAR CONSTTOKEN CONTINUE
195 %token FUNCTION RETURN VOIDTOKEN DELETETOKEN
196 %token IF THISTOKEN DO WHILE INTOKEN INSTANCEOF TYPEOF
197 %token SWITCH WITH RESERVED
198 %token THROW TRY CATCH FINALLY
201 /* give an if without an else higher precedence than an else to resolve the ambiguity */
202 %nonassoc IF_WITHOUT_ELSE
206 %token EQEQ NE /* == and != */
207 %token STREQ STRNEQ /* === and !== */
208 %token LE GE /* < and > */
209 %token OR AND /* || and && */
210 %token PLUSPLUS MINUSMINUS /* ++ and -- */
211 %token LSHIFT /* << */
212 %token RSHIFT URSHIFT /* >> and >>> */
213 %token PLUSEQUAL MINUSEQUAL /* += and -= */
214 %token MULTEQUAL DIVEQUAL /* *= and /= */
215 %token LSHIFTEQUAL /* <<= */
216 %token RSHIFTEQUAL URSHIFTEQUAL /* >>= and >>>= */
217 %token ANDEQUAL MODEQUAL /* &= and %= */
218 %token XOREQUAL OREQUAL /* ^= and |= */
219 %token <intValue> OPENBRACE /* { (with char offset) */
220 %token <intValue> CLOSEBRACE /* { (with char offset) */
223 %token <doubleValue> NUMBER
224 %token <ident> IDENT STRING
226 /* automatically inserted semicolon */
227 %token AUTOPLUSPLUS AUTOMINUSMINUS
229 /* non-terminal types */
230 %type <expressionNode> Literal ArrayLiteral
232 %type <expressionNode> PrimaryExpr PrimaryExprNoBrace
233 %type <expressionNode> MemberExpr MemberExprNoBF /* BF => brace or function */
234 %type <expressionNode> NewExpr NewExprNoBF
235 %type <expressionNode> CallExpr CallExprNoBF
236 %type <expressionNode> LeftHandSideExpr LeftHandSideExprNoBF
237 %type <expressionNode> PostfixExpr PostfixExprNoBF
238 %type <expressionNode> UnaryExpr UnaryExprNoBF UnaryExprCommon
239 %type <expressionNode> MultiplicativeExpr MultiplicativeExprNoBF
240 %type <expressionNode> AdditiveExpr AdditiveExprNoBF
241 %type <expressionNode> ShiftExpr ShiftExprNoBF
242 %type <expressionNode> RelationalExpr RelationalExprNoIn RelationalExprNoBF
243 %type <expressionNode> EqualityExpr EqualityExprNoIn EqualityExprNoBF
244 %type <expressionNode> BitwiseANDExpr BitwiseANDExprNoIn BitwiseANDExprNoBF
245 %type <expressionNode> BitwiseXORExpr BitwiseXORExprNoIn BitwiseXORExprNoBF
246 %type <expressionNode> BitwiseORExpr BitwiseORExprNoIn BitwiseORExprNoBF
247 %type <expressionNode> LogicalANDExpr LogicalANDExprNoIn LogicalANDExprNoBF
248 %type <expressionNode> LogicalORExpr LogicalORExprNoIn LogicalORExprNoBF
249 %type <expressionNode> ConditionalExpr ConditionalExprNoIn ConditionalExprNoBF
250 %type <expressionNode> AssignmentExpr AssignmentExprNoIn AssignmentExprNoBF
251 %type <expressionNode> Expr ExprNoIn ExprNoBF
253 %type <expressionNode> ExprOpt ExprNoInOpt
255 %type <statementNode> Statement Block
256 %type <statementNode> VariableStatement ConstStatement EmptyStatement ExprStatement
257 %type <statementNode> IfStatement IterationStatement ContinueStatement
258 %type <statementNode> BreakStatement ReturnStatement WithStatement
259 %type <statementNode> SwitchStatement LabelledStatement
260 %type <statementNode> ThrowStatement TryStatement
261 %type <statementNode> DebuggerStatement
262 %type <statementNode> SourceElement
264 %type <expressionNode> Initializer InitializerNoIn
265 %type <funcDeclNode> 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
286 NULLTOKEN { $$ = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); }
287 | TRUETOKEN { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); }
288 | FALSETOKEN { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); }
289 | NUMBER { $$ = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, $1), 0, 1); }
290 | STRING { $$ = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *$1), 0, 1); }
295 RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags());
296 int size = l.pattern().size() + 2; // + 2 for the two /'s
297 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
298 $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
300 | DIVEQUAL /* regexp with /= */ {
304 RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags());
305 int size = l.pattern().size() + 2; // + 2 for the two /'s
306 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
307 $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
312 IDENT ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
313 | STRING ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
314 | NUMBER ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
315 | 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; }
316 | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
318 $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0);
319 if ($4.m_features & ArgumentsFeature)
320 $7->setUsesArguments();
328 Property { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node);
329 $$.m_node.tail = $$.m_node.head;
330 $$.m_features = $1.m_features;
331 $$.m_numConstants = $1.m_numConstants; }
332 | PropertyList ',' Property { $$.m_node.head = $1.m_node.head;
333 $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail);
334 $$.m_features = $1.m_features | $3.m_features;
335 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
340 | OPENBRACE CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); }
341 | OPENBRACE PropertyList CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
342 /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */
343 | OPENBRACE PropertyList ',' CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
347 THISTOKEN { $$ = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }
350 | IDENT { $$ = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
351 | '(' Expr ')' { $$ = $2; }
355 '[' ElisionOpt ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); }
356 | '[' ElementList ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
357 | '[' ElementList ',' ElisionOpt ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); }
361 ElisionOpt AssignmentExpr { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node);
362 $$.m_node.tail = $$.m_node.head;
363 $$.m_features = $2.m_features;
364 $$.m_numConstants = $2.m_numConstants; }
365 | ElementList ',' ElisionOpt AssignmentExpr
366 { $$.m_node.head = $1.m_node.head;
367 $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node);
368 $$.m_features = $1.m_features | $4.m_features;
369 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; }
373 /* nothing */ { $$ = 0; }
379 | Elision ',' { $$ = $1 + 1; }
384 | FunctionExpr { $$ = createNodeInfo<ExpressionNode*>($1.m_node, $1.m_features, $1.m_numConstants); }
385 | MemberExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
386 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
387 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
389 | MemberExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
390 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
391 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
393 | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
394 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
395 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
401 | MemberExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
402 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
403 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
405 | MemberExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
406 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
407 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
409 | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
410 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
411 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
417 | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
418 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
419 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
425 | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
426 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
427 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
432 MemberExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
433 | CallExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
434 | CallExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
435 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
436 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
438 | CallExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
439 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
440 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); }
444 MemberExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
445 | CallExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
446 | CallExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
447 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
448 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
450 | CallExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
451 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
452 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
457 '(' ')' { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA), 0, 0); }
458 | '(' ArgumentList ')' { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
462 AssignmentExpr { $$.m_node.head = new ArgumentListNode(GLOBAL_DATA, $1.m_node);
463 $$.m_node.tail = $$.m_node.head;
464 $$.m_features = $1.m_features;
465 $$.m_numConstants = $1.m_numConstants; }
466 | ArgumentList ',' AssignmentExpr { $$.m_node.head = $1.m_node.head;
467 $$.m_node.tail = new ArgumentListNode(GLOBAL_DATA, $1.m_node.tail, $3.m_node);
468 $$.m_features = $1.m_features | $3.m_features;
469 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
477 LeftHandSideExprNoBF:
484 | 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); }
485 | 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 | 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); }
491 | LeftHandSideExprNoBF MINUSMINUS { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
495 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); }
496 | VOIDTOKEN UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new VoidNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants + 1); }
497 | TYPEOF UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeTypeOfNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
498 | 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); }
499 | 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); }
500 | 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); }
501 | 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); }
502 | '+' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new UnaryPlusNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
503 | '-' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeNegateNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
504 | '~' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeBitwiseNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
505 | '!' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
519 | 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); }
520 | 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); }
521 | MultiplicativeExpr '%' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
524 MultiplicativeExprNoBF:
526 | MultiplicativeExprNoBF '*' UnaryExpr
527 { $$ = createNodeInfo<ExpressionNode*>(new MultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
528 | MultiplicativeExprNoBF '/' UnaryExpr
529 { $$ = createNodeInfo<ExpressionNode*>(new DivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
530 | MultiplicativeExprNoBF '%' UnaryExpr
531 { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
536 | 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); }
537 | AdditiveExpr '-' MultiplicativeExpr { $$ = createNodeInfo<ExpressionNode*>(new SubNode(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 MultiplicativeExprNoBF
542 | AdditiveExprNoBF '+' MultiplicativeExpr
543 { $$ = createNodeInfo<ExpressionNode*>(new AddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
544 | AdditiveExprNoBF '-' MultiplicativeExpr
545 { $$ = createNodeInfo<ExpressionNode*>(new SubNode(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 | 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); }
551 | 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); }
552 | ShiftExpr URSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
557 | ShiftExprNoBF LSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new LeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
558 | ShiftExprNoBF RSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new RightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
559 | ShiftExprNoBF URSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
564 | RelationalExpr '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
565 | RelationalExpr '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
566 | RelationalExpr LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
567 | RelationalExpr GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
568 | RelationalExpr INSTANCEOF ShiftExpr { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
569 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
570 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
571 | RelationalExpr INTOKEN ShiftExpr { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
572 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
573 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
578 | RelationalExprNoIn '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
579 | RelationalExprNoIn '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
580 | RelationalExprNoIn LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
581 | RelationalExprNoIn GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
582 | RelationalExprNoIn INSTANCEOF ShiftExpr
583 { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
584 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
585 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
590 | RelationalExprNoBF '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
591 | RelationalExprNoBF '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
592 | RelationalExprNoBF LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
593 | RelationalExprNoBF GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
594 | RelationalExprNoBF INSTANCEOF ShiftExpr
595 { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
596 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
597 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
598 | RelationalExprNoBF INTOKEN ShiftExpr
599 { InNode* node = new InNode(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); }
606 | EqualityExpr EQEQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
607 | EqualityExpr NE RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
608 | EqualityExpr STREQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
609 | EqualityExpr STRNEQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
614 | EqualityExprNoIn EQEQ RelationalExprNoIn
615 { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
616 | EqualityExprNoIn NE RelationalExprNoIn
617 { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
618 | EqualityExprNoIn STREQ RelationalExprNoIn
619 { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
620 | EqualityExprNoIn STRNEQ RelationalExprNoIn
621 { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
626 | EqualityExprNoBF EQEQ RelationalExpr
627 { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
628 | EqualityExprNoBF NE RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
629 | EqualityExprNoBF STREQ RelationalExpr
630 { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
631 | EqualityExprNoBF STRNEQ RelationalExpr
632 { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
637 | BitwiseANDExpr '&' EqualityExpr { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
642 | BitwiseANDExprNoIn '&' EqualityExprNoIn
643 { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
648 | BitwiseANDExprNoBF '&' EqualityExpr { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
653 | BitwiseXORExpr '^' BitwiseANDExpr { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
658 | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn
659 { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
664 | BitwiseXORExprNoBF '^' BitwiseANDExpr
665 { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
670 | BitwiseORExpr '|' BitwiseXORExpr { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
675 | BitwiseORExprNoIn '|' BitwiseXORExprNoIn
676 { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
681 | BitwiseORExprNoBF '|' BitwiseXORExpr
682 { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
687 | LogicalANDExpr AND BitwiseORExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
692 | LogicalANDExprNoIn AND BitwiseORExprNoIn
693 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
698 | LogicalANDExprNoBF AND BitwiseORExpr
699 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
704 | LogicalORExpr OR LogicalANDExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
709 | LogicalORExprNoIn OR LogicalANDExprNoIn
710 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
715 | LogicalORExprNoBF OR LogicalANDExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
720 | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr
721 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
726 | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn
727 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
732 | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr
733 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
738 | LeftHandSideExpr AssignmentOperator AssignmentExpr
739 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
740 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
746 | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn
747 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
748 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
754 | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr
755 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
756 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
761 '=' { $$ = OpEqual; }
762 | PLUSEQUAL { $$ = OpPlusEq; }
763 | MINUSEQUAL { $$ = OpMinusEq; }
764 | MULTEQUAL { $$ = OpMultEq; }
765 | DIVEQUAL { $$ = OpDivEq; }
766 | LSHIFTEQUAL { $$ = OpLShift; }
767 | RSHIFTEQUAL { $$ = OpRShift; }
768 | URSHIFTEQUAL { $$ = OpURShift; }
769 | ANDEQUAL { $$ = OpAndEq; }
770 | XOREQUAL { $$ = OpXOrEq; }
771 | OREQUAL { $$ = OpOrEq; }
772 | MODEQUAL { $$ = OpModEq; }
777 | Expr ',' AssignmentExpr { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
782 | ExprNoIn ',' AssignmentExprNoIn { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
787 | ExprNoBF ',' AssignmentExpr { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
810 OPENBRACE CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0);
811 DBG($$.m_node, @1, @2); }
812 | OPENBRACE SourceElements CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
813 DBG($$.m_node, @1, @3); }
817 VAR VariableDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
818 DBG($$.m_node, @1, @3); }
819 | VAR VariableDeclarationList error { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
820 DBG($$.m_node, @1, @2);
824 VariableDeclarationList:
825 IDENT { $$.m_node = 0;
826 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
827 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
828 $$.m_funcDeclarations = 0;
829 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
830 $$.m_numConstants = 0;
832 | IDENT Initializer { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
833 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
835 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
836 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
837 $$.m_funcDeclarations = 0;
838 $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
839 $$.m_numConstants = $2.m_numConstants;
841 | VariableDeclarationList ',' IDENT
842 { $$.m_node = $1.m_node;
843 $$.m_varDeclarations = $1.m_varDeclarations;
844 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
845 $$.m_funcDeclarations = 0;
846 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
847 $$.m_numConstants = $1.m_numConstants;
849 | VariableDeclarationList ',' IDENT Initializer
850 { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
851 SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
852 $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
853 $$.m_varDeclarations = $1.m_varDeclarations;
854 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
855 $$.m_funcDeclarations = 0;
856 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
857 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
861 VariableDeclarationListNoIn:
862 IDENT { $$.m_node = 0;
863 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
864 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
865 $$.m_funcDeclarations = 0;
866 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
867 $$.m_numConstants = 0;
869 | IDENT InitializerNoIn { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
870 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
872 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
873 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
874 $$.m_funcDeclarations = 0;
875 $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
876 $$.m_numConstants = $2.m_numConstants;
878 | VariableDeclarationListNoIn ',' IDENT
879 { $$.m_node = $1.m_node;
880 $$.m_varDeclarations = $1.m_varDeclarations;
881 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
882 $$.m_funcDeclarations = 0;
883 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
884 $$.m_numConstants = $1.m_numConstants;
886 | VariableDeclarationListNoIn ',' IDENT InitializerNoIn
887 { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
888 SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
889 $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
890 $$.m_varDeclarations = $1.m_varDeclarations;
891 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
892 $$.m_funcDeclarations = 0;
893 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
894 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
899 CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
900 DBG($$.m_node, @1, @3); }
901 | CONSTTOKEN ConstDeclarationList error
902 { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
903 DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
906 ConstDeclarationList:
907 ConstDeclaration { $$.m_node.head = $1.m_node;
908 $$.m_node.tail = $$.m_node.head;
909 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
910 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $1.m_node);
911 $$.m_funcDeclarations = 0;
912 $$.m_features = $1.m_features;
913 $$.m_numConstants = $1.m_numConstants;
915 | ConstDeclarationList ',' ConstDeclaration
916 { $$.m_node.head = $1.m_node.head;
917 $1.m_node.tail->m_next = $3.m_node;
918 $$.m_node.tail = $3.m_node;
919 $$.m_varDeclarations = $1.m_varDeclarations;
920 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $3.m_node);
921 $$.m_funcDeclarations = 0;
922 $$.m_features = $1.m_features | $3.m_features;
923 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
927 IDENT { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, 0), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
928 | IDENT Initializer { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, $2.m_node), ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features, $2.m_numConstants); }
932 '=' AssignmentExpr { $$ = $2; }
936 '=' AssignmentExprNoIn { $$ = $2; }
940 ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); }
944 ExprNoBF ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
945 DBG($$.m_node, @1, @2); }
946 | ExprNoBF error { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
947 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
951 IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE
952 { $$ = createNodeDeclarationInfo<StatementNode*>(new IfNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
953 DBG($$.m_node, @1, @4); }
954 | IF '(' Expr ')' Statement ELSE Statement
955 { $$ = createNodeDeclarationInfo<StatementNode*>(new IfElseNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node),
956 mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations),
957 $3.m_features | $5.m_features | $7.m_features,
958 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
959 DBG($$.m_node, @1, @4); }
963 DO Statement WHILE '(' Expr ')' ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
964 DBG($$.m_node, @1, @3); }
965 | DO Statement WHILE '(' Expr ')' error { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
966 DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion.
967 | WHILE '(' Expr ')' Statement { $$ = createNodeDeclarationInfo<StatementNode*>(new WhileNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
968 DBG($$.m_node, @1, @4); }
969 | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement
970 { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations,
971 $3.m_features | $5.m_features | $7.m_features | $9.m_features,
972 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
973 DBG($$.m_node, @1, @8);
975 | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement
976 { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $4.m_node, $6.m_node, $8.m_node, $10.m_node, true),
977 mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations),
978 mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations),
979 $4.m_features | $6.m_features | $8.m_features | $10.m_features,
980 $4.m_numConstants + $6.m_numConstants + $8.m_numConstants + $10.m_numConstants);
981 DBG($$.m_node, @1, @9); }
982 | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement
984 ForInNode* node = new ForInNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node);
985 SET_EXCEPTION_LOCATION(node, @3.first_column, @3.last_column, @5.last_column);
986 $$ = createNodeDeclarationInfo<StatementNode*>(node, $7.m_varDeclarations, $7.m_funcDeclarations,
987 $3.m_features | $5.m_features | $7.m_features,
988 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
989 DBG($$.m_node, @1, @6);
991 | FOR '(' VAR IDENT INTOKEN Expr ')' Statement
992 { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, 0, $6.m_node, $8.m_node, @5.first_column, @5.first_column - @4.first_column, @6.last_column - @5.first_column);
993 SET_EXCEPTION_LOCATION(forIn, @4.first_column, @5.first_column + 1, @6.last_column);
994 appendToVarDeclarationList(GLOBAL_DATA, $8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
995 $$ = 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);
996 DBG($$.m_node, @1, @7); }
997 | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement
998 { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, $5.m_node, $7.m_node, $9.m_node, @5.first_column, @5.first_column - @4.first_column, @5.last_column - @5.first_column);
999 SET_EXCEPTION_LOCATION(forIn, @4.first_column, @6.first_column + 1, @7.last_column);
1000 appendToVarDeclarationList(GLOBAL_DATA, $9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
1001 $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $9.m_varDeclarations, $9.m_funcDeclarations,
1002 ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $5.m_features | $7.m_features | $9.m_features,
1003 $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1004 DBG($$.m_node, @1, @8); }
1008 /* nothing */ { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1013 /* nothing */ { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1018 CONTINUE ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1019 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1020 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1021 DBG($$.m_node, @1, @2); }
1022 | CONTINUE error { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1023 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1024 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1025 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1026 | CONTINUE IDENT ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1027 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1028 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1029 DBG($$.m_node, @1, @3); }
1030 | CONTINUE IDENT error { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1031 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1032 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1033 DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1037 BREAK ';' { BreakNode* node = new BreakNode(GLOBAL_DATA);
1038 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1039 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1040 | BREAK error { BreakNode* node = new BreakNode(GLOBAL_DATA);
1041 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1042 $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1043 | BREAK IDENT ';' { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1044 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1045 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @3); }
1046 | BREAK IDENT error { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1047 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1048 $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA, *$2), 0, 0, 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1052 RETURN ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0);
1053 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1054 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1055 | RETURN error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0);
1056 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1057 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1058 | RETURN Expr ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node);
1059 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1060 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @3); }
1061 | RETURN Expr error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node);
1062 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1063 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1067 WITH '(' Expr ')' Statement { $$ = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column),
1068 $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features | WithFeature, $3.m_numConstants + $5.m_numConstants);
1069 DBG($$.m_node, @1, @4); }
1073 SWITCH '(' Expr ')' CaseBlock { $$ = createNodeDeclarationInfo<StatementNode*>(new SwitchNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations,
1074 $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
1075 DBG($$.m_node, @1, @4); }
1079 OPENBRACE CaseClausesOpt CLOSEBRACE { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); }
1080 | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE
1081 { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, $3.m_node, $4.m_node.head),
1082 mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations),
1083 mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations),
1084 $2.m_features | $3.m_features | $4.m_features,
1085 $2.m_numConstants + $3.m_numConstants + $4.m_numConstants); }
1089 /* nothing */ { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; $$.m_features = 0; $$.m_numConstants = 0; }
1094 CaseClause { $$.m_node.head = new ClauseListNode(GLOBAL_DATA, $1.m_node);
1095 $$.m_node.tail = $$.m_node.head;
1096 $$.m_varDeclarations = $1.m_varDeclarations;
1097 $$.m_funcDeclarations = $1.m_funcDeclarations;
1098 $$.m_features = $1.m_features;
1099 $$.m_numConstants = $1.m_numConstants; }
1100 | CaseClauses CaseClause { $$.m_node.head = $1.m_node.head;
1101 $$.m_node.tail = new ClauseListNode(GLOBAL_DATA, $1.m_node.tail, $2.m_node);
1102 $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1103 $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1104 $$.m_features = $1.m_features | $2.m_features;
1105 $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1110 CASE Expr ':' { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node), 0, 0, $2.m_features, $2.m_numConstants); }
1111 | CASE Expr ':' SourceElements { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations, $2.m_features | $4.m_features, $2.m_numConstants + $4.m_numConstants); }
1115 DEFAULT ':' { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); }
1116 | DEFAULT ':' SourceElements { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1120 IDENT ':' Statement { $3.m_node->pushLabel(*$1);
1121 LabelNode* node = new LabelNode(GLOBAL_DATA, *$1, $3.m_node);
1122 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1123 $$ = createNodeDeclarationInfo<StatementNode*>(node, $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1127 THROW Expr ';' { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1128 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1129 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2);
1131 | THROW Expr error { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1132 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1133 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON;
1138 TRY Block FINALLY Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node),
1139 mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
1140 mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
1141 $2.m_features | $4.m_features,
1142 $2.m_numConstants + $4.m_numConstants);
1143 DBG($$.m_node, @1, @2); }
1144 | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, 0),
1145 mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations),
1146 mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations),
1147 $2.m_features | $7.m_features | CatchFeature,
1148 $2.m_numConstants + $7.m_numConstants);
1149 DBG($$.m_node, @1, @2); }
1150 | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
1151 { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, $9.m_node),
1152 mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations),
1153 mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations),
1154 $2.m_features | $7.m_features | $9.m_features | CatchFeature,
1155 $2.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1156 DBG($$.m_node, @1, @2); }
1160 DEBUGGER ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1161 DBG($$.m_node, @1, @2); }
1162 | DEBUGGER error { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1163 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1166 FunctionDeclaration:
1167 FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); }
1168 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1170 $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0);
1171 if ($4.m_features & ArgumentsFeature)
1172 $7->setUsesArguments();
1178 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); }
1179 | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1181 $$ = 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);
1182 if ($3.m_features & ArgumentsFeature)
1183 $6->setUsesArguments();
1186 | 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); }
1187 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1189 $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), $4.m_features | ClosureFeature, 0);
1190 if ($4.m_features & ArgumentsFeature)
1191 $7->setUsesArguments();
1196 FormalParameterList:
1197 IDENT { $$.m_node.head = new ParameterNode(GLOBAL_DATA, *$1);
1198 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
1199 $$.m_node.tail = $$.m_node.head; }
1200 | FormalParameterList ',' IDENT { $$.m_node.head = $1.m_node.head;
1201 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
1202 $$.m_node.tail = new ParameterNode(GLOBAL_DATA, $1.m_node.tail, *$3); }
1206 /* not in spec */ { $$ = FunctionBodyNode::create(GLOBAL_DATA, 0, 0, 0, NoFeatures, 0); }
1207 | SourceElements { $$ = FunctionBodyNode::create(GLOBAL_DATA, $1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0,
1208 $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0,
1209 $1.m_features, $1.m_numConstants);
1210 // As in mergeDeclarationLists() we have to ref/deref to safely get rid of
1211 // the declaration lists.
1212 if ($1.m_varDeclarations) {
1213 $1.m_varDeclarations->ref();
1214 $1.m_varDeclarations->deref();
1216 if ($1.m_funcDeclarations) {
1217 $1.m_funcDeclarations->ref();
1218 $1.m_funcDeclarations->deref();
1224 /* not in spec */ { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, @0.last_line, 0); }
1225 | SourceElements { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, $1.m_features,
1226 @1.last_line, $1.m_numConstants); }
1230 SourceElement { $$.m_node = new SourceElements(GLOBAL_DATA);
1231 $$.m_node->append($1.m_node);
1232 $$.m_varDeclarations = $1.m_varDeclarations;
1233 $$.m_funcDeclarations = $1.m_funcDeclarations;
1234 $$.m_features = $1.m_features;
1235 $$.m_numConstants = $1.m_numConstants;
1237 | SourceElements SourceElement { $$.m_node->append($2.m_node);
1238 $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1239 $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1240 $$.m_features = $1.m_features | $2.m_features;
1241 $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1246 FunctionDeclaration { $$ = createNodeDeclarationInfo<StatementNode*>($1.m_node, 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), $1.m_features, 0); $$.m_funcDeclarations->data.append($1.m_node); }
1247 | Statement { $$ = $1; }
1252 static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end)
1254 if (!loc->isLocation())
1255 return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot);
1257 if (loc->isResolveNode()) {
1258 ResolveNode* resolve = static_cast<ResolveNode*>(loc);
1259 if (op == OpEqual) {
1260 AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments);
1261 SET_EXCEPTION_LOCATION(node, start, divot, end);
1264 return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1266 if (loc->isBracketAccessorNode()) {
1267 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc);
1269 return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot());
1271 ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot);
1272 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1276 ASSERT(loc->isDotAccessorNode());
1277 DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
1279 return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
1281 ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1282 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1286 static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1288 if (!expr->isLocation())
1289 return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1291 if (expr->isResolveNode()) {
1292 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1293 return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1295 if (expr->isBracketAccessorNode()) {
1296 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1297 PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1298 node->setSubexpressionInfo(bracket->divot(), bracket->startOffset());
1301 ASSERT(expr->isDotAccessorNode());
1302 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1303 PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1304 node->setSubexpressionInfo(dot->divot(), dot->startOffset());
1308 static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1310 if (!expr->isLocation())
1311 return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1313 if (expr->isResolveNode()) {
1314 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1315 return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1317 if (expr->isBracketAccessorNode()) {
1318 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1319 PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1320 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1324 ASSERT(expr->isDotAccessorNode());
1325 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1326 PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1327 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1331 static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end)
1333 CodeFeatures features = func.m_features | args.m_features;
1334 int numConstants = func.m_numConstants + args.m_numConstants;
1335 if (!func.m_node->isLocation())
1336 return createNodeInfo<ExpressionNode*>(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants);
1337 if (func.m_node->isResolveNode()) {
1338 ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node);
1339 const Identifier& identifier = resolve->identifier();
1340 if (identifier == GLOBAL_DATA->propertyNames->eval)
1341 return createNodeInfo<ExpressionNode*>(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants);
1342 return createNodeInfo<ExpressionNode*>(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants);
1344 if (func.m_node->isBracketAccessorNode()) {
1345 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func.m_node);
1346 FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot);
1347 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1348 return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1350 ASSERT(func.m_node->isDotAccessorNode());
1351 DotAccessorNode* dot = static_cast<DotAccessorNode*>(func.m_node);
1352 FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot);
1353 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1354 return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1357 static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr)
1359 if (expr->isResolveNode()) {
1360 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1361 return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier());
1363 return new TypeOfValueNode(GLOBAL_DATA, expr);
1366 static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end)
1368 if (!expr->isLocation())
1369 return new DeleteValueNode(GLOBAL_DATA, expr);
1370 if (expr->isResolveNode()) {
1371 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1372 return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot);
1374 if (expr->isBracketAccessorNode()) {
1375 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1376 return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot);
1378 ASSERT(expr->isDotAccessorNode());
1379 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1380 return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot);
1383 static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source)
1385 PropertyNode::Type type;
1386 if (getOrSet == "get")
1387 type = PropertyNode::Getter;
1388 else if (getOrSet == "set")
1389 type = PropertyNode::Setter;
1392 return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type);
1395 static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n)
1397 if (n->isNumber()) {
1398 NumberNode* number = static_cast<NumberNode*>(n);
1400 if (number->value() > 0.0) {
1401 number->setValue(-number->value());
1406 return new NegateNode(GLOBAL_DATA, n);
1409 static NumberNode* makeNumberNode(void* globalPtr, double d)
1411 JSValue* value = JSImmediate::from(d);
1413 return new ImmediateNumberNode(GLOBAL_DATA, value, d);
1414 return new NumberNode(GLOBAL_DATA, d);
1417 static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr)
1419 if (expr->isNumber())
1420 return makeNumberNode(globalPtr, ~JSValue::toInt32(static_cast<NumberNode*>(expr)->value()));
1421 return new BitwiseNotNode(GLOBAL_DATA, expr);
1424 static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1426 if (expr1->isNumber() && expr2->isNumber())
1427 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
1428 return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1431 static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1433 if (expr1->isNumber() && expr2->isNumber())
1434 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
1435 return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1438 static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1440 if (expr1->isNumber() && expr2->isNumber())
1441 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
1442 return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1445 static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1447 if (expr1->isNumber() && expr2->isNumber())
1448 return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) << (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1449 return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1452 static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1454 if (expr1->isNumber() && expr2->isNumber())
1455 return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) >> (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1456 return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1459 /* called by yyparse on error */
1460 int yyerror(const char *)
1465 /* may we automatically insert a semicolon ? */
1466 static bool allowAutomaticSemicolon(Lexer& lexer, int yychar)
1468 return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator();
1471 static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init)
1475 return new VarDeclCommaNode(GLOBAL_DATA, list, init);
1478 // We turn variable declarations into either assignments or empty
1479 // statements (which later get stripped out), because the actual
1480 // declaration work is hoisted up to the start of the function body
1481 static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr)
1484 return new EmptyStatementNode(GLOBAL_DATA);
1485 return new VarStatementNode(GLOBAL_DATA, expr);