@mojir/lits 2.1.2 → 2.1.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.
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);
@@ -1257,26 +1264,37 @@ var sequenceNormalExpression = {
1257
1264
  paramCount: 1,
1258
1265
  },
1259
1266
  'map': {
1260
- evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1261
- var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1262
- var executeFunction = _b.executeFunction;
1263
- assertSeq(seq, sourceCodeInfo);
1264
- assertLitsFunction(fn, sourceCodeInfo);
1265
- if (Array.isArray(seq)) {
1266
- return seq.map(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
1267
+ evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1268
+ var executeFunction = _a.executeFunction;
1269
+ var fn = asLitsFunction(params.at(-1));
1270
+ var seqs = params.slice(0, -1);
1271
+ assertSeq(seqs[0], sourceCodeInfo);
1272
+ var isString = typeof seqs[0] === 'string';
1273
+ var len = seqs[0].length;
1274
+ seqs.slice(1).forEach(function (seq) {
1275
+ if (isString) {
1276
+ assertString(seq, sourceCodeInfo);
1277
+ }
1278
+ else {
1279
+ assertArray(seq, sourceCodeInfo);
1280
+ }
1281
+ len = Math.min(len, seq.length);
1282
+ });
1283
+ var paramArray = [];
1284
+ var _loop_1 = function (i) {
1285
+ paramArray.push(seqs.map(function (seq) { return seq[i]; }));
1286
+ };
1287
+ for (var i = 0; i < len; i++) {
1288
+ _loop_1(i);
1267
1289
  }
1268
- else {
1269
- return seq
1270
- .split('')
1271
- .map(function (elem) {
1272
- var newVal = executeFunction(fn, [elem], contextStack, sourceCodeInfo);
1273
- assertString(newVal, sourceCodeInfo, { char: true });
1274
- return newVal;
1275
- })
1276
- .join('');
1290
+ var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
1291
+ if (!isString) {
1292
+ return mapped;
1277
1293
  }
1294
+ mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
1295
+ return mapped.join('');
1278
1296
  },
1279
- paramCount: 2,
1297
+ paramCount: { min: 2 },
1280
1298
  },
1281
1299
  'pop': {
1282
1300
  evaluate: function (_a, sourceCodeInfo) {
@@ -1826,7 +1844,7 @@ var sequenceNormalExpression = {
1826
1844
  assertSeq(input, sourceCodeInfo);
1827
1845
  if (Array.isArray(input)) {
1828
1846
  var result = [];
1829
- var _loop_1 = function (item) {
1847
+ var _loop_2 = function (item) {
1830
1848
  assertAny(item, sourceCodeInfo);
1831
1849
  if (!result.some(function (existingItem) { return deepEqual(existingItem, item, sourceCodeInfo); })) {
1832
1850
  result.push(item);
@@ -1835,7 +1853,7 @@ var sequenceNormalExpression = {
1835
1853
  try {
1836
1854
  for (var input_1 = __values(input), input_1_1 = input_1.next(); !input_1_1.done; input_1_1 = input_1.next()) {
1837
1855
  var item = input_1_1.value;
1838
- _loop_1(item);
1856
+ _loop_2(item);
1839
1857
  }
1840
1858
  }
1841
1859
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -3671,6 +3689,26 @@ var andSpecialExpression = {
3671
3689
  }
3672
3690
  return value;
3673
3691
  },
3692
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
3693
+ var e_2, _a;
3694
+ var value = true;
3695
+ try {
3696
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
3697
+ var param = params_1_1.value;
3698
+ value = asAny(param, sourceCodeInfo);
3699
+ if (!value)
3700
+ break;
3701
+ }
3702
+ }
3703
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3704
+ finally {
3705
+ try {
3706
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
3707
+ }
3708
+ finally { if (e_2) throw e_2.error; }
3709
+ }
3710
+ return value;
3711
+ },
3674
3712
  getUndefinedSymbols: function (node, contextStack, _a) {
3675
3713
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
3676
3714
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -3955,7 +3993,7 @@ var defSpecialExpression = {
3955
3993
  var value = bindingNode[1][1];
3956
3994
  var bindingValue = evaluateNode(value, contextStack);
3957
3995
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
3958
- contextStack.exportValues(values);
3996
+ contextStack.exportValues(values, target[2]);
3959
3997
  return null;
3960
3998
  },
3961
3999
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -3967,7 +4005,7 @@ var defSpecialExpression = {
3967
4005
  walkDefaults(target, function (defaultNode) {
3968
4006
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
3969
4007
  });
3970
- contextStack.addValues(getAllBindingTargetNames(target));
4008
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
3971
4009
  return bindingResult;
3972
4010
  },
3973
4011
  };
@@ -4110,14 +4148,14 @@ var functionSpecialExpression = {
4110
4148
  _b.name = functionSymbol[1],
4111
4149
  _b.evaluatedfunction = evaluatedFunction,
4112
4150
  _b);
4113
- contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4151
+ contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4114
4152
  return null;
4115
4153
  },
4116
4154
  getUndefinedSymbols: function (node, contextStack, _a) {
4117
4155
  var _b, _c;
4118
4156
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4119
4157
  var functionName = node[1][1][1];
4120
- contextStack.addValues((_b = {}, _b[functionName] = true, _b));
4158
+ contextStack.addValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4121
4159
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4122
4160
  return getFunctionUnresolvedSymbols(node[1][2], contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4123
4161
  },
@@ -4138,7 +4176,7 @@ var defnSpecialExpression = {
4138
4176
  _b.name = functionSymbol[1],
4139
4177
  _b.evaluatedfunction = evaluatedFunctionOverloades,
4140
4178
  _b);
4141
- contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c));
4179
+ contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
4142
4180
  return null;
4143
4181
  },
4144
4182
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4146,7 +4184,7 @@ var defnSpecialExpression = {
4146
4184
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4147
4185
  var functionName = node[1][1][1];
4148
4186
  var fn = node[1][2];
4149
- contextStack.exportValues((_b = {}, _b[functionName] = true, _b));
4187
+ contextStack.exportValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
4150
4188
  var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
4151
4189
  return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
4152
4190
  },
@@ -4258,7 +4296,7 @@ var letSpecialExpression = {
4258
4296
  var value = bindingNode[1][1];
4259
4297
  var bindingValue = evaluateNode(value, contextStack);
4260
4298
  var values = evalueateBindingNodeValues(target, bindingValue, function (Node) { return evaluateNode(Node, contextStack); });
4261
- contextStack.addValues(values);
4299
+ contextStack.addValues(values, target[2]);
4262
4300
  return null;
4263
4301
  },
4264
4302
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -4270,7 +4308,7 @@ var letSpecialExpression = {
4270
4308
  walkDefaults(target, function (defaultNode) {
4271
4309
  addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
4272
4310
  });
4273
- contextStack.addValues(getAllBindingTargetNames(target));
4311
+ contextStack.addValues(getAllBindingTargetNames(target), target[2]);
4274
4312
  return bindingResult;
4275
4313
  },
4276
4314
  };
@@ -4541,6 +4579,26 @@ var orSpecialExpression = {
4541
4579
  }
4542
4580
  return value;
4543
4581
  },
4582
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4583
+ var e_2, _a;
4584
+ var value = false;
4585
+ try {
4586
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4587
+ var param = params_1_1.value;
4588
+ value = asAny(param, sourceCodeInfo);
4589
+ if (value)
4590
+ break;
4591
+ }
4592
+ }
4593
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4594
+ finally {
4595
+ try {
4596
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4597
+ }
4598
+ finally { if (e_2) throw e_2.error; }
4599
+ }
4600
+ return value;
4601
+ },
4544
4602
  getUndefinedSymbols: function (node, contextStack, _a) {
4545
4603
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4546
4604
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4559,6 +4617,11 @@ var qqSpecialExpression = {
4559
4617
  var firstResult = evaluateNode(firstNode, contextStack);
4560
4618
  return firstResult !== null && firstResult !== void 0 ? firstResult : (secondNode ? evaluateNode(secondNode, contextStack) : null);
4561
4619
  },
4620
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4621
+ var firstParam = asAny(params[0], sourceCodeInfo);
4622
+ var secondParam = params[1] !== undefined ? asAny(params[1], sourceCodeInfo) : null;
4623
+ return firstParam !== null && firstParam !== void 0 ? firstParam : secondParam;
4624
+ },
4562
4625
  getUndefinedSymbols: function (node, contextStack, _a) {
4563
4626
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4564
4627
  return getUndefinedSymbols(node[1][1].filter(function (n) { return !!n; }), contextStack, builtin, evaluateNode);
@@ -4573,6 +4636,9 @@ var recurSpecialExpression = {
4573
4636
  var evaluatedParams = params.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
4574
4637
  throw new RecurSignal(evaluatedParams);
4575
4638
  },
4639
+ evaluateAsNormalExpression: function (params) {
4640
+ throw new RecurSignal(params);
4641
+ },
4576
4642
  getUndefinedSymbols: function (node, contextStack, _a) {
4577
4643
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4578
4644
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4588,6 +4654,12 @@ var throwSpecialExpression = {
4588
4654
  });
4589
4655
  throw new UserDefinedError(message, node[2]);
4590
4656
  },
