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* makeSubNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
80 static ExpressionNode* makeLeftShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
81 static ExpressionNode* makeRightShiftNode(void*, ExpressionNode*, ExpressionNode*, bool rightHasAssignments);
82 static StatementNode* makeVarStatementNode(void*, ExpressionNode*);
83 static ExpressionNode* combineVarInitializers(void*, ExpressionNode* list, AssignResolveNode* init);
87 #pragma warning(disable: 4065)
88 #pragma warning(disable: 4244)
89 #pragma warning(disable: 4702)
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
99 #define YYPARSE_PARAM globalPtr
100 #define YYLEX_PARAM globalPtr
102 template <typename T> NodeDeclarationInfo<T> createNodeDeclarationInfo(T node, ParserRefCountedData<DeclarationStacks::VarStack>* varDecls,
103 ParserRefCountedData<DeclarationStacks::FunctionStack>* funcDecls,
107 ASSERT((info & ~AllFeatures) == 0);
108 NodeDeclarationInfo<T> result = {node, varDecls, funcDecls, info, numConstants};
112 template <typename T> NodeInfo<T> createNodeInfo(T node, CodeFeatures info, int numConstants)
114 ASSERT((info & ~AllFeatures) == 0);
115 NodeInfo<T> result = {node, info, numConstants};
119 template <typename T> T mergeDeclarationLists(T decls1, T decls2)
121 // decls1 or both are null
124 // only decls1 is non-null
129 decls1->data.append(decls2->data);
131 // We manually release the declaration lists to avoid accumulating many many
132 // unused heap allocated vectors
138 static void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, const Identifier& ident, unsigned attrs)
141 varDecls = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
143 varDecls->data.append(make_pair(ident, attrs));
147 static inline void appendToVarDeclarationList(void* globalPtr, ParserRefCountedData<DeclarationStacks::VarStack>*& varDecls, ConstDeclNode* decl)
149 unsigned attrs = DeclarationStacks::IsConstant;
151 attrs |= DeclarationStacks::HasInitializer;
152 appendToVarDeclarationList(globalPtr, varDecls, decl->m_ident, attrs);
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;
173 StatementNodeInfo statementNode;
174 FunctionBodyNode* functionBodyNode;
175 ProgramNode* programNode;
177 SourceElementsInfo sourceElements;
178 PropertyListInfo propertyList;
179 ArgumentListInfo argumentList;
180 VarDeclListInfo varDeclList;
181 ConstDeclListInfo constDeclList;
182 ClauseListInfo clauseList;
183 ElementListInfo elementList;
184 ParameterListInfo parameterList;
192 %token NULLTOKEN TRUETOKEN FALSETOKEN
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
202 /* give an if without an else higher precedence than an else to resolve the ambiguity */
203 %nonassoc IF_WITHOUT_ELSE
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) */
224 %token <doubleValue> NUMBER
225 %token <ident> IDENT STRING
227 /* automatically inserted semicolon */
228 %token AUTOPLUSPLUS AUTOMINUSMINUS
230 /* non-terminal types */
231 %type <expressionNode> Literal ArrayLiteral
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
254 %type <expressionNode> ExprOpt ExprNoInOpt
256 %type <statementNode> Statement Block
257 %type <statementNode> VariableStatement ConstStatement EmptyStatement ExprStatement
258 %type <statementNode> IfStatement IterationStatement ContinueStatement
259 %type <statementNode> BreakStatement ReturnStatement WithStatement
260 %type <statementNode> SwitchStatement LabelledStatement
261 %type <statementNode> ThrowStatement TryStatement
262 %type <statementNode> DebuggerStatement
263 %type <statementNode> SourceElement
265 %type <expressionNode> Initializer InitializerNoIn
266 %type <funcDeclNode> FunctionDeclaration
267 %type <funcExprNode> FunctionExpr
268 %type <functionBodyNode> FunctionBody
269 %type <sourceElements> SourceElements
270 %type <parameterList> FormalParameterList
271 %type <op> AssignmentOperator
272 %type <argumentsNode> Arguments
273 %type <argumentList> ArgumentList
274 %type <varDeclList> VariableDeclarationList VariableDeclarationListNoIn
275 %type <constDeclList> ConstDeclarationList
276 %type <constDeclNode> ConstDeclaration
277 %type <caseBlockNode> CaseBlock
278 %type <caseClauseNode> CaseClause DefaultClause
279 %type <clauseList> CaseClauses CaseClausesOpt
280 %type <intValue> Elision ElisionOpt
281 %type <elementList> ElementList
282 %type <propertyNode> Property
283 %type <propertyList> PropertyList
287 NULLTOKEN { $$ = createNodeInfo<ExpressionNode*>(new NullNode(GLOBAL_DATA), 0, 1); }
288 | TRUETOKEN { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, true), 0, 1); }
289 | FALSETOKEN { $$ = createNodeInfo<ExpressionNode*>(new BooleanNode(GLOBAL_DATA, false), 0, 1); }
290 | NUMBER { $$ = createNodeInfo<ExpressionNode*>(makeNumberNode(GLOBAL_DATA, $1), 0, 1); }
291 | STRING { $$ = createNodeInfo<ExpressionNode*>(new StringNode(GLOBAL_DATA, *$1), 0, 1); }
296 RegExpNode* node = new RegExpNode(GLOBAL_DATA, l.pattern(), l.flags());
297 int size = l.pattern().size() + 2; // + 2 for the two /'s
298 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
299 $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
301 | DIVEQUAL /* regexp with /= */ {
305 RegExpNode* node = new RegExpNode(GLOBAL_DATA, "=" + l.pattern(), l.flags());
306 int size = l.pattern().size() + 2; // + 2 for the two /'s
307 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.first_column + size, @1.first_column + size);
308 $$ = createNodeInfo<ExpressionNode*>(node, 0, 0);
313 IDENT ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
314 | STRING ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, *$1, $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
315 | NUMBER ':' AssignmentExpr { $$ = createNodeInfo<PropertyNode*>(new PropertyNode(GLOBAL_DATA, Identifier(GLOBAL_DATA, UString::from($1)), $3.m_node, PropertyNode::Constant), $3.m_features, $3.m_numConstants); }
316 | IDENT IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, 0, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); if (!$$.m_node) YYABORT; }
317 | IDENT IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
319 $$ = createNodeInfo<PropertyNode*>(makeGetterOrSetterPropertyNode(globalPtr, *$1, *$2, $4.m_node.head, $7, LEXER->sourceCode($6, $8, @6.first_line)), $4.m_features | ClosureFeature, 0);
320 if ($4.m_features & ArgumentsFeature)
321 $7->setUsesArguments();
329 Property { $$.m_node.head = new PropertyListNode(GLOBAL_DATA, $1.m_node);
330 $$.m_node.tail = $$.m_node.head;
331 $$.m_features = $1.m_features;
332 $$.m_numConstants = $1.m_numConstants; }
333 | PropertyList ',' Property { $$.m_node.head = $1.m_node.head;
334 $$.m_node.tail = new PropertyListNode(GLOBAL_DATA, $3.m_node, $1.m_node.tail);
335 $$.m_features = $1.m_features | $3.m_features;
336 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
341 | OPENBRACE CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA), 0, 0); }
342 | OPENBRACE PropertyList CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
343 /* allow extra comma, see http://bugs.webkit.org/show_bug.cgi?id=5939 */
344 | OPENBRACE PropertyList ',' CLOSEBRACE { $$ = createNodeInfo<ExpressionNode*>(new ObjectLiteralNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
348 THISTOKEN { $$ = createNodeInfo<ExpressionNode*>(new ThisNode(GLOBAL_DATA), ThisFeature, 0); }
351 | IDENT { $$ = createNodeInfo<ExpressionNode*>(new ResolveNode(GLOBAL_DATA, *$1, @1.first_column), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
352 | '(' Expr ')' { $$ = $2; }
356 '[' ElisionOpt ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2), 0, $2 ? 1 : 0); }
357 | '[' ElementList ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
358 | '[' ElementList ',' ElisionOpt ']' { $$ = createNodeInfo<ExpressionNode*>(new ArrayNode(GLOBAL_DATA, $4, $2.m_node.head), $2.m_features, $4 ? $2.m_numConstants + 1 : $2.m_numConstants); }
362 ElisionOpt AssignmentExpr { $$.m_node.head = new ElementNode(GLOBAL_DATA, $1, $2.m_node);
363 $$.m_node.tail = $$.m_node.head;
364 $$.m_features = $2.m_features;
365 $$.m_numConstants = $2.m_numConstants; }
366 | ElementList ',' ElisionOpt AssignmentExpr
367 { $$.m_node.head = $1.m_node.head;
368 $$.m_node.tail = new ElementNode(GLOBAL_DATA, $1.m_node.tail, $3, $4.m_node);
369 $$.m_features = $1.m_features | $4.m_features;
370 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants; }
374 /* nothing */ { $$ = 0; }
380 | Elision ',' { $$ = $1 + 1; }
385 | FunctionExpr { $$ = createNodeInfo<ExpressionNode*>($1.m_node, $1.m_features, $1.m_numConstants); }
386 | MemberExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
387 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
388 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
390 | MemberExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
391 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
392 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
394 | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
395 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
396 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
402 | MemberExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
403 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
404 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
406 | MemberExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
407 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
408 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
410 | NEW MemberExpr Arguments { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node, $3.m_node);
411 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @3.last_column);
412 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features | $3.m_features, $2.m_numConstants + $3.m_numConstants);
418 | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
419 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
420 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
426 | NEW NewExpr { NewExprNode* node = new NewExprNode(GLOBAL_DATA, $2.m_node);
427 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
428 $$ = createNodeInfo<ExpressionNode*>(node, $2.m_features, $2.m_numConstants);
433 MemberExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
434 | CallExpr Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
435 | CallExpr '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
436 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
437 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
439 | CallExpr '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
440 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
441 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants); }
445 MemberExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
446 | CallExprNoBF Arguments { $$ = makeFunctionCallNode(globalPtr, $1, $2, @1.first_column, @1.last_column, @2.last_column); }
447 | CallExprNoBF '[' Expr ']' { BracketAccessorNode* node = new BracketAccessorNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
448 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @4.last_column);
449 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants);
451 | CallExprNoBF '.' IDENT { DotAccessorNode* node = new DotAccessorNode(GLOBAL_DATA, $1.m_node, *$3);
452 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @3.last_column);
453 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features, $1.m_numConstants);
458 '(' ')' { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA), 0, 0); }
459 | '(' ArgumentList ')' { $$ = createNodeInfo<ArgumentsNode*>(new ArgumentsNode(GLOBAL_DATA, $2.m_node.head), $2.m_features, $2.m_numConstants); }
463 AssignmentExpr { $$.m_node.head = new ArgumentListNode(GLOBAL_DATA, $1.m_node);
464 $$.m_node.tail = $$.m_node.head;
465 $$.m_features = $1.m_features;
466 $$.m_numConstants = $1.m_numConstants; }
467 | ArgumentList ',' AssignmentExpr { $$.m_node.head = $1.m_node.head;
468 $$.m_node.tail = new ArgumentListNode(GLOBAL_DATA, $1.m_node.tail, $3.m_node);
469 $$.m_features = $1.m_features | $3.m_features;
470 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
478 LeftHandSideExprNoBF:
485 | LeftHandSideExpr PLUSPLUS { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
486 | LeftHandSideExpr MINUSMINUS { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
491 | LeftHandSideExprNoBF PLUSPLUS { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpPlusPlus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
492 | LeftHandSideExprNoBF MINUSMINUS { $$ = createNodeInfo<ExpressionNode*>(makePostfixNode(GLOBAL_DATA, $1.m_node, OpMinusMinus, @1.first_column, @1.last_column, @2.last_column), $1.m_features | AssignFeature, $1.m_numConstants); }
496 DELETETOKEN UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeDeleteNode(GLOBAL_DATA, $2.m_node, @1.first_column, @2.last_column, @2.last_column), $2.m_features, $2.m_numConstants); }
497 | VOIDTOKEN UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new VoidNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants + 1); }
498 | TYPEOF UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeTypeOfNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
499 | PLUSPLUS UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
500 | AUTOPLUSPLUS UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpPlusPlus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
501 | MINUSMINUS UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
502 | AUTOMINUSMINUS UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makePrefixNode(GLOBAL_DATA, $2.m_node, OpMinusMinus, @1.first_column, @2.first_column + 1, @2.last_column), $2.m_features | AssignFeature, $2.m_numConstants); }
503 | '+' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new UnaryPlusNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
504 | '-' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeNegateNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
505 | '~' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeBitwiseNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
506 | '!' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalNotNode(GLOBAL_DATA, $2.m_node), $2.m_features, $2.m_numConstants); }
520 | MultiplicativeExpr '*' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
521 | MultiplicativeExpr '/' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
522 | MultiplicativeExpr '%' UnaryExpr { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
525 MultiplicativeExprNoBF:
527 | MultiplicativeExprNoBF '*' UnaryExpr
528 { $$ = createNodeInfo<ExpressionNode*>(makeMultNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
529 | MultiplicativeExprNoBF '/' UnaryExpr
530 { $$ = createNodeInfo<ExpressionNode*>(makeDivNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
531 | MultiplicativeExprNoBF '%' UnaryExpr
532 { $$ = createNodeInfo<ExpressionNode*>(new ModNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
537 | AdditiveExpr '+' MultiplicativeExpr { $$ = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
538 | AdditiveExpr '-' MultiplicativeExpr { $$ = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
542 MultiplicativeExprNoBF
543 | AdditiveExprNoBF '+' MultiplicativeExpr
544 { $$ = createNodeInfo<ExpressionNode*>(makeAddNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
545 | AdditiveExprNoBF '-' MultiplicativeExpr
546 { $$ = createNodeInfo<ExpressionNode*>(makeSubNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
551 | ShiftExpr LSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
552 | ShiftExpr RSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
553 | ShiftExpr URSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
558 | ShiftExprNoBF LSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(makeLeftShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
559 | ShiftExprNoBF RSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(makeRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
560 | ShiftExprNoBF URSHIFT AdditiveExpr { $$ = createNodeInfo<ExpressionNode*>(new UnsignedRightShiftNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
565 | RelationalExpr '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
566 | RelationalExpr '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
567 | RelationalExpr LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
568 | RelationalExpr GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
569 | RelationalExpr INSTANCEOF ShiftExpr { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
570 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
571 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
572 | RelationalExpr INTOKEN ShiftExpr { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
573 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
574 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
579 | RelationalExprNoIn '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
580 | RelationalExprNoIn '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
581 | RelationalExprNoIn LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
582 | RelationalExprNoIn GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
583 | RelationalExprNoIn INSTANCEOF ShiftExpr
584 { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
585 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
586 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
591 | RelationalExprNoBF '<' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
592 | RelationalExprNoBF '>' ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
593 | RelationalExprNoBF LE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new LessEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
594 | RelationalExprNoBF GE ShiftExpr { $$ = createNodeInfo<ExpressionNode*>(new GreaterEqNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
595 | RelationalExprNoBF INSTANCEOF ShiftExpr
596 { InstanceOfNode* node = new InstanceOfNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
597 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
598 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
599 | RelationalExprNoBF INTOKEN ShiftExpr
600 { InNode* node = new InNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature);
601 SET_EXCEPTION_LOCATION(node, @1.first_column, @3.first_column, @3.last_column);
602 $$ = createNodeInfo<ExpressionNode*>(node, $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
607 | EqualityExpr EQEQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
608 | EqualityExpr NE RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
609 | EqualityExpr STREQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
610 | EqualityExpr STRNEQ RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
615 | EqualityExprNoIn EQEQ RelationalExprNoIn
616 { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
617 | EqualityExprNoIn NE RelationalExprNoIn
618 { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
619 | EqualityExprNoIn STREQ RelationalExprNoIn
620 { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
621 | EqualityExprNoIn STRNEQ RelationalExprNoIn
622 { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
627 | EqualityExprNoBF EQEQ RelationalExpr
628 { $$ = createNodeInfo<ExpressionNode*>(new EqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
629 | EqualityExprNoBF NE RelationalExpr { $$ = createNodeInfo<ExpressionNode*>(new NotEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
630 | EqualityExprNoBF STREQ RelationalExpr
631 { $$ = createNodeInfo<ExpressionNode*>(new StrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
632 | EqualityExprNoBF STRNEQ RelationalExpr
633 { $$ = createNodeInfo<ExpressionNode*>(new NotStrictEqualNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
638 | BitwiseANDExpr '&' EqualityExpr { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
643 | BitwiseANDExprNoIn '&' EqualityExprNoIn
644 { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
649 | BitwiseANDExprNoBF '&' EqualityExpr { $$ = createNodeInfo<ExpressionNode*>(new BitAndNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
654 | BitwiseXORExpr '^' BitwiseANDExpr { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
659 | BitwiseXORExprNoIn '^' BitwiseANDExprNoIn
660 { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
665 | BitwiseXORExprNoBF '^' BitwiseANDExpr
666 { $$ = createNodeInfo<ExpressionNode*>(new BitXOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
671 | BitwiseORExpr '|' BitwiseXORExpr { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
676 | BitwiseORExprNoIn '|' BitwiseXORExprNoIn
677 { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
682 | BitwiseORExprNoBF '|' BitwiseXORExpr
683 { $$ = createNodeInfo<ExpressionNode*>(new BitOrNode(GLOBAL_DATA, $1.m_node, $3.m_node, $3.m_features & AssignFeature), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
688 | LogicalANDExpr AND BitwiseORExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
693 | LogicalANDExprNoIn AND BitwiseORExprNoIn
694 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
699 | LogicalANDExprNoBF AND BitwiseORExpr
700 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalAnd), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
705 | LogicalORExpr OR LogicalANDExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
710 | LogicalORExprNoIn OR LogicalANDExprNoIn
711 { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
716 | LogicalORExprNoBF OR LogicalANDExpr { $$ = createNodeInfo<ExpressionNode*>(new LogicalOpNode(GLOBAL_DATA, $1.m_node, $3.m_node, OpLogicalOr), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
721 | LogicalORExpr '?' AssignmentExpr ':' AssignmentExpr
722 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
727 | LogicalORExprNoIn '?' AssignmentExprNoIn ':' AssignmentExprNoIn
728 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
733 | LogicalORExprNoBF '?' AssignmentExpr ':' AssignmentExpr
734 { $$ = createNodeInfo<ExpressionNode*>(new ConditionalNode(GLOBAL_DATA, $1.m_node, $3.m_node, $5.m_node), $1.m_features | $3.m_features | $5.m_features, $1.m_numConstants + $3.m_numConstants + $5.m_numConstants); }
739 | LeftHandSideExpr AssignmentOperator AssignmentExpr
740 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
741 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
747 | LeftHandSideExpr AssignmentOperator AssignmentExprNoIn
748 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
749 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
755 | LeftHandSideExprNoBF AssignmentOperator AssignmentExpr
756 { $$ = createNodeInfo<ExpressionNode*>(makeAssignNode(GLOBAL_DATA, $1.m_node, $2, $3.m_node, $1.m_features & AssignFeature, $3.m_features & AssignFeature,
757 @1.first_column, @2.first_column + 1, @3.last_column), $1.m_features | $3.m_features | AssignFeature, $1.m_numConstants + $3.m_numConstants);
762 '=' { $$ = OpEqual; }
763 | PLUSEQUAL { $$ = OpPlusEq; }
764 | MINUSEQUAL { $$ = OpMinusEq; }
765 | MULTEQUAL { $$ = OpMultEq; }
766 | DIVEQUAL { $$ = OpDivEq; }
767 | LSHIFTEQUAL { $$ = OpLShift; }
768 | RSHIFTEQUAL { $$ = OpRShift; }
769 | URSHIFTEQUAL { $$ = OpURShift; }
770 | ANDEQUAL { $$ = OpAndEq; }
771 | XOREQUAL { $$ = OpXOrEq; }
772 | OREQUAL { $$ = OpOrEq; }
773 | MODEQUAL { $$ = OpModEq; }
778 | Expr ',' AssignmentExpr { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
783 | ExprNoIn ',' AssignmentExprNoIn { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
788 | ExprNoBF ',' AssignmentExpr { $$ = createNodeInfo<ExpressionNode*>(new CommaNode(GLOBAL_DATA, $1.m_node, $3.m_node), $1.m_features | $3.m_features, $1.m_numConstants + $3.m_numConstants); }
811 OPENBRACE CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, 0), 0, 0, 0, 0);
812 DBG($$.m_node, @1, @2); }
813 | OPENBRACE SourceElements CLOSEBRACE { $$ = createNodeDeclarationInfo<StatementNode*>(new BlockNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
814 DBG($$.m_node, @1, @3); }
818 VAR VariableDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
819 DBG($$.m_node, @1, @3); }
820 | VAR VariableDeclarationList error { $$ = createNodeDeclarationInfo<StatementNode*>(makeVarStatementNode(GLOBAL_DATA, $2.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
821 DBG($$.m_node, @1, @2);
825 VariableDeclarationList:
826 IDENT { $$.m_node = 0;
827 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
828 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
829 $$.m_funcDeclarations = 0;
830 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
831 $$.m_numConstants = 0;
833 | IDENT Initializer { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
834 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
836 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
837 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
838 $$.m_funcDeclarations = 0;
839 $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
840 $$.m_numConstants = $2.m_numConstants;
842 | VariableDeclarationList ',' IDENT
843 { $$.m_node = $1.m_node;
844 $$.m_varDeclarations = $1.m_varDeclarations;
845 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
846 $$.m_funcDeclarations = 0;
847 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
848 $$.m_numConstants = $1.m_numConstants;
850 | VariableDeclarationList ',' IDENT Initializer
851 { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
852 SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
853 $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
854 $$.m_varDeclarations = $1.m_varDeclarations;
855 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
856 $$.m_funcDeclarations = 0;
857 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
858 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
862 VariableDeclarationListNoIn:
863 IDENT { $$.m_node = 0;
864 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
865 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, 0);
866 $$.m_funcDeclarations = 0;
867 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
868 $$.m_numConstants = 0;
870 | IDENT InitializerNoIn { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$1, $2.m_node, $2.m_features & AssignFeature);
871 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.first_column + 1, @2.last_column);
873 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
874 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$1, DeclarationStacks::HasInitializer);
875 $$.m_funcDeclarations = 0;
876 $$.m_features = ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features;
877 $$.m_numConstants = $2.m_numConstants;
879 | VariableDeclarationListNoIn ',' IDENT
880 { $$.m_node = $1.m_node;
881 $$.m_varDeclarations = $1.m_varDeclarations;
882 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, 0);
883 $$.m_funcDeclarations = 0;
884 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
885 $$.m_numConstants = $1.m_numConstants;
887 | VariableDeclarationListNoIn ',' IDENT InitializerNoIn
888 { AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, *$3, $4.m_node, $4.m_features & AssignFeature);
889 SET_EXCEPTION_LOCATION(node, @3.first_column, @4.first_column + 1, @4.last_column);
890 $$.m_node = combineVarInitializers(GLOBAL_DATA, $1.m_node, node);
891 $$.m_varDeclarations = $1.m_varDeclarations;
892 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, *$3, DeclarationStacks::HasInitializer);
893 $$.m_funcDeclarations = 0;
894 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features;
895 $$.m_numConstants = $1.m_numConstants + $4.m_numConstants;
900 CONSTTOKEN ConstDeclarationList ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
901 DBG($$.m_node, @1, @3); }
902 | CONSTTOKEN ConstDeclarationList error
903 { $$ = createNodeDeclarationInfo<StatementNode*>(new ConstStatementNode(GLOBAL_DATA, $2.m_node.head), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants);
904 DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
907 ConstDeclarationList:
908 ConstDeclaration { $$.m_node.head = $1.m_node;
909 $$.m_node.tail = $$.m_node.head;
910 $$.m_varDeclarations = new ParserRefCountedData<DeclarationStacks::VarStack>(GLOBAL_DATA);
911 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $1.m_node);
912 $$.m_funcDeclarations = 0;
913 $$.m_features = $1.m_features;
914 $$.m_numConstants = $1.m_numConstants;
916 | ConstDeclarationList ',' ConstDeclaration
917 { $$.m_node.head = $1.m_node.head;
918 $1.m_node.tail->m_next = $3.m_node;
919 $$.m_node.tail = $3.m_node;
920 $$.m_varDeclarations = $1.m_varDeclarations;
921 appendToVarDeclarationList(GLOBAL_DATA, $$.m_varDeclarations, $3.m_node);
922 $$.m_funcDeclarations = 0;
923 $$.m_features = $1.m_features | $3.m_features;
924 $$.m_numConstants = $1.m_numConstants + $3.m_numConstants; }
928 IDENT { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, 0), (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0, 0); }
929 | IDENT Initializer { $$ = createNodeInfo<ConstDeclNode*>(new ConstDeclNode(GLOBAL_DATA, *$1, $2.m_node), ((*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $2.m_features, $2.m_numConstants); }
933 '=' AssignmentExpr { $$ = $2; }
937 '=' AssignmentExprNoIn { $$ = $2; }
941 ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new EmptyStatementNode(GLOBAL_DATA), 0, 0, 0, 0); }
945 ExprNoBF ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
946 DBG($$.m_node, @1, @2); }
947 | ExprNoBF error { $$ = createNodeDeclarationInfo<StatementNode*>(new ExprStatementNode(GLOBAL_DATA, $1.m_node), 0, 0, $1.m_features, $1.m_numConstants);
948 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
952 IF '(' Expr ')' Statement %prec IF_WITHOUT_ELSE
953 { $$ = createNodeDeclarationInfo<StatementNode*>(new IfNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
954 DBG($$.m_node, @1, @4); }
955 | IF '(' Expr ')' Statement ELSE Statement
956 { $$ = createNodeDeclarationInfo<StatementNode*>(new IfElseNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node),
957 mergeDeclarationLists($5.m_varDeclarations, $7.m_varDeclarations), mergeDeclarationLists($5.m_funcDeclarations, $7.m_funcDeclarations),
958 $3.m_features | $5.m_features | $7.m_features,
959 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
960 DBG($$.m_node, @1, @4); }
964 DO Statement WHILE '(' Expr ')' ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
965 DBG($$.m_node, @1, @3); }
966 | DO Statement WHILE '(' Expr ')' error { $$ = createNodeDeclarationInfo<StatementNode*>(new DoWhileNode(GLOBAL_DATA, $2.m_node, $5.m_node), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features | $5.m_features, $2.m_numConstants + $5.m_numConstants);
967 DBG($$.m_node, @1, @3); } // Always performs automatic semicolon insertion.
968 | WHILE '(' Expr ')' Statement { $$ = createNodeDeclarationInfo<StatementNode*>(new WhileNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
969 DBG($$.m_node, @1, @4); }
970 | FOR '(' ExprNoInOpt ';' ExprOpt ';' ExprOpt ')' Statement
971 { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node, $9.m_node, false), $9.m_varDeclarations, $9.m_funcDeclarations,
972 $3.m_features | $5.m_features | $7.m_features | $9.m_features,
973 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
974 DBG($$.m_node, @1, @8);
976 | FOR '(' VAR VariableDeclarationListNoIn ';' ExprOpt ';' ExprOpt ')' Statement
977 { $$ = createNodeDeclarationInfo<StatementNode*>(new ForNode(GLOBAL_DATA, $4.m_node, $6.m_node, $8.m_node, $10.m_node, true),
978 mergeDeclarationLists($4.m_varDeclarations, $10.m_varDeclarations),
979 mergeDeclarationLists($4.m_funcDeclarations, $10.m_funcDeclarations),
980 $4.m_features | $6.m_features | $8.m_features | $10.m_features,
981 $4.m_numConstants + $6.m_numConstants + $8.m_numConstants + $10.m_numConstants);
982 DBG($$.m_node, @1, @9); }
983 | FOR '(' LeftHandSideExpr INTOKEN Expr ')' Statement
985 ForInNode* node = new ForInNode(GLOBAL_DATA, $3.m_node, $5.m_node, $7.m_node);
986 SET_EXCEPTION_LOCATION(node, @3.first_column, @3.last_column, @5.last_column);
987 $$ = createNodeDeclarationInfo<StatementNode*>(node, $7.m_varDeclarations, $7.m_funcDeclarations,
988 $3.m_features | $5.m_features | $7.m_features,
989 $3.m_numConstants + $5.m_numConstants + $7.m_numConstants);
990 DBG($$.m_node, @1, @6);
992 | FOR '(' VAR IDENT INTOKEN Expr ')' Statement
993 { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, 0, $6.m_node, $8.m_node, @5.first_column, @5.first_column - @4.first_column, @6.last_column - @5.first_column);
994 SET_EXCEPTION_LOCATION(forIn, @4.first_column, @5.first_column + 1, @6.last_column);
995 appendToVarDeclarationList(GLOBAL_DATA, $8.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
996 $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $8.m_varDeclarations, $8.m_funcDeclarations, ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $6.m_features | $8.m_features, $6.m_numConstants + $8.m_numConstants);
997 DBG($$.m_node, @1, @7); }
998 | FOR '(' VAR IDENT InitializerNoIn INTOKEN Expr ')' Statement
999 { ForInNode *forIn = new ForInNode(GLOBAL_DATA, *$4, $5.m_node, $7.m_node, $9.m_node, @5.first_column, @5.first_column - @4.first_column, @5.last_column - @5.first_column);
1000 SET_EXCEPTION_LOCATION(forIn, @4.first_column, @6.first_column + 1, @7.last_column);
1001 appendToVarDeclarationList(GLOBAL_DATA, $9.m_varDeclarations, *$4, DeclarationStacks::HasInitializer);
1002 $$ = createNodeDeclarationInfo<StatementNode*>(forIn, $9.m_varDeclarations, $9.m_funcDeclarations,
1003 ((*$4 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $5.m_features | $7.m_features | $9.m_features,
1004 $5.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1005 DBG($$.m_node, @1, @8); }
1009 /* nothing */ { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1014 /* nothing */ { $$ = createNodeInfo<ExpressionNode*>(0, 0, 0); }
1019 CONTINUE ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1020 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1021 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1022 DBG($$.m_node, @1, @2); }
1023 | CONTINUE error { ContinueNode* node = new ContinueNode(GLOBAL_DATA);
1024 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1025 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1026 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1027 | CONTINUE IDENT ';' { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1028 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1029 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1030 DBG($$.m_node, @1, @3); }
1031 | CONTINUE IDENT error { ContinueNode* node = new ContinueNode(GLOBAL_DATA, *$2);
1032 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1033 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0);
1034 DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1038 BREAK ';' { BreakNode* node = new BreakNode(GLOBAL_DATA);
1039 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1040 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1041 | BREAK error { BreakNode* node = new BreakNode(GLOBAL_DATA);
1042 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1043 $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA), 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1044 | BREAK IDENT ';' { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1045 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1046 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @3); }
1047 | BREAK IDENT error { BreakNode* node = new BreakNode(GLOBAL_DATA, *$2);
1048 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1049 $$ = createNodeDeclarationInfo<StatementNode*>(new BreakNode(GLOBAL_DATA, *$2), 0, 0, 0, 0); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1053 RETURN ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0);
1054 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1055 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @2); }
1056 | RETURN error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, 0);
1057 SET_EXCEPTION_LOCATION(node, @1.first_column, @1.last_column, @1.last_column);
1058 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, 0, 0); DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1059 | RETURN Expr ';' { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node);
1060 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1061 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @3); }
1062 | RETURN Expr error { ReturnNode* node = new ReturnNode(GLOBAL_DATA, $2.m_node);
1063 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1064 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON; }
1068 WITH '(' Expr ')' Statement { $$ = createNodeDeclarationInfo<StatementNode*>(new WithNode(GLOBAL_DATA, $3.m_node, $5.m_node, @3.last_column, @3.last_column - @3.first_column),
1069 $5.m_varDeclarations, $5.m_funcDeclarations, $3.m_features | $5.m_features | WithFeature, $3.m_numConstants + $5.m_numConstants);
1070 DBG($$.m_node, @1, @4); }
1074 SWITCH '(' Expr ')' CaseBlock { $$ = createNodeDeclarationInfo<StatementNode*>(new SwitchNode(GLOBAL_DATA, $3.m_node, $5.m_node), $5.m_varDeclarations, $5.m_funcDeclarations,
1075 $3.m_features | $5.m_features, $3.m_numConstants + $5.m_numConstants);
1076 DBG($$.m_node, @1, @4); }
1080 OPENBRACE CaseClausesOpt CLOSEBRACE { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, 0, 0), $2.m_varDeclarations, $2.m_funcDeclarations, $2.m_features, $2.m_numConstants); }
1081 | OPENBRACE CaseClausesOpt DefaultClause CaseClausesOpt CLOSEBRACE
1082 { $$ = createNodeDeclarationInfo<CaseBlockNode*>(new CaseBlockNode(GLOBAL_DATA, $2.m_node.head, $3.m_node, $4.m_node.head),
1083 mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $3.m_varDeclarations), $4.m_varDeclarations),
1084 mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $3.m_funcDeclarations), $4.m_funcDeclarations),
1085 $2.m_features | $3.m_features | $4.m_features,
1086 $2.m_numConstants + $3.m_numConstants + $4.m_numConstants); }
1090 /* nothing */ { $$.m_node.head = 0; $$.m_node.tail = 0; $$.m_varDeclarations = 0; $$.m_funcDeclarations = 0; $$.m_features = 0; $$.m_numConstants = 0; }
1095 CaseClause { $$.m_node.head = new ClauseListNode(GLOBAL_DATA, $1.m_node);
1096 $$.m_node.tail = $$.m_node.head;
1097 $$.m_varDeclarations = $1.m_varDeclarations;
1098 $$.m_funcDeclarations = $1.m_funcDeclarations;
1099 $$.m_features = $1.m_features;
1100 $$.m_numConstants = $1.m_numConstants; }
1101 | CaseClauses CaseClause { $$.m_node.head = $1.m_node.head;
1102 $$.m_node.tail = new ClauseListNode(GLOBAL_DATA, $1.m_node.tail, $2.m_node);
1103 $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1104 $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1105 $$.m_features = $1.m_features | $2.m_features;
1106 $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1111 CASE Expr ':' { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node), 0, 0, $2.m_features, $2.m_numConstants); }
1112 | CASE Expr ':' SourceElements { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, $2.m_node, $4.m_node), $4.m_varDeclarations, $4.m_funcDeclarations, $2.m_features | $4.m_features, $2.m_numConstants + $4.m_numConstants); }
1116 DEFAULT ':' { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0), 0, 0, 0, 0); }
1117 | DEFAULT ':' SourceElements { $$ = createNodeDeclarationInfo<CaseClauseNode*>(new CaseClauseNode(GLOBAL_DATA, 0, $3.m_node), $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1121 IDENT ':' Statement { $3.m_node->pushLabel(*$1);
1122 LabelNode* node = new LabelNode(GLOBAL_DATA, *$1, $3.m_node);
1123 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1124 $$ = createNodeDeclarationInfo<StatementNode*>(node, $3.m_varDeclarations, $3.m_funcDeclarations, $3.m_features, $3.m_numConstants); }
1128 THROW Expr ';' { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1129 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1130 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2);
1132 | THROW Expr error { ThrowNode* node = new ThrowNode(GLOBAL_DATA, $2.m_node);
1133 SET_EXCEPTION_LOCATION(node, @1.first_column, @2.last_column, @2.last_column);
1134 $$ = createNodeDeclarationInfo<StatementNode*>(node, 0, 0, $2.m_features, $2.m_numConstants); DBG($$.m_node, @1, @2); AUTO_SEMICOLON;
1139 TRY Block FINALLY Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, GLOBAL_DATA->propertyNames->nullIdentifier, 0, $4.m_node),
1140 mergeDeclarationLists($2.m_varDeclarations, $4.m_varDeclarations),
1141 mergeDeclarationLists($2.m_funcDeclarations, $4.m_funcDeclarations),
1142 $2.m_features | $4.m_features,
1143 $2.m_numConstants + $4.m_numConstants);
1144 DBG($$.m_node, @1, @2); }
1145 | TRY Block CATCH '(' IDENT ')' Block { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, 0),
1146 mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations),
1147 mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations),
1148 $2.m_features | $7.m_features | CatchFeature,
1149 $2.m_numConstants + $7.m_numConstants);
1150 DBG($$.m_node, @1, @2); }
1151 | TRY Block CATCH '(' IDENT ')' Block FINALLY Block
1152 { $$ = createNodeDeclarationInfo<StatementNode*>(new TryNode(GLOBAL_DATA, $2.m_node, *$5, $7.m_node, $9.m_node),
1153 mergeDeclarationLists(mergeDeclarationLists($2.m_varDeclarations, $7.m_varDeclarations), $9.m_varDeclarations),
1154 mergeDeclarationLists(mergeDeclarationLists($2.m_funcDeclarations, $7.m_funcDeclarations), $9.m_funcDeclarations),
1155 $2.m_features | $7.m_features | $9.m_features | CatchFeature,
1156 $2.m_numConstants + $7.m_numConstants + $9.m_numConstants);
1157 DBG($$.m_node, @1, @2); }
1161 DEBUGGER ';' { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1162 DBG($$.m_node, @1, @2); }
1163 | DEBUGGER error { $$ = createNodeDeclarationInfo<StatementNode*>(new DebuggerStatementNode(GLOBAL_DATA), 0, 0, 0, 0);
1164 DBG($$.m_node, @1, @1); AUTO_SEMICOLON; }
1167 FunctionDeclaration:
1168 FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | ClosureFeature, 0); DBG($6, @5, @7); }
1169 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1171 $$ = createNodeInfo(new FuncDeclNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), ((*$2 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0) | $4.m_features | ClosureFeature, 0);
1172 if ($4.m_features & ArgumentsFeature)
1173 $7->setUsesArguments();
1179 FUNCTION '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $5, LEXER->sourceCode($4, $6, @4.first_line)), ClosureFeature, 0); DBG($5, @4, @6); }
1180 | FUNCTION '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1182 $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, $6, LEXER->sourceCode($5, $7, @5.first_line), $3.m_node.head), $3.m_features | ClosureFeature, 0);
1183 if ($3.m_features & ArgumentsFeature)
1184 $6->setUsesArguments();
1187 | FUNCTION IDENT '(' ')' OPENBRACE FunctionBody CLOSEBRACE { $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $6, LEXER->sourceCode($5, $7, @5.first_line)), ClosureFeature, 0); DBG($6, @5, @7); }
1188 | FUNCTION IDENT '(' FormalParameterList ')' OPENBRACE FunctionBody CLOSEBRACE
1190 $$ = createNodeInfo(new FuncExprNode(GLOBAL_DATA, *$2, $7, LEXER->sourceCode($6, $8, @6.first_line), $4.m_node.head), $4.m_features | ClosureFeature, 0);
1191 if ($4.m_features & ArgumentsFeature)
1192 $7->setUsesArguments();
1197 FormalParameterList:
1198 IDENT { $$.m_node.head = new ParameterNode(GLOBAL_DATA, *$1);
1199 $$.m_features = (*$1 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0;
1200 $$.m_node.tail = $$.m_node.head; }
1201 | FormalParameterList ',' IDENT { $$.m_node.head = $1.m_node.head;
1202 $$.m_features = $1.m_features | ((*$3 == GLOBAL_DATA->propertyNames->arguments) ? ArgumentsFeature : 0);
1203 $$.m_node.tail = new ParameterNode(GLOBAL_DATA, $1.m_node.tail, *$3); }
1207 /* not in spec */ { $$ = FunctionBodyNode::create(GLOBAL_DATA, 0, 0, 0, NoFeatures, 0); }
1208 | SourceElements { $$ = FunctionBodyNode::create(GLOBAL_DATA, $1.m_node, $1.m_varDeclarations ? &$1.m_varDeclarations->data : 0,
1209 $1.m_funcDeclarations ? &$1.m_funcDeclarations->data : 0,
1210 $1.m_features, $1.m_numConstants);
1211 // As in mergeDeclarationLists() we have to ref/deref to safely get rid of
1212 // the declaration lists.
1213 if ($1.m_varDeclarations) {
1214 $1.m_varDeclarations->ref();
1215 $1.m_varDeclarations->deref();
1217 if ($1.m_funcDeclarations) {
1218 $1.m_funcDeclarations->ref();
1219 $1.m_funcDeclarations->deref();
1225 /* not in spec */ { GLOBAL_DATA->parser->didFinishParsing(new SourceElements(GLOBAL_DATA), 0, 0, NoFeatures, @0.last_line, 0); }
1226 | SourceElements { GLOBAL_DATA->parser->didFinishParsing($1.m_node, $1.m_varDeclarations, $1.m_funcDeclarations, $1.m_features,
1227 @1.last_line, $1.m_numConstants); }
1231 SourceElement { $$.m_node = new SourceElements(GLOBAL_DATA);
1232 $$.m_node->append($1.m_node);
1233 $$.m_varDeclarations = $1.m_varDeclarations;
1234 $$.m_funcDeclarations = $1.m_funcDeclarations;
1235 $$.m_features = $1.m_features;
1236 $$.m_numConstants = $1.m_numConstants;
1238 | SourceElements SourceElement { $$.m_node->append($2.m_node);
1239 $$.m_varDeclarations = mergeDeclarationLists($1.m_varDeclarations, $2.m_varDeclarations);
1240 $$.m_funcDeclarations = mergeDeclarationLists($1.m_funcDeclarations, $2.m_funcDeclarations);
1241 $$.m_features = $1.m_features | $2.m_features;
1242 $$.m_numConstants = $1.m_numConstants + $2.m_numConstants;
1247 FunctionDeclaration { $$ = createNodeDeclarationInfo<StatementNode*>($1.m_node, 0, new ParserRefCountedData<DeclarationStacks::FunctionStack>(GLOBAL_DATA), $1.m_features, 0); $$.m_funcDeclarations->data.append($1.m_node); }
1248 | Statement { $$ = $1; }
1253 static ExpressionNode* makeAssignNode(void* globalPtr, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end)
1255 if (!loc->isLocation())
1256 return new AssignErrorNode(GLOBAL_DATA, loc, op, expr, divot, divot - start, end - divot);
1258 if (loc->isResolveNode()) {
1259 ResolveNode* resolve = static_cast<ResolveNode*>(loc);
1260 if (op == OpEqual) {
1261 AssignResolveNode* node = new AssignResolveNode(GLOBAL_DATA, resolve->identifier(), expr, exprHasAssignments);
1262 SET_EXCEPTION_LOCATION(node, start, divot, end);
1265 return new ReadModifyResolveNode(GLOBAL_DATA, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1267 if (loc->isBracketAccessorNode()) {
1268 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc);
1270 return new AssignBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot());
1272 ReadModifyBracketNode* node = new ReadModifyBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot);
1273 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1277 ASSERT(loc->isDotAccessorNode());
1278 DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
1280 return new AssignDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
1282 ReadModifyDotNode* node = new ReadModifyDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
1283 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1287 static ExpressionNode* makePrefixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1289 if (!expr->isLocation())
1290 return new PrefixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1292 if (expr->isResolveNode()) {
1293 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1294 return new PrefixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1296 if (expr->isBracketAccessorNode()) {
1297 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1298 PrefixBracketNode* node = new PrefixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1299 node->setSubexpressionInfo(bracket->divot(), bracket->startOffset());
1302 ASSERT(expr->isDotAccessorNode());
1303 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1304 PrefixDotNode* node = new PrefixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1305 node->setSubexpressionInfo(dot->divot(), dot->startOffset());
1309 static ExpressionNode* makePostfixNode(void* globalPtr, ExpressionNode* expr, Operator op, int start, int divot, int end)
1311 if (!expr->isLocation())
1312 return new PostfixErrorNode(GLOBAL_DATA, expr, op, divot, divot - start, end - divot);
1314 if (expr->isResolveNode()) {
1315 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1316 return new PostfixResolveNode(GLOBAL_DATA, resolve->identifier(), op, divot, divot - start, end - divot);
1318 if (expr->isBracketAccessorNode()) {
1319 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1320 PostfixBracketNode* node = new PostfixBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
1321 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1325 ASSERT(expr->isDotAccessorNode());
1326 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1327 PostfixDotNode* node = new PostfixDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
1328 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1332 static ExpressionNodeInfo makeFunctionCallNode(void* globalPtr, ExpressionNodeInfo func, ArgumentsNodeInfo args, int start, int divot, int end)
1334 CodeFeatures features = func.m_features | args.m_features;
1335 int numConstants = func.m_numConstants + args.m_numConstants;
1336 if (!func.m_node->isLocation())
1337 return createNodeInfo<ExpressionNode*>(new FunctionCallValueNode(GLOBAL_DATA, func.m_node, args.m_node, divot, divot - start, end - divot), features, numConstants);
1338 if (func.m_node->isResolveNode()) {
1339 ResolveNode* resolve = static_cast<ResolveNode*>(func.m_node);
1340 const Identifier& identifier = resolve->identifier();
1341 if (identifier == GLOBAL_DATA->propertyNames->eval)
1342 return createNodeInfo<ExpressionNode*>(new EvalFunctionCallNode(GLOBAL_DATA, args.m_node, divot, divot - start, end - divot), EvalFeature | features, numConstants);
1343 return createNodeInfo<ExpressionNode*>(new FunctionCallResolveNode(GLOBAL_DATA, identifier, args.m_node, divot, divot - start, end - divot), features, numConstants);
1345 if (func.m_node->isBracketAccessorNode()) {
1346 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func.m_node);
1347 FunctionCallBracketNode* node = new FunctionCallBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), args.m_node, divot, divot - start, end - divot);
1348 node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
1349 return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1351 ASSERT(func.m_node->isDotAccessorNode());
1352 DotAccessorNode* dot = static_cast<DotAccessorNode*>(func.m_node);
1353 FunctionCallDotNode* node = new FunctionCallDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), args.m_node, divot, divot - start, end - divot);
1354 node->setSubexpressionInfo(dot->divot(), dot->endOffset());
1355 return createNodeInfo<ExpressionNode*>(node, features, numConstants);
1358 static ExpressionNode* makeTypeOfNode(void* globalPtr, ExpressionNode* expr)
1360 if (expr->isResolveNode()) {
1361 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1362 return new TypeOfResolveNode(GLOBAL_DATA, resolve->identifier());
1364 return new TypeOfValueNode(GLOBAL_DATA, expr);
1367 static ExpressionNode* makeDeleteNode(void* globalPtr, ExpressionNode* expr, int start, int divot, int end)
1369 if (!expr->isLocation())
1370 return new DeleteValueNode(GLOBAL_DATA, expr);
1371 if (expr->isResolveNode()) {
1372 ResolveNode* resolve = static_cast<ResolveNode*>(expr);
1373 return new DeleteResolveNode(GLOBAL_DATA, resolve->identifier(), divot, divot - start, end - divot);
1375 if (expr->isBracketAccessorNode()) {
1376 BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
1377 return new DeleteBracketNode(GLOBAL_DATA, bracket->base(), bracket->subscript(), divot, divot - start, end - divot);
1379 ASSERT(expr->isDotAccessorNode());
1380 DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
1381 return new DeleteDotNode(GLOBAL_DATA, dot->base(), dot->identifier(), divot, divot - start, end - divot);
1384 static PropertyNode* makeGetterOrSetterPropertyNode(void* globalPtr, const Identifier& getOrSet, const Identifier& name, ParameterNode* params, FunctionBodyNode* body, const SourceCode& source)
1386 PropertyNode::Type type;
1387 if (getOrSet == "get")
1388 type = PropertyNode::Getter;
1389 else if (getOrSet == "set")
1390 type = PropertyNode::Setter;
1393 return new PropertyNode(GLOBAL_DATA, name, new FuncExprNode(GLOBAL_DATA, GLOBAL_DATA->propertyNames->nullIdentifier, body, source, params), type);
1396 static ExpressionNode* makeNegateNode(void* globalPtr, ExpressionNode* n)
1398 if (n->isNumber()) {
1399 NumberNode* number = static_cast<NumberNode*>(n);
1401 if (number->value() > 0.0) {
1402 number->setValue(-number->value());
1407 return new NegateNode(GLOBAL_DATA, n);
1410 static NumberNode* makeNumberNode(void* globalPtr, double d)
1412 JSValue* value = JSImmediate::from(d);
1414 return new ImmediateNumberNode(GLOBAL_DATA, value, d);
1415 return new NumberNode(GLOBAL_DATA, d);
1418 static ExpressionNode* makeBitwiseNotNode(void* globalPtr, ExpressionNode* expr)
1420 if (expr->isNumber())
1421 return makeNumberNode(globalPtr, ~JSValue::toInt32(static_cast<NumberNode*>(expr)->value()));
1422 return new BitwiseNotNode(GLOBAL_DATA, expr);
1425 static ExpressionNode* makeMultNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1427 if (expr1->isNumber() && expr2->isNumber())
1428 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
1429 return new MultNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1432 static ExpressionNode* makeDivNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1434 if (expr1->isNumber() && expr2->isNumber())
1435 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
1436 return new DivNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1439 static ExpressionNode* makeAddNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1441 if (expr1->isNumber() && expr2->isNumber())
1442 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
1443 return new AddNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1446 static ExpressionNode* makeSubNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1448 if (expr1->isNumber() && expr2->isNumber())
1449 return makeNumberNode(globalPtr, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value());
1450 return new SubNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1453 static ExpressionNode* makeLeftShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1455 if (expr1->isNumber() && expr2->isNumber())
1456 return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) << (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1457 return new LeftShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1460 static ExpressionNode* makeRightShiftNode(void* globalPtr, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
1462 if (expr1->isNumber() && expr2->isNumber())
1463 return makeNumberNode(globalPtr, JSValue::toInt32(static_cast<NumberNode*>(expr1)->value()) >> (JSValue::toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
1464 return new RightShiftNode(GLOBAL_DATA, expr1, expr2, rightHasAssignments);
1467 /* called by yyparse on error */
1468 int yyerror(const char *)
1473 /* may we automatically insert a semicolon ? */
1474 static bool allowAutomaticSemicolon(Lexer& lexer, int yychar)
1476 return yychar == CLOSEBRACE || yychar == 0 || lexer.prevTerminator();
1479 static ExpressionNode* combineVarInitializers(void* globalPtr, ExpressionNode* list, AssignResolveNode* init)
1483 return new VarDeclCommaNode(GLOBAL_DATA, list, init);
1486 // We turn variable declarations into either assignments or empty
1487 // statements (which later get stripped out), because the actual
1488 // declaration work is hoisted up to the start of the function body
1489 static StatementNode* makeVarStatementNode(void* globalPtr, ExpressionNode* expr)
1492 return new EmptyStatementNode(GLOBAL_DATA);
1493 return new VarStatementNode(GLOBAL_DATA, expr);