@ibyar/expressions 0.8.2-dev.20221008 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +0 -3
  2. package/api/abstract.d.ts +6 -5
  3. package/api/abstract.js +15 -12
  4. package/api/abstract.js.map +1 -1
  5. package/api/class/class.d.ts +99 -60
  6. package/api/class/class.js +285 -233
  7. package/api/class/class.js.map +1 -1
  8. package/api/class/decorator.d.ts +2 -4
  9. package/api/class/decorator.js +6 -9
  10. package/api/class/decorator.js.map +1 -1
  11. package/api/computing/call.d.ts +2 -4
  12. package/api/computing/call.js +8 -11
  13. package/api/computing/call.js.map +1 -1
  14. package/api/computing/debugger.d.ts +1 -4
  15. package/api/computing/debugger.js +2 -5
  16. package/api/computing/debugger.js.map +1 -1
  17. package/api/computing/new.d.ts +2 -4
  18. package/api/computing/new.js +7 -10
  19. package/api/computing/new.js.map +1 -1
  20. package/api/computing/rest.d.ts +2 -4
  21. package/api/computing/rest.js +6 -9
  22. package/api/computing/rest.js.map +1 -1
  23. package/api/computing/return.d.ts +2 -4
  24. package/api/computing/return.js +6 -9
  25. package/api/computing/return.js.map +1 -1
  26. package/api/computing/spread.d.ts +2 -4
  27. package/api/computing/spread.js +6 -9
  28. package/api/computing/spread.js.map +1 -1
  29. package/api/computing/throw.d.ts +4 -8
  30. package/api/computing/throw.js +18 -23
  31. package/api/computing/throw.js.map +1 -1
  32. package/api/computing/yield.d.ts +2 -4
  33. package/api/computing/yield.js +7 -10
  34. package/api/computing/yield.js.map +1 -1
  35. package/api/definition/array.d.ts +3 -6
  36. package/api/definition/array.js +14 -18
  37. package/api/definition/array.js.map +1 -1
  38. package/api/definition/bind.d.ts +2 -3
  39. package/api/definition/bind.js +9 -10
  40. package/api/definition/bind.js.map +1 -1
  41. package/api/definition/comment.d.ts +3 -5
  42. package/api/definition/comment.js +6 -7
  43. package/api/definition/comment.js.map +1 -1
  44. package/api/definition/function.d.ts +20 -27
  45. package/api/definition/function.js +92 -110
  46. package/api/definition/function.js.map +1 -1
  47. package/api/definition/member.d.ts +2 -3
  48. package/api/definition/member.js +14 -11
  49. package/api/definition/member.js.map +1 -1
  50. package/api/definition/object.d.ts +5 -9
  51. package/api/definition/object.js +24 -30
  52. package/api/definition/object.js.map +1 -1
  53. package/api/definition/statement.d.ts +2 -4
  54. package/api/definition/statement.js +6 -9
  55. package/api/definition/statement.js.map +1 -1
  56. package/api/definition/values.d.ts +15 -40
  57. package/api/definition/values.js +49 -79
  58. package/api/definition/values.js.map +1 -1
  59. package/api/expression.d.ts +40 -26
  60. package/api/expression.js.map +1 -1
  61. package/api/index.d.ts +1 -0
  62. package/api/index.js +1 -0
  63. package/api/index.js.map +1 -1
  64. package/api/module/common.d.ts +4 -5
  65. package/api/module/common.js +12 -12
  66. package/api/module/common.js.map +1 -1
  67. package/api/module/export.d.ts +5 -10
  68. package/api/module/export.js +35 -38
  69. package/api/module/export.js.map +1 -1
  70. package/api/module/import.d.ts +6 -10
  71. package/api/module/import.js +28 -32
  72. package/api/module/import.js.map +1 -1
  73. package/api/operators/assignment.d.ts +3 -3
  74. package/api/operators/assignment.js +5 -5
  75. package/api/operators/assignment.js.map +1 -1
  76. package/api/operators/await.d.ts +3 -5
  77. package/api/operators/await.js +7 -10
  78. package/api/operators/await.js.map +1 -1
  79. package/api/operators/binary.d.ts +1 -1
  80. package/api/operators/binary.js +1 -1
  81. package/api/operators/binary.js.map +1 -1
  82. package/api/operators/chaining.d.ts +2 -3
  83. package/api/operators/chaining.js +6 -7
  84. package/api/operators/chaining.js.map +1 -1
  85. package/api/operators/comma.d.ts +2 -4
  86. package/api/operators/comma.js +6 -9
  87. package/api/operators/comma.js.map +1 -1
  88. package/api/operators/grouping.d.ts +2 -4
  89. package/api/operators/grouping.js +6 -9
  90. package/api/operators/grouping.js.map +1 -1
  91. package/api/operators/logical.d.ts +1 -1
  92. package/api/operators/logical.js +1 -1
  93. package/api/operators/logical.js.map +1 -1
  94. package/api/operators/pipeline.d.ts +2 -4
  95. package/api/operators/pipeline.js +8 -15
  96. package/api/operators/pipeline.js.map +1 -1
  97. package/api/operators/ternary.d.ts +2 -4
  98. package/api/operators/ternary.js +8 -13
  99. package/api/operators/ternary.js.map +1 -1
  100. package/api/operators/types.d.ts +1 -1
  101. package/api/operators/unary.d.ts +3 -5
  102. package/api/operators/unary.js +7 -10
  103. package/api/operators/unary.js.map +1 -1
  104. package/api/operators/update.d.ts +3 -5
  105. package/api/operators/update.js +8 -11
  106. package/api/operators/update.js.map +1 -1
  107. package/api/program.d.ts +3 -5
  108. package/api/program.js +7 -8
  109. package/api/program.js.map +1 -1
  110. package/api/statement/control/block.d.ts +2 -4
  111. package/api/statement/control/block.js +9 -14
  112. package/api/statement/control/block.js.map +1 -1
  113. package/api/statement/control/empty.d.ts +2 -5
  114. package/api/statement/control/empty.js +6 -8
  115. package/api/statement/control/empty.js.map +1 -1
  116. package/api/statement/control/if.d.ts +2 -4
  117. package/api/statement/control/if.js +8 -13
  118. package/api/statement/control/if.js.map +1 -1
  119. package/api/statement/control/switch.d.ts +4 -9
  120. package/api/statement/control/switch.js +19 -28
  121. package/api/statement/control/switch.js.map +1 -1
  122. package/api/statement/control/terminate.d.ts +4 -7
  123. package/api/statement/control/terminate.js +11 -19
  124. package/api/statement/control/terminate.js.map +1 -1
  125. package/api/statement/control/with.d.ts +21 -0
  126. package/api/statement/control/with.js +67 -0
  127. package/api/statement/control/with.js.map +1 -0
  128. package/api/statement/declarations/declares.d.ts +4 -7
  129. package/api/statement/declarations/declares.js +14 -20
  130. package/api/statement/declarations/declares.js.map +1 -1
  131. package/api/statement/iterations/for.d.ts +6 -11
  132. package/api/statement/iterations/for.js +35 -53
  133. package/api/statement/iterations/for.js.map +1 -1
  134. package/api/statement/iterations/while.d.ts +3 -6
  135. package/api/statement/iterations/while.js +14 -22
  136. package/api/statement/iterations/while.js.map +1 -1
  137. package/package.json +14 -4
  138. package/scope/finalizer.d.ts +1 -1
  139. package/scope/pool.d.ts +1 -1
  140. package/scope/proxy.d.ts +1 -1
  141. package/scope/proxy.js +1 -0
  142. package/scope/proxy.js.map +1 -1
  143. package/scope/scope.d.ts +8 -24
  144. package/scope/scope.js +25 -75
  145. package/scope/scope.js.map +1 -1
  146. package/scope/stack.d.ts +15 -3
  147. package/scope/stack.js +49 -32
  148. package/scope/stack.js.map +1 -1
  149. package/v8/enums.d.ts +4 -2
  150. package/v8/enums.js.map +1 -1
  151. package/v8/factory.d.ts +148 -0
  152. package/v8/factory.js +499 -0
  153. package/v8/factory.js.map +1 -0
  154. package/v8/inline.d.ts +50 -48
  155. package/v8/inline.js +322 -300
  156. package/v8/inline.js.map +1 -1
  157. package/v8/node.d.ts +141 -0
  158. package/v8/node.js +2 -0
  159. package/v8/node.js.map +1 -0
  160. package/v8/nodes.d.ts +0 -14
  161. package/v8/nodes.js +1 -152
  162. package/v8/nodes.js.map +1 -1
  163. package/v8/parser.d.ts +21 -18
  164. package/v8/parser.js +97 -84
  165. package/v8/parser.js.map +1 -1
  166. package/v8/stream.d.ts +2 -1
  167. package/v8/stream.js +221 -311
  168. package/v8/stream.js.map +1 -1
  169. package/v8/token.d.ts +3 -1
  170. package/v8/token.js +7 -5
  171. package/v8/token.js.map +1 -1
  172. package/visit/visitor.d.ts +1 -1
package/v8/inline.js CHANGED
@@ -1,52 +1,24 @@
1
- import { Token } from './token.js';
2
- import { TokenStream } from './stream.js';
3
- import { OfNode, Identifier, ThisNode, GetIdentifier, SetIdentifier, AsyncIdentifier, NullNode, AwaitIdentifier, ConstructorIdentifier, NameIdentifier, EvalIdentifier, ArgumentsIdentifier, TaggedTemplateExpression, TemplateLiteral, SuperIdentifier } from '../api/definition/values.js';
4
1
  import { EmptyStatement } from '../api/statement/control/empty.js';
5
- import { BlockStatement } from '../api/statement/control/block.js';
6
- import { ArrowFunctionExpression, Param, FunctionExpression, FunctionDeclaration } from '../api/definition/function.js';
7
- import { IfStatement } from '../api/statement/control/if.js';
8
- import { NewExpression } from '../api/computing/new.js';
9
- import { SpreadElement } from '../api/computing/spread.js';
10
- import { RestElement } from '../api/computing/rest.js';
11
- import { AssignmentExpression } from '../api/operators/assignment.js';
12
- import { GroupingExpression } from '../api/operators/grouping.js';
13
- import { MemberExpression } from '../api/definition/member.js';
14
- import { BindExpression } from '../api/definition/bind.js';
15
- import { ObjectExpression, Property, ObjectPattern } from '../api/definition/object.js';
16
- import { ArrayExpression, ArrayPattern } from '../api/definition/array.js';
17
- import { CallExpression } from '../api/computing/call.js';
18
- import { DoWhileNode, WhileNode } from '../api/statement/iterations/while.js';
19
- import { CatchClauseNode, ThrowStatement, TryCatchNode } from '../api/computing/throw.js';
20
- import { SwitchCase, DefaultExpression, SwitchStatement } from '../api/statement/control/switch.js';
21
- import { BreakStatement, ContinueStatement, LabeledStatement } from '../api/statement/control/terminate.js';
22
- import { ReturnStatement } from '../api/computing/return.js';
23
- import { YieldExpression } from '../api/computing/yield.js';
24
- import { VariableDeclarator, VariableDeclarationNode } from '../api/statement/declarations/declares.js';
25
- import { ForNode, ForOfNode, ForInNode, ForAwaitOfNode } from '../api/statement/iterations/for.js';
26
- import { ConditionalExpression } from '../api/operators/ternary.js';
27
- import { PipelineExpression } from '../api/operators/pipeline.js';
28
- import { LogicalExpression } from '../api/operators/logical.js';
29
- import { SequenceExpression } from '../api/operators/comma.js';
30
- import { ChainExpression } from '../api/operators/chaining.js';
31
- import { ExpressionStatement } from '../api/definition/statement.js';
32
- import { buildPostfixExpression, buildUnaryExpression, expressionFromLiteral, shortcutNumericLiteralBinaryExpression } from './nodes.js';
33
2
  import { AllowLabelledFunctionStatement, FunctionBodyType, FunctionKind, functionKindForImpl, FunctionSyntaxKind, isAsyncFunction, isAsyncGeneratorFunction, isAwaitAsIdentifierDisallowed, isClassMembersInitializerFunction, isGeneratorFunction, isModule, isResumableFunction, ParseFunctionFlag, ParsingArrowHeadFlag, PropertyKind, PropertyKindInfo, PropertyPosition, SubFunctionKind, VariableDeclarationContext } from './enums.js';