4657
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4658
+ var message = asString(params[0], sourceCodeInfo, {
4659
+ nonEmpty: true,
4660
+ });
4661
+ throw new UserDefinedError(message, undefined);
4662
+ },
4591
4663
  getUndefinedSymbols: function (node, contextStack, _a) {
4592
4664
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4593
4665
  return getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode);
@@ -4655,6 +4727,24 @@ var arraySpecialExpression = {
4655
4727
  }
4656
4728
  return result;
4657
4729
  },
4730
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4731
+ var e_2, _a;
4732
+ var result = [];
4733
+ try {
4734
+ for (var params_1 = __values(params), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
4735
+ var param = params_1_1.value;
4736
+ result.push(asAny(param, sourceCodeInfo));
4737
+ }
4738
+ }
4739
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
4740
+ finally {
4741
+ try {
4742
+ if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
4743
+ }
4744
+ finally { if (e_2) throw e_2.error; }
4745
+ }
4746
+ return result;
4747
+ },
4658
4748
  getUndefinedSymbols: function (node, contextStack, _a) {
4659
4749
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4660
4750
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4686,6 +4776,16 @@ var objectSpecialExpression = {
4686
4776
  }
4687
4777
  return result;
4688
4778
  },
4779
+ evaluateAsNormalExpression: function (params, sourceCodeInfo) {
4780
+ var result = {};
4781
+ for (var i = 0; i < params.length; i += 2) {
4782
+ var key = params[i];
4783
+ var value = params[i + 1];
4784
+ assertString(key, sourceCodeInfo);
4785
+ result[key] = value !== null && value !== void 0 ? value : null;
4786
+ }
4787
+ return result;
4788
+ },
4689
4789
  getUndefinedSymbols: function (node, contextStack, _a) {
4690
4790
  var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
4691
4791
  return getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode);
