@mojir/lits 2.1.2 → 2.1.3

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.
package/dist/index.js CHANGED
@@ -95,9 +95,15 @@ function getCodeMarker(sourceCodeInfo) {
95
95
  }
96
96
 
97
97
  function getLitsErrorMessage(message, sourceCodeInfo) {
98
- var filePathLine = (sourceCodeInfo === null || sourceCodeInfo === void 0 ? void 0 : sourceCodeInfo.filePath) ? "\n".concat(sourceCodeInfo.filePath) : '';
99
- var codeLine = (sourceCodeInfo === null || sourceCodeInfo === void 0 ? void 0 : sourceCodeInfo.code) ? "\n".concat(sourceCodeInfo.code) : '';
100
- var codeMarker = sourceCodeInfo && codeLine ? "\n".concat(getCodeMarker(sourceCodeInfo)) : '';
98
+ if (!sourceCodeInfo) {
99
+ return message;
100
+ }
101
+ var location = "".concat(sourceCodeInfo.position.line, ":").concat(sourceCodeInfo.position.column);
102
+ var filePathLine = sourceCodeInfo.filePath
103
+ ? "\n".concat(sourceCodeInfo.filePath, ":").concat(location)
104
+ : "\nLocation ".concat(location);
105
+ var codeLine = "\n".concat(sourceCodeInfo.code);
106
+ var codeMarker = "\n".concat(getCodeMarker(sourceCodeInfo));
101
107
  return "".concat(message).concat(filePathLine).concat(codeLine).concat(codeMarker);
102
108
  }
103
109
  var RecurSignal = /** @class */ (function (_super) {
@@ -210,6 +216,7 @@ var functionTypes = [
210
216
  'SomePred',
211
217
  'Fnull',
212
218
  'Builtin',
219
+ 'SpecialBuiltin',
213
220
  'NativeJsFunction',
214
221
  ];
215
222
  var functionTypeSet = new Set(functionTypes);
@@ -3671,6 +3678,26 @@ var andSpecialExpression = {
3671
3678
  }
3672
3679
  return value;
3673
3680
  },
3681
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
3682
+ var e_2, _a;
3683
+ var value = true;
3684
+ try {
3685
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
3686
+ var param = params_1_1.value;
3687
+ value = asAny(param, sourceCodeInfo);
3688
+ if (!value)
3689
+ break;
3690
+ }
3691
+ }
3692
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3693
+ finally {
3694
+ try {
3695
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
3696
+ }
3697
+ finally { if (e_2) throw e_2.error; }
3698
+ }
3699
+ return value;
3700
+ },
3674
3701
  getUndefinedSymbols: function (node, contextStack, _a) {
3675
3702
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
3676
3703
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -3955,7 +3982,7 @@ var defSpecialExpression = {
3955
3982
  var value = bindingNode[1][1];
3956
3983
  var bindingValue = evaluateNode(value, contextStack);
3957
3984
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
3958
- contextStack.exportValues(values);
3985
+ contextStack.exportValues(values, target[2]);
3959
3986
  return null;
3960
3987
  },
3961
3988
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -3967,7 +3994,7 @@ var defSpecialExpression = {
3967
3994
  walkDefaults(target, function (defaultNode) {
3968
3995
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
3969
3996
  });
3970
- contextStack.addValues(getAllBindingTargetNames(target));
3997
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
3971
3998
  return bindingResult;
3972
3999
  },
3973
4000
  };
@@ -4110,14 +4137,14 @@ var functionSpecialExpression = {
4110
4137
  _b.name = functionSymbol[1],
4111
4138
  _b.evaluatedfunction = evaluatedFunction,
4112
4139
  _b);
4113
- contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4140
+ contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4114
4141
  return null;
4115
4142
  },
4116
4143
  getUndefinedSymbols: function (node, contextStack, _a) {
4117
4144
  var _b, _c;
4118
4145
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4119
4146
  var functionName = node[1][1][1];
4120
- contextStack.addValues((_b = {}, _b[functionName] = true, _b));
4147
+ contextStack.addValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4121
4148
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4122
4149
  return getFunctionUnresolvedSymbols(node[1][2], contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4123
4150
  },
@@ -4138,7 +4165,7 @@ var defnSpecialExpression = {
4138
4165
  _b.name = functionSymbol[1],
4139
4166
  _b.evaluatedfunction = evaluatedFunctionOverloades,
4140
4167
  _b);
4141
- contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4168
+ contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4142
4169
  return null;
4143
4170
  },