34
- import { DebuggerStatement } from '../api/computing/debugger.js';
35
- import { isSloppy, isStrict, LanguageMode, } from './language.js';
3
+ import { TokenStream } from './stream.js';
4
+ import { Token } from './token.js';
5
+ import { ExpressionNodeFactory, ExpressionNodeSourcePosition } from './factory.js';
6
+ import { isSloppy, isStrict, LanguageMode } from './language.js';
36
7
  export class AbstractParser {
37
- constructor(scanner, acceptIN) {
38
- this.scanner = scanner;
39
- this.previousAcceptIN = [];
40
- this.previousFunctionKind = [];
41
- this.previousAcceptIN.push(this.acceptIN = acceptIN ?? false);
42
- this.previousFunctionKind.push(this.functionKind = FunctionKind.NormalFunction);
43
- }
44
8
  get languageMode() {
45
9
  return this.scanner.getLanguageMode();
46
10
  }
47
11
  set languageMode(mode) {
48
12
  this.scanner.setLanguageMode(mode);
49
13
  }
14
+ constructor(scanner, factory, acceptIN) {
15
+ this.scanner = scanner;
16
+ this.factory = factory;
17
+ this.previousAcceptIN = [];
18
+ this.previousFunctionKind = [];
19
+ this.previousAcceptIN.push(this.acceptIN = acceptIN ?? false);
20
+ this.previousFunctionKind.push(this.functionKind = FunctionKind.NormalFunction);
21
+ }
50
22
  position() {
51
23
  return this.scanner.getPos();
52
24
  }
@@ -93,10 +65,27 @@ export class AbstractParser {
93
65
  peekPosition() {
94
66
  return this.scanner.peekPosition();
95
67
  }
68
+ createRange(start) {
69
+ if (Number.isNaN(start?.range?.[0])) {
70
+ return;
71
+ }
72
+ return [start.range[0], this.scanner.getPos()];
73
+ }
74
+ createRangeByStart(start) {
75
+ return [start.range[0], this.scanner.getPos()];
76
+ }
77
+ createStartPosition() {
78
+ return [this.scanner.getPos(), -1];
79
+ }
80
+ updateRangeEnd(range) {
81
+ range[1] = this.scanner.getPos();
82
+ }
96
83
  consume(token) {
97
- if (this.scanner.next().isNotType(token)) {
84
+ const next = this.scanner.next();
85
+ if (next.isNotType(token)) {
98
86
  throw new Error(this.errorMessage(`Parsing ${JSON.stringify(token)}`));
99
87
  }
88
+ return next;
100
89
  }
101
90
  check(token) {
102
91
  const next = this.scanner.peek();
@@ -127,6 +116,7 @@ export class AbstractParser {
127
116
  if (current.isNotType(token)) {
128
117
  throw new Error(this.errorMessage(`Unexpected Token: ${JSON.stringify(token)}, current is ${JSON.stringify(current)}`));
129
118
  }
119
+ return current;
130
120
  }
131
121
  expectAndGetValue(token) {
132
122
  const current = this.scanner.next();
@@ -136,32 +126,30 @@ export class AbstractParser {
136
126
  return current.getValue();
137
127
  }
138
128
  checkInOrOf() {
139
- if (this.check(Token.IN)) {
140
- return 'IN';
141
- }
142
- else if (this.checkValue(OfNode)) {
143
- return 'OF';
129
+ const result = this.peekInOrOf();
130
+ if (result) {
131
+ this.scanner.next();
144
132
  }
145
- return false;
133
+ return result;
146
134
  }
147
135
  peekInOrOf() {
148
136
  var next = this.peek();
149
137
  if (next.isType(Token.IN)) {
150
138
  return 'IN';
151
139
  }
152
- else if (next.value === OfNode) {
140
+ else if (this.factory.isIdentifier(next.value) && next.value.getName() === 'of') {
153
141
  return 'OF';
154
142
  }
155
143
  return false;
156
144
  }
157
- isArguments(name) {
158
- return name instanceof Identifier && name.getName() === 'arguments';
145
+ isArguments(node) {
146
+ return this.factory.isIdentifier(node) && node.getName() === 'arguments';
159
147
  }
160
- isEval(name) {
161
- return name instanceof Identifier && name.getName() === 'eval';
148
+ isEval(node) {
149
+ return this.factory.isIdentifier(node) && node.getName() === 'eval';
162
150
  }
163
- isEvalOrArguments(name) {
164
- return name instanceof Identifier && (name.getName() === 'eval' || name.getName() === 'arguments');
151
+ isEvalOrArguments(node) {
152
+ return this.factory.isIdentifier(node) && (node.getName() === 'eval' || node.getName() === 'arguments');
165
153
  }
166
154
  isNextLetKeyword() {
167
155
  if (this.peek().isNotType(Token.LET)) {
@@ -188,9 +176,6 @@ export class AbstractParser {
188
176
  return false;
189
177
  }
190
178
  }
191
- isIdentifier(expression) {
192
- return expression instanceof Identifier;
193
- }
194
179
  markParenthesized(expression) {
195
180
  Reflect.set(expression, 'parenthesized', true);
196
181
  }
@@ -202,7 +187,7 @@ export class AbstractParser {
202
187
  }
203
188
  isAssignableIdentifier(expression) {
204
189
  // return expression instanceof AssignmentNode;
205
- if (!(expression instanceof Identifier)) {
190
+ if (!(this.factory.isIdentifier(expression))) {
206
191
  return false;
207
192
  }
208
193
  if (isStrict(this.languageMode) && this.isEvalOrArguments(expression)) {
@@ -210,23 +195,8 @@ export class AbstractParser {
210
195
  }
211
196
  return true;
212
197
  }
213
- isPattern(expression) {
214
- return expression instanceof ObjectExpression || expression instanceof ArrayExpression;
215
- }
216
- isProperty(expression) {
217
- return expression instanceof Property || expression instanceof MemberExpression;
218
- }
219
- isCallNew(expression) {
220
- return expression instanceof NewExpression;
221
- }
222
- isCall(expression) {
223
- return expression instanceof CallExpression;
224
- }
225
- isEmptyStatement(expression) {
226
- return expression instanceof EmptyStatement;
227
- }
228
198
  isValidReferenceExpression(expression) {
229
- return this.isAssignableIdentifier(expression) || this.isProperty(expression);
199
+ return this.isAssignableIdentifier(expression) || this.factory.isPropertyOrMemberExpression(expression);
230
200
  }
231
201
  expectSemicolon() {
232
202
  const tok = this.peek();
@@ -299,24 +269,29 @@ export class AbstractParser {
299
269
  }
300
270
  }
301
271
  export class JavaScriptInlineParser extends AbstractParser {
302
- static parse(source, { mode, acceptIN } = {}) {
272
+ static parse(source, { mode, acceptIN, factory, addLocation } = {}) {
303
273
  mode ?? (mode = LanguageMode.Strict);
304
274
  const stream = (typeof source === 'string')
305
275
  ? TokenStream.getTokenStream(source, mode)
306
276
  : Array.isArray(source) ? TokenStream.getTokenStream(source) : source;
307
277
  acceptIN ?? (acceptIN = false);
308
- const parser = new JavaScriptInlineParser(stream, acceptIN);
278
+ if (factory == undefined) {
279
+ const sourcePositionFactory = addLocation && typeof source === 'string' ? new ExpressionNodeSourcePosition(source) : undefined;
280
+ factory = new ExpressionNodeFactory(sourcePositionFactory);
281
+ }
282
+ const parser = new JavaScriptInlineParser(stream, factory, acceptIN);
309
283
  return parser.scan();
310
284
  }
311
- constructor(scanner, acceptIN) {
312
- super(scanner, acceptIN);
285
+ constructor(scanner, factory, acceptIN) {
286
+ super(scanner, factory, acceptIN);
313
287
  }
314
288
  scan() {
289
+ const start = this.scanner.getPos();
315
290
  const list = this.parseStatementList(Token.EOS);
316
291
  if (list.length === 1) {
317
292
  return list[0];
318
293
  }
319
- return new ExpressionStatement(list);
294
+ return this.factory.createExpressionStatement(list, [start, this.scanner.getPos()]);
320
295
  }
321
296
  /**
322
297
  * Statement ::
@@ -341,8 +316,8 @@ export class JavaScriptInlineParser extends AbstractParser {
341
316
  case Token.LBRACE:
342
317
  return this.parseBlock();
343
318
  case Token.SEMICOLON:
344
- this.consume(Token.SEMICOLON);
345
- return EmptyStatement.INSTANCE;
319
+ const semicolon = this.consume(Token.SEMICOLON);
320
+ return this.factory.createEmptyStatement(semicolon.range);
346
321
  case Token.IF:
347
322
  return this.parseIfStatement();
348
323
  case Token.DO:
@@ -366,6 +341,8 @@ export class JavaScriptInlineParser extends AbstractParser {
366
341
  return this.parseTryStatement();
367
342
  case Token.SWITCH:
368
343
  return this.parseSwitchStatement();
344
+ case Token.WITH:
345
+ return this.parseWithStatement();
369
346
  case Token.FUNCTION:
370
347
  throw new SyntaxError(this.errorMessage(`FunctionDeclaration only allowed as a StatementListItem not in an arbitrary Statement position.`));
371
348
  case Token.DEBUGGER:
@@ -381,9 +358,9 @@ export class JavaScriptInlineParser extends AbstractParser {
381
358
  }
382
359
  }
383
360
  parseDebuggerStatement() {
384
- this.consume(Token.DEBUGGER);
361
+ const token = this.consume(Token.DEBUGGER);
385
362
  this.expectSemicolon();
386
- return DebuggerStatement.INSTANCE;
363
+ return this.factory.createDebuggerStatement(token.range);
387
364
  }
388
365
  parseTryStatement() {
389
366
  // TryStatement ::
@@ -396,8 +373,9 @@ export class JavaScriptInlineParser extends AbstractParser {
396
373
  //
397
374
  // Finally ::
398
375
  // 'finally' Block
399
- this.consume(Token.TRY);
376
+ const tryToken = this.consume(Token.TRY);
400
377
  const tryBlock = this.parseBlock();
378
+ let range;
401
379
  let peek = this.peek();
402
380
  if (peek.isNotType(Token.CATCH) && peek.isNotType(Token.FINALLY)) {
403
381
  throw new Error(this.errorMessage(`Uncaught SyntaxError: Missing catch or finally after try`));
@@ -416,13 +394,15 @@ export class JavaScriptInlineParser extends AbstractParser {
416
394
  this.expect(Token.RPAREN);
417
395
  }
418
396
  const block = this.parseBlock();
419
- catchBlock = new CatchClauseNode(block, identifier);
397
+ catchBlock = this.factory.createCatchClause(block, identifier, this.createRange(peek));
398
+ range = this.createRange(tryToken);
420
399
  }
421
400
  let finallyBlock;
422
401
  if (this.check(Token.FINALLY)) {
423
402
  finallyBlock = this.parseBlock();
403
+ range = this.createRange(tryToken);
424
404
  }
425
- return new TryCatchNode(tryBlock, catchBlock, finallyBlock);
405
+ return this.factory.createTryStatement(tryBlock, catchBlock, finallyBlock, range);
426
406
  }
427
407
  parseNonRestrictedIdentifier() {
428
408
  const result = this.parseIdentifier();
@@ -432,20 +412,22 @@ export class JavaScriptInlineParser extends AbstractParser {
432
412
  return result;
433
413
  }
434
414
  parseBlock() {
435
- this.expect(Token.LBRACE);
415
+ const start = this.expect(Token.LBRACE);
436
416
  const statements = [];
437
- const block = new BlockStatement(statements);
417
+ const range = this.createRangeByStart(start);
418
+ const block = this.factory.createBlock(statements, range);
438
419
  while (this.peek().isNotType(Token.RBRACE)) {
439
420
  const stat = this.parseStatementListItem();
440
421
  if (!stat) {
441
422
  return block;
442
423
  }
443
- else if (stat instanceof EmptyStatement) {
424
+ else if (this.factory.isEmptyStatement(stat)) {
444
425
  continue;
445
426
  }
446
427
  statements.push(stat);
447
428
  }
448
429
  this.expect(Token.RBRACE);
430
+ this.updateRangeEnd(range);
449
431
  return block;
450
432
  }
451
433
  /**
@@ -469,10 +451,10 @@ export class JavaScriptInlineParser extends AbstractParser {
469
451
  parseStatementListItem() {
470
452
  switch (this.peek().token) {
471
453
  case Token.FUNCTION:
472
- return this.parseHoistableDeclaration(undefined, false);
454
+ return this.parseHoistableDeclaration(undefined, false, this.peek());
473
455
  case Token.CLASS:
474
- this.consume(Token.CLASS);
475
- return this.parseClassDeclaration(undefined, false);
456
+ const classToken = this.consume(Token.CLASS);
457
+ return this.parseClassDeclaration(undefined, false, classToken);
476
458
  case Token.VAR:
477
459
  case Token.CONST:
478
460
  return this.parseVariableDeclarations(VariableDeclarationContext.StatementListItem);
@@ -483,8 +465,8 @@ export class JavaScriptInlineParser extends AbstractParser {
483
465
  break;
484
466
  case Token.ASYNC:
485
467
  if (this.peekAhead().isType(Token.FUNCTION) && !this.scanner.hasLineTerminatorAfterNext()) {
486
- this.consume(Token.ASYNC);
487
- return this.parseAsyncFunctionDeclaration(undefined, false);
468
+ const start = this.consume(Token.ASYNC);
469
+ return this.parseAsyncFunctionDeclaration(undefined, false, start);
488
470
  }
489
471
  break;
490
472
  default:
@@ -493,7 +475,7 @@ export class JavaScriptInlineParser extends AbstractParser {
493
475
  return this.parseStatement(AllowLabelledFunctionStatement.AllowLabelledFunctionStatement);
494
476
  }
495
477
  parseFunctionExpression() {
496
- this.consume(Token.FUNCTION);
478
+ const start = this.consume(Token.FUNCTION);
497
479
  const functionKind = this.check(Token.MUL) ? FunctionKind.GeneratorFunction : FunctionKind.NormalFunction;
498
480
  let name;
499
481
  let functionSyntaxKind = FunctionSyntaxKind.AnonymousExpression;
@@ -502,9 +484,9 @@ export class JavaScriptInlineParser extends AbstractParser {
502
484
  name = this.parseIdentifier(this.getLastFunctionKind());
503
485
  functionSyntaxKind = FunctionSyntaxKind.NamedExpression;
504
486
  }
505
- return this.parseFunctionLiteral(functionKind, functionSyntaxKind, name);
487
+ return this.parseFunctionLiteral(functionKind, functionSyntaxKind, name, start);
506
488
  }
507
- parseAsyncFunctionDeclaration(names, defaultExport) {
489
+ parseAsyncFunctionDeclaration(names, defaultExport, start) {
508
490
  // AsyncFunctionDeclaration ::
509
491
  // async [no LineTerminator here] function BindingIdentifier[Await]
510
492
  // ( FormalParameters[Await] ) { AsyncFunctionBody }
@@ -512,20 +494,22 @@ export class JavaScriptInlineParser extends AbstractParser {
512
494
  throw new SyntaxError(this.errorMessage('Line Terminator Before `function` parsing `async function`.'));
513
495
  }
514
496
  this.consume(Token.FUNCTION);
515
- return this.parseHoistableDeclaration01(FunctionKind.AsyncFunction, names, defaultExport);
497
+ return this.parseHoistableDeclaration01(FunctionKind.AsyncFunction, names, defaultExport, start);
516
498
  }
517
499
  parseIfStatement() {
518
- this.consume(Token.IF);
500
+ const ifToken = this.consume(Token.IF);
519
501
  this.consume(Token.LPAREN);
520
502
  const condition = this.parseExpression();
521
503
  this.consume(Token.RPAREN);
522
504
  const thenStatement = this.parseScopedStatement();
505
+ let range;
523
506
  let elseStatement;
524
507
  if (this.peek().isType(Token.ELSE)) {
525
508
  this.consume(Token.ELSE);
526
509
  elseStatement = this.parseScopedStatement();
527
510
  }
528
- return new IfStatement(condition, thenStatement, elseStatement);
511
+ range = this.createRange(ifToken);
512
+ return this.factory.createIfStatement(condition, thenStatement, elseStatement, range);
529
513
  }
530
514
  parseScopedStatement() {
531
515
  if (isStrict(this.languageMode) || this.peek().isNotType(Token.FUNCTION)) {
@@ -538,35 +522,36 @@ export class JavaScriptInlineParser extends AbstractParser {
538
522
  parseDoWhileStatement() {
539
523
  // DoStatement ::
540
524
  // 'do' Statement 'while' '(' Expression ')' ';'
541
- this.consume(Token.DO);
525
+ const start = this.consume(Token.DO);
542
526
  const body = this.parseStatement();
543
527
  this.expect(Token.WHILE);
544
528
  this.expect(Token.LPAREN);
545
529
  const condition = this.parseExpression();
546
530
  this.expect(Token.RPAREN);
547
531
  this.check(Token.SEMICOLON);
548
- return new DoWhileNode(condition, body);
532
+ return this.factory.createDoStatement(condition, body, this.createRange(start));
549
533
  }
550
534
  parseWhileStatement() {
551
535
  // WhileStatement ::
552
536
  // 'while' '(' Expression ')' Statement
553
- this.consume(Token.WHILE);
537
+ const start = this.consume(Token.WHILE);
554
538
  this.expect(Token.LPAREN);
555
539
  const condition = this.parseExpression();
556
540
  this.expect(Token.RPAREN);
557
541
  const body = this.parseStatement();
558
- return new WhileNode(condition, body);
542
+ return this.factory.createWhileStatement(condition, body, this.createRange(start));
559
543
  }
560
544
  parseThrowStatement() {
561
545
  // ThrowStatement ::
562
546
  // 'throw' Expression ';'
563
- this.consume(Token.THROW);
547
+ const throwToken = this.consume(Token.THROW);
564
548
  if (this.scanner.hasLineTerminatorBeforeNext()) {
565
549
  throw new Error(this.scanner.createError(`New line After Throw`));
566
550
  }
567
551
  const exception = this.parseExpression();
552
+ const range = this.createRange(throwToken);
568
553
  this.expectSemicolon();
569
- return new ThrowStatement(exception);
554
+ return this.factory.createThrowStatement(exception, range);
570
555
  }
571
556
  parseSwitchStatement() {
572
557
  // SwitchStatement ::
@@ -574,19 +559,21 @@ export class JavaScriptInlineParser extends AbstractParser {
574
559
  // CaseClause ::
575
560
  // 'case' Expression ':' StatementList
576
561
  // 'default' ':' StatementList
577
- this.consume(Token.SWITCH);
562
+ const start = this.consume(Token.SWITCH);
563
+ const range = this.createRangeByStart(start);
578
564
  this.expect(Token.LPAREN);
579
565
  const tag = this.parseExpression();
580
566
  this.expect(Token.RPAREN);
581
567
  const cases = [];
582
- const switchStatement = new SwitchStatement(tag, cases);
568
+ const switchStatement = this.factory.createSwitchStatement(tag, cases, range);
583
569
  let defaultSeen = false;
584
570
  this.expect(Token.LBRACE);
585
571
  while (this.peek().isNotType(Token.RBRACE)) {
586
572
  const statements = [];
587
- let label;
573
+ let test;
574
+ const caseStart = this.scanner.peek();
588
575
  if (this.check(Token.CASE)) {
589
- label = this.parseExpression();
576
+ test = this.parseExpression();
590
577
  }
591
578
  else {
592
579
  this.expect(Token.DEFAULT);
@@ -595,21 +582,25 @@ export class JavaScriptInlineParser extends AbstractParser {
595
582
  }
596
583
  defaultSeen = true;
597
584
  }
598
- this.expect(Token.COLON);
585
+ const blockStart = this.expect(Token.COLON);
599
586
  while (this.peek().isNotType(Token.CASE)
600
587
  && this.peek().isNotType(Token.DEFAULT)
601
588
  && this.peek().isNotType(Token.RBRACE)) {
602
589
  const statement = this.parseStatementListItem();
603
- if (!statement || this.isEmptyStatement(statement)) {
590
+ if (!statement || this.factory.isEmptyStatement(statement)) {
604
591
  continue;
605
592
  }
606
593
  statements.push(statement);
607
594
  }
608
- const block = new BlockStatement(statements);
609
- const clause = defaultSeen ? new DefaultExpression(block) : new SwitchCase(label, block);
595
+ const block = this.factory.createBlock(statements, this.createRange(blockStart));
596
+ const caseRange = this.createRange(caseStart);
597
+ const clause = defaultSeen
598
+ ? this.factory.createDefaultClause(block, caseRange)
599
+ : this.factory.createCaseBlock(test, block, caseRange);
610
600
  cases.push(clause);
611
601
  }
612
602
  this.expect(Token.RBRACE);
603
+ this.updateRangeEnd(range);
613
604
  return switchStatement;
614
605
  }
615
606
  parseForStatement() {
@@ -621,7 +612,7 @@ export class JavaScriptInlineParser extends AbstractParser {
621
612
  // We parse a declaration/expression after the 'for (' and then read the first
622
613
  // expression/declaration before we know if this is a for or a for-each.
623
614
  // typename FunctionState::LoopScope loop_scope(function_state_);
624
- this.consume(Token.FOR);
615
+ const start = this.consume(Token.FOR);
625
616
  this.expect(Token.LPAREN);
626
617
  const peek = this.peek();
627
618
  const starts_with_let = peek.isType(Token.LET);
@@ -635,13 +626,13 @@ export class JavaScriptInlineParser extends AbstractParser {
635
626
  const initializer = this.parseVariableDeclarations(VariableDeclarationContext.ForStatement);
636
627
  const forMode = this.checkInOrOf();
637
628
  if (forMode) {
638
- return this.parseForEachStatementWithDeclarations(initializer, forMode);
629
+ return this.parseForEachStatementWithDeclarations(initializer, forMode, start);
639
630
  }
640
631
  this.expect(Token.SEMICOLON);
641
632
  // Parse the remaining code in the inner block scope since the declaration
642
633
  // above was parsed there. We'll finalize the unnecessary outer block scope
643
634
  // after parsing the rest of the loop.
644
- return this.parseStandardForLoopWithLexicalDeclarations(initializer);
635
+ return this.parseStandardForLoopWithLexicalDeclarations(initializer, start);
645
636
  }
646
637
  let initializer;
647
638
  if (peek.isType(Token.VAR)) {
@@ -651,7 +642,7 @@ export class JavaScriptInlineParser extends AbstractParser {
651
642
  // for_info.position = scanner() -> location().beg_pos;
652
643
  const forMode = this.checkInOrOf();
653
644
  if (forMode) {
654
- return this.parseForEachStatementWithDeclarations(initializer, forMode);
645
+ return this.parseForEachStatementWithDeclarations(initializer, forMode, start);
655
646
  }
656
647
  // init = impl() -> BuildInitializationBlock(& for_info.parsing_result);
657
648
  }
@@ -671,25 +662,25 @@ export class JavaScriptInlineParser extends AbstractParser {
671
662
  if (forMode === 'OF' && starts_with_let || expression_is_async) {
672
663
  throw new SyntaxError(this.errorMessage(starts_with_let ? 'For Of Let' : 'For Of Async'));
673
664
  }
674
- return this.parseForEachStatementWithoutDeclarations(initializer, forMode);
665
+ return this.parseForEachStatementWithoutDeclarations(initializer, forMode, start);
675
666
  }
676
667
  }
677
668
  this.expect(Token.SEMICOLON);
678
- return this.parseStandardForLoop(initializer);
669
+ return this.parseStandardForLoop(initializer, start);
679
670
  }
680
- parseStandardForLoopWithLexicalDeclarations(initializer) {
671
+ parseStandardForLoopWithLexicalDeclarations(initializer, start) {
681
672
  // The condition and the next statement of the for loop must be parsed
682
673
  // in a new scope.
683
- return this.parseStandardForLoop(initializer);
674
+ return this.parseStandardForLoop(initializer, start);
684
675
  }
685
- parseForEachStatementWithDeclarations(initializer, forMode) {
676
+ parseForEachStatementWithDeclarations(initializer, forMode, start) {
686
677
  // Just one declaration followed by in/of.
687
678
  if (initializer.getDeclarations().length != 1) {
688
679
  throw new SyntaxError(this.errorMessage('For In/Of loop Multi Bindings'));
689
680
  }
690
- return this.parseForEachStatementWithoutDeclarations(initializer, forMode);
681
+ return this.parseForEachStatementWithoutDeclarations(initializer, forMode, start);
691
682
  }
692
- parseForEachStatementWithoutDeclarations(initializer, forMode) {
683
+ parseForEachStatementWithoutDeclarations(initializer, forMode, start) {
693
684
  let enumerable;
694
685
  if (forMode == 'OF') {
695
686
  this.setAcceptIN(true);
@@ -701,32 +692,31 @@ export class JavaScriptInlineParser extends AbstractParser {
701
692
  }
702
693
  this.expect(Token.RPAREN);
703
694
  const body = this.parseStatement();
695
+ const range = this.createRange(start);
704
696
  if (forMode === 'OF') {
705
- return new ForOfNode(initializer, enumerable, body);
697
+ return this.factory.createForOfStatement(initializer, enumerable, body, range);
706
698
  }
707
699
  else if (forMode === 'IN') {
708
- return new ForInNode(initializer, enumerable, body);
709
- }
710
- else {
711
- throw new Error(this.errorMessage(`parsing for loop: ${this.position()}`));
700
+ return this.factory.createForInStatement(initializer, enumerable, body, range);
712
701
  }
702
+ throw new Error(this.errorMessage(`parsing for loop: ${this.position()}`));
713
703
  }
714
- parseStandardForLoop(initializer) {
704
+ parseStandardForLoop(initializer, start) {
715
705
  // CheckStackOverflow();
716
706
  // ForStatementT loop = factory() -> NewForStatement(stmt_pos);
717
707
  // Target target(this, loop, labels, own_labels, Target:: TARGET_FOR_ANONYMOUS);
718
- let cond = new EmptyStatement();
708
+ let cond = this.factory.createEmptyStatement();
719
709
  if (this.peek().isNotType(Token.SEMICOLON)) {
720
710
  cond = this.parseExpression();
721
711
  }
722
712
  this.expect(Token.SEMICOLON);
723
- let next = new EmptyStatement();
713
+ let next = this.factory.createEmptyStatement();
724
714
  if (this.peek().isNotType(Token.RPAREN)) {
725
715
  next = this.parseExpression();
726
716
  }
727
717
  this.expect(Token.RPAREN);
728
718
  const body = this.parseStatement();
729
- return new ForNode(body, initializer, cond, next);
719
+ return this.factory.createForStatement(body, initializer, cond, next, this.createRange(start));
730
720
  }
731
721
  parseForAwaitStatement() {
732
722
  // for await '(' ForDeclaration of AssignmentExpression ')'
@@ -735,7 +725,7 @@ export class JavaScriptInlineParser extends AbstractParser {
735
725
  if (!this.isAwaitAllowed()) {
736
726
  throw new SyntaxError(this.errorMessage('"await" is not allowed'));
737
727
  }
738
- this.expect(Token.FOR);
728
+ const start = this.expect(Token.FOR);
739
729
  this.expect(Token.AWAIT);
740
730
  this.expect(Token.LPAREN);
741
731
  let hasDeclarations = false;
@@ -772,14 +762,16 @@ export class JavaScriptInlineParser extends AbstractParser {
772
762
  this.restoreAcceptIN();
773
763
  this.expect(Token.RPAREN);
774
764
  const body = this.parseStatement();
775
- return new ForAwaitOfNode(eachVariable, iterable, body);
765
+ const range = this.createRange(start);
766
+ return this.factory.createForAwaitOfStatement(eachVariable, iterable, body, range);
776
767
  }
777
768
  parseVariableDeclarations(varContext) {
778
769
  // VariableDeclarations ::
779
770
  // ('var' | 'const' | 'let') (Identifier ('=' AssignmentExpression)?)+[',']
780
771
  // var converted into ==> 'let' by parser
781
772
  let mode;
782
- const token = this.peek().token;
773
+ const start = this.peek();
774
+ const token = start.token;
783
775
  switch (token) {
784
776
  case Token.CONST:
785
777
  this.consume(token);
@@ -799,6 +791,7 @@ export class JavaScriptInlineParser extends AbstractParser {
799
791
  do {
800
792
  let name;
801
793
  let value;
794
+ const range = this.createStartPosition();
802
795
  // Check for an identifier first, so that we can elide the pattern in cases
803
796
  // where there is no initializer (and so no proxy needs to be created).
804
797
  if (Token.isAnyIdentifier(this.peek().token)) {
@@ -826,9 +819,11 @@ export class JavaScriptInlineParser extends AbstractParser {
826
819
  }
827
820
  // value = undefined;
828
821
  }
829
- variables.push(new VariableDeclarator(name, value));
822
+ this.updateRangeEnd(range);
823
+ variables.push(this.factory.createVariableDeclaration(name, value, range));
830
824
  } while (this.check(Token.COMMA));
831
- return new VariableDeclarationNode(variables, mode);
825
+ const range = this.createRange(start);
826
+ return this.factory.createVariableStatement(variables, mode, range);
832
827
  }
833
828
  parseBindingPattern(isPattern) {
834
829
  // Pattern ::
@@ -849,9 +844,7 @@ export class JavaScriptInlineParser extends AbstractParser {
849
844
  else if (token == Token.LBRACE) {
850
845
  return this.parseObjectLiteral(isPattern);
851
846
  }
852
- else {
853
- throw new Error(this.errorMessage(`Unexpected Token: ${this.next().getValue()}`));
854
- }
847
+ throw new Error(this.errorMessage(`Unexpected Token: ${this.next().getValue()}`));
855
848
  }
856
849
  parseAndClassifyIdentifier(next) {
857
850
  // Updates made here must be reflected on ClassifyPropertyIdentifier.
@@ -874,29 +867,31 @@ export class JavaScriptInlineParser extends AbstractParser {
874
867
  // ContinueStatement ::
875
868
  // 'continue' ';'
876
869
  // Identifier? is not supported
877
- this.consume(Token.CONTINUE);
870
+ const start = this.consume(Token.CONTINUE);
878
871
  let label;
879
872
  if (!this.scanner.hasLineTerminatorBeforeNext() &&
880
873
  !Token.isAutoSemicolon(this.peek().token)) {
881
874
  // ECMA allows "eval" or "arguments" as labels even in strict mode.
882
875
  label = this.parseIdentifier();
883
876
  }
877
+ const range = this.createRange(start);
884
878
  this.expectSemicolon();
885
- return label ? new ContinueStatement(label) : ContinueStatement.CONTINUE_INSTANCE;
879
+ return this.factory.createContinueStatement(label, range);
886
880
  }
887
881
  parseBreakStatement() {
888
882
  // BreakStatement ::
889
883
  // 'break' ';'
890
884
  // Identifier? is not supported
891
- this.consume(Token.BREAK);
885
+ const start = this.consume(Token.BREAK);
892
886
  let label;
893
887
  if (!this.scanner.hasLineTerminatorBeforeNext() &&
894
888
  !Token.isAutoSemicolon(this.peek().token)) {
895
889
  // ECMA allows "eval" or "arguments" as labels even in strict mode.
896
890
  label = this.parseIdentifier();
897
891
  }
892
+ const range = this.createRange(start);
898
893
  this.expectSemicolon();
899
- return label ? new BreakStatement(label) : BreakStatement.BREAK_INSTANCE;
894
+ return this.factory.createBreakStatement(label, range);
900
895
  }
901
896
  parseReturnStatement() {
902
897
  // ReturnStatement ::
@@ -904,7 +899,7 @@ export class JavaScriptInlineParser extends AbstractParser {
904
899
  // Consume the return token. It is necessary to do that before
905
900
  // reporting any errors on it, because of the way errors are
906
901
  // reported (underlining).
907
- this.consume(Token.RETURN);
902
+ const start = this.consume(Token.RETURN);
908
903
  const tokenExp = this.peek();
909
904
  let returnValue;
910
905
  // ExpressionT return_value = impl() -> NullExpression();
@@ -917,8 +912,9 @@ export class JavaScriptInlineParser extends AbstractParser {
917
912
  else {
918
913
  returnValue = this.parseExpression();
919
914
  }
915
+ const range = this.createRange(start);
920
916
  this.expectSemicolon();
921
- return new ReturnStatement(returnValue);
917
+ return this.factory.createReturnStatement(returnValue, range);
922
918
  }
923
919
  parseExpressionOrLabelledStatement(allowFunction) {
924
920
  // ExpressionStatement | LabelledStatement ::
@@ -947,10 +943,11 @@ export class JavaScriptInlineParser extends AbstractParser {
947
943
  default:
948
944
  break;
949
945
  }
946
+ const range = this.createStartPosition();
950
947
  const startsWithIdentifier = Token.isAnyIdentifier(this.peek().token);
951
948
  this.setAcceptIN(true);
952
949
  const expression = this.parseExpressionCoverGrammar();
953
- if (this.peek().isType(Token.COLON) && startsWithIdentifier && this.isIdentifier(expression)) {
950
+ if (this.peek().isType(Token.COLON) && startsWithIdentifier && this.factory.isIdentifier(expression)) {
954
951
  // The whole expression was a single identifier, and not, e.g.,
955
952
  // something starting with an identifier or a parenthesized identifier.
956
953
  // Remove the "ghost" variable that turned out to be a label from the top
@@ -963,11 +960,13 @@ export class JavaScriptInlineParser extends AbstractParser {
963
960
  && allowFunction == AllowLabelledFunctionStatement.AllowLabelledFunctionStatement) {
964
961
  const result = this.parseFunctionDeclaration();
965
962
  this.restoreAcceptIN();
966
- return new LabeledStatement(expression, result);
963
+ this.updateRangeEnd(range);
964
+ return this.factory.createLabeledStatement(expression, result, range);
967
965
  }
968
966
  const result = this.parseStatement(allowFunction);
969
967
  this.restoreAcceptIN();
970
- return new LabeledStatement(expression, result);
968
+ this.updateRangeEnd(range);
969
+ return this.factory.createLabeledStatement(expression, result, range);
971
970
  }
972
971
  this.restoreAcceptIN();
973
972
  // Parsed expression statement, followed by semicolon.
@@ -981,11 +980,11 @@ export class JavaScriptInlineParser extends AbstractParser {
981
980
  return result;
982
981
  }
983
982
  parseFunctionDeclaration() {
984
- this.consume(Token.FUNCTION);
983
+ const start = this.consume(Token.FUNCTION);
985
984
  if (this.check(Token.MUL)) {
986
985
  throw new Error(this.errorMessage(`Error Generator In Single Statement Context`));
987
986
  }
988
- return this.parseHoistableDeclaration01(FunctionKind.NormalFunction, undefined, false);
987
+ return this.parseHoistableDeclaration01(FunctionKind.NormalFunction, undefined, false, start);
989
988
  }
990
989
  parseAsyncFunctionLiteral() {
991
990
  // AsyncFunctionLiteral ::
@@ -997,7 +996,7 @@ export class JavaScriptInlineParser extends AbstractParser {
997
996
  if (this.current().isNotType(Token.ASYNC)) {
998
997
  throw new SyntaxError(this.errorMessage('invalid token'));
999
998
  }
1000
- this.consume(Token.FUNCTION);
999
+ const start = this.consume(Token.FUNCTION);
1001
1000
  let name;
1002
1001
  let syntaxKind = FunctionSyntaxKind.AnonymousExpression;
1003
1002
  let flags = FunctionKind.AsyncFunction;
@@ -1008,17 +1007,17 @@ export class JavaScriptInlineParser extends AbstractParser {
1008
1007
  syntaxKind = FunctionSyntaxKind.NamedExpression;
1009
1008
  name = this.parseIdentifier(this.getLastFunctionKind());
1010
1009
  }
1011
- return this.parseFunctionLiteral(flags, syntaxKind, name);
1010
+ return this.parseFunctionLiteral(flags, syntaxKind, name, start);
1012
1011
  }
1013
- parseHoistableDeclaration(names, defaultExport) {
1012
+ parseHoistableDeclaration(names, defaultExport, start) {
1014
1013
  this.consume(Token.FUNCTION);
1015
1014
  let flags = FunctionKind.NormalFunction;
1016
1015
  if (this.check(Token.MUL)) {
1017
1016
  flags = FunctionKind.GeneratorFunction;
1018
1017
  }
1019
- return this.parseHoistableDeclaration01(flags, names, defaultExport);
1018
+ return this.parseHoistableDeclaration01(flags, names, defaultExport, start);
1020
1019
  }
1021
- parseHoistableDeclaration01(flag, names, defaultExport) {
1020
+ parseHoistableDeclaration01(flag, names, defaultExport, start) {
1022
1021
  // FunctionDeclaration ::
1023
1022
  // 'function' Identifier '(' FormalParameters ')' '{' FunctionBody '}'
1024
1023
  // 'function' '(' FormalParameters ')' '{' FunctionBody '}'
@@ -1037,7 +1036,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1037
1036
  let name;
1038
1037
  if (this.peek().isType(Token.LPAREN)) {
1039
1038
  if (defaultExport) {
1040
- name = new Identifier('default');
1039
+ name = this.factory.createIdentifier('default', this.createRange(start));
1041
1040
  }
1042
1041
  else {
1043
1042
  throw new SyntaxError(this.errorMessage('Missing Function Name'));
@@ -1047,7 +1046,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1047
1046
  name = this.parseIdentifier(this.getLastFunctionKind());
1048
1047
  }
1049
1048
  names?.push(name.toString());
1050
- return this.parseFunctionLiteral(flag, FunctionSyntaxKind.Declaration, name);
1049
+ return this.parseFunctionLiteral(flag, FunctionSyntaxKind.Declaration, name, start);
1051
1050
  }
1052
1051
  parseIdentifier(kind) {
1053
1052
  kind ?? (kind = this.functionKind);
@@ -1064,9 +1063,9 @@ export class JavaScriptInlineParser extends AbstractParser {
1064
1063
  const current = this.current();
1065
1064
  switch (current.token) {
1066
1065
  case Token.AWAIT:
1067
- return AwaitIdentifier;
1066
+ return this.factory.createIdentifier('await', current.range);
1068
1067
  case Token.ASYNC:
1069
- return AsyncIdentifier;
1068
+ return this.factory.createIdentifier('async', current.range);
1070
1069
  case Token.IDENTIFIER:
1071
1070
  case Token.PRIVATE_NAME:
1072
1071
  return current.getValue();
@@ -1075,20 +1074,20 @@ export class JavaScriptInlineParser extends AbstractParser {
1075
1074
  }
1076
1075
  const name = current.getValue().toString();
1077
1076
  if (name == 'constructor') {
1078
- return ConstructorIdentifier;
1077
+ return this.factory.createIdentifier('constructor', current.range);
1079
1078
  }
1080
1079
  if (name == 'name') {
1081
- return NameIdentifier;
1080
+ return this.factory.createIdentifier('name', current.range);
1082
1081
  }
1083
1082
  if (name == 'eval') {
1084
- return EvalIdentifier;
1083
+ return this.factory.createIdentifier('eval', current.range);
1085
1084
  }
1086
1085
  else if (name == 'arguments') {
1087
- return ArgumentsIdentifier;
1086
+ return this.factory.createIdentifier('arguments', current.range);
1088
1087
  }
1089
1088
  return current.getValue();
1090
1089
  }
1091
- parseFunctionLiteral(flag, functionSyntaxKind, name) {
1090
+ parseFunctionLiteral(flag, functionSyntaxKind, name, start) {
1092
1091
  // Function ::
1093
1092
  // '(' FormalParameterList? ')' '{' FunctionBody '}'
1094
1093
  this.setFunctionKind(flag);
@@ -1096,16 +1095,18 @@ export class JavaScriptInlineParser extends AbstractParser {
1096
1095
  this.expect(Token.LPAREN);
1097
1096
  const formals = this.parseFormalParameterList(functionInfo);
1098
1097
  this.expect(Token.RPAREN);
1099
- this.expect(Token.LBRACE);
1098
+ const bodyStart = this.expect(Token.LBRACE);
1100
1099
  this.setAcceptIN(true);
1101
1100
  const body = this.parseFunctionBody(flag, FunctionBodyType.BLOCK, functionSyntaxKind);
1102
1101
  this.restoreAcceptIN();
1103
1102
  this.restoreFunctionKind();
1104
- const bodyBlock = new BlockStatement(body);
1103
+ const bodyRange = this.createRange(bodyStart);
1104
+ const funcRange = this.createRange(start);
1105
+ const bodyBlock = this.factory.createBlock(body, bodyRange);
1105
1106
  if (name) {
1106
- return new FunctionDeclaration(formals, bodyBlock, isAsyncFunction(flag), isGeneratorFunction(flag), name);
1107
+ return this.factory.createFunctionDeclaration(formals, bodyBlock, isAsyncFunction(flag), isGeneratorFunction(flag), name, funcRange);
1107
1108
  }
1108
- return new FunctionExpression(formals, bodyBlock, isAsyncFunction(flag), isGeneratorFunction(flag));
1109
+ return this.factory.createFunctionExpression(formals, bodyBlock, isAsyncFunction(flag), isGeneratorFunction(flag), funcRange);
1109
1110
  }
1110
1111
  parseFunctionBody(kind, bodyType, functionSyntaxKind) {
1111
1112
  // Building the parameter initialization block declares the parameters.
@@ -1157,7 +1158,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1157
1158
  if (!stat) {
1158
1159
  break;
1159
1160
  }
1160
- if (this.isEmptyStatement(stat)) {
1161
+ if (this.factory.isEmptyStatement(stat)) {
1161
1162
  continue;
1162
1163
  }
1163
1164
  list.push(stat);
@@ -1199,20 +1200,25 @@ export class JavaScriptInlineParser extends AbstractParser {
1199
1200
  parseFormalParameter(functionInfo) {
1200
1201
  // FormalParameter[Yield,GeneratorParameter] :
1201
1202
  // BindingElement[?Yield, ?GeneratorParameter]
1203
+ const range = this.createStartPosition();
1202
1204
  functionInfo.rest = this.check(Token.ELLIPSIS);
1203
- let pattern = this.parseBindingPattern(true);
1205
+ const pattern = this.parseBindingPattern(true);
1204
1206
  let initializer;
1205
1207
  if (this.check(Token.ASSIGN)) {
1206
1208
  if (functionInfo.rest) {
1207
1209
  throw new Error(this.errorMessage(`Rest Default Initializer`));
1208
1210
  }
1209
1211
  this.setAcceptIN(true);
1210
- const value = this.parseAssignmentExpression();
1212
+ const right = this.parseAssignmentExpression();
1211
1213
  this.restoreAcceptIN();
1212
- initializer = new Param(pattern, value);
1214
+ this.updateRangeEnd(range);
1215
+ const left = this.checkParamType(pattern);
1216
+ initializer = this.factory.createAssignmentPattern(left, right, range);
1213
1217
  }
1214
1218
  else {
1215
- initializer = new Param(pattern);
1219
+ this.updateRangeEnd(range);
1220
+ const param = this.checkParamType(pattern);
1221
+ initializer = functionInfo.rest ? this.factory.createRestElement(param, param.range && [range[0], param.range[1]]) : param;
1216
1222
  }
1217
1223
  return initializer;
1218
1224
  }
@@ -1240,8 +1246,9 @@ export class JavaScriptInlineParser extends AbstractParser {
1240
1246
  return this.expressionListToExpression(list);
1241
1247
  }
1242
1248
  parseArrowParametersWithRest(list) {
1243
- this.consume(Token.ELLIPSIS);
1249
+ const start = this.consume(Token.ELLIPSIS);
1244
1250
  const pattern = this.parseBindingPattern(true);
1251
+ const range = this.createRange(start);
1245
1252
  if (this.peek().isType(Token.ASSIGN)) {
1246
1253
  throw new Error(this.errorMessage(`Error A rest parameter cannot have an initializer`));
1247
1254
  }
@@ -1254,7 +1261,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1254
1261
  if (this.peek().isNotType(Token.RPAREN) || this.peekAhead().isNotType(Token.ARROW)) {
1255
1262
  throw new Error(this.errorMessage(`Error Unexpected Token At ${this.position()}`));
1256
1263
  }
1257
- list.push(new SpreadElement(pattern));
1264
+ list.push(this.factory.createSpreadElement(pattern, range));
1258
1265
  return this.expressionListToExpression(list);
1259
1266
  }
1260
1267
  expressionListToExpression(list) {
@@ -1262,11 +1269,13 @@ export class JavaScriptInlineParser extends AbstractParser {
1262
1269
  if (list.length === 1) {
1263
1270
  return first;
1264
1271
  }
1265
- if (first instanceof SequenceExpression) {
1272
+ if (this.factory.isSequenceExpression(first)) {
1266
1273
  first.getExpressions().push(...list.slice(1));
1267
1274
  return first;
1268
1275
  }
1269
- return new SequenceExpression(list);
1276
+ const range = this.createRange(list.at(0));
1277
+ range && this.updateRangeEnd(range);
1278
+ return this.factory.createCommaListExpression(list, range);
1270
1279
  }
1271
1280
  parseMemberExpression() {
1272
1281
  // MemberExpression ::
@@ -1284,15 +1293,6 @@ export class JavaScriptInlineParser extends AbstractParser {
1284
1293
  const result = this.parsePrimaryExpression();
1285
1294
  return this.parseMemberExpressionContinuation(result);
1286
1295
  }
1287
- toParamNode(expression) {
1288
- if (expression instanceof AssignmentExpression) {
1289
- return new Param(expression.getLeft(), expression.getRight());
1290
- }
1291
- if (expression instanceof GroupingExpression) {
1292
- return new Param(expression.getNode());
1293
- }
1294
- return new Param(expression);
1295
- }
1296
1296
  parsePrimaryExpression() {
1297
1297
  // PrimaryExpression ::
1298
1298
  // 'this'
@@ -1327,28 +1327,22 @@ export class JavaScriptInlineParser extends AbstractParser {
1327
1327
  if (this.peek().isType(Token.ARROW)) {
1328
1328
  this.setFunctionKind(kind);
1329
1329
  const name = this.parseAndClassifyIdentifier(token);
1330
- const params = [];
1331
- if (name instanceof SequenceExpression) {
1332
- params.push(...name.getExpressions().map(this.toParamNode));
1333
- }
1334
- else {
1335
- params.push(this.toParamNode(name));
1336
- }
1337
- const arrow = this.parseArrowFunctionLiteral(params, kind);
1330
+ const params = this.factory.isSequenceExpression(name) ? name.getExpressions() : [name];
1331
+ const arrow = this.parseArrowFunctionLiteral(params, kind, this.createRange(token));
1338
1332
  this.restoreFunctionKind();
1339
1333
  return arrow;
1340
1334
  }
1341
1335
  return this.parseAndClassifyIdentifier(token);
1342
1336
  }
1343
1337
  if (Token.isLiteral(token.token)) {
1344
- return expressionFromLiteral(this.next());
1338
+ return this.next().getValue();
1345
1339
  }
1346
1340
  switch (token.token) {
1347
1341
  case Token.NEW:
1348
1342
  return this.parseMemberWithPresentNewPrefixesExpression();
1349
1343
  case Token.THIS:
1350
1344
  this.consume(Token.THIS);
1351
- return ThisNode;
1345
+ return this.factory.createThis(token.range);
1352
1346
  case Token.DIV:
1353
1347
  case Token.DIV_ASSIGN:
1354
1348
  // case Token.REGEXP_LITERAL:
@@ -1374,7 +1368,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1374
1368
  if (!this.peek().isType(Token.ARROW)) {
1375
1369
  throw new Error(this.errorMessage(`Unexpected Token: ${Token.RPAREN.getName()}`));
1376
1370
  }
1377
- const result = new SequenceExpression([]);
1371
+ const result = this.factory.createCommaListExpression([], this.createRange(token));
1378
1372
  this.markParenthesized(result);
1379
1373
  return result;
1380
1374
  }
@@ -1418,8 +1412,8 @@ export class JavaScriptInlineParser extends AbstractParser {
1418
1412
  // single TEMPLATE_SPAN and no expressions.
1419
1413
  if (next.isType(Token.TEMPLATE_TAIL)) {
1420
1414
  this.consume(Token.TEMPLATE_TAIL);
1421
- const string = next.getValue().string;
1422
- return this.createTemplateLiteralExpressionNode([string], [], tag);
1415
+ const template = next.getValue();
1416
+ return this.createTemplateLiteralExpressionNode([template.string], [], tag, template.range);
1423
1417
  }
1424
1418
  this.consume(Token.TEMPLATE_SPAN);
1425
1419
  const expressions = [];
@@ -1449,13 +1443,11 @@ export class JavaScriptInlineParser extends AbstractParser {
1449
1443
  // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
1450
1444
  return this.createTemplateLiteralExpressionNode(strings, expressions, tag);
1451
1445
  }
1452
- createTemplateLiteralExpressionNode(strings, expressions, tag) {
1446
+ createTemplateLiteralExpressionNode(strings, expressions, tag, range) {
1453
1447
  if (tag) {
1454
- return new TaggedTemplateExpression(tag, strings, expressions);
1455
- }
1456
- else {
1457
- return new TemplateLiteral(strings, expressions);
1448
+ return this.factory.createTaggedTemplateExpression(tag, strings, expressions, range);
1458
1449
  }
1450
+ return this.factory.createTemplateExpression(strings, expressions, range);
1459
1451
  }
1460
1452
  parseMemberWithPresentNewPrefixesExpression() {
1461
1453
  // NewExpression ::
@@ -1476,19 +1468,19 @@ export class JavaScriptInlineParser extends AbstractParser {
1476
1468
  // new new foo() means new (new foo())
1477
1469
  // new new foo().bar().baz means (new (new foo()).bar()).baz
1478
1470
  // new super.x means new (super.x)
1479
- this.consume(Token.NEW);
1471
+ const start = this.consume(Token.NEW);
1480
1472
  let result;
1481
1473
  // CheckStackOverflow();
1482
1474
  if (this.peek().isType(Token.IMPORT) && this.peekAhead().isType(Token.LPAREN)) {
1483
1475
  throw new SyntaxError(this.errorMessage(`Import Call Not New Expression`));
1484
1476
  }
1485
1477
  else if (this.peek().isType(Token.PERIOD)) {
1486
- result = this.parseNewTargetExpression();
1478
+ result = this.parseNewTargetExpression(start);
1487
1479
  return this.parseMemberExpressionContinuation(result);
1488
1480
  }
1489
1481
  else {
1490
1482
  result = this.parseMemberExpression();
1491
- if (result === SuperIdentifier) {
1483
+ if (this.factory.isSuper(result)) {
1492
1484
  // new super() is never allowed
1493
1485
  throw new SyntaxError(this.errorMessage(`Unexpected Super, new super() is never allowed`));
1494
1486
  }
@@ -1496,14 +1488,14 @@ export class JavaScriptInlineParser extends AbstractParser {
1496
1488
  if (this.peek().isType(Token.LPAREN)) {
1497
1489
  // NewExpression with arguments.
1498
1490
  const args = this.parseArguments();
1499
- result = new NewExpression(result, args);
1491
+ result = this.factory.createNewExpression(result, args, this.createRange(start));
1500
1492
  // The expression can still continue with . or [ after the arguments.
1501
1493
  return this.parseMemberExpressionContinuation(result);
1502
1494
  }
1503
1495
  if (this.peek().isType(Token.QUESTION_PERIOD)) {
1504
1496
  throw new SyntaxError(this.errorMessage(`Optional Chaining with New not allowed, new x?.y()`));
1505
1497
  }
1506
- return new NewExpression(result);
1498
+ return this.factory.createNewExpression(result, undefined, this.createRange(start));
1507
1499
  }
1508
1500
  parseArguments(maybeArrow) {
1509
1501
  // Arguments ::
@@ -1511,12 +1503,13 @@ export class JavaScriptInlineParser extends AbstractParser {
1511
1503
  this.consume(Token.LPAREN);
1512
1504
  const args = [];
1513
1505
  while (this.peek().isNotType(Token.RPAREN)) {
1506
+ const range = this.createStartPosition();
1514
1507
  const isSpread = this.check(Token.ELLIPSIS);
1515
1508
  this.setAcceptIN(true);
1516
1509
  let argument = this.parseAssignmentExpressionCoverGrammar();
1517
1510
  if (ParsingArrowHeadFlag.MaybeArrowHead === maybeArrow) {
1518
1511
  if (isSpread) {
1519
- if (argument instanceof AssignmentExpression) {
1512
+ if (this.factory.isAssignmentExpression(argument)) {
1520
1513
  this.restoreAcceptIN();
1521
1514
  throw new Error(this.errorMessage(` Rest parameter may not have a default initializer'`));
1522
1515
  }
@@ -1527,7 +1520,8 @@ export class JavaScriptInlineParser extends AbstractParser {
1527
1520
  }
1528
1521
  }
1529
1522
  if (isSpread) {
1530
- argument = new SpreadElement(argument);
1523
+ this.updateRangeEnd(range);
1524
+ argument = this.factory.createSpreadElement(argument, range);
1531
1525
  }
1532
1526
  args.push(argument);
1533
1527
  this.restoreAcceptIN();
@@ -1545,6 +1539,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1545
1539
  // ArrowFunction
1546
1540
  // YieldExpression
1547
1541
  // LeftHandSideExpression AssignmentOperator AssignmentExpression
1542
+ const range = this.createStartPosition();
1548
1543
  if (this.peek().isType(Token.YIELD) && isGeneratorFunction(this.functionKind)) {
1549
1544
  return this.parseYieldExpression();
1550
1545
  }
@@ -1557,48 +1552,34 @@ export class JavaScriptInlineParser extends AbstractParser {
1557
1552
  ;
1558
1553
  // Arrow functions.
1559
1554
  if (op === Token.ARROW) {
1560
- if (!this.isIdentifier(expression) && !this.isParenthesized(expression)) {
1555
+ if (!this.factory.isIdentifier(expression) && !this.isParenthesized(expression)) {
1561
1556
  throw new Error(this.errorMessage(`Malformed Arrow Fun Param List`));
1562
1557
  }
1563
1558
  const kind = FunctionKind.NormalFunction;
1564
1559
  this.setFunctionKind(kind);
1565
1560
  let arrow;
1566
- if (expression instanceof SequenceExpression) {
1567
- const params = expression.getExpressions().map(expr => new Param(expr));
1568
- const last = params.at(-1)?.getIdentifier();
1569
- if (last instanceof SpreadElement) {
1570
- const arg = last.getArgument();
1571
- let param = arg;
1572
- if (arg instanceof ArrayExpression) {
1573
- param = new ArrayPattern(arg.getElements());
1574
- }
1575
- else if (arg instanceof ObjectExpression) {
1576
- param = new ObjectPattern(arg.getProperties());
1577
- }
1578
- params[params.length - 1] = new Param(new RestElement(param));
1579
- }
1580
- arrow = this.parseArrowFunctionLiteral(params, FunctionKind.NormalFunction);
1561
+ if (this.factory.isSequenceExpression(expression)) {
1562
+ arrow = this.parseArrowFunctionLiteral(expression.getExpressions(), FunctionKind.NormalFunction, range);
1581
1563
  }
1582
- else if (expression instanceof GroupingExpression) {
1583
- arrow = this.parseArrowFunctionLiteral([new Param(expression.getNode())], FunctionKind.NormalFunction);
1564
+ else if (this.factory.isGroupingExpression(expression)) {
1565
+ arrow = this.parseArrowFunctionLiteral([expression.getNode()], FunctionKind.NormalFunction, range);
1584
1566
  }
1585
1567
  else {
1586
1568
  this.clearParenthesized(expression);
1587
- arrow = this.parseArrowFunctionLiteral([new Param(expression)], FunctionKind.NormalFunction);
1569
+ arrow = this.parseArrowFunctionLiteral([expression], FunctionKind.NormalFunction, range);
1588
1570
  }
1589
1571
  this.restoreFunctionKind();
1590
1572
  return arrow;
1591
1573
  }
1592
1574
  if (this.isAssignableIdentifier(expression)) {
1593
1575
  }
1594
- else if (this.isProperty(expression)) {
1576
+ else if (this.factory.isPropertyOrMemberExpression(expression)) {
1595
1577
  }
1596
- else if (this.isPattern(expression) && Token.isAssignment(op)) {
1578
+ else if (this.factory.canBePattern(expression) && Token.isAssignment(op)) {
1597
1579
  // Destructuring assignment.
1598
- expression = expression instanceof ObjectExpression
1599
- ? new ObjectPattern(expression.getProperties())
1600
- : new ArrayPattern(expression.getElements());
1601
- // expression_scope() -> ValidateAsPattern(expression, lhs_beg_pos, end_position());
1580
+ expression = this.factory.isObjectExpression(expression)
1581
+ ? this.factory.createObjectBindingPattern(expression.getProperties(), expression.range)
1582
+ : this.factory.createArrayBindingPattern(expression.getElements(), expression.range);
1602
1583
  }
1603
1584
  else {
1604
1585
  if (!this.isValidReferenceExpression(expression)) {
@@ -1615,12 +1596,34 @@ export class JavaScriptInlineParser extends AbstractParser {
1615
1596
  if (!Token.isAssignment(op)) {
1616
1597
  throw new Error(this.errorMessage(`Invalid Destructuring Target`));
1617
1598
  }
1618
- return new AssignmentExpression(op.getName(), expression, right);
1599
+ this.updateRangeEnd(range);
1600
+ return this.factory.createAssignment(op.getName(), expression, right, range);
1619
1601
  }
1620
1602
  parseAssignmentExpression() {
1621
1603
  return this.parseAssignmentExpressionCoverGrammar();
1622
1604
  }
1623
- parseArrowFunctionLiteral(parameters, kind) {
1605
+ checkParamType(node) {
1606
+ if (this.factory.isArrayExpression(node)) {
1607
+ return this.factory.createArrayBindingPattern(node.getElements(), node.range);
1608
+ }
1609
+ else if (this.factory.isObjectExpression(node)) {
1610
+ return this.factory.createObjectBindingPattern(node.getProperties(), node.range);
1611
+ }
1612
+ else if (this.factory.isSpreadElement(node)) {
1613
+ let arg = node.getArgument();
1614
+ // let param = arg;
1615
+ if (this.factory.isArrayExpression(arg)) {
1616
+ arg = this.factory.createArrayBindingPattern(arg.getElements(), arg.range);
1617
+ }
1618
+ else if (this.factory.isObjectExpression(arg)) {
1619
+ arg = this.factory.createObjectBindingPattern(arg.getProperties(), arg.range);
1620
+ }
1621
+ return this.factory.createRestElement(arg, node.range);
1622
+ }
1623
+ return node;
1624
+ }
1625
+ parseArrowFunctionLiteral(parameters, kind, range) {
1626
+ parameters = parameters.map(node => this.checkParamType(node));
1624
1627
  if (this.peek().isNotType(Token.ARROW)) {
1625
1628
  throw new SyntaxError(this.errorMessage('SyntaxError Expecting Arrow Token'));
1626
1629
  }
@@ -1640,7 +1643,8 @@ export class JavaScriptInlineParser extends AbstractParser {
1640
1643
  has_braces = false;
1641
1644
  body = this.parseFunctionBody(kind, FunctionBodyType.EXPRESSION, FunctionSyntaxKind.AnonymousExpression);
1642
1645
  }
1643
- return new ArrowFunctionExpression(parameters, body, !has_braces, isAsyncFunction(kind));
1646
+ this.updateRangeEnd(range);
1647
+ return this.factory.createArrowFunction(parameters, body, !has_braces, isAsyncFunction(kind), range);
1644
1648
  }
1645
1649
  parseRegExpLiteral() {
1646
1650
  if (!this.scanner.scanRegExpPattern()) {
@@ -1651,23 +1655,24 @@ export class JavaScriptInlineParser extends AbstractParser {
1651
1655
  parseArrayLiteral(isPattern) {
1652
1656
  // ArrayLiteral ::
1653
1657
  // '[' Expression? (',' Expression?)* ']'
1654
- this.consume(Token.LBRACK);
1658
+ const start = this.consume(Token.LBRACK);
1655
1659
  let first_spread_index = -1;
1656
1660
  const values = [];
1657
1661
  while (!this.check(Token.RBRACK)) {
1658
1662
  let elem;
1659
- if (this.peek().isType(Token.COMMA)) {
1663
+ const peek = this.peek();
1664
+ if (peek.isType(Token.COMMA)) {
1660
1665
  elem = null;
1661
1666
  }
1662
1667
  else if (this.check(Token.ELLIPSIS)) {
1663
1668
  this.setAcceptIN(true);
1664
1669
  const argument = this.parsePossibleDestructuringSubPattern();
1665
1670
  this.restoreAcceptIN();
1666
- elem = new SpreadElement(argument);
1671
+ elem = this.factory.createSpreadElement(argument, this.createRange(peek));
1667
1672
  if (first_spread_index < 0) {
1668
1673
  first_spread_index = values.length;
1669
1674
  }
1670
- if (argument instanceof AssignmentExpression && isPattern) {
1675
+ if (this.factory.isAssignmentExpression(argument) && isPattern) {
1671
1676
  throw new SyntaxError(this.errorMessage('Invalid Destructuring Target'));
1672
1677
  }
1673
1678
  if (this.peek().isType(Token.COMMA)) {
@@ -1684,7 +1689,11 @@ export class JavaScriptInlineParser extends AbstractParser {
1684
1689
  this.expect(Token.COMMA);
1685
1690
  }
1686
1691
  }
1687
- return new (isPattern ? ArrayPattern : ArrayExpression)(values);
1692
+ const range = this.createRange(start);
1693
+ if (isPattern) {
1694
+ return this.factory.createArrayBindingPattern(values, range);
1695
+ }
1696
+ return this.factory.createArrayLiteralExpression(values, range);
1688
1697
  }
1689
1698
  parsePossibleDestructuringSubPattern() {
1690
1699
  return this.parseAssignmentExpressionCoverGrammar();
@@ -1692,7 +1701,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1692
1701
  parseObjectLiteral(isPattern) {
1693
1702
  // ObjectLiteral ::
1694
1703
  // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
1695
- this.consume(Token.LBRACE);
1704
+ const start = this.consume(Token.LBRACE);
1696
1705
  const properties = [];
1697
1706
  while (!this.check(Token.RBRACE)) {
1698
1707
  const property = this.parseObjectPropertyDefinition(isPattern);
@@ -1701,10 +1710,11 @@ export class JavaScriptInlineParser extends AbstractParser {
1701
1710
  this.expect(Token.COMMA);
1702
1711
  }
1703
1712
  }
1713
+ const range = this.createRange(start);
1704
1714
  if (isPattern) {
1705
- return new ObjectPattern(properties);
1715
+ return this.factory.createObjectBindingPattern(properties, range);
1706
1716
  }
1707
- return new ObjectExpression(properties);
1717
+ return this.factory.createObjectLiteralExpression(properties, range);
1708
1718
  }
1709
1719
  parseObjectPropertyDefinition(isPattern) {
1710
1720
  const propInfo = new PropertyKindInfo();
@@ -1713,15 +1723,17 @@ export class JavaScriptInlineParser extends AbstractParser {
1713
1723
  case PropertyKind.Spread:
1714
1724
  let value = nameExpression;
1715
1725
  if (isPattern) {
1716
- value = new RestElement(value.getArgument());
1726
+ value = this.factory.createRestElement(value.getArgument(), value.range);
1717
1727
  }
1718
- return new Property(value.getArgument(), value, 'init', false, false, propInfo.isComputedName);
1728
+ const range = this.createRange(propInfo.rangeStart);
1729
+ return this.factory.createPropertyDeclaration(value.getArgument(), value, 'init', false, false, propInfo.isComputedName, range);
1719
1730
  case PropertyKind.Value: {
1720
1731
  this.consume(Token.COLON);
1721
1732
  this.setAcceptIN(true);
1722
1733
  const value = this.parsePossibleDestructuringSubPattern();
1723
1734
  this.restoreAcceptIN();
1724
- return new Property(nameExpression, value, 'init', false, false, propInfo.isComputedName);
1735
+ const range = this.createRange(propInfo.rangeStart);
1736
+ return this.factory.createPropertyDeclaration(nameExpression, value, 'init', false, false, propInfo.isComputedName, range);
1725
1737
  }
1726
1738
  case PropertyKind.Assign:
1727
1739
  case PropertyKind.ShorthandOrClassField:
@@ -1732,7 +1744,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1732
1744
  //
1733
1745
  // CoverInitializedName
1734
1746
  // IdentifierReference Initializer?
1735
- const lhs = new Identifier(propInfo.name);
1747
+ const lhs = this.factory.createIdentifier(propInfo.name, this.createRange(propInfo.rangeStart));
1736
1748
  if (!this.isAssignableIdentifier(lhs)) {
1737
1749
  throw new Error(this.errorMessage('Strict Eval Arguments'));
1738
1750
  }
@@ -1742,46 +1754,51 @@ export class JavaScriptInlineParser extends AbstractParser {
1742
1754
  this.setAcceptIN(true);
1743
1755
  const rhs = this.parseAssignmentExpression();
1744
1756
  this.restoreAcceptIN();
1745
- value = new AssignmentExpression(Token.ASSIGN.getName(), lhs, rhs);
1757
+ value = this.factory.createAssignment(Token.ASSIGN.getName(), lhs, rhs, this.createRange(propInfo.rangeStart));
1746
1758
  }
1747
1759
  else {
1748
1760
  value = lhs;
1749
1761
  }
1750
- return new Property(nameExpression, value, 'init', false, propInfo.kind !== PropertyKind.Assign, propInfo.isComputedName);
1762
+ const range = this.createRange(propInfo.rangeStart);
1763
+ return this.factory.createPropertyDeclaration(nameExpression, value, 'init', false, propInfo.kind !== PropertyKind.Assign, propInfo.isComputedName, range);
1751
1764
  }
1752
1765
  case PropertyKind.Method: {
1753
1766
  // MethodDefinition
1754
1767
  // PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
1755
1768
  // '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
1756
1769
  const kind = this.methodKindFor(propInfo.isStatic, propInfo.funcFlag);
1757
- const value = this.parseFunctionLiteral(kind, FunctionSyntaxKind.AccessorOrMethod, propInfo.name ? new Identifier(propInfo.name) : undefined);
1758
- return new Property(nameExpression, value, 'init', true, false, propInfo.isComputedName);
1770
+ const value = this.parseFunctionLiteral(kind, FunctionSyntaxKind.AccessorOrMethod, propInfo.name ? this.factory.createIdentifier(propInfo.name) : undefined, propInfo.rangeStart);
1771
+ const range = this.createRange(propInfo.rangeStart);
1772
+ return this.factory.createPropertyDeclaration(nameExpression, value, 'init', true, false, propInfo.isComputedName, range);
1759
1773
  }
1760
1774
  case PropertyKind.AccessorGetter:
1761
1775
  case PropertyKind.AccessorSetter: {
1762
1776
  const isGet = propInfo.kind == PropertyKind.AccessorGetter;
1763
1777
  const kind = this.methodKindFor(propInfo.isStatic, propInfo.funcFlag);
1764
- const value = this.parseFunctionLiteral(kind, FunctionSyntaxKind.AccessorOrMethod, propInfo.name ? new Identifier(propInfo.name) : undefined);
1765
- return new Property(nameExpression, value, isGet ? 'get' : 'set', false, false, propInfo.isComputedName);
1778
+ const value = this.parseFunctionLiteral(kind, FunctionSyntaxKind.AccessorOrMethod, propInfo.name ? this.factory.createIdentifier(propInfo.name, this.createRange(propInfo.rangeStart)) : undefined, propInfo.rangeStart);
1779
+ const range = this.createRange(propInfo.rangeStart);
1780
+ return this.factory.createPropertyDeclaration(nameExpression, value, isGet ? 'get' : 'set', false, false, propInfo.isComputedName, range);
1766
1781
  }
1767
1782
  case PropertyKind.ClassField:
1768
1783
  case PropertyKind.NotSet:
1769
- return NullNode;
1784
+ return this.factory.createNull(this.createRange(propInfo.rangeStart));
1770
1785
  }
1771
1786
  }
1772
1787
  parseProperty(propInfo) {
1773
1788
  let nextToken = this.peek();
1789
+ propInfo.rangeStart = nextToken;
1774
1790
  if (this.check(Token.ASYNC)) {
1775
1791
  // async
1776
1792
  nextToken = this.peek();
1777
1793
  if (nextToken.isNotType(Token.MUL)
1778
1794
  && propInfo.parsePropertyKindFromToken(nextToken.token)
1779
1795
  || this.scanner.hasLineTerminatorBeforeNext()) {
1780
- return AsyncIdentifier;
1796
+ return this.factory.createIdentifier('async', this.createRange(propInfo.rangeStart));
1781
1797
  }
1782
1798
  propInfo.kind = PropertyKind.Method;
1783
1799
  propInfo.funcFlag = ParseFunctionFlag.IsAsync;
1784
1800
  }
1801
+ nextToken = this.peek();
1785
1802
  if (this.check(Token.MUL)) {
1786
1803
  // async*
1787
1804
  propInfo.kind = PropertyKind.Method;
@@ -1791,7 +1808,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1791
1808
  if (propInfo.kind == PropertyKind.NotSet && nextToken.isType(Token.GET) || nextToken.isType(Token.SET)) {
1792
1809
  const token = this.next();
1793
1810
  if (propInfo.parsePropertyKindFromToken(this.peek().token)) {
1794
- return nextToken.isType(Token.GET) ? GetIdentifier : SetIdentifier;
1811
+ return this.factory.createIdentifier(nextToken.isType(Token.GET) ? 'get' : 'set', this.createRange(propInfo.rangeStart));
1795
1812
  }
1796
1813
  if (token.isType(Token.GET)) {
1797
1814
  propInfo.kind = PropertyKind.AccessorGetter;
@@ -1851,7 +1868,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1851
1868
  }
1852
1869
  propInfo.name = propertyName.toString();
1853
1870
  this.restoreAcceptIN();
1854
- return new SpreadElement(propertyName);
1871
+ return this.factory.createSpreadElement(propertyName, this.createRange(nextToken));
1855
1872
  }
1856
1873
  default:
1857
1874
  propertyName = this.parsePropertyOrPrivatePropertyName();
@@ -1880,7 +1897,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1880
1897
  this.consume(Token.LBRACK);
1881
1898
  this.setAcceptIN(true);
1882
1899
  const index = this.parseExpressionCoverGrammar();
1883
- expression = new MemberExpression(expression, index, true);
1900
+ expression = this.factory.createPropertyAssignment(expression, index, true, false, this.createRange(expression));
1884
1901
  this.expect(Token.RBRACK);
1885
1902
  this.restoreAcceptIN();
1886
1903
  break;
@@ -1888,7 +1905,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1888
1905
  case Token.PERIOD: {
1889
1906
  this.consume(Token.PERIOD);
1890
1907
  const key = this.parsePropertyOrPrivatePropertyName();
1891
- expression = new MemberExpression(expression, key, false);
1908
+ expression = this.factory.createPropertyAssignment(expression, key, false, false, this.createRange(expression));
1892
1909
  break;
1893
1910
  }
1894
1911
  case Token.TEMPLATE_SPAN:
@@ -1909,7 +1926,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1909
1926
  }
1910
1927
  // check keyword as identifier
1911
1928
  if (Token.isPropertyName(next.token) && next.isNotType(Token.EOS)) {
1912
- return new Identifier(next.token.getName());
1929
+ return this.factory.createIdentifier(next.token.getName(), next.range);
1913
1930
  }
1914
1931
  throw new SyntaxError(this.errorMessage(`Parsing property expression: Unexpected Token`));
1915
1932
  }
@@ -1949,13 +1966,13 @@ export class JavaScriptInlineParser extends AbstractParser {
1949
1966
  break;
1950
1967
  }
1951
1968
  if (body) {
1952
- return new PipelineExpression(lhs, body);
1969
+ return this.factory.createPipelineExpression(lhs, body, undefined, this.createRange(lhs));
1953
1970
  }
1954
1971
  if (token.isType(Token.LPAREN)) {
1955
1972
  // parse arrow function
1956
1973
  // x |> ( y => y+1 )
1957
1974
  body = this.parsePrimaryExpression();
1958
- return new PipelineExpression(lhs, body);
1975
+ return this.factory.createPipelineExpression(lhs, body, undefined, this.createRange(lhs));
1959
1976
  }
1960
1977
  // parse angular-like and f# and partial operator syntax
1961
1978
  const func = this.parseMemberExpression(); //this.parseLogicalExpression();
@@ -1965,6 +1982,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1965
1982
  // support angular pipeline syntax
1966
1983
  do {
1967
1984
  this.consume(Token.COLON);
1985
+ const peek = this.peek();
1968
1986
  const isSpread = this.check(Token.ELLIPSIS);
1969
1987
  if (this.peek().isType(Token.CONDITIONAL)) {
1970
1988
  this.consume(Token.CONDITIONAL);
@@ -1978,7 +1996,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1978
1996
  else {
1979
1997
  const arg = this.parseAssignmentExpressionCoverGrammar();
1980
1998
  if (isSpread) {
1981
- args.push(new SpreadElement(arg));
1999
+ args.push(this.factory.createSpreadElement(arg, this.createRange(peek)));
1982
2000
  }
1983
2001
  else {
1984
2002
  args.push(arg);
@@ -1991,6 +2009,7 @@ export class JavaScriptInlineParser extends AbstractParser {
1991
2009
  this.consume(Token.LPAREN);
1992
2010
  let indexed = false;
1993
2011
  while (this.peek().isNotType(Token.RPAREN)) {
2012
+ const peek = this.peek();
1994
2013
  const isSpread = this.check(Token.ELLIPSIS);
1995
2014
  if (this.peek().isType(Token.CONDITIONAL)) {
1996
2015
  this.consume(Token.CONDITIONAL);
@@ -2005,7 +2024,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2005
2024
  else {
2006
2025
  const arg = this.parseAssignmentExpressionCoverGrammar();
2007
2026
  if (isSpread) {
2008
- args.push(new SpreadElement(arg));
2027
+ args.push(this.factory.createSpreadElement(arg, this.createRange(peek)));
2009
2028
  }
2010
2029
  else {
2011
2030
  args.push(arg);
@@ -2017,14 +2036,14 @@ export class JavaScriptInlineParser extends AbstractParser {
2017
2036
  // should be indexed, has partial operator
2018
2037
  if (!indexed) {
2019
2038
  // z |> method(x, y) === method(x, y)(z)
2020
- body = new CallExpression(func, args);
2021
- return new PipelineExpression(lhs, body);
2039
+ body = this.factory.createCallExpression(func, args, false, this.createRange(func));
2040
+ return this.factory.createPipelineExpression(lhs, body, undefined, this.createRange(lhs));
2022
2041
  }
2023
2042
  break;
2024
2043
  default:
2025
2044
  break;
2026
2045
  }
2027
- return new PipelineExpression(lhs, func, args);
2046
+ return this.factory.createPipelineExpression(lhs, func, args, this.createRange(lhs));
2028
2047
  }
2029
2048
  parseConditionalExpression() {
2030
2049
  // ConditionalExpression ::
@@ -2059,9 +2078,9 @@ export class JavaScriptInlineParser extends AbstractParser {
2059
2078
  while (Token.precedence(this.peek().token, this.acceptIN) === prec1) {
2060
2079
  let y;
2061
2080
  let op = this.next();
2062
- const is_right_associative = op.isType(Token.EXP);
2063
- const next_prec = is_right_associative ? prec1 : prec1 + 1;
2064
- y = this.parseBinaryExpression(next_prec);
2081
+ const isRightAssociative = op.isType(Token.EXP);
2082
+ const nextPrecedence = isRightAssociative ? prec1 : prec1 + 1;
2083
+ y = this.parseBinaryExpression(nextPrecedence);
2065
2084
  // For now we distinguish between comparisons and other binary
2066
2085
  // operations. (We could combine the two and get rid of this
2067
2086
  // code and AST node eventually.)
@@ -2077,14 +2096,14 @@ export class JavaScriptInlineParser extends AbstractParser {
2077
2096
  break;
2078
2097
  default: break;
2079
2098
  }
2080
- x = shortcutNumericLiteralBinaryExpression(x, y, cmp);
2099
+ x = this.factory.createInfixExpression(cmp.getName(), x, y, this.createRange(x));
2081
2100
  if (op.isNotType(cmp)) {
2082
2101
  // The comparison was negated - add a NOT.
2083
- x = buildUnaryExpression(x, Token.NOT);
2102
+ x = this.factory.createUnaryExpression(Token.NOT.getName(), x, this.createRange(x));
2084
2103
  }
2085
2104
  }
2086
2105
  else {
2087
- x = shortcutNumericLiteralBinaryExpression(x, y, op.token);
2106
+ x = this.factory.createInfixExpression(op.token.getName(), x, y, this.createRange(x));
2088
2107
  }
2089
2108
  }
2090
2109
  --prec1;
@@ -2137,11 +2156,11 @@ export class JavaScriptInlineParser extends AbstractParser {
2137
2156
  const expression = this.parseUnaryExpression();
2138
2157
  if (Token.isUnary(op.token)) {
2139
2158
  if (op.isType(Token.DELETE)) {
2140
- if (this.isIdentifier(expression) && isStrict(this.languageMode)) {
2159
+ if (this.factory.isIdentifier(expression) && isStrict(this.languageMode)) {
2141
2160
  // "delete identifier" is a syntax error in strict mode.
2142
2161
  throw new Error(this.errorMessage(`"delete identifier" is a syntax error in strict mode`));
2143
2162
  }
2144
- if (expression instanceof MemberExpression && expression.getProperty().toString().startsWith('#')) {
2163
+ if (this.factory.isMemberExpression(expression) && expression.getProperty().toString().startsWith('#')) {
2145
2164
  throw new Error(this.errorMessage(`"Delete Private Field" is a syntax error`));
2146
2165
  }
2147
2166
  }
@@ -2151,7 +2170,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2151
2170
  }
2152
2171
  if (Token.isCount(op.token) || Token.isUnary(op.token)) {
2153
2172
  // Allow the parser to rewrite the expression.
2154
- return buildUnaryExpression(expression, op.token);
2173
+ return this.factory.createUnaryExpression(op.token.getName(), expression, op.range);
2155
2174
  }
2156
2175
  throw new Error(this.errorMessage(`while rewrite unary operation`));
2157
2176
  }
@@ -2169,7 +2188,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2169
2188
  throw new Error(this.errorMessage(`Invalid LHS In Postfix Op.`));
2170
2189
  }
2171
2190
  const op = this.next();
2172
- return buildPostfixExpression(expression, op.token);
2191
+ return this.factory.createUpdateExpression(op.token.getName(), expression, false, this.createRange(expression));
2173
2192
  }
2174
2193
  parseLeftHandSideExpression() {
2175
2194
  // LeftHandSideExpression ::
@@ -2181,7 +2200,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2181
2200
  }
2182
2201
  parseLeftHandSideContinuation(result) {
2183
2202
  if (this.peek().isType(Token.LPAREN)
2184
- && this.isIdentifier(result)
2203
+ && this.factory.isIdentifier(result)
2185
2204
  && this.scanner.currentToken().isType(Token.ASYNC)
2186
2205
  && !this.scanner.hasLineTerminatorBeforeNext()) {
2187
2206
  const args = this.parseArguments(ParsingArrowHeadFlag.AsyncArrowFunction);
@@ -2192,7 +2211,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2192
2211
  // async ( Arguments ) => ...
2193
2212
  return this.expressionListToExpression(args);
2194
2213
  }
2195
- result = new CallExpression(result, args);
2214
+ result = this.factory.createCallExpression(result, args, false, this.createRange(result));
2196
2215
  if (!Token.isPropertyOrCall(this.peek().token))
2197
2216
  return result;
2198
2217
  }
@@ -2211,7 +2230,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2211
2230
  if (Token.isPropertyOrCall(this.peek().token))
2212
2231
  continue;
2213
2232
  const key = this.parsePropertyOrPrivatePropertyName();
2214
- result = new MemberExpression(result, key, false, isOptional);
2233
+ result = this.factory.createPropertyAssignment(result, key, false, isOptional, this.createRange(result));
2215
2234
  break;
2216
2235
  }
2217
2236
  /* Property */
@@ -2220,7 +2239,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2220
2239
  this.setAcceptIN(true);
2221
2240
  const index = this.parseExpressionCoverGrammar();
2222
2241
  this.restoreAcceptIN();
2223
- result = new MemberExpression(result, index, true, isOptional);
2242
+ result = this.factory.createPropertyAssignment(result, index, true, isOptional, this.createRange(result));
2224
2243
  this.expect(Token.RBRACK);
2225
2244
  break;
2226
2245
  }
@@ -2231,13 +2250,13 @@ export class JavaScriptInlineParser extends AbstractParser {
2231
2250
  }
2232
2251
  this.consume(Token.PERIOD);
2233
2252
  const key = this.parsePropertyOrPrivatePropertyName();
2234
- result = new MemberExpression(result, key, false, isOptional);
2253
+ result = this.factory.createPropertyAssignment(result, key, false, isOptional, this.createRange(result));
2235
2254
  break;
2236
2255
  }
2237
2256
  /* Call */
2238
2257
  case Token.LPAREN: {
2239
2258
  const args = this.parseArguments();
2240
- result = new CallExpression(result, args, isOptional);
2259
+ result = this.factory.createCallExpression(result, args, isOptional, this.createRange(result));
2241
2260
  break;
2242
2261
  }
2243
2262
  /* bind call */
@@ -2247,7 +2266,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2247
2266
  }
2248
2267
  this.consume(Token.BIND);
2249
2268
  const key = this.parsePropertyOrPrivatePropertyName();
2250
- result = new BindExpression(result, key, false, isOptional);
2269
+ result = this.factory.createBindExpression(result, key, false, isOptional, this.createRange(result));
2251
2270
  break;
2252
2271
  }
2253
2272
  /* chain bind call */
@@ -2259,7 +2278,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2259
2278
  isOptional = true;
2260
2279
  optionalChaining = true;
2261
2280
  const key = this.parsePropertyOrPrivatePropertyName();
2262
- result = new BindExpression(result, key, true, isOptional);
2281
+ result = this.factory.createBindExpression(result, key, true, isOptional, this.createRange(result));
2263
2282
  break;
2264
2283
  }
2265
2284
  default:
@@ -2276,17 +2295,17 @@ export class JavaScriptInlineParser extends AbstractParser {
2276
2295
  }
2277
2296
  } while (Token.isPropertyOrCall(this.peek().token));
2278
2297
  if (optionalChaining) {
2279
- result = new ChainExpression(result);
2298
+ result = this.factory.createChainExpression(result, this.createRange(result));
2280
2299
  }
2281
2300
  return result;
2282
2301
  }
2283
2302
  parseAwaitExpression() {
2284
- this.consume(Token.AWAIT);
2303
+ const start = this.consume(Token.AWAIT);
2285
2304
  const value = this.parseUnaryExpression();
2286
2305
  if (this.peek().isType(Token.EXP)) {
2287
2306
  throw new Error(this.scanner.createError(`Unexpected Token Unary Exponentiation`));
2288
2307
  }
2289
- return buildUnaryExpression(value, Token.AWAIT);
2308
+ return this.factory.createAwaitExpression(value, this.createRange(start));
2290
2309
  }
2291
2310
  parseNullishExpression(expression) {
2292
2311
  // CoalesceExpression ::
@@ -2307,7 +2326,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2307
2326
  }
2308
2327
  expression = list.pop();
2309
2328
  expression = list.reverse()
2310
- .reduce((previous, current) => new LogicalExpression(Token.NULLISH.getName(), current, previous), expression);
2329
+ .reduce((previous, current) => this.factory.createLogicalExpression(Token.NULLISH.getName(), current, previous), expression);
2311
2330
  return expression;
2312
2331
  }
2313
2332
  parseConditionalContinuation(expression) {
@@ -2317,7 +2336,7 @@ export class JavaScriptInlineParser extends AbstractParser {
2317
2336
  this.restoreAcceptIN();
2318
2337
  this.expect(Token.COLON);
2319
2338
  const right = this.parseAssignmentExpression();
2320
- return new ConditionalExpression(expression, left, right);
2339
+ return this.factory.createConditionalExpression(expression, left, right);
2321
2340
  }
2322
2341
  parseYieldExpression() {
2323
2342
  // YieldExpression ::
@@ -2352,15 +2371,15 @@ export class JavaScriptInlineParser extends AbstractParser {
2352
2371
  break;
2353
2372
  }
2354
2373
  }
2355
- return new YieldExpression(delegating, expression);
2374
+ return this.factory.createYieldExpression(delegating, expression);
2356
2375
  }
2357
- parseNewTargetExpression() {
2376
+ parseNewTargetExpression(start) {
2358
2377
  throw new Error(this.errorMessage('Expression (new.target) not supported.'));
2359
2378
  }
2360
2379
  parseClassExpression() {
2361
2380
  throw new Error(this.errorMessage(`Expression (class) not supported.`));
2362
2381
  }
2363
- parseClassDeclaration(names, defaultExport) {
2382
+ parseClassDeclaration(names, defaultExport, start) {
2364
2383
  throw new Error(this.errorMessage(`Expression (class) not supported.`));
2365
2384
  }
2366
2385
  parseClassLiteral(name, isStrictReserved) {
@@ -2372,5 +2391,8 @@ export class JavaScriptInlineParser extends AbstractParser {
2372
2391
  parseImportExpressions() {
2373
2392
  throw new Error(this.errorMessage('Expression (import) not supported.'));
2374
2393
  }
2394
+ parseWithStatement() {
2395
+ throw new Error(this.errorMessage('Expression (with) not supported.'));
2396
+ }
2375
2397
  }
2376
2398
  //# sourceMappingURL=inline.js.map