@mojir/lits 2.1.5 → 2.1.7

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.
@@ -920,6 +920,32 @@ function assertCharArray(value, sourceCodeInfo) {
920
920
  throw getAssertionError('array of strings', value, sourceCodeInfo);
921
921
  }
922
922
 
923
+ function mapObjects(_a) {
924
+ var colls = _a.colls, contextStack = _a.contextStack, executeFunction = _a.executeFunction, fn = _a.fn, sourceCodeInfo = _a.sourceCodeInfo;
925
+ assertObj(colls[0], sourceCodeInfo);
926
+ var keys = Object.keys(colls[0]);
927
+ var params = {};
928
+ colls.forEach(function (obj) {
929
+ assertObj(obj, sourceCodeInfo);
930
+ var objKeys = Object.keys(obj);
931
+ if (objKeys.length !== keys.length) {
932
+ throw new LitsError("All objects must have the same keys. Expected: ".concat(keys.join(', '), ". Found: ").concat(objKeys.join(', ')), sourceCodeInfo);
933
+ }
934
+ if (!objKeys.every(function (key) { return keys.includes(key); })) {
935
+ throw new LitsError("All objects must have the same keys. Expected: ".concat(keys.join(', '), ". Found: ").concat(objKeys.join(', ')), sourceCodeInfo);
936
+ }
937
+ Object.entries(obj).forEach(function (_a) {
938
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
939
+ if (!params[key])
940
+ params[key] = [];
941
+ params[key].push(value);
942
+ });
943
+ });
944
+ return keys.reduce(function (result, key) {
945
+ result[key] = executeFunction(fn, params[key], contextStack, sourceCodeInfo);
946
+ return result;
947
+ }, {});
948
+ }
923
949
  function cloneAndGetMeta(originalColl, keys, sourceCodeInfo) {
924
950
  var coll = cloneColl(originalColl);
925
951
  var butLastKeys = keys.slice(0, keys.length - 1);
@@ -1012,6 +1038,188 @@ function assoc(coll, key, value, sourceCodeInfo) {
1012
1038
  return copy;
1013
1039
  }
1014
1040
  var collectionNormalExpression = {
1041
+ 'filter': {
1042
+ evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1043
+ var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
1044
+ var executeFunction = _b.executeFunction;
1045
+ assertColl(coll, sourceCodeInfo);
1046
+ assertFunctionLike(fn, sourceCodeInfo);
1047
+ if (Array.isArray(coll)) {
1048
+ var result = coll.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
1049
+ return result;
1050
+ }
1051
+ if (isString(coll)) {
1052
+ return coll
1053
+ .split('')
1054
+ .filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); })
1055
+ .join('');
1056
+ }
1057
+ return Object.entries(coll)
1058
+ .filter(function (_a) {
1059
+ var _b = __read(_a, 2), value = _b[1];
1060
+ return executeFunction(fn, [value], contextStack, sourceCodeInfo);
1061
+ })
1062
+ .reduce(function (result, _a) {
1063
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
1064
+ result[key] = value;
1065
+ return result;
1066
+ }, {});
1067
+ },
1068
+ paramCount: 2,
1069
+ },
1070
+ 'map': {
1071
+ evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1072
+ var executeFunction = _a.executeFunction;
1073
+ var fn = asFunctionLike(params.at(-1), sourceCodeInfo);
1074
+ if (isObj(params[0])) {
1075
+ return mapObjects({
1076
+ colls: params.slice(0, -1),
1077
+ fn: fn,
1078
+ sourceCodeInfo: sourceCodeInfo,
1079
+ contextStack: contextStack,
1080
+ executeFunction: executeFunction,
1081
+ });
1082
+ }
1083
+ var seqs = params.slice(0, -1);
1084
+ assertSeq(seqs[0], sourceCodeInfo);
1085
+ var isStr = typeof seqs[0] === 'string';
1086
+ var len = seqs[0].length;
1087
+ seqs.slice(1).forEach(function (seq) {
1088
+ if (isStr) {
1089
+ assertString(seq, sourceCodeInfo);
1090
+ }
1091
+ else {
1092
+ assertArray(seq, sourceCodeInfo);
1093
+ }
1094
+ len = Math.min(len, seq.length);
1095
+ });
1096
+ var paramArray = [];
1097
+ var _loop_1 = function (i) {
1098
+ paramArray.push(seqs.map(function (seq) { return seq[i]; }));
1099
+ };
1100
+ for (var i = 0; i < len; i++) {
1101
+ _loop_1(i);
1102
+ }
1103
+ var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
1104
+ if (!isStr) {
1105
+ return mapped;
1106
+ }
1107
+ mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
1108
+ return mapped.join('');
1109
+ },
1110
+ paramCount: { min: 2 },
1111
+ },
1112
+ 'reduce': {
1113
+ evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1114
+ var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
1115
+ var executeFunction = _b.executeFunction;
1116
+ assertColl(coll, sourceCodeInfo);
1117
+ assertFunctionLike(fn, sourceCodeInfo);
1118
+ assertAny(initial, sourceCodeInfo);
1119
+ if (typeof coll === 'string') {
1120
+ assertString(initial, sourceCodeInfo);
1121
+ if (coll.length === 0)
1122
+ return initial;
1123
+ return coll.split('').reduce(function (result, elem) {
1124
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1125
+ }, initial);
1126
+ }
1127
+ else if (Array.isArray(coll)) {
1128
+ if (coll.length === 0)
1129
+ return initial;
1130
+ return coll.reduce(function (result, elem) {
1131
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1132
+ }, initial);
1133
+ }
1134
+ else {
1135
+ if (Object.keys(coll).length === 0)
1136
+ return initial;
1137
+ return Object.entries(coll).reduce(function (result, _a) {
1138
+ var _b = __read(_a, 2), elem = _b[1];
1139
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1140
+ }, initial);
1141
+ }
1142
+ },
1143
+ paramCount: 3,
1144
+ },
1145
+ 'reduce-right': {
1146
+ evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1147
+ var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
1148
+ var executeFunction = _b.executeFunction;
1149
+ assertColl(coll, sourceCodeInfo);
1150
+ assertFunctionLike(fn, sourceCodeInfo);
1151
+ assertAny(initial, sourceCodeInfo);
1152
+ if (typeof coll === 'string') {
1153
+ if (coll.length === 0)
1154
+ return initial;
1155
+ return coll.split('').reduceRight(function (result, elem) {
1156
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1157
+ }, initial);
1158
+ }
1159
+ else if (Array.isArray(coll)) {
1160
+ if (coll.length === 0)
1161
+ return initial;
1162
+ return coll.reduceRight(function (result, elem) {
1163
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1164
+ }, initial);
1165
+ }
1166
+ else {
1167
+ if (Object.keys(coll).length === 0)
1168
+ return initial;
1169
+ return Object.entries(coll).reduceRight(function (result, _a) {
1170
+ var _b = __read(_a, 2), elem = _b[1];
1171
+ return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1172
+ }, initial);
1173
+ }
1174
+ },
1175
+ paramCount: 3,
1176
+ },
1177
+ 'reductions': {
1178
+ evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1179
+ var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
1180
+ var executeFunction = _b.executeFunction;
1181
+ assertColl(coll, sourceCodeInfo);
1182
+ assertFunctionLike(fn, sourceCodeInfo);
1183
+ assertAny(initial, sourceCodeInfo);
1184
+ assertAny(initial, sourceCodeInfo);
1185
+ if (typeof coll === 'string') {
1186
+ assertString(initial, sourceCodeInfo);
1187
+ if (coll.length === 0)
1188
+ return [initial];
1189
+ var resultArray_1 = [initial];
1190
+ coll.split('').reduce(function (result, elem) {
1191
+ var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1192
+ resultArray_1.push(newVal);
1193
+ return newVal;
1194
+ }, initial);
1195
+ return resultArray_1;
1196
+ }
1197
+ else if (Array.isArray(coll)) {
1198
+ if (coll.length === 0)
1199
+ return [initial];
1200
+ var resultArray_2 = [initial];
1201
+ coll.reduce(function (result, elem) {
1202
+ var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1203
+ resultArray_2.push(newVal);
1204
+ return newVal;
1205
+ }, initial);
1206
+ return resultArray_2;
1207
+ }
1208
+ else {
1209
+ if (Object.keys(coll).length === 0)
1210
+ return [initial];
1211
+ var resultArray_3 = [initial];
1212
+ Object.entries(coll).reduce(function (result, _a) {
1213
+ var _b = __read(_a, 2), elem = _b[1];
1214
+ var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1215
+ resultArray_3.push(newVal);
1216
+ return newVal;
1217
+ }, initial);
1218
+ return resultArray_3;
1219
+ }
1220
+ },
1221
+ paramCount: 3,
1222
+ },
1015
1223
  'get': {
1016
1224
  evaluate: function (params, sourceCodeInfo) {
1017
1225
  var _a = __read(params, 2), coll = _a[0], key = _a[1];
@@ -1315,13 +1523,15 @@ var arrayNormalExpression = {
1315
1523
  paramCount: 2,
1316
1524
  },
1317
1525
  flatten: {
1318
- evaluate: function (_a) {
1319
- var _b = __read(_a, 1), seq = _b[0];
1320
- if (!Array.isArray(seq))
1321
- return [];
1322
- return seq.flat(Number.POSITIVE_INFINITY);
1526
+ evaluate: function (_a, sourceCodeInfo) {
1527
+ var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
1528
+ assertArray(seq, sourceCodeInfo);
1529
+ var actualDepth = depth === undefined || depth === Number.POSITIVE_INFINITY
1530
+ ? Number.POSITIVE_INFINITY
1531
+ : asNumber(depth, sourceCodeInfo, { integer: true, nonNegative: true });
1532
+ return seq.flat(actualDepth);
1323
1533
  },
1324
- paramCount: 1,
1534
+ paramCount: { min: 1, max: 2 },
1325
1535
  },
1326
1536
  mapcat: {
1327
1537
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
@@ -1354,23 +1564,6 @@ var sequenceNormalExpression = {
1354
1564
  },
1355
1565
  paramCount: { min: 2, max: 3 },
1356
1566
  },
1357
- 'filter': {
1358
- evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1359
- var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1360
- var executeFunction = _b.executeFunction;
1361
- assertSeq(seq, sourceCodeInfo);
1362
- assertFunctionLike(fn, sourceCodeInfo);
1363
- if (Array.isArray(seq)) {
1364
- var result = seq.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
1365
- return result;
1366
- }
1367
- return seq
1368
- .split('')
1369
- .filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); })
1370
- .join('');
1371
- },
1372
- paramCount: 2,
1373
- },
1374
1567
  'first': {
1375
1568
  evaluate: function (_a, sourceCodeInfo) {
1376
1569
  var _b = __read(_a, 1), array = _b[0];
@@ -1393,39 +1586,6 @@ var sequenceNormalExpression = {
1393
1586
  },
1394
1587
  paramCount: 1,
1395
1588
  },
1396
- 'map': {
1397
- evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1398
- var executeFunction = _a.executeFunction;
1399
- var fn = asFunctionLike(params.at(-1), sourceCodeInfo);
1400
- var seqs = params.slice(0, -1);
1401
- assertSeq(seqs[0], sourceCodeInfo);
1402
- var isString = typeof seqs[0] === 'string';
1403
- var len = seqs[0].length;
1404
- seqs.slice(1).forEach(function (seq) {
1405
- if (isString) {
1406
- assertString(seq, sourceCodeInfo);
1407
- }
1408
- else {
1409
- assertArray(seq, sourceCodeInfo);
1410
- }
1411
- len = Math.min(len, seq.length);
1412
- });
1413
- var paramArray = [];
1414
- var _loop_1 = function (i) {
1415
- paramArray.push(seqs.map(function (seq) { return seq[i]; }));
1416
- };
1417
- for (var i = 0; i < len; i++) {
1418
- _loop_1(i);
1419
- }
1420
- var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
1421
- if (!isString) {
1422
- return mapped;
1423
- }
1424
- mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
1425
- return mapped.join('');
1426
- },
1427
- paramCount: { min: 2 },
1428
- },
1429
1589
  'pop': {
1430
1590
  evaluate: function (_a, sourceCodeInfo) {
1431
1591
  var _b = __read(_a, 1), seq = _b[0];
@@ -1508,160 +1668,6 @@ var sequenceNormalExpression = {
1508
1668
  },
1509
1669
  paramCount: { min: 2 },
1510
1670
  },
1511
- 'reductions': {
1512
- evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1513
- var executeFunction = _a.executeFunction;
1514
- var _b = __read(params, 2), seq = _b[0], fn = _b[1];
1515
- assertSeq(seq, sourceCodeInfo);
1516
- assertFunctionLike(fn, sourceCodeInfo);
1517
- if (params.length === 2) {
1518
- if (seq.length === 0)
1519
- return [executeFunction(fn, [], contextStack, sourceCodeInfo)];
1520
- else if (seq.length === 1)
1521
- return [toAny(seq[0])];
1522
- if (typeof seq === 'string') {
1523
- var chars = seq.split('');
1524
- var resultArray_1 = [asAny(chars[0], sourceCodeInfo)];
1525
- chars.slice(1).reduce(function (result, elem) {
1526
- var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1527
- resultArray_1.push(newVal);
1528
- return newVal;
1529
- }, asAny(chars[0], sourceCodeInfo));
1530
- return resultArray_1;
1531
- }
1532
- else {
1533
- var resultArray_2 = [toAny(seq[0])];
1534
- seq.slice(1).reduce(function (result, elem) {
1535
- var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1536
- resultArray_2.push(newVal);
1537
- return newVal;
1538
- }, toAny(seq[0]));
1539
- return resultArray_2;
1540
- }
1541
- }
1542
- else {
1543
- var val = params[2];
1544
- assertAny(val, sourceCodeInfo);
1545
- if (typeof seq === 'string') {
1546
- assertString(val, sourceCodeInfo);
1547
- if (seq.length === 0)
1548
- return [val];
1549
- var resultArray_3 = [val];
1550
- seq.split('').reduce(function (result, elem) {
1551
- var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1552
- resultArray_3.push(newVal);
1553
- return newVal;
1554
- }, val);
1555
- return resultArray_3;
1556
- }
1557
- else {
1558
- if (seq.length === 0)
1559
- return [val];
1560
- var resultArray_4 = [val];
1561
- seq.reduce(function (result, elem) {
1562
- var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1563
- resultArray_4.push(newVal);
1564
- return newVal;
1565
- }, val);
1566
- return resultArray_4;
1567
- }
1568
- }
1569
- },
1570
- paramCount: { min: 2, max: 3 },
1571
- },
1572
- 'reduce': {
1573
- evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1574
- var executeFunction = _a.executeFunction;
1575
- var _b = __read(params, 2), seq = _b[0], fn = _b[1];
1576
- assertSeq(seq, sourceCodeInfo);
1577
- assertFunctionLike(fn, sourceCodeInfo);
1578
- if (params.length === 2) {
1579
- if (seq.length === 0)
1580
- return executeFunction(fn, [], contextStack, sourceCodeInfo);
1581
- else if (seq.length === 1)
1582
- return toAny(seq[0]);
1583
- if (typeof seq === 'string') {
1584
- var chars = seq.split('');
1585
- return chars.slice(1).reduce(function (result, elem) {
1586
- var val = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1587
- return val;
1588
- }, asAny(chars[0], sourceCodeInfo));
1589
- }
1590
- else {
1591
- return seq.slice(1).reduce(function (result, elem) {
1592
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1593
- }, toAny(seq[0]));
1594
- }
1595
- }
1596
- else {
1597
- var val = params[2];
1598
- assertAny(val, sourceCodeInfo);
1599
- if (typeof seq === 'string') {
1600
- assertString(val, sourceCodeInfo);
1601
- if (seq.length === 0)
1602
- return val;
1603
- return seq.split('').reduce(function (result, elem) {
1604
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1605
- }, val);
1606
- }
1607
- else {
1608
- if (seq.length === 0)
1609
- return val;
1610
- return seq.reduce(function (result, elem) {
1611
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1612
- }, val);
1613
- }
1614
- }
1615
- },
1616
- paramCount: { min: 2, max: 3 },
1617
- },
1618
- 'reduce-right': {
1619
- evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1620
- var executeFunction = _a.executeFunction;
1621
- var _b = __read(params, 2), seq = _b[0], fn = _b[1];
1622
- assertSeq(seq, sourceCodeInfo);
1623
- assertFunctionLike(fn, sourceCodeInfo);
1624
- if (params.length === 2) {
1625
- if (seq.length === 0)
1626
- return executeFunction(fn, [], contextStack, sourceCodeInfo);
1627
- else if (seq.length === 1)
1628
- return toAny(seq[0]);
1629
- if (typeof seq === 'string') {
1630
- var chars = seq.split('');
1631
- return chars.slice(0, chars.length - 1).reduceRight(function (result, elem) {
1632
- var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1633
- assertString(newVal, sourceCodeInfo);
1634
- return newVal;
1635
- }, chars[chars.length - 1]);
1636
- }
1637
- else {
1638
- return seq.slice(0, seq.length - 1).reduceRight(function (result, elem) {
1639
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1640
- }, asAny(seq[seq.length - 1], sourceCodeInfo));
1641
- }
1642
- }
1643
- else {
1644
- var val = params[2];
1645
- assertAny(val, sourceCodeInfo);
1646
- assertSeq(seq, sourceCodeInfo);
1647
- if (typeof seq === 'string') {
1648
- if (seq.length === 0)
1649
- return val;
1650
- return seq.split('').reduceRight(function (result, elem) {
1651
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1652
- }, val);
1653
- }
1654
- else {
1655
- if (seq.length === 0)
1656
- return val;
1657
- return seq.reduceRight(function (result, elem) {
1658
- return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
1659
- }, val);
1660
- }
1661
- }
1662
- },
1663
- paramCount: { min: 2, max: 3 },
1664
- },
1665
1671
  'rest': {
1666
1672
  evaluate: function (_a, sourceCodeInfo) {
1667
1673
  var _b = __read(_a, 1), seq = _b[0];
@@ -1980,7 +1986,7 @@ var sequenceNormalExpression = {
1980
1986
  assertSeq(input, sourceCodeInfo);
1981
1987
  if (Array.isArray(input)) {
1982
1988
  var result = [];
1983
- var _loop_2 = function (item) {
1989
+ var _loop_1 = function (item) {
1984
1990
  assertAny(item, sourceCodeInfo);
1985
1991
  if (!result.some(function (existingItem) { return deepEqual(existingItem, item, sourceCodeInfo); })) {
1986
1992
  result.push(item);
@@ -1989,7 +1995,7 @@ var sequenceNormalExpression = {
1989
1995
  try {
1990
1996
  for (var input_1 = __values(input), input_1_1 = input_1.next(); !input_1_1.done; input_1_1 = input_1.next()) {
1991
1997
  var item = input_1_1.value;
1992
- _loop_2(item);
1998
+ _loop_1(item);
1993
1999
  }
1994
2000
  }
1995
2001
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -3975,6 +3981,13 @@ var regexpNormalExpression = {
3975
3981
  assertString(sourceArg, sourceCodeInfo);
3976
3982
  var source = sourceArg || '(?:)';
3977
3983
  var flags = typeof flagsArg === 'string' ? flagsArg : '';
3984
+ try {
3985
+ // eslint-disable-next-line no-new
3986
+ new RegExp(source, flags); // Throws if invalid regexp
3987
+ }
3988
+ catch (e) {
3989
+ throw new LitsError("Invalid regular expression: ".concat(source, " ").concat(flags), sourceCodeInfo);
3990
+ }
3978
3991
  return _b = {},
3979
3992
  _b[REGEXP_SYMBOL] = true,
3980
3993
  _b.sourceCodeInfo = sourceCodeInfo,
@@ -4293,6 +4306,15 @@ function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
4293
4306
  }
4294
4307
 
4295
4308
  var functionalNormalExpression = {
4309
+ '|>': {
4310
+ evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
4311
+ var _c = __read(_a, 2), value = _c[0], func = _c[1];
4312
+ var executeFunction = _b.executeFunction;
4313
+ assertFunctionLike(func, sourceCodeInfo);
4314
+ return executeFunction(func, [value], contextStack, sourceCodeInfo);
4315
+ },
4316
+ paramCount: 2,
4317
+ },
4296
4318
  'apply': {
4297
4319
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
4298
4320
  var _c = __read(_a), func = _c[0], params = _c.slice(1);
@@ -4313,20 +4335,6 @@ var functionalNormalExpression = {
4313
4335
  },
4314
4336
  paramCount: 1,
4315
4337
  },
4316
- 'partial': {
4317
- evaluate: function (_a, sourceCodeInfo) {
4318
- var _b;
4319
- var _c = __read(_a), fn = _c[0], params = _c.slice(1);
4320
- return _b = {},
4321
- _b[FUNCTION_SYMBOL] = true,
4322
- _b.sourceCodeInfo = sourceCodeInfo,
4323
- _b.functionType = 'Partial',
4324
- _b.function = asFunctionLike(fn, sourceCodeInfo),
4325
- _b.params = params,
4326
- _b;
4327
- },
4328
- paramCount: { min: 1 },
4329
- },
4330
4338
  'comp': {
4331
4339
  evaluate: function (params, sourceCodeInfo) {
4332
4340
  var _a;
@@ -7086,10 +7094,10 @@ var linearAlgebraNormalExpression = {
7086
7094
  assertVector(vectorA, sourceCodeInfo);
7087
7095
  assertVector(vectorB, sourceCodeInfo);
7088
7096
  if (vectorA.length < 2) {
7089
- throw new Error('Vectors must have at least 2 elements');
7097
+ throw new LitsError('Vectors must have at least 2 elements', sourceCodeInfo);
7090
7098
  }
7091
7099
  if (vectorA.length !== vectorB.length) {
7092
- throw new Error('Vectors must be of the same length');
7100
+ throw new LitsError('Vectors must be of the same length', sourceCodeInfo);
7093
7101
  }
7094
7102
  assertNumber(lag, sourceCodeInfo, {
7095
7103
  integer: true,
@@ -8341,7 +8349,7 @@ var partitionsNormalExpressions = {
8341
8349
  if (n === 0)
8342
8350
  return 1;
8343
8351
  if (n > partitionNumbers.length) {
8344
- throw new Error("n is too large. The maximum value is ".concat(partitionNumbers.length - 1, "."));
8352
+ throw new LitsError("n is too large. The maximum value is ".concat(partitionNumbers.length - 1, "."), sourceCodeInfo);
8345
8353
  }
8346
8354
  return partitionNumbers[n - 1];
8347
8355
  },
@@ -10480,7 +10488,12 @@ var combinatoricalNormalExpression = {
10480
10488
  var _b = __read(_a, 2), a = _b[0], m = _b[1];
10481
10489
  assertNumber(a, sourceCodeInfo, { integer: true, positive: true });
10482
10490
  assertNumber(m, sourceCodeInfo, { integer: true, positive: true });
10483
- return modInverse(a, m);
10491
+ try {
10492
+ return modInverse(a, m);
10493
+ }
10494
+ catch (error) {
10495
+ throw new LitsError(error, sourceCodeInfo);
10496
+ }
10484
10497
  },
10485
10498
  paramCount: 2,
10486
10499
  },
@@ -10499,7 +10512,7 @@ var combinatoricalNormalExpression = {
10499
10512
  assertVector(remainders, sourceCodeInfo);
10500
10513
  assertVector(moduli, sourceCodeInfo);
10501
10514
  if (remainders.length !== moduli.length) {
10502
- throw new Error('Remainders and moduli must have the same length.');
10515
+ throw new LitsError('Remainders and moduli must have the same length.', sourceCodeInfo);
10503
10516
  }
10504
10517
  try {
10505
10518
  return chineseRemainder(remainders, moduli);
@@ -11253,6 +11266,7 @@ var nonNumberReservedSymbolRecord = {
11253
11266
  function: null,
11254
11267
  export: null,
11255
11268
  as: null,
11269
+ _: null,
11256
11270
  };
11257
11271
  var phi = (1 + Math.sqrt(5)) / 2;
11258
11272
  var numberReservedSymbolRecord = {
@@ -11942,7 +11956,11 @@ var objectSpecialExpression = {
11942
11956
  }
11943
11957
  else {
11944
11958
  var key = evaluateNode(keyNode, contextStack);
11945
- var value = evaluateNode(params[i + 1], contextStack);
11959
+ var valueNode = params[i + 1];
11960
+ if (valueNode === undefined) {
11961
+ throw new LitsError('Missing value for key', keyNode[2]);
11962
+ }
11963
+ var value = evaluateNode(valueNode, contextStack);
11946
11964
  assertString(key, keyNode[2]);
11947
11965
  result[key] = value;
11948
11966
  }
@@ -12102,8 +12120,27 @@ var functionExecutors = {
12102
12120
  }
12103
12121
  },
12104
12122
  Partial: function (fn, params, sourceCodeInfo, contextStack, _a) {
12123
+ var e_2, _b;
12105
12124
  var executeFunction = _a.executeFunction;
12106
- return executeFunction(fn.function, __spreadArray(__spreadArray([], __read(fn.params), false), __read(params), false), contextStack, sourceCodeInfo);
12125
+ var actualParams = __spreadArray([], __read(fn.params), false);
12126
+ if (params.length !== fn.placeholders.length) {
12127
+ throw new LitsError("(partial) expects ".concat(fn.placeholders.length, " arguments, got ").concat(params.length, "."), sourceCodeInfo);
12128
+ }
12129
+ var paramsCopy = __spreadArray([], __read(params), false);
12130
+ try {
12131
+ for (var _c = __values(fn.placeholders), _d = _c.next(); !_d.done; _d = _c.next()) {
12132
+ var placeholderIndex = _d.value;
12133
+ actualParams.splice(placeholderIndex, 0, paramsCopy.shift());
12134
+ }
12135
+ }
12136
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
12137
+ finally {
12138
+ try {
12139
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
12140
+ }
12141
+ finally { if (e_2) throw e_2.error; }
12142
+ }
12143
+ return executeFunction(fn.function, actualParams, contextStack, sourceCodeInfo);
12107
12144
  },
12108
12145
  Comp: function (fn, params, sourceCodeInfo, contextStack, _a) {
12109
12146
  var executeFunction = _a.executeFunction;
@@ -12129,66 +12166,66 @@ var functionExecutors = {
12129
12166
  return !executeFunction(fn.function, params, contextStack, sourceCodeInfo);
12130
12167
  },
12131
12168
  EveryPred: function (fn, params, sourceCodeInfo, contextStack, _a) {
12132
- var e_2, _b, e_3, _c;
12169
+ var e_3, _b, e_4, _c;
12133
12170
  var executeFunction = _a.executeFunction;
12134
12171
  try {
12135
12172
  for (var _d = __values(fn.params), _e = _d.next(); !_e.done; _e = _d.next()) {
12136
12173
  var f = _e.value;
12137
12174
  try {
12138
- for (var params_1 = (e_3 = void 0, __values(params)), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
12175
+ for (var params_1 = (e_4 = void 0, __values(params)), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
12139
12176
  var param = params_1_1.value;
12140
12177
  var result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo);
12141
12178
  if (!result)
12142
12179
  return false;
12143
12180
  }
12144
12181
  }
12145
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
12182
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
12146
12183
  finally {
12147
12184
  try {
12148
12185
  if (params_1_1 && !params_1_1.done && (_c = params_1.return)) _c.call(params_1);
12149
12186
  }
12150
- finally { if (e_3) throw e_3.error; }
12187
+ finally { if (e_4) throw e_4.error; }
12151
12188
  }
12152
12189
  }
12153
12190
  }
12154
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
12191
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
12155
12192
  finally {
12156
12193
  try {
12157
12194
  if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
12158
12195
  }
12159
- finally { if (e_2) throw e_2.error; }
12196
+ finally { if (e_3) throw e_3.error; }
12160
12197
  }
12161
12198
  return true;
12162
12199
  },
12163
12200
  SomePred: function (fn, params, sourceCodeInfo, contextStack, _a) {
12164
- var e_4, _b, e_5, _c;
12201
+ var e_5, _b, e_6, _c;
12165
12202
  var executeFunction = _a.executeFunction;
12166
12203
  try {
12167
12204
  for (var _d = __values(fn.params), _e = _d.next(); !_e.done; _e = _d.next()) {
12168
12205
  var f = _e.value;
12169
12206
  try {
12170
- for (var params_2 = (e_5 = void 0, __values(params)), params_2_1 = params_2.next(); !params_2_1.done; params_2_1 = params_2.next()) {
12207
+ for (var params_2 = (e_6 = void 0, __values(params)), params_2_1 = params_2.next(); !params_2_1.done; params_2_1 = params_2.next()) {
12171
12208
  var param = params_2_1.value;
12172
12209
  var result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo);
12173
12210
  if (result)
12174
12211
  return true;
12175
12212
  }
12176
12213
  }
12177
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
12214
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
12178
12215
  finally {
12179
12216
  try {
12180
12217
  if (params_2_1 && !params_2_1.done && (_c = params_2.return)) _c.call(params_2);
12181
12218
  }
12182
- finally { if (e_5) throw e_5.error; }
12219
+ finally { if (e_6) throw e_6.error; }
12183
12220
  }
12184
12221
  }
12185
12222
  }
12186
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
12223
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
12187
12224
  finally {
12188
12225
  try {
12189
12226
  if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
12190
12227
  }
12191
- finally { if (e_4) throw e_4.error; }
12228
+ finally { if (e_5) throw e_5.error; }
12192
12229
  }
12193
12230
  return false;
12194
12231
  },
@@ -12261,6 +12298,9 @@ function evaluateString(node) {
12261
12298
  }
12262
12299
  function evaluateReservedSymbol(node) {
12263
12300
  var reservedName = node[1];
12301
+ if (!['true', 'false', 'null'].includes(reservedName)) {
12302
+ throw new LitsError("Reserved symbol ".concat(reservedName, " cannot be evaluated"), node[2]);
12303
+ }
12264
12304
  var value = reservedSymbolRecord[reservedName];
12265
12305
  return asNonUndefined(value, node[2]);
12266
12306
  }
@@ -12268,7 +12308,8 @@ function evaluateNormalExpression(node, contextStack) {
12268
12308
  var sourceCodeInfo = node[2];
12269
12309
  var paramNodes = node[1][1];
12270
12310
  var params = [];
12271
- paramNodes.forEach(function (paramNode) {
12311
+ var placeholders = [];
12312
+ paramNodes.forEach(function (paramNode, index) {
12272
12313
  if (isSpreadNode(paramNode)) {
12273
12314
  var spreadValue = evaluateNode(paramNode[1], contextStack);
12274
12315
  if (Array.isArray(spreadValue)) {
@@ -12278,12 +12319,27 @@ function evaluateNormalExpression(node, contextStack) {
12278
12319
  throw new LitsError("Spread operator requires an array, got ".concat(valueToString(paramNode)), paramNode[2]);
12279
12320
  }
12280
12321
  }
12322
+ else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {
12323
+ placeholders.push(index);
12324
+ }
12281
12325
  else {
12282
12326
  params.push(evaluateNode(paramNode, contextStack));
12283
12327
  }
12284
12328
  });
12285
12329
  if (isNormalExpressionNodeWithName(node)) {
12286
12330
  var nameSymbol = node[1][0];
12331
+ if (placeholders.length > 0) {
12332
+ var fn = evaluateNode(nameSymbol, contextStack);
12333
+ var partialFunction = {
12334
+ '^^fn^^': true,
12335
+ 'function': asFunctionLike(fn, sourceCodeInfo),
12336
+ 'functionType': 'Partial',
12337
+ params: params,
12338
+ placeholders: placeholders,
12339
+ sourceCodeInfo: sourceCodeInfo,
12340
+ };
12341
+ return partialFunction;
12342
+ }
12287
12343
  if (isNormalBuiltinSymbolNode(nameSymbol)) {
12288
12344
  var type = nameSymbol[1];
12289
12345
  var normalExpression = builtin.allNormalExpressions[type];
@@ -12300,6 +12356,17 @@ function evaluateNormalExpression(node, contextStack) {
12300
12356
  else {
12301
12357
  var fnNode = node[1][0];
12302
12358
  var fn = asFunctionLike(evaluateNode(fnNode, contextStack), sourceCodeInfo);
12359
+ if (placeholders.length > 0) {
12360
+ var partialFunction = {
12361
+ '^^fn^^': true,
12362
+ 'function': asFunctionLike(fn, sourceCodeInfo),
12363
+ 'functionType': 'Partial',
12364
+ params: params,
12365
+ placeholders: placeholders,
12366
+ sourceCodeInfo: sourceCodeInfo,
12367
+ };
12368
+ return partialFunction;
12369
+ }
12303
12370
  return executeFunction(fn, params, contextStack, sourceCodeInfo);
12304
12371
  }
12305
12372
  }
@@ -12605,6 +12672,7 @@ var binaryOperators = [
12605
12672
  '&&', // logical AND
12606
12673
  '||', // logical OR
12607
12674
  '??', // nullish coalescing
12675
+ '|>', // pipe
12608
12676
  ];
12609
12677
  var otherOperators = [
12610
12678
  '->', // lambda
@@ -12783,21 +12851,30 @@ var tokenizeNumber = function (input, position) {
12783
12851
  var char = input[i];
12784
12852
  if (char === '_') {
12785
12853
  if (!decimalNumberRegExp.test(input[i - 1]) || !decimalNumberRegExp.test(input[i + 1])) {
12786
- return NO_MATCH;
12854
+ if (i === start) {
12855
+ return NO_MATCH;
12856
+ }
12857
+ throw new LitsError("Invalid number format at position ".concat(i, "."), undefined);
12787
12858
  }
12788
12859
  }
12789
12860
  else if (char === '.') {
12790
- if (i === start || hasDecimalPoint || hasExponent) {
12861
+ if (i === start) {
12791
12862
  return NO_MATCH;
12792
12863
  }
12864
+ if (hasDecimalPoint || hasExponent) {
12865
+ throw new LitsError("Invalid number format at position ".concat(i, "."), undefined);
12866
+ }
12793
12867
  hasDecimalPoint = true;
12794
12868
  }
12795
12869
  else if (char === 'e' || char === 'E') {
12796
- if (i === start || hasExponent) {
12870
+ if (i === start) {
12797
12871
  return NO_MATCH;
12798
12872
  }
12873
+ if (hasExponent) {
12874
+ throw new LitsError("Invalid number format at position ".concat(i, "."), undefined);
12875
+ }
12799
12876
  if (input[i - 1] === '.' || input[i - 1] === '+' || input[i - 1] === '-') {
12800
- return NO_MATCH;
12877
+ throw new LitsError("Invalid number format at position ".concat(i, "."), undefined);
12801
12878
  }
12802
12879
  if (input[i + 1] === '+' || input[i + 1] === '-') {
12803
12880
  i += 1;
@@ -12817,7 +12894,7 @@ var tokenizeNumber = function (input, position) {
12817
12894
  }
12818
12895
  var nextChar = input[i];
12819
12896
  if (nextChar && !postNumberRegExp.test(nextChar)) {
12820
- return NO_MATCH;
12897
+ throw new LitsError("Invalid number format at position ".concat(i, "."), undefined);
12821
12898
  }
12822
12899
  return [length, ['Number', input.substring(position, i)]];
12823
12900
  };
@@ -12983,10 +13060,10 @@ function tokenize(input, debug, filePath) {
12983
13060
  hasDebugData: debug,
12984
13061
  };
12985
13062
  while (position < input.length) {
12986
- var tokenDescriptor = getCurrentToken(input, position);
12987
13063
  var sourceCodeInfo = debug
12988
13064
  ? createSourceCodeInfo(input, position, filePath)
12989
13065
  : undefined;
13066
+ var tokenDescriptor = getCurrentToken(input, position);
12990
13067
  if (!tokenDescriptor) {
12991
13068
  throw new LitsError("Unrecognized character '".concat(input[position], "'."), sourceCodeInfo);
12992
13069
  }
@@ -13096,9 +13173,6 @@ function isOperatorToken(token, operatorName) {
13096
13173
  }
13097
13174
  function assertOperatorToken(token, operatorName) {
13098
13175
  if (!isOperatorToken(token, operatorName)) {
13099
- if (operatorName) {
13100
- throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), token[2]);
13101
- }
13102
13176
  throwUnexpectedToken('Operator', operatorName, token);
13103
13177
  }
13104
13178
  }
@@ -13168,8 +13242,8 @@ function isA_BinaryOperatorToken(token) {
13168
13242
  return (token === null || token === void 0 ? void 0 : token[0]) === 'Operator' && isBinaryOperator(token[1]);
13169
13243
  }
13170
13244
  function throwUnexpectedToken(expected, expectedValue, actual) {
13171
- var actualOutput = "".concat(actual[0], " '").concat(actual[1], "'");
13172
- throw new LitsError("Unexpected token: ".concat(actualOutput, ", expected ").concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), actual[2]);
13245
+ var actualOutput = actual ? "".concat(actual[0], " '").concat(actual[1], "'") : 'end of input';
13246
+ throw new LitsError("Unexpected token: ".concat(actualOutput, ", expected ").concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), actual === null || actual === void 0 ? void 0 : actual[2]);
13173
13247
  }
13174
13248
 
13175
13249
  function minifyTokenStream(tokenStream, _a) {
@@ -13198,8 +13272,8 @@ function untokenize(tokenStream) {
13198
13272
  }, '');
13199
13273
  }
13200
13274
 
13201
- var exponentiationPrecedence = 10;
13202
- var binaryFunctionalOperatorPrecedence = 1;
13275
+ var exponentiationPrecedence = 11;
13276
+ var binaryFunctionalOperatorPrecedence = 2;
13203
13277
  var placeholderRegexp = /^\$([1-9]\d?)?$/;
13204
13278
  function withSourceCodeInfo(node, sourceCodeInfo) {
13205
13279
  if (sourceCodeInfo) {
@@ -13214,38 +13288,40 @@ function getPrecedence(operatorSign, sourceCodeInfo) {
13214
13288
  case '*': // multiplication
13215
13289
  case '/': // division
13216
13290
  case '%': // remainder
13217
- return 9;
13291
+ return 10;
13218
13292
  case '+': // addition
13219
13293
  case '-': // subtraction
13220
- return 8;
13294
+ return 9;
13221
13295
  case '<<': // left shift
13222
13296
  case '>>': // signed right shift
13223
13297
  case '>>>': // unsigned right shift
13224
- return 7;
13298
+ return 8;
13225
13299
  case '++': // string concatenation
13226
- return 6;
13300
+ return 7;
13227
13301
  case '<': // less than
13228
13302
  case '<=': // less than or equal
13229
13303
  case '≤': // less than or equal
13230
13304
  case '>': // greater than
13231
13305
  case '>=': // greater than or equal
13232
13306
  case '≥': // greater than or equal
13233
- return 5;
13307
+ return 6;
13234
13308
  case '=': // equal
13235
13309
  case '!=': // not equal
13236
13310
  case '≠': // not equal
13237
13311
  case '~': // approximate
13238
13312
  case '≈': // approximate
13239
- return 4;
13313
+ return 5;
13240
13314
  case '&': // bitwise AND
13241
13315
  case 'xor': // bitwise XOR
13242
13316
  case '|': // bitwise OR
13243
- return 3;
13317
+ return 4;
13244
13318
  case '&&': // logical AND
13245
13319
  case '||': // logical OR
13246
13320
  case '??': // nullish coalescing
13247
- return 2;
13248
- // leave room for binaryFunctionalOperatorPrecedence = 1
13321
+ return 3;
13322
+ case '|>': // pipe
13323
+ return 1;
13324
+ // leave room for binaryFunctionalOperatorPrecedence = 2
13249
13325
  /* v8 ignore next 2 */
13250
13326
  default:
13251
13327
  throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
@@ -13289,6 +13365,7 @@ function fromBinaryOperatorToNode(operator, symbolNode, left, right, sourceCodeI
13289
13365
  case '|':
13290
13366
  case '~':
13291
13367
  case '≈':
13368
+ case '|>':
13292
13369
  return createNamedNormalExpressionNode(symbolNode, [left, right], sourceCodeInfo);
13293
13370
  case '&&':
13294
13371
  case '||':
@@ -13314,6 +13391,11 @@ var Parser = /** @class */ (function () {
13314
13391
  Parser.prototype.peek = function () {
13315
13392
  return this.tokenStream.tokens[this.parseState.position];
13316
13393
  };
13394
+ Parser.prototype.peekSourceCodeInfo = function () {
13395
+ var _a;
13396
+ var currentToken = this.peek();
13397
+ return currentToken ? currentToken[2] : (_a = this.tokenStream.tokens.at(-1)) === null || _a === void 0 ? void 0 : _a[2];
13398
+ };
13317
13399
  Parser.prototype.peekAhead = function (count) {
13318
13400
  return this.tokenStream.tokens[this.parseState.position + count];
13319
13401
  };
@@ -13329,7 +13411,7 @@ var Parser = /** @class */ (function () {
13329
13411
  }
13330
13412
  else {
13331
13413
  if (!this.isAtEnd()) {
13332
- throw new LitsError('Expected ;', this.peek()[2]);
13414
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
13333
13415
  }
13334
13416
  }
13335
13417
  }
@@ -13418,15 +13500,21 @@ var Parser = /** @class */ (function () {
13418
13500
  }
13419
13501
  return left;
13420
13502
  };
13503
+ Parser.prototype.asToken = function (token) {
13504
+ if (!token) {
13505
+ throw new LitsError('Unexpected end of input', this.peekSourceCodeInfo());
13506
+ }
13507
+ return token;
13508
+ };
13421
13509
  Parser.prototype.parseOperand = function () {
13422
13510
  var operand = this.parseOperandPart();
13423
13511
  var token = this.peek();
13424
13512
  while (isOperatorToken(token, '.') || isLBracketToken(token) || isLParenToken(token)) {
13425
13513
  if (token[1] === '.') {
13426
13514
  this.advance();
13427
- var symbolToken = this.peek();
13515
+ var symbolToken = this.asToken(this.peek());
13428
13516
  if (!isSymbolToken(symbolToken)) {
13429
- throw new LitsError('Expected symbol', this.peek()[2]);
13517
+ throw new LitsError('Expected symbol', this.peekSourceCodeInfo());
13430
13518
  }
13431
13519
  var stringNode = withSourceCodeInfo([NodeTypes.String, symbolToken[1]], symbolToken[2]);
13432
13520
  operand = createAccessorNode(operand, stringNode, token[2]);
@@ -13437,7 +13525,7 @@ var Parser = /** @class */ (function () {
13437
13525
  this.advance();
13438
13526
  var expression = this.parseExpression();
13439
13527
  if (!isRBracketToken(this.peek())) {
13440
- throw new LitsError('Expected closing bracket', this.peek()[2]);
13528
+ throw new LitsError('Expected closing bracket', this.peekSourceCodeInfo());
13441
13529
  }
13442
13530
  operand = createAccessorNode(operand, expression, token[2]);
13443
13531
  this.advance();
@@ -13451,7 +13539,7 @@ var Parser = /** @class */ (function () {
13451
13539
  return operand;
13452
13540
  };
13453
13541
  Parser.prototype.parseOperandPart = function () {
13454
- var token = this.peek();
13542
+ var token = this.asToken(this.peek());
13455
13543
  // Parentheses
13456
13544
  if (isLParenToken(token)) {
13457
13545
  var positionBefore = this.parseState.position;
@@ -13463,7 +13551,7 @@ var Parser = /** @class */ (function () {
13463
13551
  this.advance();
13464
13552
  var expression = this.parseExpression();
13465
13553
  if (!isRParenToken(this.peek())) {
13466
- throw new LitsError('Expected closing parenthesis', this.peek()[2]);
13554
+ throw new LitsError('Expected closing parenthesis', this.peekSourceCodeInfo());
13467
13555
  }
13468
13556
  this.advance();
13469
13557
  return expression;
@@ -13523,7 +13611,7 @@ var Parser = /** @class */ (function () {
13523
13611
  while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
13524
13612
  if (isOperatorToken(this.peek(), '...')) {
13525
13613
  this.advance();
13526
- params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
13614
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peekSourceCodeInfo()));
13527
13615
  }
13528
13616
  else {
13529
13617
  var token = this.peek();
@@ -13539,7 +13627,7 @@ var Parser = /** @class */ (function () {
13539
13627
  this.advance();
13540
13628
  }
13541
13629
  else {
13542
- throw new LitsError('Expected key to be a symbol or a string', this.peek()[2]);
13630
+ throw new LitsError('Expected key to be a symbol or a string', this.peekSourceCodeInfo());
13543
13631
  }
13544
13632
  assertOperatorToken(this.peek(), ':=');
13545
13633
  this.advance();
@@ -13547,7 +13635,7 @@ var Parser = /** @class */ (function () {
13547
13635
  }
13548
13636
  var nextToken = this.peek();
13549
13637
  if (!isOperatorToken(nextToken, ',') && !isRBraceToken(nextToken)) {
13550
- throw new LitsError('Expected comma or closing brace', this.peek()[2]);
13638
+ throw new LitsError('Expected comma or closing brace', this.peekSourceCodeInfo());
13551
13639
  }
13552
13640
  if (isOperatorToken(nextToken, ',')) {
13553
13641
  this.advance();
@@ -13564,14 +13652,14 @@ var Parser = /** @class */ (function () {
13564
13652
  while (!this.isAtEnd() && !isRBracketToken(this.peek())) {
13565
13653
  if (isOperatorToken(this.peek(), '...')) {
13566
13654
  this.advance();
13567
- params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
13655
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peekSourceCodeInfo()));
13568
13656
  }
13569
13657
  else {
13570
13658
  params.push(this.parseExpression());
13571
13659
  }
13572
13660
  var nextToken = this.peek();
13573
13661
  if (!isOperatorToken(nextToken, ',') && !isRBracketToken(nextToken)) {
13574
- throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
13662
+ throw new LitsError('Expected comma or closing parenthesis', this.peekSourceCodeInfo());
13575
13663
  }
13576
13664
  if (isOperatorToken(nextToken, ',')) {
13577
13665
  this.advance();
@@ -13582,26 +13670,27 @@ var Parser = /** @class */ (function () {
13582
13670
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.array, params]], firstToken[2]);
13583
13671
  };
13584
13672
  Parser.prototype.parseFunctionCall = function (symbol) {
13673
+ var _a;
13585
13674
  this.advance();
13586
13675
  var params = [];
13587
13676
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
13588
13677
  if (isOperatorToken(this.peek(), '...')) {
13589
13678
  this.advance();
13590
- params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peek()[2]));
13679
+ params.push(withSourceCodeInfo([NodeTypes.Spread, this.parseExpression()], this.peekSourceCodeInfo()));
13591
13680
  }
13592
13681
  else {
13593
13682
  params.push(this.parseExpression());
13594
13683
  }
13595
13684
  var nextToken = this.peek();
13596
13685
  if (!isOperatorToken(nextToken, ',') && !isRParenToken(nextToken)) {
13597
- throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
13686
+ throw new LitsError('Expected comma or closing parenthesis', (_a = this.peek()) === null || _a === void 0 ? void 0 : _a[2]);
13598
13687
  }
13599
13688
  if (isOperatorToken(nextToken, ',')) {
13600
13689
  this.advance();
13601
13690
  }
13602
13691
  }
13603
13692
  if (!isRParenToken(this.peek())) {
13604
- throw new LitsError('Expected closing parenthesis', this.peek()[2]);
13693
+ throw new LitsError('Expected closing parenthesis', this.peekSourceCodeInfo());
13605
13694
  }
13606
13695
  this.advance();
13607
13696
  if (isSpecialBuiltinSymbolNode(symbol)) { // Named function
@@ -13631,14 +13720,14 @@ var Parser = /** @class */ (function () {
13631
13720
  if (params.length !== 1) {
13632
13721
  throw new LitsError('Expected exactly one parameter', symbol[2]);
13633
13722
  }
13634
- var _a = __read(params, 1), param = _a[0];
13723
+ var _b = __read(params, 1), param = _b[0];
13635
13724
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param]], symbol[2]);
13636
13725
  }
13637
13726
  case specialExpressionTypes.throw: {
13638
13727
  if (params.length !== 1) {
13639
13728
  throw new LitsError('Expected exactly one parameter', symbol[2]);
13640
13729
  }
13641
- var _b = __read(params, 1), param = _b[0];
13730
+ var _c = __read(params, 1), param = _c[0];
13642
13731
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param]], symbol[2]);
13643
13732
  }
13644
13733
  case specialExpressionTypes['0_fn']:
@@ -13658,7 +13747,7 @@ var Parser = /** @class */ (function () {
13658
13747
  }
13659
13748
  };
13660
13749
  Parser.prototype.parseLambdaFunction = function () {
13661
- var firstToken = this.peek();
13750
+ var firstToken = this.asToken(this.peek());
13662
13751
  if (isLParenToken(firstToken)
13663
13752
  && isSymbolToken(this.peekAhead(1))
13664
13753
  && isOperatorToken(this.peekAhead(2), '->')) {
@@ -13692,7 +13781,7 @@ var Parser = /** @class */ (function () {
13692
13781
  var functionArguments = [];
13693
13782
  while (!this.isAtEnd() && !isRParenToken(this.peek()) && !isSymbolToken(this.peek(), 'let')) {
13694
13783
  if (rest) {
13695
- throw new LitsError('Rest argument must be last', this.peek()[2]);
13784
+ throw new LitsError('Rest argument must be last', this.peekSourceCodeInfo());
13696
13785
  }
13697
13786
  var bindingTarget = this.parseBindingTarget();
13698
13787
  if (bindingTarget[1][1] !== undefined) {
@@ -13702,25 +13791,25 @@ var Parser = /** @class */ (function () {
13702
13791
  rest = true;
13703
13792
  }
13704
13793
  if (defaults && !bindingTarget[1][1]) {
13705
- throw new LitsError('Default arguments must be last', this.peek()[2]);
13794
+ throw new LitsError('Default arguments must be last', this.peekSourceCodeInfo());
13706
13795
  }
13707
13796
  functionArguments.push(bindingTarget);
13708
13797
  if (!isOperatorToken(this.peek(), ',') && !isRParenToken(this.peek()) && !isSymbolToken(this.peek(), 'let')) {
13709
- throw new LitsError('Expected comma or closing parenthesis', this.peek()[2]);
13798
+ throw new LitsError('Expected comma or closing parenthesis', this.peekSourceCodeInfo());
13710
13799
  }
13711
13800
  if (isOperatorToken(this.peek(), ',')) {
13712
13801
  this.advance();
13713
13802
  }
13714
13803
  }
13715
13804
  if (!isRParenToken(this.peek())) {
13716
- throw new LitsError('Expected closing parenthesis', this.peek()[2]);
13805
+ throw new LitsError('Expected closing parenthesis', this.peekSourceCodeInfo());
13717
13806
  }
13718
13807
  this.advance();
13719
13808
  return functionArguments;
13720
13809
  };
13721
13810
  Parser.prototype.parseShorthandLamdaFunction = function () {
13722
13811
  var _a;
13723
- var firstToken = this.peek();
13812
+ var firstToken = this.asToken(this.peek());
13724
13813
  this.advance();
13725
13814
  var startPos = this.parseState.position;
13726
13815
  var exprNode = this.parseExpression();
@@ -13778,7 +13867,7 @@ var Parser = /** @class */ (function () {
13778
13867
  }
13779
13868
  var defaultValue = this.parseOptionalDefaulValue();
13780
13869
  if (requireDefaultValue && !defaultValue) {
13781
- throw new LitsError('Expected assignment', this.peek()[2]);
13870
+ throw new LitsError('Expected assignment', this.peekSourceCodeInfo());
13782
13871
  }
13783
13872
  return withSourceCodeInfo([bindingTargetTypes.symbol, [symbol, defaultValue]], firstToken[2]);
13784
13873
  }
@@ -13790,7 +13879,7 @@ var Parser = /** @class */ (function () {
13790
13879
  this.advance();
13791
13880
  var symbol = asUserDefinedSymbolNode(this.parseSymbol());
13792
13881
  if (isOperatorToken(this.peek(), ':=')) {
13793
- throw new LitsError('Rest argument can not have default value', this.peek()[2]);
13882
+ throw new LitsError('Rest argument can not have default value', this.peekSourceCodeInfo());
13794
13883
  }
13795
13884
  return withSourceCodeInfo([bindingTargetTypes.rest, [symbol[1], undefined]], firstToken[2]);
13796
13885
  }
@@ -13798,7 +13887,7 @@ var Parser = /** @class */ (function () {
13798
13887
  if (isLBracketToken(firstToken)) {
13799
13888
  this.advance();
13800
13889
  var elements = [];
13801
- var token = this.peek();
13890
+ var token = this.asToken(this.peek());
13802
13891
  var rest = false;
13803
13892
  while (!isRBracketToken(token)) {
13804
13893
  if (rest) {
@@ -13807,7 +13896,7 @@ var Parser = /** @class */ (function () {
13807
13896
  if (isOperatorToken(token, ',')) {
13808
13897
  elements.push(null);
13809
13898
  this.advance();
13810
- token = this.peek();
13899
+ token = this.asToken(this.peek());
13811
13900
  continue;
13812
13901
  }
13813
13902
  var target = this.parseBindingTarget();
@@ -13815,17 +13904,17 @@ var Parser = /** @class */ (function () {
13815
13904
  rest = true;
13816
13905
  }
13817
13906
  elements.push(target);
13818
- token = this.peek();
13907
+ token = this.asToken(this.peek());
13819
13908
  if (!isRBracketToken(token)) {
13820
13909
  assertOperatorToken(token, ',');
13821
13910
  this.advance();
13822
13911
  }
13823
- token = this.peek();
13912
+ token = this.asToken(this.peek());
13824
13913
  }
13825
13914
  this.advance();
13826
13915
  var defaultValue = this.parseOptionalDefaulValue();
13827
13916
  if (requireDefaultValue && !defaultValue) {
13828
- throw new LitsError('Expected assignment', this.peek()[2]);
13917
+ throw new LitsError('Expected assignment', this.peekSourceCodeInfo());
13829
13918
  }
13830
13919
  return withSourceCodeInfo([bindingTargetTypes.array, [elements, defaultValue]], firstToken[2]);
13831
13920
  }
@@ -13833,7 +13922,7 @@ var Parser = /** @class */ (function () {
13833
13922
  if (isLBraceToken(firstToken)) {
13834
13923
  this.advance();
13835
13924
  var elements = {};
13836
- var token = this.peek();
13925
+ var token = this.asToken(this.peek());
13837
13926
  var rest = false;
13838
13927
  while (!isRBraceToken(token)) {
13839
13928
  if (rest) {
@@ -13844,7 +13933,7 @@ var Parser = /** @class */ (function () {
13844
13933
  this.advance();
13845
13934
  }
13846
13935
  var key = asUserDefinedSymbolNode(this.parseSymbol());
13847
- token = this.peek();
13936
+ token = this.asToken(this.peek());
13848
13937
  if (isReservedSymbolToken(token, 'as')) {
13849
13938
  if (rest) {
13850
13939
  throw new LitsError('Rest argument can not have alias', token[2]);
@@ -13861,7 +13950,7 @@ var Parser = /** @class */ (function () {
13861
13950
  throw new LitsError("Duplicate binding name: ".concat(key), token[2]);
13862
13951
  }
13863
13952
  if (rest && isOperatorToken(this.peek(), ':=')) {
13864
- throw new LitsError('Rest argument can not have default value', this.peek()[2]);
13953
+ throw new LitsError('Rest argument can not have default value', this.peekSourceCodeInfo());
13865
13954
  }
13866
13955
  elements[key[1]] = rest
13867
13956
  ? withSourceCodeInfo([bindingTargetTypes.rest, [key[1], this.parseOptionalDefaulValue()]], firstToken[2])
@@ -13874,17 +13963,17 @@ var Parser = /** @class */ (function () {
13874
13963
  assertOperatorToken(this.peek(), ',');
13875
13964
  this.advance();
13876
13965
  }
13877
- token = this.peek();
13966
+ token = this.asToken(this.peek());
13878
13967
  }
13879
13968
  this.advance();
13880
- token = this.peek();
13969
+ token = this.asToken(this.peek());
13881
13970
  var defaultValue = this.parseOptionalDefaulValue();
13882
13971
  if (requireDefaultValue && !defaultValue) {
13883
13972
  throw new LitsError('Expected assignment', token[2]);
13884
13973
  }
13885
13974
  return withSourceCodeInfo([bindingTargetTypes.object, [elements, defaultValue]], firstToken[2]);
13886
13975
  }
13887
- throw new LitsError('Expected symbol', this.peek()[2]);
13976
+ throw new LitsError('Expected symbol', this.peekSourceCodeInfo());
13888
13977
  };
13889
13978
  Parser.prototype.parseLet = function (token, optionalSemicolon) {
13890
13979
  if (optionalSemicolon === void 0) { optionalSemicolon = false; }
@@ -13907,7 +13996,7 @@ var Parser = /** @class */ (function () {
13907
13996
  this.advance();
13908
13997
  }
13909
13998
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
13910
- throw new LitsError('Expected ;', this.peek()[2]);
13999
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
13911
14000
  }
13912
14001
  }
13913
14002
  assertReservedSymbolToken(this.peek(), 'end');
@@ -13931,7 +14020,7 @@ var Parser = /** @class */ (function () {
13931
14020
  token = this.peek();
13932
14021
  }
13933
14022
  if (bindingNodes.length === 0) {
13934
- throw new LitsError('Expected binding', this.peek()[2]);
14023
+ throw new LitsError('Expected binding', this.peekSourceCodeInfo());
13935
14024
  }
13936
14025
  assertSymbolToken(token, 'do');
13937
14026
  this.advance();
@@ -13942,7 +14031,7 @@ var Parser = /** @class */ (function () {
13942
14031
  this.advance();
13943
14032
  }
13944
14033
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
13945
- throw new LitsError('Expected ;', this.peek()[2]);
14034
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
13946
14035
  }
13947
14036
  }
13948
14037
  assertReservedSymbolToken(this.peek(), 'end');
@@ -13958,7 +14047,7 @@ var Parser = /** @class */ (function () {
13958
14047
  this.advance();
13959
14048
  }
13960
14049
  else if (!isReservedSymbolToken(this.peek(), 'catch')) {
13961
- throw new LitsError('Expected ;', this.peek()[2]);
14050
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
13962
14051
  }
13963
14052
  }
13964
14053
  var tryExpression = tryExpressions.length === 1
@@ -13980,7 +14069,7 @@ var Parser = /** @class */ (function () {
13980
14069
  this.advance();
13981
14070
  }
13982
14071
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
13983
- throw new LitsError('Expected ;', this.peek()[2]);
14072
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
13984
14073
  }
13985
14074
  }
13986
14075
  assertReservedSymbolToken(this.peek(), 'end');
@@ -14016,7 +14105,7 @@ var Parser = /** @class */ (function () {
14016
14105
  this.advance();
14017
14106
  }
14018
14107
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
14019
- throw new LitsError('Expected ;', this.peek()[2]);
14108
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14020
14109
  }
14021
14110
  }
14022
14111
  assertReservedSymbolToken(this.peek(), 'end');
@@ -14030,13 +14119,13 @@ var Parser = /** @class */ (function () {
14030
14119
  this.advance();
14031
14120
  var bindingNode = this.parseBinding();
14032
14121
  var modifiers = [];
14033
- var token = this.peek();
14122
+ var token = this.asToken(this.peek());
14034
14123
  if (!isSymbolToken(token, 'do') && !isReservedSymbolToken(this.peek(), 'each') && !isOperatorToken(token, ',')) {
14035
14124
  throw new LitsError('Expected do, each or comma', token[2]);
14036
14125
  }
14037
14126
  if (isOperatorToken(token, ',')) {
14038
14127
  this.advance();
14039
- token = this.peek();
14128
+ token = this.asToken(this.peek());
14040
14129
  }
14041
14130
  if (!isSymbolToken(token, 'let')
14042
14131
  && !isReservedSymbolToken(token, 'when')
@@ -14056,14 +14145,14 @@ var Parser = /** @class */ (function () {
14056
14145
  throw new LitsError('Duplicate binding', letNode[1][1][2]);
14057
14146
  }
14058
14147
  letBindings.push(letNode[1][1]);
14059
- token = this_2.peek();
14148
+ token = this_2.asToken(this_2.peek());
14060
14149
  if (!isSymbolToken(token, 'do') && !isReservedSymbolToken(this_2.peek(), 'each') && !isOperatorToken(token, ',')) {
14061
14150
  throw new LitsError('Expected do, each or comma', token[2]);
14062
14151
  }
14063
14152
  if (isOperatorToken(token, ',')) {
14064
14153
  this_2.advance();
14065
14154
  }
14066
- token = this_2.peek();
14155
+ token = this_2.asToken(this_2.peek());
14067
14156
  };
14068
14157
  var this_2 = this;
14069
14158
  while (isSymbolToken(token, 'let')) {
@@ -14089,14 +14178,14 @@ var Parser = /** @class */ (function () {
14089
14178
  modifiers.push('&while');
14090
14179
  whileNode = this.parseExpression();
14091
14180
  }
14092
- token = this.peek();
14181
+ token = this.asToken(this.peek());
14093
14182
  if (!isSymbolToken(token, 'do') && !isReservedSymbolToken(this.peek(), 'each') && !isOperatorToken(token, ',')) {
14094
14183
  throw new LitsError('Expected do or comma', token[2]);
14095
14184
  }
14096
14185
  if (isOperatorToken(token, ',')) {
14097
14186
  this.advance();
14098
14187
  }
14099
- token = this.peek();
14188
+ token = this.asToken(this.peek());
14100
14189
  }
14101
14190
  if (!isSymbolToken(token, 'do') && !isReservedSymbolToken(this.peek(), 'each')) {
14102
14191
  throw new LitsError('Expected do or each', token[2]);
@@ -14133,7 +14222,7 @@ var Parser = /** @class */ (function () {
14133
14222
  this.advance();
14134
14223
  }
14135
14224
  else if (!isReservedSymbolToken(this.peek(), 'else') && !isReservedSymbolToken(this.peek(), 'end')) {
14136
- throw new LitsError('Expected ;', this.peek()[2]);
14225
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14137
14226
  }
14138
14227
  }
14139
14228
  var thenExpression = thenExpressions.length === 1
@@ -14149,7 +14238,7 @@ var Parser = /** @class */ (function () {
14149
14238
  this.advance();
14150
14239
  }
14151
14240
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
14152
- throw new LitsError('Expected ;', this.peek()[2]);
14241
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14153
14242
  }
14154
14243
  }
14155
14244
  elseExpression = elseExpressions.length === 1
@@ -14180,7 +14269,7 @@ var Parser = /** @class */ (function () {
14180
14269
  this.advance();
14181
14270
  }
14182
14271
  else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14183
- throw new LitsError('Expected ;', this.peek()[2]);
14272
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14184
14273
  }
14185
14274
  }
14186
14275
  var thenExpression = expressions.length === 1
@@ -14215,7 +14304,7 @@ var Parser = /** @class */ (function () {
14215
14304
  this.advance();
14216
14305
  }
14217
14306
  else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14218
- throw new LitsError('Expected ;', this.peek()[2]);
14307
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14219
14308
  }
14220
14309
  }
14221
14310
  var thenExpression = expressions.length === 1
@@ -14242,7 +14331,7 @@ var Parser = /** @class */ (function () {
14242
14331
  this.advance();
14243
14332
  }
14244
14333
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
14245
- throw new LitsError('Expected ;', this.peek()[2]);
14334
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14246
14335
  }
14247
14336
  }
14248
14337
  assertReservedSymbolToken(this.peek(), 'end');
@@ -14286,7 +14375,7 @@ var Parser = /** @class */ (function () {
14286
14375
  this.advance();
14287
14376
  }
14288
14377
  else if (!isReservedSymbolToken(this.peek(), 'end')) {
14289
- throw new LitsError('Expected ;', this.peek()[2]);
14378
+ throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14290
14379
  }
14291
14380
  }
14292
14381
  assertReservedSymbolToken(this.peek(), 'end');
@@ -14297,7 +14386,7 @@ var Parser = /** @class */ (function () {
14297
14386
  ]]], token[2]);
14298
14387
  }
14299
14388
  else {
14300
- throw new LitsError('Expected let or function', this.peek()[2]);
14389
+ throw new LitsError('Expected let or function', this.peekSourceCodeInfo());
14301
14390
  }
14302
14391
  };
14303
14392
  Parser.prototype.stringToSymbolNode = function (value, sourceCodeInfo) {
@@ -14322,7 +14411,7 @@ var Parser = /** @class */ (function () {
14322
14411
  });
14323
14412
  };
14324
14413
  Parser.prototype.parseSymbol = function () {
14325
- var token = this.peek();
14414
+ var token = this.asToken(this.peek());
14326
14415
  this.advance();
14327
14416
  if (!isSymbolToken(token)) {
14328
14417
  throw new LitsError("Expected symbol token, got ".concat(token[0]), token[2]);
@@ -14344,7 +14433,7 @@ var Parser = /** @class */ (function () {
14344
14433
  return withSourceCodeInfo([NodeTypes.ReservedSymbol, token[1]], token[2]);
14345
14434
  };
14346
14435
  Parser.prototype.parseNumber = function () {
14347
- var token = this.peek();
14436
+ var token = this.asToken(this.peek());
14348
14437
  this.advance();
14349
14438
  var value = token[1];
14350
14439
  var negative = value[0] === '-';
@@ -14352,7 +14441,7 @@ var Parser = /** @class */ (function () {
14352
14441
  return withSourceCodeInfo([NodeTypes.Number, negative ? -Number(numberString) : Number(numberString)], token[2]);
14353
14442
  };
14354
14443
  Parser.prototype.parseString = function () {
14355
- var token = this.peek();
14444
+ var token = this.asToken(this.peek());
14356
14445
  this.advance();
14357
14446
  var value = token[1].substring(1, token[1].length - 1)
14358
14447
  .replace(/(\\{2})|(\\")|(\\n)|(\\t)|(\\r)|(\\b)|(\\f)|\\(.)/g, function (_, backslash, doubleQuote, newline, tab, carriageReturn, backspace, formFeed, normalChar) {
@@ -14384,7 +14473,7 @@ var Parser = /** @class */ (function () {
14384
14473
  return withSourceCodeInfo([NodeTypes.String, value], token[2]);
14385
14474
  };
14386
14475
  Parser.prototype.parseRegexpShorthand = function () {
14387
- var token = this.peek();
14476
+ var token = this.asToken(this.peek());
14388
14477
  this.advance();
14389
14478
  var endStringPosition = token[1].lastIndexOf('"');
14390
14479
  var regexpString = token[1].substring(2, endStringPosition);