4144
4171
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4146,7 +4173,7 @@ var defnSpecialExpression = {
4146
4173
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4147
4174
  var functionName = node[1][1][1];
4148
4175
  var fn = node[1][2];
4149
- contextStack.exportValues((_b = {}, _b[functionName] = true, _b));
4176
+ contextStack.exportValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4150
4177
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4151
4178
  return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4152
4179
  },
@@ -4258,7 +4285,7 @@ var letSpecialExpression = {
4258
4285
  var value = bindingNode[1][1];
4259
4286
  var bindingValue = evaluateNode(value, contextStack);
4260
4287
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
4261
- contextStack.addValues(values);
4288
+ contextStack.addValues(values, target[2]);
4262
4289
  return null;
4263
4290
  },
4264
4291
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4270,7 +4297,7 @@ var letSpecialExpression = {
4270
4297
  walkDefaults(target, function (defaultNode) {
4271
4298
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
4272
4299
  });
4273
- contextStack.addValues(getAllBindingTargetNames(target));
4300
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
4274
4301
  return bindingResult;
4275
4302
  },
4276
4303
  };
@@ -4541,6 +4568,26 @@ var orSpecialExpression = {
4541
4568
  }
4542
4569
  return value;
4543
4570
  },
4571
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4572
+ var e_2, _a;
4573
+ var value = false;
4574
+ try {
4575
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4576
+ var param = params_1_1.value;
4577
+ value = asAny(param, sourceCodeInfo);
4578
+ if (value)
4579
+ break;
4580
+ }
4581
+ }
4582
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4583
+ finally {
4584
+ try {
4585
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4586
+ }
4587
+ finally { if (e_2) throw e_2.error; }
4588
+ }
4589
+ return value;
4590
+ },
4544
4591
  getUndefinedSymbols: function (node, contextStack, _a) {
4545
4592
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4546
4593
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4559,6 +4606,11 @@ var qqSpecialExpression = {
4559
4606
  var firstResult = evaluateNode(firstNode, contextStack);
4560
4607
  return firstResult !== null && firstResult !== void 0 ? firstResult : (secondNode ? evaluateNode(secondNode, contextStack) : null);
4561
4608
  },
4609
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4610
+ var firstParam = asAny(params[0], sourceCodeInfo);
4611
+ var secondParam = params[1] !== undefined ? asAny(params[1], sourceCodeInfo) : null;
4612
+ return firstParam !== null && firstParam !== void 0 ? firstParam : secondParam;
4613
+ },
4562
4614
  getUndefinedSymbols: function (node, contextStack, _a) {
4563
4615
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4564
4616
  return getUndefinedSymbols(node[1][1].filter(function (n) { return !!n; }), contextStack, builtin, evaluateNode);
@@ -4573,6 +4625,9 @@ var recurSpecialExpression = {
4573
4625
  var evaluatedParams = params.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
4574
4626
  throw new RecurSignal(evaluatedParams);
4575
4627
  },
4628
+ evaluateAsNormalExpression: function (params) {
4629
+ throw new RecurSignal(params);
4630
+ },
4576
4631
  getUndefinedSymbols: function (node, contextStack, _a) {
4577
4632
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4578
4633
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4588,6 +4643,12 @@ var throwSpecialExpression = {
4588
4643
  });
4589
4644
  throw new UserDefinedError(message, node[2]);
4590
4645
  },
4646
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4647
+ var message = asString(params[0], sourceCodeInfo, {
4648
+ nonEmpty: true,
4649
+ });
4650
+ throw new UserDefinedError(message, undefined);
4651
+ },
4591
4652
  getUndefinedSymbols: function (node, contextStack, _a) {
4592
4653
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4593
4654
  return getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode);