@@ -4811,7 +4911,7 @@ function findUnresolvedSymbolsInNode(node, contextStack, builtin, evaluateNode)
4811
4911
  return findUnresolvedSymbolsInNode(node[1], contextStack, builtin, evaluateNode);
4812
4912
  /* v8 ignore next 2 */
4813
4913
  default:
4814
- throw new Error("Unhandled node type: ".concat(nodeType));
4914
+ throw new LitsError("Unhandled node type: ".concat(nodeType), node[2]);
4815
4915
  }
4816
4916
  }
4817
4917
 
@@ -5019,6 +5119,16 @@ var functionExecutors = {
5019
5119
  var normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuitinSymbolType], sourceCodeInfo);
5020
5120
  return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
5021
5121
  },
5122
+ SpecialBuiltin: function (fn, params, sourceCodeInfo, contextStack, _a) {
5123
+ var executeFunction = _a.executeFunction;
5124
+ var specialExpression = asNonUndefined(specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo);
5125
+ if (specialExpression.evaluateAsNormalExpression) {
5126
+ return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction: executeFunction });
5127
+ }
5128
+ else {
5129
+ throw new LitsError("Special builtin function ".concat(fn.specialBuiltinSymbolType, " is not supported as normal expression."), sourceCodeInfo);
5130
+ }
5131
+ },
5022
5132
  };
