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