@@ -4655,6 +4716,24 @@ var arraySpecialExpression = {
4655
4716
  }
4656
4717
  return result;
4657
4718
  },
4719
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4720
+ var e_2, _a;
4721
+ var result = [];
4722
+ try {
4723
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4724
+ var param = params_1_1.value;
4725
+ result.push(asAny(param, sourceCodeInfo));
4726
+ }
4727
+ }
4728
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4729
+ finally {
4730
+ try {
4731
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4732
+ }
4733
+ finally { if (e_2) throw e_2.error; }
4734
+ }
4735
+ return result;
4736
+ },
4658
4737
  getUndefinedSymbols: function (node, contextStack, _a) {
4659
4738
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4660
4739
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4686,6 +4765,16 @@ var objectSpecialExpression = {
4686
4765
  }
4687
4766
  return result;
4688
4767
  },
4768
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4769
+ var result = {};
4770
+ for (var i = 0; i < params.length; i += 2) {
4771
+ var key = params[i];
4772
+ var value = params[i + 1];
4773
+ assertString(key, sourceCodeInfo);
4774
+ result[key] = value !== null && value !== void 0 ? value : null;
4775
+ }
4776
+ return result;
4777
+ },
4689
4778
  getUndefinedSymbols: function (node, contextStack, _a) {
4690
4779
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4691
4780
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4811,7 +4900,7 @@ function findUnresolvedSymbolsInNode(node, contextStack, builtin, evaluateNode)
4811
4900
  return findUnresolvedSymbolsInNode(node[1], contextStack, builtin, evaluateNode);
4812
4901
  /* v8 ignore next 2 */
4813
4902
  default:
4814
- throw new Error("Unhandled node type: ".concat(nodeType));
4903
+ throw new LitsError("Unhandled node type: ".concat(nodeType), node[2]);
4815
4904
  }
4816
4905
  }
4817
4906
 
@@ -5019,6 +5108,16 @@ var functionExecutors = {
5019
5108
  var normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuitinSymbolType], sourceCodeInfo);
5020
5109
  return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
5021
5110
  },
5111
+ SpecialBuiltin: function (fn, params, sourceCodeInfo, contextStack, _a) {
5112
+ var executeFunction = _a.executeFunction;
5113
+ var specialExpression = asNonUndefined(specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo);
5114
+ if (specialExpression.evaluateAsNormalExpression) {
5115
+ return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
5116
+ }
5117
+ else {
5118
+ throw new LitsError("Special builtin function ".concat(fn.specialBuiltinSymbolType, " is not supported as normal expression."), sourceCodeInfo);
5119
+ }
5120
+ },
5022
5121
  };
5023
5122
 