5023
5133
 
5024
5134
  function evaluate(ast, contextStack) {
@@ -5074,7 +5184,21 @@ function evaluateReservedSymbol(node) {
5074
5184
  function evaluateNormalExpression(node, contextStack) {
5075
5185
  var sourceCodeInfo = node[2];
5076
5186
  var paramNodes = node[1][1];
5077
- var params = paramNodes.map(function (paramNode) { return evaluateNode(paramNode, contextStack); });
5187
+ var params = [];
5188
+ paramNodes.forEach(function (paramNode) {
5189
+ if (isSpreadNode(paramNode)) {
5190
+ var spreadValue = evaluateNode(paramNode[1], contextStack);
5191
+ if (Array.isArray(spreadValue)) {
5192
+ params.push.apply(params, __spreadArray([], __read(spreadValue), false));
5193
+ }
5194
+ else {
5195
+ throw new LitsError("Spread operator requires an array, got ".concat(valueToString(paramNode)), paramNode[2]);
5196
+ }
5197
+ }
5198
+ else {
5199
+ params.push(evaluateNode(paramNode, contextStack));
5200
+ }
5201
+ });
5078
5202
  if (isNormalExpressionNodeWithName(node)) {
5079
5203
  var nameSymbol = node[1][0];
5080
5204
  if (isNormalBuiltinSymbolNode(nameSymbol)) {
@@ -5176,19 +5300,19 @@ var ContextStackImpl = /** @class */ (function () {
5176
5300
  var contexts = [{}, context];
5177
5301
  return new ContextStackImpl({ contexts: contexts });
5178
5302
  };
5179
- ContextStackImpl.prototype.exportValues = function (values) {
5303
+ ContextStackImpl.prototype.exportValues = function (values, sourceCodeInfo) {
5180
5304
  var e_1, _a;
5181
5305
  try {
5182
5306
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5183
5307
  var _d = __read(_c.value, 2), name_1 = _d[0], value = _d[1];
5184
5308
  if (this.globalContext[name_1]) {
5185
- throw new Error("Cannot redefine exported value \"".concat(name_1, "\""));
5309
+ throw new LitsError("Cannot redefine exported value \"".concat(name_1, "\""), sourceCodeInfo);
5186
5310
  }
5187
5311
  if (specialExpressionKeys.includes(name_1)) {
5188
- throw new Error("Cannot shadow special expression \"".concat(name_1, "\""));
5312
+ throw new LitsError("Cannot shadow special expression \"".concat(name_1, "\""), sourceCodeInfo);
5189
5313
  }
5190
5314
  if (normalExpressionKeys.includes(name_1)) {
5191
- throw new Error("Cannot shadow builtin function \"".concat(name_1, "\""));
5315
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_1, "\""), sourceCodeInfo);
5192
5316
  }
5193
5317
  this.globalContext[name_1] = { value: value };
5194
5318
  }
@@ -5200,22 +5324,22 @@ var ContextStackImpl = /** @class */ (function () {
5200
5324
  }
5201
5325
  finally { if (e_1) throw e_1.error; }
5202
5326
  }
5203
- this.addValues(values);
5327
+ this.addValues(values, sourceCodeInfo);
5204
5328
  };
5205
- ContextStackImpl.prototype.addValues = function (values) {
5329
+ ContextStackImpl.prototype.addValues = function (values, sourceCodeInfo) {
5206
5330
  var e_2, _a;
5207
5331
  var currentContext = this.contexts[0];
5208
5332
  try {
5209
5333
  for (var _b = __values(Object.entries(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
5210
5334
  var _d = __read(_c.value, 2), name_2 = _d[0], value = _d[1];
5211
5335
  if (currentContext[name_2]) {
5212
- throw new Error("Cannot redefine value \"".concat(name_2, "\""));
5336
+ throw new LitsError("Cannot redefine value \"".concat(name_2, "\""), sourceCodeInfo);
5213
5337
  }
5214
5338
  if (specialExpressionKeys.includes(name_2)) {
5215
- throw new Error("Cannot shadow special expression \"".concat(name_2, "\""));
5339
+ throw new LitsError("Cannot shadow special expression \"".concat(name_2, "\""), sourceCodeInfo);
5216
5340
  }
5217
5341
  if (normalExpressionKeys.includes(name_2)) {
5218
- throw new Error("Cannot shadow builtin function \"".concat(name_2, "\""));
5342
+ throw new LitsError("Cannot shadow builtin function \"".concat(name_2, "\""), sourceCodeInfo);
5219
5343
  }
5220
5344
  currentContext[name_2] = { value: toAny(value) };
5221
5345
  }
@@ -5295,18 +5419,36 @@ var ContextStackImpl = /** @class */ (function () {
5295
5419
  return null;
5296
5420
  };
5297
5421
  ContextStackImpl.prototype.evaluateSymbol = function (node) {
5298
- var _a;
5422
+ var _a, _b;
5299
5423
  if (isSpecialBuiltinSymbolNode(node)) {
5300
- throw new Error('Special builtin symbols should not be evaluated');
5424
+ var functionType = node[1];
5425
+ switch (functionType) {
5426
+ case specialExpressionTypes['&&']:
5427
+ case specialExpressionTypes['||']:
5428
+ case specialExpressionTypes.array:
5429
+ case specialExpressionTypes.object:
5430
+ case specialExpressionTypes['defined?']:
5431
+ case specialExpressionTypes.recur:
5432
+ case specialExpressionTypes.throw:
5433
+ case specialExpressionTypes['??']:
5434
+ return _a = {},
5435
+ _a[FUNCTION_SYMBOL] = true,
5436
+ _a.functionType = 'SpecialBuiltin',
5437
+ _a.specialBuiltinSymbolType = functionType,
5438
+ _a.sourceCodeInfo = node[2],
5439
+ _a;
5440
+ default:
5441
+ throw new LitsError("Unknown special builtin symbol type: ".concat(functionType), node[2]);
5442
+ }
5301
5443
  }
5302
5444
  if (isNormalBuiltinSymbolNode(node)) {
5303
5445
  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;
5446
+ return _b = {},
5447
+ _b[FUNCTION_SYMBOL] = true,
5448
+ _b.functionType = 'Builtin',
5449
+ _b.normalBuitinSymbolType = type,
5450
+ _b.sourceCodeInfo = node[2],
5451
+ _b;
5310
5452
  }
5311
5453
  var lookUpResult = this.lookUp(node);
5312
5454
  if (isContextEntry(lookUpResult))
@@ -5978,7 +6120,7 @@ function withSourceCodeInfo(node, sourceCodeInfo) {
5978
6120
  }
5979
6121
  return node;
5980
6122
  }
5981
- function getPrecedence(operatorSign) {
6123
+ function getPrecedence(operatorSign, sourceCodeInfo) {
5982
6124
  switch (operatorSign) {
5983
6125
  case '**': // exponentiation
5984
6126
  return exponentiationPrecedence;
@@ -6017,7 +6159,7 @@ function getPrecedence(operatorSign) {
6017
6159
  // leave room for binaryFunctionalOperatorPrecedence = 1
6018
6160
  /* v8 ignore next 2 */
6019
6161
  default:
6020
- throw new Error("Unknown binary operator: ".concat(operatorSign));
6162
+ throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
6021
6163
  }
6022
6164
  }
6023
6165
  function createNamedNormalExpressionNode(symbolNode, params, sourceCodeInfo) {
@@ -6150,7 +6292,7 @@ var Parser = /** @class */ (function () {
6150
6292
  while (!this.isAtExpressionEnd()) {
6151
6293
  if (isA_BinaryOperatorToken(operator)) {
6152
6294
  var name_1 = operator[1];
6153
- var newPrecedece = getPrecedence(name_1);
6295
+ var newPrecedece = getPrecedence(name_1, operator[2]);
6154
6296
  if (newPrecedece <= precedence
6155
6297
  // ** (exponentiation) is right associative
6156
6298
  && !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {
@@ -6230,7 +6372,7 @@ var Parser = /** @class */ (function () {
6230
6372
  this.advance();
6231
6373
  var expression = this.parseExpression();
6232
6374
  if (!isRParenToken(this.peek())) {
6233
- throw new Error('Expected closing parenthesis');
6375
+ throw new LitsError('Expected closing parenthesis', this.peek()[2]);
6234
6376
  }
6235
6377
  this.advance();
6236
6378
  return expression;
@@ -6352,7 +6494,13 @@ var Parser = /** @class */ (function () {
6352
6494
  this.advance();
6353
6495
  var params = [];
6354
6496
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
6355
- params.push(this.parseExpression());
6497
+ if (isOperatorToken(this.peek(), '...')) {
6498
+ this.advance();
6499
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
6500
+ }
6501
+ else {
6502
+ params.push(this.parseExpression());
6503
+ }
6356
6504
  var nextToken = this.peek();
6357
6505
  if (!isOperatorToken(nextToken, ',') && !isRParenToken(nextToken)) {
6358
6506
  throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
@@ -6408,7 +6556,7 @@ var Parser = /** @class */ (function () {
6408
6556
  throw new LitsError("".concat(type, " is not allowed"), symbol[2]);
6409
6557
  /* v8 ignore next 2 */
6410
6558
  default:
6411
- throw new Error("Unknown special expression: ".concat(type));
6559
+ throw new LitsError("Unknown special expression: ".concat(type), symbol[2]);
6412
6560
  }
6413
6561
  }
6414
6562
  else if (isNormalBuiltinSymbolNode(symbol) || isNormalBuiltinSymbolNode(symbol)) {
@@ -11166,19 +11314,23 @@ var sequenceReference = {
11166
11314
  type: 'any',
11167
11315
  rest: true,
11168
11316
  },
11169
- args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seq: {
11317
+ args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seqs: {
11170
11318
  type: 'sequence',
11319
+ rest: true,
11320
+ description: 'At least one.',
11171
11321
  }, fun: {
11172
11322
  type: 'function',
11173
11323
  } }),
11174
11324
  variants: [
11175
- { argumentNames: ['seq', 'fun'] },
11325
+ { argumentNames: ['seqs', 'fun'] },
11176
11326
  ],
11177
- description: 'Creates a new array populated with the results of calling $fun on every elements in $seq.',
11327
+ description: 'Creates a new array populated with the results of calling $fun on every element in $seqs.',
11178
11328
  examples: [
11329
+ '[1, 2, 3] map -',
11179
11330
  '[1, 2, 3] map -> -($)',
11180
11331
  'map(["Albert", "Mojir", 42], str)',
11181
11332
  'map([1, 2, 3], inc)',
11333
+ 'map([1, 2, 3], [1, 10, 100], *)',
11182
11334
  ],
11183
11335
  },
11184
11336
  'filter': {