5024
5123
  function evaluate(ast, contextStack) {
@@ -5074,7 +5173,21 @@ function evaluateReservedSymbol(node) {
5074
5173
  function evaluateNormalExpression(node, contextStack) {
5075
5174
  var sourceCodeInfo = node[2];
5076
5175
  var paramNodes = node[1][1];
5077
- var params = paramNodes.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
5176
+ var params = [];
5177
+ paramNodes.forEach(function (paramNode) {
5178
+ if (isSpreadNode(paramNode)) {
5179
+ var spreadValue = evaluateNode(paramNode[1], contextStack);
5180
+ if (Array.isArray(spreadValue)) {
5181
+ params.push.apply(params, __spreadArray([], __read(spreadValue), false));
5182
+ }
5183
+ else {
5184
+ throw new LitsError("Spread operator requires an array, got ".concat(valueToString(paramNode)), paramNode[2]);
5185
+ }
5186
+ }
5187
+ else {
5188
+ params.push(evaluateNode(paramNode, contextStack));
5189
+ }
5190
+ });
5078
5191
  if (isNormalExpressionNodeWithName(node)) {
5079
5192
  var nameSymbol = node[1][0];
5080
5193
  if (isNormalBuiltinSymbolNode(nameSymbol)) {
@@ -5176,19 +5289,19 @@ var ContextStackImpl = /** @class */ (function () {
5176
5289
  var contexts = [{}, context];
5177
5290
  return new ContextStackImpl({ contexts: contexts });
5178
5291
  };
5179
- ContextStackImpl.prototype.exportValues = function (values) {
5292
+ ContextStackImpl.prototype.exportValues = function (values, sourceCodeInfo) {
5180
5293
  var e_1, _a;
5181
5294
  try {
5182
5295
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5183
5296
  var _d = __read(_c.value, 2), name_1 = _d[0], value = _d[1];
5184
5297
  if (this.globalContext[name_1]) {
5185
- throw new Error("Cannot redefine exported value \"".concat(name_1, "\""));
5298
+ throw new LitsError("Cannot redefine exported value \"".concat(name_1, "\""), sourceCodeInfo);
5186
5299
  }
5187
5300
  if (specialExpressionKeys.includes(name_1)) {
5188
- throw new Error("Cannot shadow special expression \"".concat(name_1, "\""));
5301
+ throw new LitsError("Cannot shadow special expression \"".concat(name_1, "\""), sourceCodeInfo);
5189
5302
  }
5190
5303
  if (normalExpressionKeys.includes(name_1)) {
5191
- throw new Error("Cannot shadow builtin function \"".concat(name_1, "\""));
5304
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_1, "\""), sourceCodeInfo);
5192
5305
  }
5193
5306
  this.globalContext[name_1] = { value: value };
5194
5307
  }
@@ -5200,22 +5313,22 @@ var ContextStackImpl = /** @class */ (function () {
5200
5313
  }
5201
5314
  finally { if (e_1) throw e_1.error; }
5202
5315
  }
5203
- this.addValues(values);
5316
+ this.addValues(values, sourceCodeInfo);
5204
5317
  };
5205
- ContextStackImpl.prototype.addValues = function (values) {
5318
+ ContextStackImpl.prototype.addValues = function (values, sourceCodeInfo) {
5206
5319
  var e_2, _a;
5207
5320
  var currentContext = this.contexts[0];
5208
5321
  try {
5209
5322
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5210
5323
  var _d = __read(_c.value, 2), name_2 = _d[0], value = _d[1];
5211
5324
  if (currentContext[name_2]) {
5212
- throw new Error("Cannot redefine value \"".concat(name_2, "\""));
5325
+ throw new LitsError("Cannot redefine value \"".concat(name_2, "\""), sourceCodeInfo);
5213
5326
  }
5214
5327
  if (specialExpressionKeys.includes(name_2)) {
5215
- throw new Error("Cannot shadow special expression \"".concat(name_2, "\""));
5328
+ throw new LitsError("Cannot shadow special expression \"".concat(name_2, "\""), sourceCodeInfo);
5216
5329
  }
5217
5330
  if (normalExpressionKeys.includes(name_2)) {
5218
- throw new Error("Cannot shadow builtin function \"".concat(name_2, "\""));
5331
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_2, "\""), sourceCodeInfo);
5219
5332
  }
5220
5333
  currentContext[name_2] = { value: toAny(value) };
5221
5334
  }
@@ -5295,18 +5408,36 @@ var ContextStackImpl = /** @class */ (function () {
5295
5408
  return null;
5296
5409
  };
5297
5410
  ContextStackImpl.prototype.evaluateSymbol = function (node) {
5298
- var _a;
5411
+ var _a, _b;
5299
5412
  if (isSpecialBuiltinSymbolNode(node)) {
5300
- throw new Error('Special builtin symbols should not be evaluated');
5413
+ var functionType = node[1];
5414
+ switch (functionType) {
5415
+ case specialExpressionTypes['&&']:
5416
+ case specialExpressionTypes['||']:
5417
+ case specialExpressionTypes.array:
5418
+ case specialExpressionTypes.object:
5419
+ case specialExpressionTypes['defined?']:
5420
+ case specialExpressionTypes.recur:
5421
+ case specialExpressionTypes.throw:
5422
+ case specialExpressionTypes['??']:
5423
+ return _a = {},
5424
+ _a[FUNCTION_SYMBOL] = true,
5425
+ _a.functionType = 'SpecialBuiltin',
5426
+ _a.specialBuiltinSymbolType = functionType,
5427
+ _a.sourceCodeInfo = node[2],
5428
+ _a;
5429
+ default:
5430
+ throw new LitsError("Unknown special builtin symbol type: ".concat(functionType), node[2]);
5431
+ }
5301
5432
  }
5302
5433
  if (isNormalBuiltinSymbolNode(node)) {
5303
5434
  var type = node[1];
5304
- return _a = {},
5305
- _a[FUNCTION_SYMBOL] = true,
5306
- _a.functionType = 'Builtin',
5307
- _a.normalBuitinSymbolType = type,
5308
- _a.sourceCodeInfo = node[2],
5309
- _a;
5435
+ return _b = {},
5436
+ _b[FUNCTION_SYMBOL] = true,
5437
+ _b.functionType = 'Builtin',
5438
+ _b.normalBuitinSymbolType = type,
5439
+ _b.sourceCodeInfo = node[2],
5440
+ _b;
5310
5441
  }
5311
5442
  var lookUpResult = this.lookUp(node);
5312
5443
  if (isContextEntry(lookUpResult))
@@ -5978,7 +6109,7 @@ function withSourceCodeInfo(node, sourceCodeInfo) {
5978
6109
  }
5979
6110
  return node;
5980
6111
  }
5981
- function getPrecedence(operatorSign) {
6112
+ function getPrecedence(operatorSign, sourceCodeInfo) {
5982
6113
  switch (operatorSign) {
5983
6114
  case '**': // exponentiation
5984
6115
  return exponentiationPrecedence;
@@ -6017,7 +6148,7 @@ function getPrecedence(operatorSign) {
6017
6148
  // leave room for binaryFunctionalOperatorPrecedence = 1
6018
6149
  /* v8 ignore next 2 */
6019
6150
  default:
6020
- throw new Error("Unknown binary operator: ".concat(operatorSign));
6151
+ throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
6021
6152
  }
6022
6153
  }
6023
6154
  function createNamedNormalExpressionNode(symbolNode, params, sourceCodeInfo) {
@@ -6150,7 +6281,7 @@ var Parser = /** @class */ (function () {
6150
6281
  while (!this.isAtExpressionEnd()) {
6151
6282
  if (isA_BinaryOperatorToken(operator)) {
6152
6283
  var name_1 = operator[1];
6153
- var newPrecedece = getPrecedence(name_1);
6284
+ var newPrecedece = getPrecedence(name_1, operator[2]);
6154
6285
  if (newPrecedece <= precedence
6155
6286
  // ** (exponentiation) is right associative
6156
6287
  && !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {
@@ -6230,7 +6361,7 @@ var Parser = /** @class */ (function () {
6230
6361
  this.advance();
6231
6362
  var expression = this.parseExpression();
6232
6363
  if (!isRParenToken(this.peek())) {
6233
- throw new Error('Expected closing parenthesis');
6364
+ throw new LitsError('Expected closing parenthesis', this.peek()[2]);
6234
6365
  }
6235
6366
  this.advance();
6236
6367
  return expression;
@@ -6352,7 +6483,13 @@ var Parser = /** @class */ (function () {
6352
6483
  this.advance();
6353
6484
  var params = [];
6354
6485
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
6355
- params.push(this.parseExpression());
6486
+ if (isOperatorToken(this.peek(), '...')) {
6487
+ this.advance();
6488
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
6489
+ }
6490
+ else {
6491
+ params.push(this.parseExpression());
6492
+ }
6356
6493
  var nextToken = this.peek();
6357
6494
  if (!isOperatorToken(nextToken, ',') && !isRParenToken(nextToken)) {
6358
6495
  throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
@@ -6408,7 +6545,7 @@ var Parser = /** @class */ (function () {
6408
6545
  throw new LitsError("".concat(type, " is not allowed"), symbol[2]);
6409
6546
  /* v8 ignore next 2 */
6410
6547
  default:
6411
- throw new Error("Unknown special expression: ".concat(type));
6548
+ throw new LitsError("Unknown special expression: ".concat(type), symbol[2]);
6412
6549
  }
6413
6550
  }
6414
6551
  else if (isNormalBuiltinSymbolNode(symbol) || isNormalBuiltinSymbolNode(symbol)) {