@mojir/lits 2.0.10 → 2.0.13
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/cli/cli.js +1792 -1693
- package/dist/cli/reference/api.d.ts +10 -10
- package/dist/cli/reference/index.d.ts +2 -2
- package/dist/cli/src/builtin/index.d.ts +2 -2
- package/dist/cli/src/builtin/interface.d.ts +1 -1
- package/dist/cli/src/builtin/normalExpressions/categories/sequence.d.ts +1 -3
- package/dist/cli/src/builtin/specialExpressions/commonParser.d.ts +1 -1
- package/dist/cli/src/parser/AlgebraicParser.d.ts +6 -0
- package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +3 -2
- package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +50 -32
- package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +1 -0
- package/dist/cli/src/tokenizer/tokens.d.ts +2 -2
- package/dist/index.esm.js +1791 -1692
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1791 -1692
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1791 -1692
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +10 -10
- package/dist/reference/index.d.ts +2 -2
- package/dist/src/builtin/index.d.ts +2 -2
- package/dist/src/builtin/interface.d.ts +1 -1
- package/dist/src/builtin/normalExpressions/categories/sequence.d.ts +1 -3
- package/dist/src/builtin/specialExpressions/commonParser.d.ts +1 -1
- package/dist/src/parser/AlgebraicParser.d.ts +6 -0
- package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +3 -2
- package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +50 -32
- package/dist/src/tokenizer/polish/polishTokenizers.d.ts +1 -0
- package/dist/src/tokenizer/tokens.d.ts +2 -2
- package/dist/testFramework.esm.js +1022 -825
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +1022 -825
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
|
@@ -368,19 +368,17 @@ var algebraicOnlyValueTokenTypes = [
|
|
|
368
368
|
'A_SingleLineComment',
|
|
369
369
|
'A_MultiLineComment',
|
|
370
370
|
'A_Number',
|
|
371
|
+
'A_BasePrefixedNumber',
|
|
371
372
|
];
|
|
372
373
|
var algebraicValueTokenTypes = __spreadArray(__spreadArray([], __read(commomValueTokenTypes), false), __read(algebraicOnlyValueTokenTypes), false);
|
|
373
374
|
__spreadArray(__spreadArray([], __read(algebraicSimpleTokenTypes), false), __read(algebraicValueTokenTypes), false);
|
|
374
|
-
var
|
|
375
|
-
// Unary only operators
|
|
375
|
+
var symbolicUnaryOperators = [
|
|
376
376
|
'!', // logical NOT
|
|
377
377
|
'~', // bitwise NOT
|
|
378
|
-
'
|
|
379
|
-
'
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
'...',
|
|
383
|
-
'.', // property accessor
|
|
378
|
+
'+', // addition
|
|
379
|
+
'-', // subtraction
|
|
380
|
+
];
|
|
381
|
+
var symbolicBinaryOperators = [
|
|
384
382
|
'**', // exponentiation
|
|
385
383
|
'*', // multiplication
|
|
386
384
|
'/', // division
|
|
@@ -404,15 +402,83 @@ var AlgebraicOperators = [
|
|
|
404
402
|
'||', // logical OR
|
|
405
403
|
'??', // nullish coalescing
|
|
406
404
|
];
|
|
407
|
-
|
|
408
|
-
|
|
405
|
+
var otherSymbolicOperators = [
|
|
406
|
+
'=>', // lambda
|
|
407
|
+
'...', // rest
|
|
408
|
+
'.', // property accessor
|
|
409
|
+
',', // item separator
|
|
410
|
+
'=', // property assignment
|
|
411
|
+
];
|
|
412
|
+
var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(symbolicUnaryOperators), false), __read(symbolicBinaryOperators), false), __read(otherSymbolicOperators), false);
|
|
413
|
+
var nonFunctionOperators = [
|
|
414
|
+
'??',
|
|
415
|
+
'and',
|
|
416
|
+
'comment',
|
|
417
|
+
'cond',
|
|
418
|
+
'declared?',
|
|
419
|
+
'if',
|
|
420
|
+
'if-not',
|
|
421
|
+
'or',
|
|
422
|
+
'when',
|
|
423
|
+
'when-not',
|
|
424
|
+
'do',
|
|
425
|
+
'time!',
|
|
426
|
+
'throw',
|
|
427
|
+
'let',
|
|
428
|
+
'def',
|
|
429
|
+
'defs',
|
|
430
|
+
'if-let',
|
|
431
|
+
'when-let',
|
|
432
|
+
'when-first',
|
|
433
|
+
'fn',
|
|
434
|
+
'defn',
|
|
435
|
+
'defns',
|
|
436
|
+
'try',
|
|
437
|
+
'recur',
|
|
438
|
+
'loop',
|
|
439
|
+
'doseq',
|
|
440
|
+
'while',
|
|
441
|
+
];
|
|
442
|
+
var nonFunctionOperatorSet = new Set(nonFunctionOperators);
|
|
443
|
+
function isFunctionOperator(operator) {
|
|
444
|
+
return !nonFunctionOperatorSet.has(operator);
|
|
445
|
+
}
|
|
446
|
+
var symbolicUnaryOperatorSet = new Set(symbolicUnaryOperators);
|
|
447
|
+
function isSymbolicUnaryOperator(operator) {
|
|
448
|
+
return symbolicUnaryOperatorSet.has(operator);
|
|
449
|
+
}
|
|
450
|
+
var symbolicBinaryOperatorSet = new Set(symbolicBinaryOperators);
|
|
451
|
+
function isSymbolicBinaryOperator(operator) {
|
|
452
|
+
return symbolicBinaryOperatorSet.has(operator);
|
|
453
|
+
}
|
|
454
|
+
var symbolicOperatorSet = new Set(symbolicOperators);
|
|
455
|
+
function isSymbolicOperator(operator) {
|
|
456
|
+
return symbolicOperatorSet.has(operator);
|
|
409
457
|
}
|
|
410
458
|
function isA_SymbolToken(token) {
|
|
411
459
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Symbol';
|
|
412
460
|
}
|
|
461
|
+
function assertA_SymbolToken(token) {
|
|
462
|
+
if (!isA_SymbolToken(token)) {
|
|
463
|
+
throwUnexpectedToken('A_Symbol', token);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function asA_SymbolToken(token) {
|
|
467
|
+
assertA_SymbolToken(token);
|
|
468
|
+
return token;
|
|
469
|
+
}
|
|
470
|
+
function isA_BinaryOperatorToken(token) {
|
|
471
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Operator' && isSymbolicBinaryOperator(token[1]);
|
|
472
|
+
}
|
|
413
473
|
function isA_ReservedSymbolToken(token) {
|
|
414
474
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_ReservedSymbol';
|
|
415
475
|
}
|
|
476
|
+
function isA_CommentToken(token) {
|
|
477
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_SingleLineComment';
|
|
478
|
+
}
|
|
479
|
+
function isA_MultiLineCommentToken(token) {
|
|
480
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_MultiLineComment';
|
|
481
|
+
}
|
|
416
482
|
function isA_OperatorToken(token, operatorName) {
|
|
417
483
|
if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_Operator') {
|
|
418
484
|
return false;
|
|
@@ -424,9 +490,10 @@ function isA_OperatorToken(token, operatorName) {
|
|
|
424
490
|
}
|
|
425
491
|
function assertA_OperatorToken(token, operatorName) {
|
|
426
492
|
if (!isA_OperatorToken(token, operatorName)) {
|
|
427
|
-
{
|
|
493
|
+
if (operatorName) {
|
|
428
494
|
throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
|
|
429
495
|
}
|
|
496
|
+
throwUnexpectedToken('A_Operator', token);
|
|
430
497
|
}
|
|
431
498
|
}
|
|
432
499
|
function isA_WhitespaceToken(token) {
|
|
@@ -435,6 +502,9 @@ function isA_WhitespaceToken(token) {
|
|
|
435
502
|
function isA_NumberToken(token) {
|
|
436
503
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Number';
|
|
437
504
|
}
|
|
505
|
+
function isA_BasePrefixedNumberToken(token) {
|
|
506
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_BasePrefixedNumber';
|
|
507
|
+
}
|
|
438
508
|
|
|
439
509
|
var modifierNames = ['&', '&let', '&when', '&while'];
|
|
440
510
|
var polishOnlySimpleTokenTypes = [
|
|
@@ -1400,7 +1470,7 @@ var collectionNormalExpression = {
|
|
|
1400
1470
|
},
|
|
1401
1471
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
1402
1472
|
},
|
|
1403
|
-
'
|
|
1473
|
+
'get_in': {
|
|
1404
1474
|
evaluate: function (params, sourceCodeInfo) {
|
|
1405
1475
|
var e_1, _a;
|
|
1406
1476
|
var _b;
|
|
@@ -1474,13 +1544,20 @@ var collectionNormalExpression = {
|
|
|
1474
1544
|
assertColl(coll, sourceCodeInfo);
|
|
1475
1545
|
if (Array.isArray(coll))
|
|
1476
1546
|
return coll.includes(value);
|
|
1477
|
-
if (typeof coll === 'string')
|
|
1478
|
-
|
|
1547
|
+
if (typeof coll === 'string') {
|
|
1548
|
+
if (typeof value === 'string') {
|
|
1549
|
+
return coll.includes(value);
|
|
1550
|
+
}
|
|
1551
|
+
else if (typeof value === 'number') {
|
|
1552
|
+
return coll.includes("".concat(value));
|
|
1553
|
+
}
|
|
1554
|
+
return false;
|
|
1555
|
+
}
|
|
1479
1556
|
return Object.values(coll).includes(value);
|
|
1480
1557
|
},
|
|
1481
1558
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1482
1559
|
},
|
|
1483
|
-
'
|
|
1560
|
+
'has_some?': {
|
|
1484
1561
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1485
1562
|
var e_2, _b, e_3, _c, e_4, _d;
|
|
1486
1563
|
var _e = __read(_a, 2), coll = _e[0], seq = _e[1];
|
|
@@ -1540,7 +1617,7 @@ var collectionNormalExpression = {
|
|
|
1540
1617
|
},
|
|
1541
1618
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1542
1619
|
},
|
|
1543
|
-
'
|
|
1620
|
+
'has_every?': {
|
|
1544
1621
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1545
1622
|
var e_5, _b, e_6, _c, e_7, _d;
|
|
1546
1623
|
var _e = __read(_a, 2), coll = _e[0], seq = _e[1];
|
|
@@ -1612,7 +1689,7 @@ var collectionNormalExpression = {
|
|
|
1612
1689
|
},
|
|
1613
1690
|
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
1614
1691
|
},
|
|
1615
|
-
'
|
|
1692
|
+
'assoc_in': {
|
|
1616
1693
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1617
1694
|
var _b = __read(_a, 3), originalColl = _b[0], keys = _b[1], value = _b[2];
|
|
1618
1695
|
assertColl(originalColl, sourceCodeInfo);
|
|
@@ -1648,7 +1725,7 @@ var collectionNormalExpression = {
|
|
|
1648
1725
|
},
|
|
1649
1726
|
validate: function (node) { return assertNumberOfParams({ min: 3 }, node); },
|
|
1650
1727
|
},
|
|
1651
|
-
'
|
|
1728
|
+
'update_in': {
|
|
1652
1729
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1653
1730
|
var _c = __read(_a), originalColl = _c[0], keys = _c[1], fn = _c[2], params = _c.slice(3);
|
|
1654
1731
|
var executeFunction = _b.executeFunction;
|
|
@@ -1698,7 +1775,7 @@ var collectionNormalExpression = {
|
|
|
1698
1775
|
},
|
|
1699
1776
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
1700
1777
|
},
|
|
1701
|
-
'
|
|
1778
|
+
'not_empty': {
|
|
1702
1779
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1703
1780
|
var _b = __read(_a, 1), coll = _b[0];
|
|
1704
1781
|
if (coll === null)
|
|
@@ -1714,10 +1791,10 @@ var collectionNormalExpression = {
|
|
|
1714
1791
|
},
|
|
1715
1792
|
'every?': {
|
|
1716
1793
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1717
|
-
var _c = __read(_a, 2),
|
|
1794
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1718
1795
|
var executeFunction = _b.executeFunction;
|
|
1719
|
-
assertLitsFunction(fn, sourceCodeInfo);
|
|
1720
1796
|
assertColl(coll, sourceCodeInfo);
|
|
1797
|
+
assertLitsFunction(fn, sourceCodeInfo);
|
|
1721
1798
|
if (Array.isArray(coll))
|
|
1722
1799
|
return coll.every(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
|
|
1723
1800
|
if (typeof coll === 'string')
|
|
@@ -1728,7 +1805,7 @@ var collectionNormalExpression = {
|
|
|
1728
1805
|
},
|
|
1729
1806
|
'any?': {
|
|
1730
1807
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1731
|
-
var _c = __read(_a, 2),
|
|
1808
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1732
1809
|
var executeFunction = _b.executeFunction;
|
|
1733
1810
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
1734
1811
|
assertColl(coll, sourceCodeInfo);
|
|
@@ -1740,9 +1817,9 @@ var collectionNormalExpression = {
|
|
|
1740
1817
|
},
|
|
1741
1818
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1742
1819
|
},
|
|
1743
|
-
'
|
|
1820
|
+
'not_any?': {
|
|
1744
1821
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1745
|
-
var _c = __read(_a, 2),
|
|
1822
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1746
1823
|
var executeFunction = _b.executeFunction;
|
|
1747
1824
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
1748
1825
|
assertColl(coll, sourceCodeInfo);
|
|
@@ -1754,9 +1831,9 @@ var collectionNormalExpression = {
|
|
|
1754
1831
|
},
|
|
1755
1832
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1756
1833
|
},
|
|
1757
|
-
'
|
|
1834
|
+
'not_every?': {
|
|
1758
1835
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1759
|
-
var _c = __read(_a, 2),
|
|
1836
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1760
1837
|
var executeFunction = _b.executeFunction;
|
|
1761
1838
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
1762
1839
|
assertColl(coll, sourceCodeInfo);
|
|
@@ -1770,77 +1847,82 @@ var collectionNormalExpression = {
|
|
|
1770
1847
|
},
|
|
1771
1848
|
};
|
|
1772
1849
|
|
|
1773
|
-
var
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
var newVal = executeFunction(fn, [elem], contextStack, sourceCodeInfo);
|
|
1789
|
-
assertString(newVal, sourceCodeInfo, { char: true });
|
|
1790
|
-
return newVal;
|
|
1791
|
-
})
|
|
1792
|
-
.join('');
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
else {
|
|
1796
|
-
params.slice(2).forEach(function (collParam) {
|
|
1797
|
-
if (isStringSeq)
|
|
1798
|
-
assertString(collParam, sourceCodeInfo);
|
|
1799
|
-
else
|
|
1800
|
-
assertArray(collParam, sourceCodeInfo);
|
|
1801
|
-
if (length !== collParam.length)
|
|
1802
|
-
throw new LitsError('All arguments to "map" must have the same length.', sourceCodeInfo);
|
|
1803
|
-
});
|
|
1804
|
-
if (isStringSeq) {
|
|
1805
|
-
var result = '';
|
|
1806
|
-
var _loop_1 = function (i) {
|
|
1807
|
-
var fnParams = params.slice(1).map(function (l) { return l[i]; });
|
|
1808
|
-
var newValue = executeFunction(fn, fnParams, contextStack, sourceCodeInfo);
|
|
1809
|
-
assertString(newValue, sourceCodeInfo, { char: true });
|
|
1810
|
-
result += newValue;
|
|
1811
|
-
};
|
|
1812
|
-
for (var i = 0; i < length; i += 1) {
|
|
1813
|
-
_loop_1(i);
|
|
1850
|
+
var arrayNormalExpression = {
|
|
1851
|
+
array: {
|
|
1852
|
+
evaluate: function (params) { return params; },
|
|
1853
|
+
},
|
|
1854
|
+
range: {
|
|
1855
|
+
evaluate: function (params, sourceCodeInfo) {
|
|
1856
|
+
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1857
|
+
var from;
|
|
1858
|
+
var to;
|
|
1859
|
+
var step;
|
|
1860
|
+
assertNumber(first, sourceCodeInfo, { finite: true });
|
|
1861
|
+
if (params.length === 1) {
|
|
1862
|
+
from = 0;
|
|
1863
|
+
to = first;
|
|
1864
|
+
step = to >= 0 ? 1 : -1;
|
|
1814
1865
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1866
|
+
else if (params.length === 2) {
|
|
1867
|
+
assertNumber(second, sourceCodeInfo, { finite: true });
|
|
1868
|
+
from = first;
|
|
1869
|
+
to = second;
|
|
1870
|
+
step = to >= from ? 1 : -1;
|
|
1871
|
+
}
|
|
1872
|
+
else {
|
|
1873
|
+
assertNumber(second, sourceCodeInfo, { finite: true });
|
|
1874
|
+
assertNumber(third, sourceCodeInfo, { finite: true });
|
|
1875
|
+
from = first;
|
|
1876
|
+
to = second;
|
|
1877
|
+
step = third;
|
|
1878
|
+
if (to > from)
|
|
1879
|
+
assertNumber(step, sourceCodeInfo, { positive: true });
|
|
1880
|
+
else if (to < from)
|
|
1881
|
+
assertNumber(step, sourceCodeInfo, { negative: true });
|
|
1882
|
+
else
|
|
1883
|
+
assertNumber(step, sourceCodeInfo, { nonZero: true });
|
|
1825
1884
|
}
|
|
1885
|
+
var result = [];
|
|
1886
|
+
for (var i = from; step < 0 ? i > to : i < to; i += step)
|
|
1887
|
+
result.push(i);
|
|
1826
1888
|
return result;
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
'cons': {
|
|
1889
|
+
},
|
|
1890
|
+
validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
|
|
1891
|
+
},
|
|
1892
|
+
repeat: {
|
|
1832
1893
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1833
|
-
var _b = __read(_a, 2),
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1894
|
+
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1895
|
+
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
1896
|
+
var result = [];
|
|
1897
|
+
for (var i = 0; i < count; i += 1)
|
|
1898
|
+
result.push(value);
|
|
1899
|
+
return result;
|
|
1900
|
+
},
|
|
1901
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1902
|
+
},
|
|
1903
|
+
flatten: {
|
|
1904
|
+
evaluate: function (_a) {
|
|
1905
|
+
var _b = __read(_a, 1), seq = _b[0];
|
|
1906
|
+
if (!Array.isArray(seq))
|
|
1907
|
+
return [];
|
|
1908
|
+
return seq.flat(Number.POSITIVE_INFINITY);
|
|
1909
|
+
},
|
|
1910
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1911
|
+
},
|
|
1912
|
+
mapcat: {
|
|
1913
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1914
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1915
|
+
var executeFunction = _b.executeFunction;
|
|
1916
|
+
assertArray(arr, sourceCodeInfo);
|
|
1917
|
+
assertLitsFunction(fn, sourceCodeInfo);
|
|
1918
|
+
return arr.map(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); }).flat(1);
|
|
1840
1919
|
},
|
|
1841
1920
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1842
1921
|
},
|
|
1843
|
-
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
var sequenceNormalExpression = {
|
|
1925
|
+
nth: {
|
|
1844
1926
|
evaluate: function (params, sourceCodeInfo) {
|
|
1845
1927
|
var _a = __read(params, 2), seq = _a[0], i = _a[1];
|
|
1846
1928
|
var defaultValue = toAny(params[2]);
|
|
@@ -1852,12 +1934,12 @@ var sequenceNormalExpression = {
|
|
|
1852
1934
|
},
|
|
1853
1935
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
1854
1936
|
},
|
|
1855
|
-
|
|
1937
|
+
filter: {
|
|
1856
1938
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1857
|
-
var _c = __read(_a, 2),
|
|
1939
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1858
1940
|
var executeFunction = _b.executeFunction;
|
|
1859
|
-
assertLitsFunction(fn, sourceCodeInfo);
|
|
1860
1941
|
assertSeq(seq, sourceCodeInfo);
|
|
1942
|
+
assertLitsFunction(fn, sourceCodeInfo);
|
|
1861
1943
|
if (Array.isArray(seq))
|
|
1862
1944
|
return seq.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
|
|
1863
1945
|
return seq
|
|
@@ -1867,7 +1949,7 @@ var sequenceNormalExpression = {
|
|
|
1867
1949
|
},
|
|
1868
1950
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1869
1951
|
},
|
|
1870
|
-
|
|
1952
|
+
first: {
|
|
1871
1953
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1872
1954
|
var _b = __read(_a, 1), array = _b[0];
|
|
1873
1955
|
if (array === null)
|
|
@@ -1877,7 +1959,7 @@ var sequenceNormalExpression = {
|
|
|
1877
1959
|
},
|
|
1878
1960
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1879
1961
|
},
|
|
1880
|
-
|
|
1962
|
+
last: {
|
|
1881
1963
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1882
1964
|
var _b = __read(_a, 1), array = _b[0];
|
|
1883
1965
|
if (array === null)
|
|
@@ -1887,25 +1969,42 @@ var sequenceNormalExpression = {
|
|
|
1887
1969
|
},
|
|
1888
1970
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1889
1971
|
},
|
|
1890
|
-
|
|
1891
|
-
evaluate:
|
|
1892
|
-
|
|
1972
|
+
map: {
|
|
1973
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1974
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1975
|
+
var executeFunction = _b.executeFunction;
|
|
1976
|
+
assertSeq(seq, sourceCodeInfo);
|
|
1977
|
+
assertLitsFunction(fn, sourceCodeInfo);
|
|
1978
|
+
if (Array.isArray(seq)) {
|
|
1979
|
+
return seq.map(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
|
|
1980
|
+
}
|
|
1981
|
+
else {
|
|
1982
|
+
return seq
|
|
1983
|
+
.split('')
|
|
1984
|
+
.map(function (elem) {
|
|
1985
|
+
var newVal = executeFunction(fn, [elem], contextStack, sourceCodeInfo);
|
|
1986
|
+
assertString(newVal, sourceCodeInfo, { char: true });
|
|
1987
|
+
return newVal;
|
|
1988
|
+
})
|
|
1989
|
+
.join('');
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1893
1993
|
},
|
|
1894
|
-
|
|
1994
|
+
pop: {
|
|
1895
1995
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1896
1996
|
var _b = __read(_a, 1), seq = _b[0];
|
|
1897
1997
|
assertSeq(seq, sourceCodeInfo);
|
|
1898
|
-
if (typeof seq === 'string')
|
|
1998
|
+
if (typeof seq === 'string') {
|
|
1899
1999
|
return seq.substring(0, seq.length - 1);
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
return copy;
|
|
2000
|
+
}
|
|
2001
|
+
return seq.slice(0, seq.length - 1);
|
|
1903
2002
|
},
|
|
1904
2003
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1905
2004
|
},
|
|
1906
|
-
|
|
2005
|
+
position: {
|
|
1907
2006
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1908
|
-
var _c = __read(_a, 2),
|
|
2007
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1909
2008
|
var executeFunction = _b.executeFunction;
|
|
1910
2009
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
1911
2010
|
if (seq === null)
|
|
@@ -1922,7 +2021,7 @@ var sequenceNormalExpression = {
|
|
|
1922
2021
|
},
|
|
1923
2022
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1924
2023
|
},
|
|
1925
|
-
|
|
2024
|
+
index_of: {
|
|
1926
2025
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1927
2026
|
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
1928
2027
|
assertAny(value, sourceCodeInfo);
|
|
@@ -1941,7 +2040,7 @@ var sequenceNormalExpression = {
|
|
|
1941
2040
|
},
|
|
1942
2041
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1943
2042
|
},
|
|
1944
|
-
|
|
2043
|
+
push: {
|
|
1945
2044
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1946
2045
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
1947
2046
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -1955,20 +2054,19 @@ var sequenceNormalExpression = {
|
|
|
1955
2054
|
},
|
|
1956
2055
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
1957
2056
|
},
|
|
1958
|
-
|
|
2057
|
+
reductions: {
|
|
1959
2058
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1960
2059
|
var executeFunction = _a.executeFunction;
|
|
1961
|
-
var
|
|
2060
|
+
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
2061
|
+
assertSeq(seq, sourceCodeInfo);
|
|
1962
2062
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
1963
2063
|
if (params.length === 2) {
|
|
1964
|
-
|
|
1965
|
-
assertSeq(arr, sourceCodeInfo);
|
|
1966
|
-
if (arr.length === 0)
|
|
2064
|
+
if (seq.length === 0)
|
|
1967
2065
|
return [executeFunction(fn, [], contextStack, sourceCodeInfo)];
|
|
1968
|
-
else if (
|
|
1969
|
-
return [toAny(
|
|
1970
|
-
if (typeof
|
|
1971
|
-
var chars =
|
|
2066
|
+
else if (seq.length === 1)
|
|
2067
|
+
return [toAny(seq[0])];
|
|
2068
|
+
if (typeof seq === 'string') {
|
|
2069
|
+
var chars = seq.split('');
|
|
1972
2070
|
var resultArray_1 = [asAny(chars[0], sourceCodeInfo)];
|
|
1973
2071
|
chars.slice(1).reduce(function (result, elem) {
|
|
1974
2072
|
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
@@ -1978,19 +2076,18 @@ var sequenceNormalExpression = {
|
|
|
1978
2076
|
return resultArray_1;
|
|
1979
2077
|
}
|
|
1980
2078
|
else {
|
|
1981
|
-
var resultArray_2 = [toAny(
|
|
1982
|
-
|
|
2079
|
+
var resultArray_2 = [toAny(seq[0])];
|
|
2080
|
+
seq.slice(1).reduce(function (result, elem) {
|
|
1983
2081
|
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1984
2082
|
resultArray_2.push(newVal);
|
|
1985
2083
|
return newVal;
|
|
1986
|
-
}, toAny(
|
|
2084
|
+
}, toAny(seq[0]));
|
|
1987
2085
|
return resultArray_2;
|
|
1988
2086
|
}
|
|
1989
2087
|
}
|
|
1990
2088
|
else {
|
|
1991
|
-
var
|
|
2089
|
+
var val = params[2];
|
|
1992
2090
|
assertAny(val, sourceCodeInfo);
|
|
1993
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1994
2091
|
if (typeof seq === 'string') {
|
|
1995
2092
|
assertString(val, sourceCodeInfo);
|
|
1996
2093
|
if (seq.length === 0)
|
|
@@ -2018,35 +2115,33 @@ var sequenceNormalExpression = {
|
|
|
2018
2115
|
},
|
|
2019
2116
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2020
2117
|
},
|
|
2021
|
-
|
|
2118
|
+
reduce: {
|
|
2022
2119
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2023
2120
|
var executeFunction = _a.executeFunction;
|
|
2024
|
-
var
|
|
2121
|
+
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
2122
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2025
2123
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2026
2124
|
if (params.length === 2) {
|
|
2027
|
-
|
|
2028
|
-
assertSeq(arr, sourceCodeInfo);
|
|
2029
|
-
if (arr.length === 0)
|
|
2125
|
+
if (seq.length === 0)
|
|
2030
2126
|
return executeFunction(fn, [], contextStack, sourceCodeInfo);
|
|
2031
|
-
else if (
|
|
2032
|
-
return toAny(
|
|
2033
|
-
if (typeof
|
|
2034
|
-
var chars =
|
|
2127
|
+
else if (seq.length === 1)
|
|
2128
|
+
return toAny(seq[0]);
|
|
2129
|
+
if (typeof seq === 'string') {
|
|
2130
|
+
var chars = seq.split('');
|
|
2035
2131
|
return chars.slice(1).reduce(function (result, elem) {
|
|
2036
2132
|
var val = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
2037
2133
|
return val;
|
|
2038
2134
|
}, asAny(chars[0], sourceCodeInfo));
|
|
2039
2135
|
}
|
|
2040
2136
|
else {
|
|
2041
|
-
return
|
|
2137
|
+
return seq.slice(1).reduce(function (result, elem) {
|
|
2042
2138
|
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
2043
|
-
}, toAny(
|
|
2139
|
+
}, toAny(seq[0]));
|
|
2044
2140
|
}
|
|
2045
2141
|
}
|
|
2046
2142
|
else {
|
|
2047
|
-
var
|
|
2143
|
+
var val = params[2];
|
|
2048
2144
|
assertAny(val, sourceCodeInfo);
|
|
2049
|
-
assertSeq(seq, sourceCodeInfo);
|
|
2050
2145
|
if (typeof seq === 'string') {
|
|
2051
2146
|
assertString(val, sourceCodeInfo);
|
|
2052
2147
|
if (seq.length === 0)
|
|
@@ -2067,14 +2162,13 @@ var sequenceNormalExpression = {
|
|
|
2067
2162
|
},
|
|
2068
2163
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2069
2164
|
},
|
|
2070
|
-
|
|
2165
|
+
reduce_right: {
|
|
2071
2166
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2072
2167
|
var executeFunction = _a.executeFunction;
|
|
2073
|
-
var
|
|
2168
|
+
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
2169
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2074
2170
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2075
2171
|
if (params.length === 2) {
|
|
2076
|
-
var _b = __read(params, 2), seq = _b[1];
|
|
2077
|
-
assertSeq(seq, sourceCodeInfo);
|
|
2078
2172
|
if (seq.length === 0)
|
|
2079
2173
|
return executeFunction(fn, [], contextStack, sourceCodeInfo);
|
|
2080
2174
|
else if (seq.length === 1)
|
|
@@ -2094,7 +2188,7 @@ var sequenceNormalExpression = {
|
|
|
2094
2188
|
}
|
|
2095
2189
|
}
|
|
2096
2190
|
else {
|
|
2097
|
-
var
|
|
2191
|
+
var val = params[2];
|
|
2098
2192
|
assertAny(val, sourceCodeInfo);
|
|
2099
2193
|
assertSeq(seq, sourceCodeInfo);
|
|
2100
2194
|
if (typeof seq === 'string') {
|
|
@@ -2116,20 +2210,20 @@ var sequenceNormalExpression = {
|
|
|
2116
2210
|
},
|
|
2117
2211
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2118
2212
|
},
|
|
2119
|
-
|
|
2213
|
+
rest: {
|
|
2120
2214
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2121
|
-
var _b = __read(_a, 1),
|
|
2122
|
-
assertSeq(
|
|
2123
|
-
if (Array.isArray(
|
|
2124
|
-
if (
|
|
2215
|
+
var _b = __read(_a, 1), seq = _b[0];
|
|
2216
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2217
|
+
if (Array.isArray(seq)) {
|
|
2218
|
+
if (seq.length <= 1)
|
|
2125
2219
|
return [];
|
|
2126
|
-
return
|
|
2220
|
+
return seq.slice(1);
|
|
2127
2221
|
}
|
|
2128
|
-
return
|
|
2222
|
+
return seq.substring(1);
|
|
2129
2223
|
},
|
|
2130
2224
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2131
2225
|
},
|
|
2132
|
-
|
|
2226
|
+
nthrest: {
|
|
2133
2227
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2134
2228
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2135
2229
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2141,22 +2235,22 @@ var sequenceNormalExpression = {
|
|
|
2141
2235
|
},
|
|
2142
2236
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2143
2237
|
},
|
|
2144
|
-
|
|
2238
|
+
next: {
|
|
2145
2239
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2146
|
-
var _b = __read(_a, 1),
|
|
2147
|
-
assertSeq(
|
|
2148
|
-
if (Array.isArray(
|
|
2149
|
-
if (
|
|
2240
|
+
var _b = __read(_a, 1), seq = _b[0];
|
|
2241
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2242
|
+
if (Array.isArray(seq)) {
|
|
2243
|
+
if (seq.length <= 1)
|
|
2150
2244
|
return null;
|
|
2151
|
-
return
|
|
2245
|
+
return seq.slice(1);
|
|
2152
2246
|
}
|
|
2153
|
-
if (
|
|
2247
|
+
if (seq.length <= 1)
|
|
2154
2248
|
return null;
|
|
2155
|
-
return
|
|
2249
|
+
return seq.substring(1);
|
|
2156
2250
|
},
|
|
2157
2251
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2158
2252
|
},
|
|
2159
|
-
|
|
2253
|
+
nthnext: {
|
|
2160
2254
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2161
2255
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2162
2256
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2170,7 +2264,7 @@ var sequenceNormalExpression = {
|
|
|
2170
2264
|
},
|
|
2171
2265
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2172
2266
|
},
|
|
2173
|
-
|
|
2267
|
+
reverse: {
|
|
2174
2268
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2175
2269
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2176
2270
|
if (seq === null)
|
|
@@ -2182,17 +2276,17 @@ var sequenceNormalExpression = {
|
|
|
2182
2276
|
},
|
|
2183
2277
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2184
2278
|
},
|
|
2185
|
-
|
|
2279
|
+
second: {
|
|
2186
2280
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2187
|
-
var _b = __read(_a, 1),
|
|
2188
|
-
if (
|
|
2281
|
+
var _b = __read(_a, 1), seq = _b[0];
|
|
2282
|
+
if (seq === null)
|
|
2189
2283
|
return null;
|
|
2190
|
-
assertSeq(
|
|
2191
|
-
return toAny(
|
|
2284
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2285
|
+
return toAny(seq[1]);
|
|
2192
2286
|
},
|
|
2193
2287
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2194
2288
|
},
|
|
2195
|
-
|
|
2289
|
+
shift: {
|
|
2196
2290
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2197
2291
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2198
2292
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2204,7 +2298,7 @@ var sequenceNormalExpression = {
|
|
|
2204
2298
|
},
|
|
2205
2299
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2206
2300
|
},
|
|
2207
|
-
|
|
2301
|
+
slice: {
|
|
2208
2302
|
evaluate: function (params, sourceCodeInfo) {
|
|
2209
2303
|
var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
|
|
2210
2304
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2218,10 +2312,10 @@ var sequenceNormalExpression = {
|
|
|
2218
2312
|
},
|
|
2219
2313
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
|
|
2220
2314
|
},
|
|
2221
|
-
|
|
2315
|
+
some: {
|
|
2222
2316
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2223
2317
|
var _c;
|
|
2224
|
-
var _d = __read(_a, 2),
|
|
2318
|
+
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
2225
2319
|
var executeFunction = _b.executeFunction;
|
|
2226
2320
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2227
2321
|
if (seq === null)
|
|
@@ -2235,12 +2329,12 @@ var sequenceNormalExpression = {
|
|
|
2235
2329
|
},
|
|
2236
2330
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2237
2331
|
},
|
|
2238
|
-
|
|
2332
|
+
sort: {
|
|
2239
2333
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2240
2334
|
var executeFunction = _a.executeFunction;
|
|
2335
|
+
var _b = __read(params, 1), seq = _b[0];
|
|
2241
2336
|
var defaultComparer = params.length === 1;
|
|
2242
|
-
var
|
|
2243
|
-
var comparer = defaultComparer ? null : params[0];
|
|
2337
|
+
var comparer = defaultComparer ? null : params[1];
|
|
2244
2338
|
assertSeq(seq, sourceCodeInfo);
|
|
2245
2339
|
if (typeof seq === 'string') {
|
|
2246
2340
|
var result_1 = seq.split('');
|
|
@@ -2273,13 +2367,14 @@ var sequenceNormalExpression = {
|
|
|
2273
2367
|
},
|
|
2274
2368
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
2275
2369
|
},
|
|
2276
|
-
|
|
2370
|
+
sort_by: {
|
|
2277
2371
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2278
2372
|
var executeFunction = _a.executeFunction;
|
|
2373
|
+
var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
|
|
2279
2374
|
var defaultComparer = params.length === 2;
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
var
|
|
2375
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2376
|
+
assertAny(keyfn, sourceCodeInfo);
|
|
2377
|
+
var comparer = defaultComparer ? null : params[2];
|
|
2283
2378
|
if (typeof seq === 'string') {
|
|
2284
2379
|
var result_2 = seq.split('');
|
|
2285
2380
|
if (defaultComparer) {
|
|
@@ -2323,9 +2418,9 @@ var sequenceNormalExpression = {
|
|
|
2323
2418
|
},
|
|
2324
2419
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2325
2420
|
},
|
|
2326
|
-
|
|
2421
|
+
take: {
|
|
2327
2422
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2328
|
-
var _b = __read(_a, 2),
|
|
2423
|
+
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2329
2424
|
assertNumber(n, sourceCodeInfo);
|
|
2330
2425
|
assertSeq(input, sourceCodeInfo);
|
|
2331
2426
|
var num = Math.max(Math.ceil(n), 0);
|
|
@@ -2333,9 +2428,9 @@ var sequenceNormalExpression = {
|
|
|
2333
2428
|
},
|
|
2334
2429
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2335
2430
|
},
|
|
2336
|
-
|
|
2431
|
+
take_last: {
|
|
2337
2432
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2338
|
-
var _b = __read(_a, 2),
|
|
2433
|
+
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2339
2434
|
assertSeq(array, sourceCodeInfo);
|
|
2340
2435
|
assertNumber(n, sourceCodeInfo);
|
|
2341
2436
|
var num = Math.max(Math.ceil(n), 0);
|
|
@@ -2344,10 +2439,10 @@ var sequenceNormalExpression = {
|
|
|
2344
2439
|
},
|
|
2345
2440
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2346
2441
|
},
|
|
2347
|
-
|
|
2442
|
+
take_while: {
|
|
2348
2443
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2349
2444
|
var e_1, _c;
|
|
2350
|
-
var _d = __read(_a, 2),
|
|
2445
|
+
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
2351
2446
|
var executeFunction = _b.executeFunction;
|
|
2352
2447
|
assertSeq(seq, sourceCodeInfo);
|
|
2353
2448
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
@@ -2372,9 +2467,9 @@ var sequenceNormalExpression = {
|
|
|
2372
2467
|
},
|
|
2373
2468
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2374
2469
|
},
|
|
2375
|
-
|
|
2470
|
+
drop: {
|
|
2376
2471
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2377
|
-
var _b = __read(_a, 2),
|
|
2472
|
+
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2378
2473
|
assertNumber(n, sourceCodeInfo);
|
|
2379
2474
|
var num = Math.max(Math.ceil(n), 0);
|
|
2380
2475
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2382,9 +2477,9 @@ var sequenceNormalExpression = {
|
|
|
2382
2477
|
},
|
|
2383
2478
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2384
2479
|
},
|
|
2385
|
-
|
|
2480
|
+
drop_last: {
|
|
2386
2481
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2387
|
-
var _b = __read(_a, 2),
|
|
2482
|
+
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2388
2483
|
assertSeq(array, sourceCodeInfo);
|
|
2389
2484
|
assertNumber(n, sourceCodeInfo);
|
|
2390
2485
|
var num = Math.max(Math.ceil(n), 0);
|
|
@@ -2393,9 +2488,9 @@ var sequenceNormalExpression = {
|
|
|
2393
2488
|
},
|
|
2394
2489
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2395
2490
|
},
|
|
2396
|
-
|
|
2491
|
+
drop_while: {
|
|
2397
2492
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2398
|
-
var _c = __read(_a, 2),
|
|
2493
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2399
2494
|
var executeFunction = _b.executeFunction;
|
|
2400
2495
|
assertSeq(seq, sourceCodeInfo);
|
|
2401
2496
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
@@ -2409,7 +2504,7 @@ var sequenceNormalExpression = {
|
|
|
2409
2504
|
},
|
|
2410
2505
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2411
2506
|
},
|
|
2412
|
-
|
|
2507
|
+
unshift: {
|
|
2413
2508
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2414
2509
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2415
2510
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2423,59 +2518,7 @@ var sequenceNormalExpression = {
|
|
|
2423
2518
|
},
|
|
2424
2519
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2425
2520
|
},
|
|
2426
|
-
|
|
2427
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2428
|
-
var _b = __read(_a, 2), prob = _b[0], seq = _b[1];
|
|
2429
|
-
assertNumber(prob, sourceCodeInfo, { finite: true });
|
|
2430
|
-
assertSeq(seq, sourceCodeInfo);
|
|
2431
|
-
if (typeof seq === 'string') {
|
|
2432
|
-
return seq
|
|
2433
|
-
.split('')
|
|
2434
|
-
.filter(function () { return Math.random() < prob; })
|
|
2435
|
-
.join('');
|
|
2436
|
-
}
|
|
2437
|
-
else {
|
|
2438
|
-
return seq.filter(function () { return Math.random() < prob; });
|
|
2439
|
-
}
|
|
2440
|
-
},
|
|
2441
|
-
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2442
|
-
},
|
|
2443
|
-
'rand-nth!': {
|
|
2444
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2445
|
-
var _b = __read(_a, 1), seq = _b[0];
|
|
2446
|
-
assertSeq(seq, sourceCodeInfo);
|
|
2447
|
-
if (seq.length === 0)
|
|
2448
|
-
return null;
|
|
2449
|
-
var index = Math.floor(Math.random() * seq.length);
|
|
2450
|
-
if (typeof seq === 'string')
|
|
2451
|
-
return toAny(seq.split('')[index]);
|
|
2452
|
-
return toAny(seq[index]);
|
|
2453
|
-
},
|
|
2454
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2455
|
-
},
|
|
2456
|
-
'shuffle!': {
|
|
2457
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2458
|
-
var _b = __read(_a, 1), input = _b[0];
|
|
2459
|
-
assertSeq(input, sourceCodeInfo);
|
|
2460
|
-
var array = typeof input === 'string' ? __spreadArray([], __read(input.split('')), false) : __spreadArray([], __read(input), false);
|
|
2461
|
-
var remainingLength = array.length;
|
|
2462
|
-
var arrayElement;
|
|
2463
|
-
var pickedIndex;
|
|
2464
|
-
// Fisher–Yates Shuffle
|
|
2465
|
-
while (remainingLength) {
|
|
2466
|
-
remainingLength -= 1;
|
|
2467
|
-
// Pick a remaining element
|
|
2468
|
-
pickedIndex = Math.floor(Math.random() * remainingLength);
|
|
2469
|
-
// And swap it with the current element.
|
|
2470
|
-
arrayElement = toAny(array[remainingLength]);
|
|
2471
|
-
array[remainingLength] = toAny(array[pickedIndex]);
|
|
2472
|
-
array[pickedIndex] = arrayElement;
|
|
2473
|
-
}
|
|
2474
|
-
return typeof input === 'string' ? array.join('') : array;
|
|
2475
|
-
},
|
|
2476
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2477
|
-
},
|
|
2478
|
-
'distinct': {
|
|
2521
|
+
distinct: {
|
|
2479
2522
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2480
2523
|
var _b = __read(_a, 1), input = _b[0];
|
|
2481
2524
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2485,7 +2528,7 @@ var sequenceNormalExpression = {
|
|
|
2485
2528
|
},
|
|
2486
2529
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2487
2530
|
},
|
|
2488
|
-
|
|
2531
|
+
remove: {
|
|
2489
2532
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2490
2533
|
var _c = __read(_a, 2), fn = _c[0], input = _c[1];
|
|
2491
2534
|
var executeFunction = _b.executeFunction;
|
|
@@ -2500,7 +2543,7 @@ var sequenceNormalExpression = {
|
|
|
2500
2543
|
},
|
|
2501
2544
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2502
2545
|
},
|
|
2503
|
-
|
|
2546
|
+
remove_at: {
|
|
2504
2547
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2505
2548
|
var _b = __read(_a, 2), index = _b[0], input = _b[1];
|
|
2506
2549
|
assertNumber(index, sourceCodeInfo);
|
|
@@ -2517,7 +2560,7 @@ var sequenceNormalExpression = {
|
|
|
2517
2560
|
},
|
|
2518
2561
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2519
2562
|
},
|
|
2520
|
-
|
|
2563
|
+
split_at: {
|
|
2521
2564
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2522
2565
|
var _b = __read(_a, 2), pos = _b[0], seq = _b[1];
|
|
2523
2566
|
assertNumber(pos, sourceCodeInfo, { finite: true });
|
|
@@ -2527,7 +2570,7 @@ var sequenceNormalExpression = {
|
|
|
2527
2570
|
},
|
|
2528
2571
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2529
2572
|
},
|
|
2530
|
-
|
|
2573
|
+
split_with: {
|
|
2531
2574
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2532
2575
|
var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
|
|
2533
2576
|
var executeFunction = _b.executeFunction;
|
|
@@ -2542,7 +2585,7 @@ var sequenceNormalExpression = {
|
|
|
2542
2585
|
},
|
|
2543
2586
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2544
2587
|
},
|
|
2545
|
-
|
|
2588
|
+
frequencies: {
|
|
2546
2589
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2547
2590
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2548
2591
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2558,7 +2601,7 @@ var sequenceNormalExpression = {
|
|
|
2558
2601
|
},
|
|
2559
2602
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2560
2603
|
},
|
|
2561
|
-
|
|
2604
|
+
group_by: {
|
|
2562
2605
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2563
2606
|
var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
|
|
2564
2607
|
var executeFunction = _b.executeFunction;
|
|
@@ -2576,7 +2619,7 @@ var sequenceNormalExpression = {
|
|
|
2576
2619
|
},
|
|
2577
2620
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2578
2621
|
},
|
|
2579
|
-
|
|
2622
|
+
partition: {
|
|
2580
2623
|
evaluate: function (params, sourceCodeInfo) {
|
|
2581
2624
|
var len = params.length;
|
|
2582
2625
|
var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
|
|
@@ -2591,7 +2634,7 @@ var sequenceNormalExpression = {
|
|
|
2591
2634
|
},
|
|
2592
2635
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
|
|
2593
2636
|
},
|
|
2594
|
-
|
|
2637
|
+
partition_all: {
|
|
2595
2638
|
evaluate: function (params, sourceCodeInfo) {
|
|
2596
2639
|
var len = params.length;
|
|
2597
2640
|
var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
|
|
@@ -2601,7 +2644,7 @@ var sequenceNormalExpression = {
|
|
|
2601
2644
|
},
|
|
2602
2645
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2603
2646
|
},
|
|
2604
|
-
|
|
2647
|
+
partition_by: {
|
|
2605
2648
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2606
2649
|
var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
|
|
2607
2650
|
var executeFunction = _b.executeFunction;
|
|
@@ -2651,94 +2694,22 @@ function partition(n, step, seq, pad, sourceCodeInfo) {
|
|
|
2651
2694
|
return isStringSeq ? result.map(function (x) { return x.join(''); }) : result;
|
|
2652
2695
|
}
|
|
2653
2696
|
|
|
2654
|
-
var
|
|
2655
|
-
|
|
2656
|
-
evaluate: function (
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
2661
|
-
var from;
|
|
2662
|
-
var to;
|
|
2663
|
-
var step;
|
|
2664
|
-
assertNumber(first, sourceCodeInfo, { finite: true });
|
|
2665
|
-
if (params.length === 1) {
|
|
2666
|
-
from = 0;
|
|
2667
|
-
to = first;
|
|
2668
|
-
step = to >= 0 ? 1 : -1;
|
|
2669
|
-
}
|
|
2670
|
-
else if (params.length === 2) {
|
|
2671
|
-
assertNumber(second, sourceCodeInfo, { finite: true });
|
|
2672
|
-
from = first;
|
|
2673
|
-
to = second;
|
|
2674
|
-
step = to >= from ? 1 : -1;
|
|
2675
|
-
}
|
|
2676
|
-
else {
|
|
2677
|
-
assertNumber(second, sourceCodeInfo, { finite: true });
|
|
2678
|
-
assertNumber(third, sourceCodeInfo, { finite: true });
|
|
2679
|
-
from = first;
|
|
2680
|
-
to = second;
|
|
2681
|
-
step = third;
|
|
2682
|
-
if (to > from)
|
|
2683
|
-
assertNumber(step, sourceCodeInfo, { positive: true });
|
|
2684
|
-
else if (to < from)
|
|
2685
|
-
assertNumber(step, sourceCodeInfo, { negative: true });
|
|
2686
|
-
else
|
|
2687
|
-
assertNumber(step, sourceCodeInfo, { nonZero: true });
|
|
2688
|
-
}
|
|
2689
|
-
var result = [];
|
|
2690
|
-
for (var i = from; step < 0 ? i > to : i < to; i += step)
|
|
2691
|
-
result.push(i);
|
|
2692
|
-
return result;
|
|
2697
|
+
var mathNormalExpression = {
|
|
2698
|
+
'inc': {
|
|
2699
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2700
|
+
var _b = __read(_a, 1), first = _b[0];
|
|
2701
|
+
assertNumber(first, sourceCodeInfo);
|
|
2702
|
+
return first + 1;
|
|
2693
2703
|
},
|
|
2694
|
-
validate: function (node) { return assertNumberOfParams(
|
|
2704
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2695
2705
|
},
|
|
2696
|
-
|
|
2706
|
+
'dec': {
|
|
2697
2707
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2698
|
-
var _b = __read(_a,
|
|
2699
|
-
assertNumber(
|
|
2700
|
-
|
|
2701
|
-
for (var i = 0; i < count; i += 1)
|
|
2702
|
-
result.push(value);
|
|
2703
|
-
return result;
|
|
2708
|
+
var _b = __read(_a, 1), first = _b[0];
|
|
2709
|
+
assertNumber(first, sourceCodeInfo);
|
|
2710
|
+
return first - 1;
|
|
2704
2711
|
},
|
|
2705
|
-
validate: function (node) { return assertNumberOfParams(
|
|
2706
|
-
},
|
|
2707
|
-
flatten: {
|
|
2708
|
-
evaluate: function (_a) {
|
|
2709
|
-
var _b = __read(_a, 1), seq = _b[0];
|
|
2710
|
-
if (!Array.isArray(seq))
|
|
2711
|
-
return [];
|
|
2712
|
-
return seq.flat(Number.POSITIVE_INFINITY);
|
|
2713
|
-
},
|
|
2714
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2715
|
-
},
|
|
2716
|
-
mapcat: {
|
|
2717
|
-
evaluate: function (params, sourceCodeInfo, contextStack, helpers) {
|
|
2718
|
-
var mapResult = evaluateMap(params, sourceCodeInfo, contextStack, helpers);
|
|
2719
|
-
assertArray(mapResult, sourceCodeInfo);
|
|
2720
|
-
return mapResult.flat(1);
|
|
2721
|
-
},
|
|
2722
|
-
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2723
|
-
},
|
|
2724
|
-
};
|
|
2725
|
-
|
|
2726
|
-
var mathNormalExpression = {
|
|
2727
|
-
'inc': {
|
|
2728
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2729
|
-
var _b = __read(_a, 1), first = _b[0];
|
|
2730
|
-
assertNumber(first, sourceCodeInfo);
|
|
2731
|
-
return first + 1;
|
|
2732
|
-
},
|
|
2733
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2734
|
-
},
|
|
2735
|
-
'dec': {
|
|
2736
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2737
|
-
var _b = __read(_a, 1), first = _b[0];
|
|
2738
|
-
assertNumber(first, sourceCodeInfo);
|
|
2739
|
-
return first - 1;
|
|
2740
|
-
},
|
|
2741
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2712
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2742
2713
|
},
|
|
2743
2714
|
'+': {
|
|
2744
2715
|
evaluate: function (params, sourceCodeInfo) {
|
|
@@ -2877,21 +2848,6 @@ var mathNormalExpression = {
|
|
|
2877
2848
|
},
|
|
2878
2849
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2879
2850
|
},
|
|
2880
|
-
'rand!': {
|
|
2881
|
-
evaluate: function (parameters, sourceCodeInfo) {
|
|
2882
|
-
var num = asNumber(parameters.length === 1 ? parameters[0] : 1, sourceCodeInfo);
|
|
2883
|
-
return Math.random() * num;
|
|
2884
|
-
},
|
|
2885
|
-
validate: function (node) { return assertNumberOfParams({ min: 0, max: 1 }, node); },
|
|
2886
|
-
},
|
|
2887
|
-
'rand-int!': {
|
|
2888
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
2889
|
-
var _b = __read(_a, 1), first = _b[0];
|
|
2890
|
-
assertNumber(first, sourceCodeInfo);
|
|
2891
|
-
return Math.floor(Math.random() * Math.abs(first)) * Math.sign(first);
|
|
2892
|
-
},
|
|
2893
|
-
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2894
|
-
},
|
|
2895
2851
|
'min': {
|
|
2896
2852
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2897
2853
|
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
@@ -2934,25 +2890,25 @@ var mathNormalExpression = {
|
|
|
2934
2890
|
},
|
|
2935
2891
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2936
2892
|
},
|
|
2937
|
-
'
|
|
2893
|
+
'max_safe_integer': {
|
|
2938
2894
|
evaluate: function () {
|
|
2939
2895
|
return Number.MAX_SAFE_INTEGER;
|
|
2940
2896
|
},
|
|
2941
2897
|
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
2942
2898
|
},
|
|
2943
|
-
'
|
|
2899
|
+
'min_safe_integer': {
|
|
2944
2900
|
evaluate: function () {
|
|
2945
2901
|
return Number.MIN_SAFE_INTEGER;
|
|
2946
2902
|
},
|
|
2947
2903
|
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
2948
2904
|
},
|
|
2949
|
-
'
|
|
2905
|
+
'max_value': {
|
|
2950
2906
|
evaluate: function () {
|
|
2951
2907
|
return Number.MAX_VALUE;
|
|
2952
2908
|
},
|
|
2953
2909
|
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
2954
2910
|
},
|
|
2955
|
-
'
|
|
2911
|
+
'min_value': {
|
|
2956
2912
|
evaluate: function () {
|
|
2957
2913
|
return Number.MIN_VALUE;
|
|
2958
2914
|
},
|
|
@@ -2964,13 +2920,13 @@ var mathNormalExpression = {
|
|
|
2964
2920
|
},
|
|
2965
2921
|
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
2966
2922
|
},
|
|
2967
|
-
'
|
|
2923
|
+
'positive_infinity': {
|
|
2968
2924
|
evaluate: function () {
|
|
2969
2925
|
return Number.POSITIVE_INFINITY;
|
|
2970
2926
|
},
|
|
2971
2927
|
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
2972
2928
|
},
|
|
2973
|
-
'
|
|
2929
|
+
'negative_infinity': {
|
|
2974
2930
|
evaluate: function () {
|
|
2975
2931
|
return Number.NEGATIVE_INFINITY;
|
|
2976
2932
|
},
|
|
@@ -3124,12 +3080,12 @@ var mathNormalExpression = {
|
|
|
3124
3080
|
},
|
|
3125
3081
|
};
|
|
3126
3082
|
|
|
3127
|
-
var version = "2.0.
|
|
3083
|
+
var version = "2.0.13";
|
|
3128
3084
|
|
|
3129
3085
|
var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
3130
3086
|
var xyRegexp = /[xy]/g;
|
|
3131
3087
|
var miscNormalExpression = {
|
|
3132
|
-
'
|
|
3088
|
+
'!=': {
|
|
3133
3089
|
evaluate: function (params) {
|
|
3134
3090
|
for (var i = 0; i < params.length - 1; i += 1) {
|
|
3135
3091
|
for (var j = i + 1; j < params.length; j += 1) {
|
|
@@ -3380,7 +3336,7 @@ var assertNormalExpression = {
|
|
|
3380
3336
|
},
|
|
3381
3337
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3382
3338
|
},
|
|
3383
|
-
'assert
|
|
3339
|
+
'assert!=': {
|
|
3384
3340
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3385
3341
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3386
3342
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3390,7 +3346,7 @@ var assertNormalExpression = {
|
|
|
3390
3346
|
},
|
|
3391
3347
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3392
3348
|
},
|
|
3393
|
-
'
|
|
3349
|
+
'assert_equal': {
|
|
3394
3350
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3395
3351
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3396
3352
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3401,7 +3357,7 @@ var assertNormalExpression = {
|
|
|
3401
3357
|
},
|
|
3402
3358
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3403
3359
|
},
|
|
3404
|
-
'
|
|
3360
|
+
'assert_not_equal': {
|
|
3405
3361
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3406
3362
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3407
3363
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3412,7 +3368,7 @@ var assertNormalExpression = {
|
|
|
3412
3368
|
},
|
|
3413
3369
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3414
3370
|
},
|
|
3415
|
-
'
|
|
3371
|
+
'assert_gt': {
|
|
3416
3372
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3417
3373
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3418
3374
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3422,7 +3378,7 @@ var assertNormalExpression = {
|
|
|
3422
3378
|
},
|
|
3423
3379
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3424
3380
|
},
|
|
3425
|
-
'
|
|
3381
|
+
'assert_gte': {
|
|
3426
3382
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3427
3383
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3428
3384
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3432,7 +3388,7 @@ var assertNormalExpression = {
|
|
|
3432
3388
|
},
|
|
3433
3389
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3434
3390
|
},
|
|
3435
|
-
'
|
|
3391
|
+
'assert_lt': {
|
|
3436
3392
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3437
3393
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3438
3394
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3442,7 +3398,7 @@ var assertNormalExpression = {
|
|
|
3442
3398
|
},
|
|
3443
3399
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3444
3400
|
},
|
|
3445
|
-
'
|
|
3401
|
+
'assert_lte': {
|
|
3446
3402
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3447
3403
|
var _b = __read(_a, 3), first = _b[0], second = _b[1], message = _b[2];
|
|
3448
3404
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3452,7 +3408,7 @@ var assertNormalExpression = {
|
|
|
3452
3408
|
},
|
|
3453
3409
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3454
3410
|
},
|
|
3455
|
-
'
|
|
3411
|
+
'assert_true': {
|
|
3456
3412
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3457
3413
|
var _b = __read(_a, 2), first = _b[0], message = _b[1];
|
|
3458
3414
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3462,7 +3418,7 @@ var assertNormalExpression = {
|
|
|
3462
3418
|
},
|
|
3463
3419
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3464
3420
|
},
|
|
3465
|
-
'
|
|
3421
|
+
'assert_false': {
|
|
3466
3422
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3467
3423
|
var _b = __read(_a, 2), first = _b[0], message = _b[1];
|
|
3468
3424
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3472,7 +3428,7 @@ var assertNormalExpression = {
|
|
|
3472
3428
|
},
|
|
3473
3429
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3474
3430
|
},
|
|
3475
|
-
'
|
|
3431
|
+
'assert_truthy': {
|
|
3476
3432
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3477
3433
|
var _b = __read(_a, 2), first = _b[0], message = _b[1];
|
|
3478
3434
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3482,7 +3438,7 @@ var assertNormalExpression = {
|
|
|
3482
3438
|
},
|
|
3483
3439
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3484
3440
|
},
|
|
3485
|
-
'
|
|
3441
|
+
'assert_falsy': {
|
|
3486
3442
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3487
3443
|
var _b = __read(_a, 2), first = _b[0], message = _b[1];
|
|
3488
3444
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3492,7 +3448,7 @@ var assertNormalExpression = {
|
|
|
3492
3448
|
},
|
|
3493
3449
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3494
3450
|
},
|
|
3495
|
-
'
|
|
3451
|
+
'assert_null': {
|
|
3496
3452
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3497
3453
|
var _b = __read(_a, 2), first = _b[0], message = _b[1];
|
|
3498
3454
|
message = typeof message === 'string' && message ? " \"".concat(message, "\"") : '';
|
|
@@ -3502,7 +3458,7 @@ var assertNormalExpression = {
|
|
|
3502
3458
|
},
|
|
3503
3459
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3504
3460
|
},
|
|
3505
|
-
'
|
|
3461
|
+
'assert_throws': {
|
|
3506
3462
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
3507
3463
|
var _c = __read(_a, 2), func = _c[0], message = _c[1];
|
|
3508
3464
|
var executeFunction = _b.executeFunction;
|
|
@@ -3518,7 +3474,7 @@ var assertNormalExpression = {
|
|
|
3518
3474
|
},
|
|
3519
3475
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3520
3476
|
},
|
|
3521
|
-
'
|
|
3477
|
+
'assert_throws_error': {
|
|
3522
3478
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
3523
3479
|
var _c = __read(_a, 3), func = _c[0], throwMessage = _c[1], message = _c[2];
|
|
3524
3480
|
var executeFunction = _b.executeFunction;
|
|
@@ -3539,7 +3495,7 @@ var assertNormalExpression = {
|
|
|
3539
3495
|
},
|
|
3540
3496
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3541
3497
|
},
|
|
3542
|
-
'
|
|
3498
|
+
'assert_not_throws': {
|
|
3543
3499
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
3544
3500
|
var _c = __read(_a, 2), func = _c[0], message = _c[1];
|
|
3545
3501
|
var executeFunction = _b.executeFunction;
|
|
@@ -3573,25 +3529,25 @@ var objectNormalExpression = {
|
|
|
3573
3529
|
},
|
|
3574
3530
|
'keys': {
|
|
3575
3531
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3576
|
-
var _b = __read(_a, 1),
|
|
3577
|
-
assertObj(
|
|
3578
|
-
return Object.keys(
|
|
3532
|
+
var _b = __read(_a, 1), obj = _b[0];
|
|
3533
|
+
assertObj(obj, sourceCodeInfo);
|
|
3534
|
+
return Object.keys(obj);
|
|
3579
3535
|
},
|
|
3580
3536
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3581
3537
|
},
|
|
3582
3538
|
'vals': {
|
|
3583
3539
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3584
|
-
var _b = __read(_a, 1),
|
|
3585
|
-
assertObj(
|
|
3586
|
-
return Object.values(
|
|
3540
|
+
var _b = __read(_a, 1), obj = _b[0];
|
|
3541
|
+
assertObj(obj, sourceCodeInfo);
|
|
3542
|
+
return Object.values(obj);
|
|
3587
3543
|
},
|
|
3588
3544
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3589
3545
|
},
|
|
3590
3546
|
'entries': {
|
|
3591
3547
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3592
|
-
var _b = __read(_a, 1),
|
|
3593
|
-
assertObj(
|
|
3594
|
-
return Object.entries(
|
|
3548
|
+
var _b = __read(_a, 1), obj = _b[0];
|
|
3549
|
+
assertObj(obj, sourceCodeInfo);
|
|
3550
|
+
return Object.entries(obj);
|
|
3595
3551
|
},
|
|
3596
3552
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3597
3553
|
},
|
|
@@ -3633,11 +3589,11 @@ var objectNormalExpression = {
|
|
|
3633
3589
|
'merge-with': {
|
|
3634
3590
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
3635
3591
|
var executeFunction = _a.executeFunction;
|
|
3636
|
-
var
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
return null;
|
|
3592
|
+
var first = params[0];
|
|
3593
|
+
var fn = params.at(-1);
|
|
3594
|
+
var rest = params.slice(1, -1);
|
|
3640
3595
|
assertObj(first, sourceCodeInfo);
|
|
3596
|
+
assertLitsFunction(fn, sourceCodeInfo);
|
|
3641
3597
|
return rest.reduce(function (result, obj) {
|
|
3642
3598
|
assertObj(obj, sourceCodeInfo);
|
|
3643
3599
|
Object.entries(obj).forEach(function (entry) {
|
|
@@ -3651,7 +3607,7 @@ var objectNormalExpression = {
|
|
|
3651
3607
|
return result;
|
|
3652
3608
|
}, __assign({}, first));
|
|
3653
3609
|
},
|
|
3654
|
-
validate: function (node) { return assertNumberOfParams({ min:
|
|
3610
|
+
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
3655
3611
|
},
|
|
3656
3612
|
'zipmap': {
|
|
3657
3613
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -3817,7 +3773,7 @@ var predicatesNormalExpression = {
|
|
|
3817
3773
|
},
|
|
3818
3774
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3819
3775
|
},
|
|
3820
|
-
'
|
|
3776
|
+
'positive_infinity?': {
|
|
3821
3777
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3822
3778
|
var _b = __read(_a, 1), value = _b[0];
|
|
3823
3779
|
assertNumber(value, sourceCodeInfo);
|
|
@@ -3825,7 +3781,7 @@ var predicatesNormalExpression = {
|
|
|
3825
3781
|
},
|
|
3826
3782
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3827
3783
|
},
|
|
3828
|
-
'
|
|
3784
|
+
'negative_infinity?': {
|
|
3829
3785
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3830
3786
|
var _b = __read(_a, 1), value = _b[0];
|
|
3831
3787
|
assertNumber(value, sourceCodeInfo);
|
|
@@ -3861,7 +3817,7 @@ var predicatesNormalExpression = {
|
|
|
3861
3817
|
},
|
|
3862
3818
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3863
3819
|
},
|
|
3864
|
-
'
|
|
3820
|
+
'not_empty?': {
|
|
3865
3821
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3866
3822
|
var _b = __read(_a, 1), coll = _b[0];
|
|
3867
3823
|
if (coll === null)
|
|
@@ -4195,7 +4151,7 @@ function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
|
|
|
4195
4151
|
}
|
|
4196
4152
|
|
|
4197
4153
|
var functionalNormalExpression = {
|
|
4198
|
-
|
|
4154
|
+
apply: {
|
|
4199
4155
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
4200
4156
|
var _c = __read(_a), func = _c[0], params = _c.slice(1);
|
|
4201
4157
|
var executeFunction = _b.executeFunction;
|
|
@@ -4208,14 +4164,14 @@ var functionalNormalExpression = {
|
|
|
4208
4164
|
},
|
|
4209
4165
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
4210
4166
|
},
|
|
4211
|
-
|
|
4167
|
+
identity: {
|
|
4212
4168
|
evaluate: function (_a) {
|
|
4213
4169
|
var _b = __read(_a, 1), value = _b[0];
|
|
4214
4170
|
return toAny(value);
|
|
4215
4171
|
},
|
|
4216
4172
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4217
4173
|
},
|
|
4218
|
-
|
|
4174
|
+
partial: {
|
|
4219
4175
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4220
4176
|
var _b;
|
|
4221
4177
|
var _c = __read(_a), fn = _c[0], params = _c.slice(1);
|
|
@@ -4229,7 +4185,7 @@ var functionalNormalExpression = {
|
|
|
4229
4185
|
},
|
|
4230
4186
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
4231
4187
|
},
|
|
4232
|
-
|
|
4188
|
+
comp: {
|
|
4233
4189
|
evaluate: function (fns, sourceCodeInfo) {
|
|
4234
4190
|
var _a;
|
|
4235
4191
|
if (fns.length > 1) {
|
|
@@ -4246,7 +4202,7 @@ var functionalNormalExpression = {
|
|
|
4246
4202
|
_a;
|
|
4247
4203
|
},
|
|
4248
4204
|
},
|
|
4249
|
-
|
|
4205
|
+
constantly: {
|
|
4250
4206
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4251
4207
|
var _b;
|
|
4252
4208
|
var _c = __read(_a, 1), value = _c[0];
|
|
@@ -4259,7 +4215,7 @@ var functionalNormalExpression = {
|
|
|
4259
4215
|
},
|
|
4260
4216
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4261
4217
|
},
|
|
4262
|
-
|
|
4218
|
+
juxt: {
|
|
4263
4219
|
evaluate: function (fns, sourceCodeInfo) {
|
|
4264
4220
|
var _a;
|
|
4265
4221
|
return _a = {},
|
|
@@ -4271,7 +4227,7 @@ var functionalNormalExpression = {
|
|
|
4271
4227
|
},
|
|
4272
4228
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
4273
4229
|
},
|
|
4274
|
-
|
|
4230
|
+
complement: {
|
|
4275
4231
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4276
4232
|
var _b;
|
|
4277
4233
|
var _c = __read(_a, 1), fn = _c[0];
|
|
@@ -4284,7 +4240,7 @@ var functionalNormalExpression = {
|
|
|
4284
4240
|
},
|
|
4285
4241
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4286
4242
|
},
|
|
4287
|
-
|
|
4243
|
+
every_pred: {
|
|
4288
4244
|
evaluate: function (fns, sourceCodeInfo) {
|
|
4289
4245
|
var _a;
|
|
4290
4246
|
return _a = {},
|
|
@@ -4296,7 +4252,7 @@ var functionalNormalExpression = {
|
|
|
4296
4252
|
},
|
|
4297
4253
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
4298
4254
|
},
|
|
4299
|
-
|
|
4255
|
+
some_pred: {
|
|
4300
4256
|
evaluate: function (fns, sourceCodeInfo) {
|
|
4301
4257
|
var _a;
|
|
4302
4258
|
return _a = {},
|
|
@@ -4308,7 +4264,7 @@ var functionalNormalExpression = {
|
|
|
4308
4264
|
},
|
|
4309
4265
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
4310
4266
|
},
|
|
4311
|
-
|
|
4267
|
+
fnil: {
|
|
4312
4268
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4313
4269
|
var _b;
|
|
4314
4270
|
var _c = __read(_a), fn = _c[0], params = _c.slice(1);
|
|
@@ -4327,7 +4283,7 @@ var functionalNormalExpression = {
|
|
|
4327
4283
|
var normalExpressions = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, bitwiseNormalExpression), collectionNormalExpression), arrayNormalExpression), sequenceNormalExpression), mathNormalExpression), miscNormalExpression), assertNormalExpression), objectNormalExpression), predicatesNormalExpression), regexpNormalExpression), stringNormalExpression), functionalNormalExpression);
|
|
4328
4284
|
|
|
4329
4285
|
var andSpecialExpression = {
|
|
4330
|
-
|
|
4286
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4331
4287
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4332
4288
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4333
4289
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
@@ -4367,7 +4323,7 @@ var andSpecialExpression = {
|
|
|
4367
4323
|
},
|
|
4368
4324
|
};
|
|
4369
4325
|
|
|
4370
|
-
function
|
|
4326
|
+
function getCommonPolishSpecialExpressionParser(name) {
|
|
4371
4327
|
return function (tokenStream, parseState, firstToken, _a) {
|
|
4372
4328
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4373
4329
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -4382,14 +4338,14 @@ function getCommonParser(name) {
|
|
|
4382
4338
|
}
|
|
4383
4339
|
|
|
4384
4340
|
var commentSpecialExpression = {
|
|
4385
|
-
|
|
4341
|
+
polishParse: getCommonPolishSpecialExpressionParser('comment'),
|
|
4386
4342
|
validateParameterCount: function () { return undefined; },
|
|
4387
4343
|
evaluate: function () { return null; },
|
|
4388
4344
|
findUnresolvedIdentifiers: function () { return new Set(); },
|
|
4389
4345
|
};
|
|
4390
4346
|
|
|
4391
4347
|
var condSpecialExpression = {
|
|
4392
|
-
|
|
4348
|
+
polishParse: getCommonPolishSpecialExpressionParser('cond'),
|
|
4393
4349
|
validateParameterCount: function (node) { return assertEvenNumberOfParams(node); },
|
|
4394
4350
|
evaluate: function (node, contextStack, _a) {
|
|
4395
4351
|
var e_1, _b;
|
|
@@ -4419,7 +4375,7 @@ var condSpecialExpression = {
|
|
|
4419
4375
|
};
|
|
4420
4376
|
|
|
4421
4377
|
var declaredSpecialExpression = {
|
|
4422
|
-
|
|
4378
|
+
polishParse: getCommonPolishSpecialExpressionParser('declared?'),
|
|
4423
4379
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
4424
4380
|
evaluate: function (node, contextStack) {
|
|
4425
4381
|
var lookUpResult = contextStack.lookUp(node.p[0]);
|
|
@@ -4453,7 +4409,7 @@ function assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo) {
|
|
|
4453
4409
|
}
|
|
4454
4410
|
|
|
4455
4411
|
var defSpecialExpression = {
|
|
4456
|
-
|
|
4412
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4457
4413
|
var _b;
|
|
4458
4414
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4459
4415
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -4493,7 +4449,7 @@ var defSpecialExpression = {
|
|
|
4493
4449
|
};
|
|
4494
4450
|
|
|
4495
4451
|
var defsSpecialExpression = {
|
|
4496
|
-
|
|
4452
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4497
4453
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4498
4454
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4499
4455
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
@@ -4533,7 +4489,7 @@ var defsSpecialExpression = {
|
|
|
4533
4489
|
};
|
|
4534
4490
|
|
|
4535
4491
|
var doSpecialExpression = {
|
|
4536
|
-
|
|
4492
|
+
polishParse: getCommonPolishSpecialExpressionParser('do'),
|
|
4537
4493
|
validateParameterCount: function () { return undefined; },
|
|
4538
4494
|
evaluate: function (node, contextStack, _a) {
|
|
4539
4495
|
var e_1, _b;
|
|
@@ -4594,7 +4550,7 @@ function combinate(arrays) {
|
|
|
4594
4550
|
}
|
|
4595
4551
|
|
|
4596
4552
|
var defnSpecialExpression = {
|
|
4597
|
-
|
|
4553
|
+
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4598
4554
|
var _a;
|
|
4599
4555
|
var parseToken = parsers.parseToken;
|
|
4600
4556
|
var functionName = parseToken(tokenStream, parseState);
|
|
@@ -4638,7 +4594,7 @@ var defnSpecialExpression = {
|
|
|
4638
4594
|
},
|
|
4639
4595
|
};
|
|
4640
4596
|
var defnsSpecialExpression = {
|
|
4641
|
-
|
|
4597
|
+
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4642
4598
|
var parseToken = parsers.parseToken;
|
|
4643
4599
|
var functionName = parseToken(tokenStream, parseState);
|
|
4644
4600
|
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
@@ -4685,7 +4641,7 @@ var defnsSpecialExpression = {
|
|
|
4685
4641
|
},
|
|
4686
4642
|
};
|
|
4687
4643
|
var fnSpecialExpression = {
|
|
4688
|
-
|
|
4644
|
+
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4689
4645
|
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
4690
4646
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4691
4647
|
var node = {
|
|
@@ -4929,7 +4885,7 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
|
|
|
4929
4885
|
}
|
|
4930
4886
|
|
|
4931
4887
|
var ifSpecialExpression = {
|
|
4932
|
-
|
|
4888
|
+
polishParse: getCommonPolishSpecialExpressionParser('if'),
|
|
4933
4889
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4934
4890
|
evaluate: function (node, contextStack, _a) {
|
|
4935
4891
|
var _b;
|
|
@@ -4953,7 +4909,7 @@ var ifSpecialExpression = {
|
|
|
4953
4909
|
};
|
|
4954
4910
|
|
|
4955
4911
|
var ifLetSpecialExpression = {
|
|
4956
|
-
|
|
4912
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4957
4913
|
var _b, _c;
|
|
4958
4914
|
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4959
4915
|
var bindings = parseBindings(tokenStream, parseState);
|
|
@@ -5001,7 +4957,7 @@ var ifLetSpecialExpression = {
|
|
|
5001
4957
|
};
|
|
5002
4958
|
|
|
5003
4959
|
var ifNotSpecialExpression = {
|
|
5004
|
-
|
|
4960
|
+
polishParse: getCommonPolishSpecialExpressionParser('if-not'),
|
|
5005
4961
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
5006
4962
|
evaluate: function (node, contextStack, _a) {
|
|
5007
4963
|
var _b;
|
|
@@ -5025,7 +4981,7 @@ var ifNotSpecialExpression = {
|
|
|
5025
4981
|
};
|
|
5026
4982
|
|
|
5027
4983
|
var letSpecialExpression = {
|
|
5028
|
-
|
|
4984
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5029
4985
|
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5030
4986
|
var bindings = parseBindings(tokenStream, parseState);
|
|
5031
4987
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -5097,7 +5053,7 @@ var letSpecialExpression = {
|
|
|
5097
5053
|
};
|
|
5098
5054
|
|
|
5099
5055
|
var loopSpecialExpression = {
|
|
5100
|
-
|
|
5056
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5101
5057
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket, parseBindings = _a.parseBindings;
|
|
5102
5058
|
var bindings = parseBindings(tokenStream, parseState);
|
|
5103
5059
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -5363,7 +5319,7 @@ function analyze$1(node, contextStack, findUnresolvedIdentifiers, builtin) {
|
|
|
5363
5319
|
return result;
|
|
5364
5320
|
}
|
|
5365
5321
|
var forSpecialExpression = {
|
|
5366
|
-
|
|
5322
|
+
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
5367
5323
|
var parseTokensUntilClosingBracket = parsers.parseTokensUntilClosingBracket;
|
|
5368
5324
|
var loopBindings = parseLoopBindings(tokenStream, parseState, parsers);
|
|
5369
5325
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -5385,7 +5341,7 @@ var forSpecialExpression = {
|
|
|
5385
5341
|
},
|
|
5386
5342
|
};
|
|
5387
5343
|
var doseqSpecialExpression = {
|
|
5388
|
-
|
|
5344
|
+
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
5389
5345
|
var parseTokensUntilClosingBracket = parsers.parseTokensUntilClosingBracket;
|
|
5390
5346
|
var loopBindings = parseLoopBindings(tokenStream, parseState, parsers);
|
|
5391
5347
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
@@ -5411,7 +5367,7 @@ var doseqSpecialExpression = {
|
|
|
5411
5367
|
};
|
|
5412
5368
|
|
|
5413
5369
|
var orSpecialExpression = {
|
|
5414
|
-
|
|
5370
|
+
polishParse: getCommonPolishSpecialExpressionParser('or'),
|
|
5415
5371
|
validateParameterCount: function () { return undefined; },
|
|
5416
5372
|
evaluate: function (node, contextStack, _a) {
|
|
5417
5373
|
var e_1, _b;
|
|
@@ -5441,7 +5397,7 @@ var orSpecialExpression = {
|
|
|
5441
5397
|
};
|
|
5442
5398
|
|
|
5443
5399
|
var qqSpecialExpression = {
|
|
5444
|
-
|
|
5400
|
+
polishParse: getCommonPolishSpecialExpressionParser('??'),
|
|
5445
5401
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
5446
5402
|
evaluate: function (node, contextStack, _a) {
|
|
5447
5403
|
var _b;
|
|
@@ -5462,7 +5418,7 @@ var qqSpecialExpression = {
|
|
|
5462
5418
|
};
|
|
5463
5419
|
|
|
5464
5420
|
var recurSpecialExpression = {
|
|
5465
|
-
|
|
5421
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5466
5422
|
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5467
5423
|
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5468
5424
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
@@ -5487,7 +5443,7 @@ var recurSpecialExpression = {
|
|
|
5487
5443
|
};
|
|
5488
5444
|
|
|
5489
5445
|
var throwSpecialExpression = {
|
|
5490
|
-
|
|
5446
|
+
polishParse: getCommonPolishSpecialExpressionParser('throw'),
|
|
5491
5447
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
5492
5448
|
evaluate: function (node, contextStack, _a) {
|
|
5493
5449
|
var _b, _c;
|
|
@@ -5504,7 +5460,7 @@ var throwSpecialExpression = {
|
|
|
5504
5460
|
};
|
|
5505
5461
|
|
|
5506
5462
|
var timeSpecialExpression = {
|
|
5507
|
-
|
|
5463
|
+
polishParse: getCommonPolishSpecialExpressionParser('time!'),
|
|
5508
5464
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
5509
5465
|
evaluate: function (node, contextStack, _a) {
|
|
5510
5466
|
var evaluateAstNode = _a.evaluateAstNode;
|
|
@@ -5523,7 +5479,7 @@ var timeSpecialExpression = {
|
|
|
5523
5479
|
};
|
|
5524
5480
|
|
|
5525
5481
|
var trySpecialExpression = {
|
|
5526
|
-
|
|
5482
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5527
5483
|
var _b, _c, _d;
|
|
5528
5484
|
var parseToken = _a.parseToken;
|
|
5529
5485
|
var tryExpression = parseToken(tokenStream, parseState);
|
|
@@ -5578,7 +5534,7 @@ var trySpecialExpression = {
|
|
|
5578
5534
|
};
|
|
5579
5535
|
|
|
5580
5536
|
var whenSpecialExpression = {
|
|
5581
|
-
|
|
5537
|
+
polishParse: getCommonPolishSpecialExpressionParser('when'),
|
|
5582
5538
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5583
5539
|
evaluate: function (node, contextStack, _a) {
|
|
5584
5540
|
var e_1, _b;
|
|
@@ -5611,7 +5567,7 @@ var whenSpecialExpression = {
|
|
|
5611
5567
|
};
|
|
5612
5568
|
|
|
5613
5569
|
var whenFirstSpecialExpression = {
|
|
5614
|
-
|
|
5570
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5615
5571
|
var _b, _c;
|
|
5616
5572
|
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5617
5573
|
var bindings = parseBindings(tokenStream, parseState);
|
|
@@ -5673,7 +5629,7 @@ var whenFirstSpecialExpression = {
|
|
|
5673
5629
|
};
|
|
5674
5630
|
|
|
5675
5631
|
var whenLetSpecialExpression = {
|
|
5676
|
-
|
|
5632
|
+
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5677
5633
|
var _b, _c;
|
|
5678
5634
|
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5679
5635
|
var bindings = parseBindings(tokenStream, parseState);
|
|
@@ -5730,7 +5686,7 @@ var whenLetSpecialExpression = {
|
|
|
5730
5686
|
};
|
|
5731
5687
|
|
|
5732
5688
|
var whenNotSpecialExpression = {
|
|
5733
|
-
|
|
5689
|
+
polishParse: getCommonPolishSpecialExpressionParser('when-not'),
|
|
5734
5690
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5735
5691
|
evaluate: function (node, contextStack, _a) {
|
|
5736
5692
|
var e_1, _b;
|
|
@@ -6881,13 +6837,34 @@ function parseSymbol(tokenStream, parseState) {
|
|
|
6881
6837
|
if (!isA_SymbolToken(tkn) && !isP_SymbolToken(tkn)) {
|
|
6882
6838
|
throw new LitsError("Expected symbol token, got ".concat(tkn[0]), (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
6883
6839
|
}
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6840
|
+
if (tkn[1][0] !== '\'') {
|
|
6841
|
+
return {
|
|
6842
|
+
t: AstNodeType.Symbol,
|
|
6843
|
+
v: tkn[1],
|
|
6844
|
+
p: [],
|
|
6845
|
+
n: undefined,
|
|
6846
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6847
|
+
};
|
|
6848
|
+
}
|
|
6849
|
+
else {
|
|
6850
|
+
var value = tkn[1].substring(1, tkn[1].length - 1)
|
|
6851
|
+
.replace(/(\\{2})|(\\')|\\(.)/g, function (_, backslash, singleQuote, normalChar) {
|
|
6852
|
+
if (backslash) {
|
|
6853
|
+
return '\\';
|
|
6854
|
+
}
|
|
6855
|
+
if (singleQuote) {
|
|
6856
|
+
return '\'';
|
|
6857
|
+
}
|
|
6858
|
+
return "\\".concat(normalChar);
|
|
6859
|
+
});
|
|
6860
|
+
return {
|
|
6861
|
+
t: AstNodeType.Symbol,
|
|
6862
|
+
v: value,
|
|
6863
|
+
p: [],
|
|
6864
|
+
n: undefined,
|
|
6865
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6866
|
+
};
|
|
6867
|
+
}
|
|
6891
6868
|
}
|
|
6892
6869
|
function parseReservedSymbol(tokenStream, parseState) {
|
|
6893
6870
|
var _a;
|
|
@@ -6906,7 +6883,23 @@ function parseReservedSymbol(tokenStream, parseState) {
|
|
|
6906
6883
|
function parseNumber(tokenStream, parseState) {
|
|
6907
6884
|
var _a;
|
|
6908
6885
|
var tkn = tokenStream.tokens[parseState.position++];
|
|
6909
|
-
if (
|
|
6886
|
+
if (isA_NumberToken(tkn)) {
|
|
6887
|
+
var numberString_1 = tkn[1];
|
|
6888
|
+
var periodToken = tokenStream.tokens[parseState.position];
|
|
6889
|
+
var decimalToken = tokenStream.tokens[parseState.position + 1];
|
|
6890
|
+
if (isA_OperatorToken(periodToken, '.') && isA_NumberToken(decimalToken)) {
|
|
6891
|
+
numberString_1 += ".".concat(decimalToken[1]);
|
|
6892
|
+
parseState.position += 2;
|
|
6893
|
+
}
|
|
6894
|
+
return {
|
|
6895
|
+
t: AstNodeType.Number,
|
|
6896
|
+
v: Number(numberString_1),
|
|
6897
|
+
p: [],
|
|
6898
|
+
n: undefined,
|
|
6899
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6900
|
+
};
|
|
6901
|
+
}
|
|
6902
|
+
if (!isP_NumberToken(tkn) && !isA_BasePrefixedNumberToken(tkn)) {
|
|
6910
6903
|
throw new LitsError("Expected number token, got ".concat(tkn), (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
6911
6904
|
}
|
|
6912
6905
|
var value = tkn[1];
|
|
@@ -6958,63 +6951,60 @@ function parseString(tokenStream, parseState) {
|
|
|
6958
6951
|
};
|
|
6959
6952
|
}
|
|
6960
6953
|
|
|
6961
|
-
var exponentiationPrecedence =
|
|
6954
|
+
var exponentiationPrecedence = 10;
|
|
6955
|
+
var binaryFunctionalOperatorPrecedence = 1;
|
|
6962
6956
|
var placeholderRegexp$1 = /^\$([1-9]\d?)?$/;
|
|
6963
|
-
function getPrecedence(
|
|
6964
|
-
var operatorSign = operator[1];
|
|
6957
|
+
function getPrecedence(operatorSign) {
|
|
6965
6958
|
switch (operatorSign) {
|
|
6966
|
-
case '.': // accessor
|
|
6967
|
-
return 10;
|
|
6968
6959
|
case '**': // exponentiation
|
|
6969
6960
|
return exponentiationPrecedence;
|
|
6970
6961
|
case '*': // multiplication
|
|
6971
6962
|
case '/': // division
|
|
6972
6963
|
case '%': // remainder
|
|
6973
|
-
return
|
|
6964
|
+
return 9;
|
|
6974
6965
|
case '+': // addition
|
|
6975
6966
|
case '-': // subtraction
|
|
6976
|
-
return
|
|
6967
|
+
return 8;
|
|
6977
6968
|
case '<<': // left shift
|
|
6978
6969
|
case '>>': // signed right shift
|
|
6979
6970
|
case '>>>': // unsigned right shift
|
|
6980
|
-
return
|
|
6971
|
+
return 7;
|
|
6981
6972
|
case '++': // string concatenation
|
|
6982
|
-
return
|
|
6973
|
+
return 6;
|
|
6983
6974
|
case '<': // less than
|
|
6984
6975
|
case '<=': // less than or equal
|
|
6985
6976
|
case '>': // greater than
|
|
6986
6977
|
case '>=': // greater than or equal
|
|
6987
|
-
return
|
|
6978
|
+
return 5;
|
|
6988
6979
|
case '==': // equal
|
|
6989
6980
|
case '!=': // not equal
|
|
6990
|
-
return
|
|
6981
|
+
return 4;
|
|
6991
6982
|
case '&': // bitwise AND
|
|
6992
6983
|
case '^': // bitwise XOR
|
|
6993
6984
|
case '|': // bitwise OR
|
|
6994
|
-
return
|
|
6985
|
+
return 3;
|
|
6995
6986
|
case '&&': // logical AND
|
|
6996
6987
|
case '||': // logical OR
|
|
6997
6988
|
case '??': // nullish coalescing
|
|
6998
|
-
return
|
|
6999
|
-
|
|
7000
|
-
case '!': // logical NOT
|
|
7001
|
-
case '~': // bitwise NOT
|
|
7002
|
-
case '=': // property assignemnt operator
|
|
7003
|
-
case ',': // element delimiter
|
|
7004
|
-
case '=>': // Only used in lamda function parser
|
|
7005
|
-
case '...': // Only used in lamda function parser
|
|
7006
|
-
throw new Error("Unknown binary operator: ".concat(operatorSign));
|
|
6989
|
+
return 2;
|
|
6990
|
+
// leave room for binaryFunctionalOperatorPrecedence = 1
|
|
7007
6991
|
default:
|
|
7008
6992
|
throw new Error("Unknown binary operator: ".concat(operatorSign));
|
|
7009
6993
|
}
|
|
7010
6994
|
}
|
|
7011
6995
|
function createNamedNormalExpressionNode(name, params, token) {
|
|
7012
|
-
|
|
6996
|
+
var _a;
|
|
6997
|
+
var node = {
|
|
7013
6998
|
t: AstNodeType.NormalExpression,
|
|
7014
6999
|
n: name,
|
|
7015
7000
|
p: params,
|
|
7016
7001
|
token: getTokenDebugData(token) && token,
|
|
7017
7002
|
};
|
|
7003
|
+
var builtinExpression = builtin.normalExpressions[node.n];
|
|
7004
|
+
if (builtinExpression) {
|
|
7005
|
+
(_a = builtinExpression.validate) === null || _a === void 0 ? void 0 : _a.call(builtinExpression, __assign(__assign({}, node), { p: withoutCommentNodes(node.p) }));
|
|
7006
|
+
}
|
|
7007
|
+
return node;
|
|
7018
7008
|
}
|
|
7019
7009
|
function fromSymbolToStringNode(symbol) {
|
|
7020
7010
|
return {
|
|
@@ -7051,9 +7041,8 @@ function fromUnaryAlgebraicToAstNode(operator, operand) {
|
|
|
7051
7041
|
throw new Error("Unknown operator: ".concat(operatorName));
|
|
7052
7042
|
}
|
|
7053
7043
|
}
|
|
7054
|
-
function
|
|
7044
|
+
function fromBinaryOperatorToAstNode(operator, left, right, token) {
|
|
7055
7045
|
var _a, _b, _c;
|
|
7056
|
-
var token = hasTokenDebugData(operator) ? operator : undefined;
|
|
7057
7046
|
var operatorName = operator[1];
|
|
7058
7047
|
switch (operatorName) {
|
|
7059
7048
|
case '.':
|
|
@@ -7092,7 +7081,7 @@ function fromBinaryAlgebraicToAstNode(operator, left, right) {
|
|
|
7092
7081
|
case '==':
|
|
7093
7082
|
return createNamedNormalExpressionNode('=', [left, right], token);
|
|
7094
7083
|
case '!=':
|
|
7095
|
-
return createNamedNormalExpressionNode('
|
|
7084
|
+
return createNamedNormalExpressionNode('!=', [left, right], token);
|
|
7096
7085
|
case '&':
|
|
7097
7086
|
return createNamedNormalExpressionNode('bit-and', [left, right], token);
|
|
7098
7087
|
case '^':
|
|
@@ -7149,45 +7138,82 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7149
7138
|
var left = this.parseOperand();
|
|
7150
7139
|
while (!this.isAtEnd() && !isA_OperatorToken(this.peek(), ',') && !isRBracketToken(this.peek()) && !isRParenToken(this.peek())) {
|
|
7151
7140
|
var operator = this.peek();
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
}
|
|
7159
|
-
// Handle index accessor
|
|
7160
|
-
else if (isLBracketToken(operator)) {
|
|
7161
|
-
if (precedence >= 9) {
|
|
7141
|
+
if (isA_BinaryOperatorToken(operator)) {
|
|
7142
|
+
var name_1 = operator[1];
|
|
7143
|
+
var newPrecedece = getPrecedence(name_1);
|
|
7144
|
+
if (newPrecedece <= precedence
|
|
7145
|
+
// ** (exponentiation) is right associative
|
|
7146
|
+
&& !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {
|
|
7162
7147
|
break;
|
|
7163
7148
|
}
|
|
7164
7149
|
this.advance();
|
|
7165
|
-
var right = this.parseExpression(
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
}
|
|
7169
|
-
this.advance();
|
|
7170
|
-
left = createAccessorNode(left, right, operator);
|
|
7150
|
+
var right = this.parseExpression(newPrecedece);
|
|
7151
|
+
var token = hasTokenDebugData(operator) ? operator : undefined;
|
|
7152
|
+
left = fromBinaryOperatorToAstNode(operator, left, right, token);
|
|
7171
7153
|
}
|
|
7172
|
-
else {
|
|
7173
|
-
if (!
|
|
7154
|
+
else if (isA_SymbolToken(operator)) {
|
|
7155
|
+
if (!isFunctionOperator(operator[1])) {
|
|
7174
7156
|
break;
|
|
7175
7157
|
}
|
|
7176
|
-
var newPrecedece =
|
|
7177
|
-
if (newPrecedece <= precedence
|
|
7178
|
-
// ** (exponentiation) is right associative
|
|
7179
|
-
&& !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {
|
|
7158
|
+
var newPrecedece = binaryFunctionalOperatorPrecedence;
|
|
7159
|
+
if (newPrecedece <= precedence) {
|
|
7180
7160
|
break;
|
|
7181
7161
|
}
|
|
7182
7162
|
this.advance();
|
|
7183
7163
|
var right = this.parseExpression(newPrecedece);
|
|
7184
|
-
|
|
7164
|
+
var token = hasTokenDebugData(operator) ? operator : undefined;
|
|
7165
|
+
left = createNamedNormalExpressionNode(operator[1], [left, right], token);
|
|
7166
|
+
}
|
|
7167
|
+
else {
|
|
7168
|
+
break;
|
|
7185
7169
|
}
|
|
7186
7170
|
}
|
|
7171
|
+
if (!left) {
|
|
7172
|
+
throw new LitsError('Expected operand', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7173
|
+
}
|
|
7187
7174
|
return left;
|
|
7188
7175
|
};
|
|
7189
7176
|
AlgebraicParser.prototype.parseOperand = function () {
|
|
7190
|
-
var _a;
|
|
7177
|
+
var _a, _b;
|
|
7178
|
+
var operand = this.parseOperandPart();
|
|
7179
|
+
var token = this.peek();
|
|
7180
|
+
while (isA_OperatorToken(token, '.') || isLBracketToken(token) || isLParenToken(token)) {
|
|
7181
|
+
if (token[1] === '.') {
|
|
7182
|
+
this.advance();
|
|
7183
|
+
var symbolToken = this.peek();
|
|
7184
|
+
if (!isA_SymbolToken(symbolToken)) {
|
|
7185
|
+
throw new LitsError('Expected symbol', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7186
|
+
}
|
|
7187
|
+
var stringNode = {
|
|
7188
|
+
t: AstNodeType.String,
|
|
7189
|
+
v: symbolToken[1],
|
|
7190
|
+
token: getTokenDebugData(symbolToken) && symbolToken,
|
|
7191
|
+
p: [],
|
|
7192
|
+
n: undefined,
|
|
7193
|
+
};
|
|
7194
|
+
operand = createAccessorNode(operand, stringNode, token);
|
|
7195
|
+
this.advance();
|
|
7196
|
+
token = this.peek();
|
|
7197
|
+
}
|
|
7198
|
+
else if (isLBracketToken(token)) {
|
|
7199
|
+
this.advance();
|
|
7200
|
+
var expression = this.parseExpression();
|
|
7201
|
+
if (!isRBracketToken(this.peek())) {
|
|
7202
|
+
throw new LitsError('Expected closing bracket', (_b = getTokenDebugData(this.peek())) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7203
|
+
}
|
|
7204
|
+
operand = createAccessorNode(operand, expression, token);
|
|
7205
|
+
this.advance();
|
|
7206
|
+
token = this.peek();
|
|
7207
|
+
}
|
|
7208
|
+
else if (isLParenToken(token)) {
|
|
7209
|
+
operand = this.parseFunctionCall(operand);
|
|
7210
|
+
token = this.peek();
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
return operand;
|
|
7214
|
+
};
|
|
7215
|
+
AlgebraicParser.prototype.parseOperandPart = function () {
|
|
7216
|
+
var _a, _b;
|
|
7191
7217
|
var token = this.peek();
|
|
7192
7218
|
// Parentheses
|
|
7193
7219
|
if (isLParenToken(token)) {
|
|
@@ -7206,14 +7232,17 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7206
7232
|
return expression;
|
|
7207
7233
|
}
|
|
7208
7234
|
// Unary operators
|
|
7209
|
-
if (isA_OperatorToken(token)) {
|
|
7235
|
+
else if (isA_OperatorToken(token)) {
|
|
7210
7236
|
var operatorName = token[1];
|
|
7211
|
-
if (
|
|
7237
|
+
if (isSymbolicUnaryOperator(operatorName)) {
|
|
7212
7238
|
this.advance();
|
|
7213
7239
|
var operand = this.parseOperand();
|
|
7240
|
+
if (operand === null) {
|
|
7241
|
+
throw new LitsError('Expected operand', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7242
|
+
}
|
|
7214
7243
|
return fromUnaryAlgebraicToAstNode(token, operand);
|
|
7215
7244
|
}
|
|
7216
|
-
|
|
7245
|
+
if (operatorName === '=>') {
|
|
7217
7246
|
return this.parseShorthandLamdaFunction();
|
|
7218
7247
|
}
|
|
7219
7248
|
else {
|
|
@@ -7231,6 +7260,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7231
7260
|
var tokenType = token[0];
|
|
7232
7261
|
switch (tokenType) {
|
|
7233
7262
|
case 'A_Number':
|
|
7263
|
+
case 'A_BasePrefixedNumber':
|
|
7234
7264
|
return parseNumber(this.tokenStream, this.parseState);
|
|
7235
7265
|
case 'String':
|
|
7236
7266
|
return parseString(this.tokenStream, this.parseState);
|
|
@@ -7266,18 +7296,21 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7266
7296
|
return node;
|
|
7267
7297
|
}
|
|
7268
7298
|
default:
|
|
7269
|
-
throw new LitsError("Unknown token type: ".concat(tokenType), (
|
|
7299
|
+
throw new LitsError("Unknown token type: ".concat(tokenType), (_b = getTokenDebugData(token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7270
7300
|
}
|
|
7271
7301
|
};
|
|
7272
7302
|
AlgebraicParser.prototype.parseObject = function () {
|
|
7273
|
-
var _a, _b;
|
|
7303
|
+
var _a, _b, _c;
|
|
7274
7304
|
var firstToken = asLBraceToken(this.peek());
|
|
7275
7305
|
this.advance();
|
|
7276
7306
|
var params = [];
|
|
7277
7307
|
while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
|
|
7278
7308
|
var key = this.parseOperand();
|
|
7309
|
+
if (key === null) {
|
|
7310
|
+
throw new LitsError('Expected key', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7311
|
+
}
|
|
7279
7312
|
if (key.t !== AstNodeType.Symbol && key.t !== AstNodeType.String) {
|
|
7280
|
-
throw new LitsError('Expected key to be a symbol or a string', (
|
|
7313
|
+
throw new LitsError('Expected key to be a symbol or a string', (_b = getTokenDebugData(this.peek())) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7281
7314
|
}
|
|
7282
7315
|
params.push({
|
|
7283
7316
|
t: AstNodeType.String,
|
|
@@ -7291,7 +7324,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7291
7324
|
params.push(this.parseExpression());
|
|
7292
7325
|
var nextToken = this.peek();
|
|
7293
7326
|
if (!isA_OperatorToken(nextToken, ',') && !isRBraceToken(nextToken)) {
|
|
7294
|
-
throw new LitsError('Expected comma or closing brace', (
|
|
7327
|
+
throw new LitsError('Expected comma or closing brace', (_c = getTokenDebugData(this.peek())) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
7295
7328
|
}
|
|
7296
7329
|
if (isA_OperatorToken(nextToken, ',')) {
|
|
7297
7330
|
this.advance();
|
|
@@ -7331,9 +7364,13 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7331
7364
|
};
|
|
7332
7365
|
};
|
|
7333
7366
|
AlgebraicParser.prototype.parseFunctionCall = function (symbol) {
|
|
7334
|
-
var _a, _b
|
|
7335
|
-
var
|
|
7367
|
+
var _a, _b;
|
|
7368
|
+
var isNamedFunction = symbol.t === AstNodeType.Symbol;
|
|
7336
7369
|
this.advance();
|
|
7370
|
+
if (isNamedFunction && symbol.v === 'for') {
|
|
7371
|
+
return this.parseFor(symbol);
|
|
7372
|
+
}
|
|
7373
|
+
var params = [];
|
|
7337
7374
|
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
7338
7375
|
params.push(this.parseExpression());
|
|
7339
7376
|
var nextToken = this.peek();
|
|
@@ -7348,10 +7385,10 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7348
7385
|
throw new LitsError('Expected closing parenthesis', (_b = getTokenDebugData(this.peek())) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7349
7386
|
}
|
|
7350
7387
|
this.advance();
|
|
7351
|
-
if (
|
|
7388
|
+
if (isNamedFunction) {
|
|
7352
7389
|
if (specialExpressionKeys.includes(symbol.v)) {
|
|
7353
|
-
var
|
|
7354
|
-
switch (
|
|
7390
|
+
var name_2 = symbol.v;
|
|
7391
|
+
switch (name_2) {
|
|
7355
7392
|
case '??':
|
|
7356
7393
|
case 'and':
|
|
7357
7394
|
case 'comment':
|
|
@@ -7365,18 +7402,19 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7365
7402
|
case 'do':
|
|
7366
7403
|
case 'time!':
|
|
7367
7404
|
case 'throw': {
|
|
7368
|
-
var
|
|
7405
|
+
var node = {
|
|
7369
7406
|
t: AstNodeType.SpecialExpression,
|
|
7370
|
-
n:
|
|
7407
|
+
n: name_2,
|
|
7371
7408
|
p: params,
|
|
7372
7409
|
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
7373
7410
|
};
|
|
7374
|
-
builtin.specialExpressions[
|
|
7375
|
-
return
|
|
7411
|
+
builtin.specialExpressions[node.n].validateParameterCount(node);
|
|
7412
|
+
return node;
|
|
7376
7413
|
}
|
|
7414
|
+
case 'let':
|
|
7415
|
+
return this.parseLet(symbol, params);
|
|
7377
7416
|
case 'def':
|
|
7378
7417
|
case 'defs':
|
|
7379
|
-
case 'let':
|
|
7380
7418
|
case 'if-let':
|
|
7381
7419
|
case 'when-let':
|
|
7382
7420
|
case 'when-first':
|
|
@@ -7387,18 +7425,12 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7387
7425
|
case 'recur':
|
|
7388
7426
|
case 'loop':
|
|
7389
7427
|
case 'doseq':
|
|
7390
|
-
|
|
7391
|
-
throw new Error("Special expression ".concat(name_1, " is not available in algebraic notation"));
|
|
7428
|
+
throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
|
|
7392
7429
|
default:
|
|
7393
|
-
throw new Error("Unknown special expression: ".concat(
|
|
7430
|
+
throw new Error("Unknown special expression: ".concat(name_2));
|
|
7394
7431
|
}
|
|
7395
7432
|
}
|
|
7396
|
-
|
|
7397
|
-
var builtinExpression = builtin.normalExpressions[node.n];
|
|
7398
|
-
if (builtinExpression) {
|
|
7399
|
-
(_c = builtinExpression.validate) === null || _c === void 0 ? void 0 : _c.call(builtinExpression, __assign(__assign({}, node), { p: withoutCommentNodes(node.p) }));
|
|
7400
|
-
}
|
|
7401
|
-
return node;
|
|
7433
|
+
return createNamedNormalExpressionNode(symbol.v, params, symbol.token);
|
|
7402
7434
|
}
|
|
7403
7435
|
else {
|
|
7404
7436
|
return {
|
|
@@ -7410,31 +7442,40 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7410
7442
|
}
|
|
7411
7443
|
};
|
|
7412
7444
|
AlgebraicParser.prototype.parseLambdaFunction = function () {
|
|
7413
|
-
var _a;
|
|
7445
|
+
var _a, _b;
|
|
7414
7446
|
var firstToken = this.peek();
|
|
7415
7447
|
this.advance();
|
|
7416
|
-
var
|
|
7448
|
+
var rest = false;
|
|
7449
|
+
var letBindingObject;
|
|
7417
7450
|
var args = [];
|
|
7418
7451
|
var restArg;
|
|
7419
7452
|
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
7420
|
-
if (
|
|
7421
|
-
|
|
7422
|
-
throw new LitsError('Multiple spread operators in lambda function', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7423
|
-
}
|
|
7424
|
-
this.advance();
|
|
7425
|
-
spread = true;
|
|
7426
|
-
}
|
|
7427
|
-
var symbolToken = this.peek();
|
|
7428
|
-
if (!isA_SymbolToken(symbolToken)) {
|
|
7429
|
-
return null;
|
|
7453
|
+
if (letBindingObject) {
|
|
7454
|
+
throw new LitsError('Expected right parentheses', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7430
7455
|
}
|
|
7431
|
-
if (
|
|
7432
|
-
|
|
7456
|
+
if (isLBraceToken(this.peek())) {
|
|
7457
|
+
letBindingObject = this.parseObject();
|
|
7433
7458
|
}
|
|
7434
7459
|
else {
|
|
7435
|
-
|
|
7460
|
+
if (isA_OperatorToken(this.peek(), '...')) {
|
|
7461
|
+
if (rest) {
|
|
7462
|
+
throw new LitsError('Multiple spread operators in lambda function', (_b = getTokenDebugData(this.peek())) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7463
|
+
}
|
|
7464
|
+
this.advance();
|
|
7465
|
+
rest = true;
|
|
7466
|
+
}
|
|
7467
|
+
var symbolToken = this.peek();
|
|
7468
|
+
if (!isA_SymbolToken(symbolToken)) {
|
|
7469
|
+
return null;
|
|
7470
|
+
}
|
|
7471
|
+
if (rest) {
|
|
7472
|
+
restArg = symbolToken[1];
|
|
7473
|
+
}
|
|
7474
|
+
else {
|
|
7475
|
+
args.push(symbolToken[1]);
|
|
7476
|
+
}
|
|
7477
|
+
this.advance();
|
|
7436
7478
|
}
|
|
7437
|
-
this.advance();
|
|
7438
7479
|
if (!isA_OperatorToken(this.peek(), ',') && !isRParenToken(this.peek())) {
|
|
7439
7480
|
return null;
|
|
7440
7481
|
}
|
|
@@ -7450,6 +7491,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7450
7491
|
return null;
|
|
7451
7492
|
}
|
|
7452
7493
|
this.advance();
|
|
7494
|
+
var letBindings = letBindingObject ? arrayToPairs(letBindingObject.p) : [];
|
|
7453
7495
|
var body = this.parseExpression();
|
|
7454
7496
|
var arity = restArg !== undefined ? { min: args.length } : args.length;
|
|
7455
7497
|
return {
|
|
@@ -7460,7 +7502,17 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7460
7502
|
as: {
|
|
7461
7503
|
m: args,
|
|
7462
7504
|
r: restArg,
|
|
7463
|
-
b:
|
|
7505
|
+
b: letBindings.map(function (pair) {
|
|
7506
|
+
var key = pair[0];
|
|
7507
|
+
var value = pair[1];
|
|
7508
|
+
return {
|
|
7509
|
+
t: AstNodeType.Binding,
|
|
7510
|
+
n: key.v,
|
|
7511
|
+
v: value,
|
|
7512
|
+
p: [],
|
|
7513
|
+
token: getTokenDebugData(key.token) && key.token,
|
|
7514
|
+
};
|
|
7515
|
+
}),
|
|
7464
7516
|
},
|
|
7465
7517
|
b: [body],
|
|
7466
7518
|
a: arity,
|
|
@@ -7469,7 +7521,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7469
7521
|
};
|
|
7470
7522
|
};
|
|
7471
7523
|
AlgebraicParser.prototype.parseShorthandLamdaFunction = function () {
|
|
7472
|
-
var _a, _b, _c
|
|
7524
|
+
var _a, _b, _c;
|
|
7473
7525
|
var firstToken = this.peek();
|
|
7474
7526
|
this.advance();
|
|
7475
7527
|
var startPos = this.parseState.position;
|
|
@@ -7494,9 +7546,6 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7494
7546
|
throw new LitsError('Can\'t specify more than 20 arguments', (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
7495
7547
|
}
|
|
7496
7548
|
}
|
|
7497
|
-
if (isA_OperatorToken(tkn, '=>')) {
|
|
7498
|
-
throw new LitsError('Nested shortcut functions are not allowed', (_d = getTokenDebugData(firstToken)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo);
|
|
7499
|
-
}
|
|
7500
7549
|
}
|
|
7501
7550
|
var mandatoryArguments = [];
|
|
7502
7551
|
for (var i = 1; i <= arity; i += 1) {
|
|
@@ -7524,12 +7573,151 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7524
7573
|
};
|
|
7525
7574
|
return node;
|
|
7526
7575
|
};
|
|
7576
|
+
AlgebraicParser.prototype.parseLet = function (letSymbol, params) {
|
|
7577
|
+
var _a, _b;
|
|
7578
|
+
if (params.length !== 2) {
|
|
7579
|
+
throw new LitsError('let expects two arguments', (_a = getTokenDebugData(letSymbol.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7580
|
+
}
|
|
7581
|
+
var letObject = params[0];
|
|
7582
|
+
if (letObject.t !== AstNodeType.NormalExpression || letObject.n !== 'object') {
|
|
7583
|
+
throw new LitsError('let expects an object as first argument', (_b = getTokenDebugData(letObject.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7584
|
+
}
|
|
7585
|
+
var letBindings = arrayToPairs(letObject.p);
|
|
7586
|
+
var expression = params[1];
|
|
7587
|
+
return {
|
|
7588
|
+
t: AstNodeType.SpecialExpression,
|
|
7589
|
+
n: 'let',
|
|
7590
|
+
p: [expression],
|
|
7591
|
+
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
7592
|
+
bs: letBindings.map(function (pair) {
|
|
7593
|
+
var key = pair[0];
|
|
7594
|
+
var value = pair[1];
|
|
7595
|
+
return {
|
|
7596
|
+
t: AstNodeType.Binding,
|
|
7597
|
+
n: key.v,
|
|
7598
|
+
v: value,
|
|
7599
|
+
p: [],
|
|
7600
|
+
token: getTokenDebugData(key.token) && key.token,
|
|
7601
|
+
};
|
|
7602
|
+
}),
|
|
7603
|
+
};
|
|
7604
|
+
};
|
|
7605
|
+
AlgebraicParser.prototype.parseFor = function (forSymbol) {
|
|
7606
|
+
var forLoopBindings = [
|
|
7607
|
+
this.parseForLoopBinding(),
|
|
7608
|
+
];
|
|
7609
|
+
var nextToken = this.peekAhead();
|
|
7610
|
+
while (isA_SymbolToken(nextToken) && nextToken[1] === 'of') {
|
|
7611
|
+
forLoopBindings.push(this.parseForLoopBinding());
|
|
7612
|
+
nextToken = this.peekAhead();
|
|
7613
|
+
}
|
|
7614
|
+
var expression = this.parseExpression();
|
|
7615
|
+
assertRParenToken(this.peek());
|
|
7616
|
+
this.advance();
|
|
7617
|
+
return {
|
|
7618
|
+
t: AstNodeType.SpecialExpression,
|
|
7619
|
+
n: 'for',
|
|
7620
|
+
p: [expression],
|
|
7621
|
+
token: getTokenDebugData(forSymbol.token) && forSymbol.token,
|
|
7622
|
+
l: forLoopBindings,
|
|
7623
|
+
};
|
|
7624
|
+
};
|
|
7625
|
+
// export interface LoopBindingNode {
|
|
7626
|
+
// b: BindingNode // Binding
|
|
7627
|
+
// m: Array<'&let' | '&when' | '&while'> // Modifiers
|
|
7628
|
+
// l?: BindingNode[] // Let-Bindings
|
|
7629
|
+
// wn?: AstNode // When Node
|
|
7630
|
+
// we?: AstNode // While Node
|
|
7631
|
+
// }
|
|
7632
|
+
AlgebraicParser.prototype.parseForLoopBinding = function () {
|
|
7633
|
+
var _a;
|
|
7634
|
+
var bindingNode = this.parseBinding();
|
|
7635
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
7636
|
+
this.advance();
|
|
7637
|
+
return {
|
|
7638
|
+
b: bindingNode,
|
|
7639
|
+
m: [],
|
|
7640
|
+
};
|
|
7641
|
+
}
|
|
7642
|
+
var modifiers = [];
|
|
7643
|
+
var token = this.peek();
|
|
7644
|
+
if (!isA_SymbolToken(token)) {
|
|
7645
|
+
throw new LitsError('Expected symbol let, when or while', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7646
|
+
}
|
|
7647
|
+
var letBindings;
|
|
7648
|
+
if (token[1] === 'let') {
|
|
7649
|
+
modifiers.push('&let');
|
|
7650
|
+
letBindings = [];
|
|
7651
|
+
this.advance();
|
|
7652
|
+
var letObject = this.parseObject();
|
|
7653
|
+
letBindings = arrayToPairs(letObject.p).map(function (pair) {
|
|
7654
|
+
var key = pair[0];
|
|
7655
|
+
var value = pair[1];
|
|
7656
|
+
return {
|
|
7657
|
+
t: AstNodeType.Binding,
|
|
7658
|
+
n: key.v,
|
|
7659
|
+
v: value,
|
|
7660
|
+
p: [],
|
|
7661
|
+
token: getTokenDebugData(key.token) && key.token,
|
|
7662
|
+
};
|
|
7663
|
+
});
|
|
7664
|
+
}
|
|
7665
|
+
token = this.peek();
|
|
7666
|
+
var whenNode;
|
|
7667
|
+
var whileNode;
|
|
7668
|
+
while (isA_SymbolToken(token)
|
|
7669
|
+
&& ((token[1] === 'when' && !modifiers.includes('&when'))
|
|
7670
|
+
|| (token[1] === 'while' && !modifiers.includes('&while')))) {
|
|
7671
|
+
this.advance();
|
|
7672
|
+
if (token[1] === 'when') {
|
|
7673
|
+
modifiers.push('&when');
|
|
7674
|
+
whenNode = this.parseExpression();
|
|
7675
|
+
}
|
|
7676
|
+
else {
|
|
7677
|
+
modifiers.push('&while');
|
|
7678
|
+
whileNode = this.parseExpression();
|
|
7679
|
+
}
|
|
7680
|
+
token = this.peek();
|
|
7681
|
+
}
|
|
7682
|
+
assertA_OperatorToken(token, ',');
|
|
7683
|
+
this.advance();
|
|
7684
|
+
return {
|
|
7685
|
+
b: bindingNode,
|
|
7686
|
+
m: modifiers,
|
|
7687
|
+
l: letBindings,
|
|
7688
|
+
wn: whenNode,
|
|
7689
|
+
we: whileNode,
|
|
7690
|
+
};
|
|
7691
|
+
};
|
|
7692
|
+
AlgebraicParser.prototype.parseBinding = function () {
|
|
7693
|
+
var _a;
|
|
7694
|
+
var firstToken = asA_SymbolToken(this.peek());
|
|
7695
|
+
var name = firstToken[1];
|
|
7696
|
+
this.advance();
|
|
7697
|
+
var ofSymbol = asA_SymbolToken(this.peek());
|
|
7698
|
+
if (ofSymbol[1] !== 'of') {
|
|
7699
|
+
throw new LitsError('Expected "of"', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7700
|
+
}
|
|
7701
|
+
this.advance();
|
|
7702
|
+
var value = this.parseExpression();
|
|
7703
|
+
var node = {
|
|
7704
|
+
t: AstNodeType.Binding,
|
|
7705
|
+
n: name,
|
|
7706
|
+
v: value,
|
|
7707
|
+
p: [],
|
|
7708
|
+
token: getTokenDebugData(firstToken) && firstToken,
|
|
7709
|
+
};
|
|
7710
|
+
return node;
|
|
7711
|
+
};
|
|
7527
7712
|
AlgebraicParser.prototype.isAtEnd = function () {
|
|
7528
7713
|
return this.parseState.position >= this.tokenStream.tokens.length;
|
|
7529
7714
|
};
|
|
7530
7715
|
AlgebraicParser.prototype.peek = function () {
|
|
7531
7716
|
return this.tokenStream.tokens[this.parseState.position];
|
|
7532
7717
|
};
|
|
7718
|
+
AlgebraicParser.prototype.peekAhead = function () {
|
|
7719
|
+
return this.tokenStream.tokens[this.parseState.position + 1];
|
|
7720
|
+
};
|
|
7533
7721
|
return AlgebraicParser;
|
|
7534
7722
|
}());
|
|
7535
7723
|
|
|
@@ -7721,12 +7909,12 @@ function parseBindings(tokenStream, parseState) {
|
|
|
7721
7909
|
return bindings;
|
|
7722
7910
|
}
|
|
7723
7911
|
function parseBinding(tokenStream, parseState) {
|
|
7724
|
-
var firstToken = asP_SymbolToken(tokenStream.tokens[parseState.position
|
|
7725
|
-
var name =
|
|
7912
|
+
var firstToken = asP_SymbolToken(tokenStream.tokens[parseState.position]);
|
|
7913
|
+
var name = parseSymbol(tokenStream, parseState);
|
|
7726
7914
|
var value = parseState.parseToken(tokenStream, parseState);
|
|
7727
7915
|
var node = {
|
|
7728
7916
|
t: AstNodeType.Binding,
|
|
7729
|
-
n: name,
|
|
7917
|
+
n: name.v,
|
|
7730
7918
|
v: value,
|
|
7731
7919
|
p: [],
|
|
7732
7920
|
token: getTokenDebugData(firstToken) && firstToken,
|
|
@@ -7767,7 +7955,7 @@ function parseSpecialExpression(tokenStream, parseState) {
|
|
|
7767
7955
|
var firstToken = asLParenToken(tokenStream.tokens[parseState.position++]);
|
|
7768
7956
|
var nameToken = asP_SymbolToken(tokenStream.tokens[parseState.position++]);
|
|
7769
7957
|
var expressionName = nameToken[1];
|
|
7770
|
-
var _b = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo), parse = _b.
|
|
7958
|
+
var _b = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo), parse = _b.polishParse, validateParameterCount = _b.validateParameterCount;
|
|
7771
7959
|
var node = parse(tokenStream, parseState, firstToken, {
|
|
7772
7960
|
parseExpression: parseExpression,
|
|
7773
7961
|
parseTokensUntilClosingBracket: parseTokensUntilClosingBracket,
|
|
@@ -7866,7 +8054,11 @@ function parse(tokenStream) {
|
|
|
7866
8054
|
}
|
|
7867
8055
|
function removeUnnecessaryTokens(tokenStream) {
|
|
7868
8056
|
var tokens = tokenStream.tokens.filter(function (token) {
|
|
7869
|
-
if (isP_CommentToken(token)
|
|
8057
|
+
if (isP_CommentToken(token)
|
|
8058
|
+
|| isA_CommentToken(token)
|
|
8059
|
+
|| isA_MultiLineCommentToken(token)
|
|
8060
|
+
|| isA_WhitespaceToken(token)
|
|
8061
|
+
|| isP_WhitespaceToken(token)) {
|
|
7870
8062
|
return false;
|
|
7871
8063
|
}
|
|
7872
8064
|
return true;
|
|
@@ -7961,44 +8153,259 @@ var commonTokenizers = [
|
|
|
7961
8153
|
tokenizeString,
|
|
7962
8154
|
];
|
|
7963
8155
|
|
|
7964
|
-
var
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
}
|
|
7975
|
-
|
|
7976
|
-
}
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
}
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
8156
|
+
var algebraicReservedNamesRecord = {
|
|
8157
|
+
'true': { value: true },
|
|
8158
|
+
'false': { value: false },
|
|
8159
|
+
'nil': { value: null },
|
|
8160
|
+
'null': { value: null },
|
|
8161
|
+
'def': { value: null, forbidden: true },
|
|
8162
|
+
'defs': { value: null, forbidden: true },
|
|
8163
|
+
'if-let': { value: null, forbidden: true },
|
|
8164
|
+
'when-let': { value: null, forbidden: true },
|
|
8165
|
+
'when-first': { value: null, forbidden: true },
|
|
8166
|
+
'fn': { value: null, forbidden: true },
|
|
8167
|
+
'defn': { value: null, forbidden: true },
|
|
8168
|
+
'defns': { value: null, forbidden: true },
|
|
8169
|
+
'try': { value: null, forbidden: true },
|
|
8170
|
+
'recur': { value: null, forbidden: true },
|
|
8171
|
+
'loop': { value: null, forbidden: true },
|
|
8172
|
+
'time!': { value: null, forbidden: true },
|
|
8173
|
+
'doseq': { value: null, forbidden: true },
|
|
8174
|
+
};
|
|
8175
|
+
|
|
8176
|
+
var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
|
|
8177
|
+
var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
|
|
8178
|
+
var whitespaceRegExp$1 = /\s/;
|
|
8179
|
+
var tokenizeA_Whitespace = function (input, position) {
|
|
8180
|
+
var char = input[position];
|
|
8181
|
+
if (!char || !whitespaceRegExp$1.test(char)) {
|
|
8182
|
+
return NO_MATCH;
|
|
8183
|
+
}
|
|
8184
|
+
var value = char;
|
|
8185
|
+
position += 1;
|
|
8186
|
+
char = input[position];
|
|
8187
|
+
while (char && whitespaceRegExp$1.test(char)) {
|
|
8188
|
+
value += char;
|
|
8189
|
+
position += 1;
|
|
8190
|
+
char = input[position];
|
|
8191
|
+
}
|
|
8192
|
+
return [value.length, ['A_Whitespace', value]];
|
|
7991
8193
|
};
|
|
7992
|
-
var endOfNumberRegExp = /[\s)\]},;#`]/;
|
|
7993
8194
|
var decimalNumberRegExp$1 = /\d/;
|
|
7994
8195
|
var octalNumberRegExp$1 = /[0-7]/;
|
|
7995
8196
|
var hexNumberRegExp$1 = /[0-9a-f]/i;
|
|
7996
8197
|
var binaryNumberRegExp$1 = /[01]/;
|
|
7997
|
-
var
|
|
8198
|
+
var tokenizeA_Number = function (input, position) {
|
|
8199
|
+
var i;
|
|
8200
|
+
for (i = position; i < input.length; i += 1) {
|
|
8201
|
+
var char = input[i];
|
|
8202
|
+
if (!decimalNumberRegExp$1.test(char)) {
|
|
8203
|
+
break;
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
8206
|
+
var length = i - position;
|
|
8207
|
+
if (length === 0) {
|
|
8208
|
+
return NO_MATCH;
|
|
8209
|
+
}
|
|
8210
|
+
return [length, ['A_Number', input.substring(position, i)]];
|
|
8211
|
+
};
|
|
8212
|
+
var tokenizeA_BasePrefixedNumber = function (input, position) {
|
|
8213
|
+
if (input[position] !== '0') {
|
|
8214
|
+
return NO_MATCH;
|
|
8215
|
+
}
|
|
8216
|
+
var baseChar = input[position + 1];
|
|
8217
|
+
var type = baseChar === 'b' || baseChar === 'B'
|
|
8218
|
+
? 'binary'
|
|
8219
|
+
: baseChar === 'o' || baseChar === 'O'
|
|
8220
|
+
? 'octal'
|
|
8221
|
+
: baseChar === 'x' || baseChar === 'X'
|
|
8222
|
+
? 'hex'
|
|
8223
|
+
: null;
|
|
8224
|
+
if (type === null) {
|
|
8225
|
+
return NO_MATCH;
|
|
8226
|
+
}
|
|
8227
|
+
var i;
|
|
8228
|
+
for (i = position + 2; i < input.length; i += 1) {
|
|
8229
|
+
var char = input[i];
|
|
8230
|
+
if (type === 'binary' && !binaryNumberRegExp$1.test(char)) {
|
|
8231
|
+
break;
|
|
8232
|
+
}
|
|
8233
|
+
if (type === 'octal' && !octalNumberRegExp$1.test(char)) {
|
|
8234
|
+
break;
|
|
8235
|
+
}
|
|
8236
|
+
if (type === 'hex' && !hexNumberRegExp$1.test(char)) {
|
|
8237
|
+
break;
|
|
8238
|
+
}
|
|
8239
|
+
}
|
|
8240
|
+
var length = i - position;
|
|
8241
|
+
if (length <= 2) {
|
|
8242
|
+
return NO_MATCH;
|
|
8243
|
+
}
|
|
8244
|
+
return [length, ['A_BasePrefixedNumber', input.substring(position, i)]];
|
|
8245
|
+
};
|
|
8246
|
+
var tokenizeA_ReservedSymbolToken = function (input, position) {
|
|
8247
|
+
var e_1, _a;
|
|
8248
|
+
try {
|
|
8249
|
+
for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8250
|
+
var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
|
|
8251
|
+
var length_1 = reservedName.length;
|
|
8252
|
+
var nextChar = input[position + length_1];
|
|
8253
|
+
if (nextChar && identifierRegExp.test(nextChar))
|
|
8254
|
+
continue;
|
|
8255
|
+
var name_1 = input.substring(position, position + length_1);
|
|
8256
|
+
if (name_1 === reservedName) {
|
|
8257
|
+
if (forbidden)
|
|
8258
|
+
throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
|
|
8259
|
+
return [length_1, ['A_ReservedSymbol', reservedName]];
|
|
8260
|
+
}
|
|
8261
|
+
}
|
|
8262
|
+
}
|
|
8263
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8264
|
+
finally {
|
|
8265
|
+
try {
|
|
8266
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8267
|
+
}
|
|
8268
|
+
finally { if (e_1) throw e_1.error; }
|
|
8269
|
+
}
|
|
8270
|
+
return NO_MATCH;
|
|
8271
|
+
};
|
|
8272
|
+
var tokenizeA_Symbol = function (input, position) {
|
|
8273
|
+
var value = input[position];
|
|
8274
|
+
if (!value) {
|
|
8275
|
+
return NO_MATCH;
|
|
8276
|
+
}
|
|
8277
|
+
if (value === '\'') {
|
|
8278
|
+
var length_2 = 1;
|
|
8279
|
+
var char = input[position + length_2];
|
|
8280
|
+
var escaping = false;
|
|
8281
|
+
while (char !== '\'' || escaping) {
|
|
8282
|
+
if (char === undefined)
|
|
8283
|
+
throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
|
|
8284
|
+
length_2 += 1;
|
|
8285
|
+
if (escaping) {
|
|
8286
|
+
escaping = false;
|
|
8287
|
+
value += char;
|
|
8288
|
+
}
|
|
8289
|
+
else {
|
|
8290
|
+
if (char === '\\') {
|
|
8291
|
+
escaping = true;
|
|
8292
|
+
}
|
|
8293
|
+
value += char;
|
|
8294
|
+
}
|
|
8295
|
+
char = input[position + length_2];
|
|
8296
|
+
}
|
|
8297
|
+
value += '\''; // closing quote
|
|
8298
|
+
return [length_2 + 1, ['A_Symbol', value]];
|
|
8299
|
+
}
|
|
8300
|
+
if (identifierFirstCharacterRegExp.test(value)) {
|
|
8301
|
+
var initialPosition = position;
|
|
8302
|
+
position += 1;
|
|
8303
|
+
var char = input[position];
|
|
8304
|
+
while (char && identifierRegExp.test(char)) {
|
|
8305
|
+
value += char;
|
|
8306
|
+
position += 1;
|
|
8307
|
+
char = input[position];
|
|
8308
|
+
}
|
|
8309
|
+
return [position - initialPosition, ['A_Symbol', value]];
|
|
8310
|
+
}
|
|
8311
|
+
return NO_MATCH;
|
|
8312
|
+
};
|
|
8313
|
+
var tokenizeA_Operator = function (input, position) {
|
|
8314
|
+
var _a;
|
|
8315
|
+
var threeChars = input.slice(position, position + 3);
|
|
8316
|
+
if (position + 2 < input.length && isSymbolicOperator(threeChars)) {
|
|
8317
|
+
return [3, ['A_Operator', threeChars]];
|
|
8318
|
+
}
|
|
8319
|
+
var twoChars = input.slice(position, position + 2);
|
|
8320
|
+
if (position + 1 < input.length && isSymbolicOperator(twoChars)) {
|
|
8321
|
+
return [2, ['A_Operator', twoChars]];
|
|
8322
|
+
}
|
|
8323
|
+
var oneChar = (_a = input[position]) !== null && _a !== void 0 ? _a : '';
|
|
8324
|
+
if (isSymbolicOperator(oneChar)) {
|
|
8325
|
+
return [1, ['A_Operator', oneChar]];
|
|
8326
|
+
}
|
|
8327
|
+
return NO_MATCH;
|
|
8328
|
+
};
|
|
8329
|
+
var tokenizeA_MultiLineComment = function (input, position) {
|
|
8330
|
+
if (input[position] === '/' && input[position + 1] === '*') {
|
|
8331
|
+
var length_3 = 2;
|
|
8332
|
+
var value = '/*';
|
|
8333
|
+
while (input[position + length_3] !== '*' && input[position + length_3 + 1] !== '/' && position + length_3 + 1 < input.length) {
|
|
8334
|
+
value += input[position + length_3];
|
|
8335
|
+
length_3 += 1;
|
|
8336
|
+
}
|
|
8337
|
+
if (position + length_3 + 1 >= input.length) {
|
|
8338
|
+
throw new LitsError('Comment not closed', undefined);
|
|
8339
|
+
}
|
|
8340
|
+
value += '*/';
|
|
8341
|
+
length_3 += 2;
|
|
8342
|
+
return [length_3, ['A_MultiLineComment', value]];
|
|
8343
|
+
}
|
|
8344
|
+
return NO_MATCH;
|
|
8345
|
+
};
|
|
8346
|
+
var tokenizeA_SingleLineComment = function (input, position) {
|
|
8347
|
+
if (input[position] === '/' && input[position + 1] === '/') {
|
|
8348
|
+
var length_4 = 2;
|
|
8349
|
+
var value = '//';
|
|
8350
|
+
while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
|
|
8351
|
+
value += input[position + length_4];
|
|
8352
|
+
length_4 += 1;
|
|
8353
|
+
}
|
|
8354
|
+
return [length_4, ['A_SingleLineComment', value]];
|
|
8355
|
+
}
|
|
8356
|
+
return NO_MATCH;
|
|
8357
|
+
};
|
|
8358
|
+
// All tokenizers, order matters!
|
|
8359
|
+
var algebraicTokenizers = __spreadArray(__spreadArray([
|
|
8360
|
+
tokenizeA_Whitespace,
|
|
8361
|
+
tokenizeA_MultiLineComment,
|
|
8362
|
+
tokenizeA_SingleLineComment
|
|
8363
|
+
], __read(commonTokenizers), false), [
|
|
8364
|
+
tokenizeA_BasePrefixedNumber,
|
|
8365
|
+
tokenizeA_Number,
|
|
8366
|
+
tokenizeA_Operator,
|
|
8367
|
+
tokenizeA_ReservedSymbolToken,
|
|
8368
|
+
tokenizeA_Symbol,
|
|
8369
|
+
], false);
|
|
8370
|
+
|
|
8371
|
+
var whitespaceRegExp = /\s|,/;
|
|
8372
|
+
var tokenizeP_Comment = function (input, position) {
|
|
8373
|
+
if (input[position] === ';') {
|
|
8374
|
+
var length_1 = 0;
|
|
8375
|
+
var value = '';
|
|
8376
|
+
while (input[position + length_1] !== '\n' && position + length_1 < input.length) {
|
|
8377
|
+
value += input[position + length_1];
|
|
8378
|
+
length_1 += 1;
|
|
8379
|
+
}
|
|
8380
|
+
return [length_1, ['P_Comment', value]];
|
|
8381
|
+
}
|
|
8382
|
+
return NO_MATCH;
|
|
8383
|
+
};
|
|
8384
|
+
var tokenizeP_Whitespace = function (input, position) {
|
|
8385
|
+
var char = input[position];
|
|
8386
|
+
if (!char || !whitespaceRegExp.test(char)) {
|
|
8387
|
+
return NO_MATCH;
|
|
8388
|
+
}
|
|
8389
|
+
var value = char;
|
|
8390
|
+
position += 1;
|
|
8391
|
+
char = input[position];
|
|
8392
|
+
while (char && whitespaceRegExp.test(char)) {
|
|
8393
|
+
value += char;
|
|
8394
|
+
position += 1;
|
|
8395
|
+
char = input[position];
|
|
8396
|
+
}
|
|
8397
|
+
return [value.length, ['P_Whitespace', value]];
|
|
8398
|
+
};
|
|
8399
|
+
var endOfNumberRegExp = /[\s)\]},;#`]/;
|
|
8400
|
+
var decimalNumberRegExp = /\d/;
|
|
8401
|
+
var octalNumberRegExp = /[0-7]/;
|
|
8402
|
+
var hexNumberRegExp = /[0-9a-f]/i;
|
|
8403
|
+
var binaryNumberRegExp = /[01]/;
|
|
8404
|
+
var firstCharRegExp = /[0-9.-]/;
|
|
7998
8405
|
var tokenizeP_Number = function (input, position) {
|
|
7999
8406
|
var type = 'decimal';
|
|
8000
8407
|
var firstChar = input[position];
|
|
8001
|
-
if (!firstCharRegExp
|
|
8408
|
+
if (!firstCharRegExp.test(firstChar))
|
|
8002
8409
|
return NO_MATCH;
|
|
8003
8410
|
var hasDecimals = firstChar === '.';
|
|
8004
8411
|
var i;
|
|
@@ -8008,7 +8415,7 @@ var tokenizeP_Number = function (input, position) {
|
|
|
8008
8415
|
break;
|
|
8009
8416
|
if (char === '.') {
|
|
8010
8417
|
var nextChar = input[i + 1];
|
|
8011
|
-
if (typeof nextChar === 'string' && !decimalNumberRegExp
|
|
8418
|
+
if (typeof nextChar === 'string' && !decimalNumberRegExp.test(nextChar))
|
|
8012
8419
|
break;
|
|
8013
8420
|
}
|
|
8014
8421
|
if (i === position + 1 && firstChar === '0') {
|
|
@@ -8026,19 +8433,19 @@ var tokenizeP_Number = function (input, position) {
|
|
|
8026
8433
|
}
|
|
8027
8434
|
}
|
|
8028
8435
|
if (type === 'decimal' && hasDecimals) {
|
|
8029
|
-
if (!decimalNumberRegExp
|
|
8436
|
+
if (!decimalNumberRegExp.test(char))
|
|
8030
8437
|
return NO_MATCH;
|
|
8031
8438
|
}
|
|
8032
8439
|
else if (type === 'binary') {
|
|
8033
|
-
if (!binaryNumberRegExp
|
|
8440
|
+
if (!binaryNumberRegExp.test(char))
|
|
8034
8441
|
return NO_MATCH;
|
|
8035
8442
|
}
|
|
8036
8443
|
else if (type === 'octal') {
|
|
8037
|
-
if (!octalNumberRegExp
|
|
8444
|
+
if (!octalNumberRegExp.test(char))
|
|
8038
8445
|
return NO_MATCH;
|
|
8039
8446
|
}
|
|
8040
8447
|
else if (type === 'hex') {
|
|
8041
|
-
if (!hexNumberRegExp
|
|
8448
|
+
if (!hexNumberRegExp.test(char))
|
|
8042
8449
|
return NO_MATCH;
|
|
8043
8450
|
}
|
|
8044
8451
|
else {
|
|
@@ -8046,7 +8453,7 @@ var tokenizeP_Number = function (input, position) {
|
|
|
8046
8453
|
hasDecimals = true;
|
|
8047
8454
|
continue;
|
|
8048
8455
|
}
|
|
8049
|
-
if (!decimalNumberRegExp
|
|
8456
|
+
if (!decimalNumberRegExp.test(char))
|
|
8050
8457
|
return NO_MATCH;
|
|
8051
8458
|
}
|
|
8052
8459
|
}
|
|
@@ -8058,17 +8465,45 @@ var tokenizeP_Number = function (input, position) {
|
|
|
8058
8465
|
};
|
|
8059
8466
|
var P_symbolRegExp = new RegExp(polishIdentifierCharacterClass);
|
|
8060
8467
|
var tokenizeP_Symbol = function (input, position) {
|
|
8061
|
-
var
|
|
8062
|
-
|
|
8063
|
-
var value = '';
|
|
8064
|
-
if (!char || !P_symbolRegExp.test(char))
|
|
8468
|
+
var value = input[position];
|
|
8469
|
+
if (!value) {
|
|
8065
8470
|
return NO_MATCH;
|
|
8066
|
-
while (char && P_symbolRegExp.test(char)) {
|
|
8067
|
-
value += char;
|
|
8068
|
-
length += 1;
|
|
8069
|
-
char = input[position + length];
|
|
8070
8471
|
}
|
|
8071
|
-
|
|
8472
|
+
if (value === '\'') {
|
|
8473
|
+
var length_2 = 1;
|
|
8474
|
+
var char = input[position + length_2];
|
|
8475
|
+
var escaping = false;
|
|
8476
|
+
while (char !== '\'' || escaping) {
|
|
8477
|
+
if (char === undefined)
|
|
8478
|
+
throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
|
|
8479
|
+
length_2 += 1;
|
|
8480
|
+
if (escaping) {
|
|
8481
|
+
escaping = false;
|
|
8482
|
+
value += char;
|
|
8483
|
+
}
|
|
8484
|
+
else {
|
|
8485
|
+
if (char === '\\') {
|
|
8486
|
+
escaping = true;
|
|
8487
|
+
}
|
|
8488
|
+
value += char;
|
|
8489
|
+
}
|
|
8490
|
+
char = input[position + length_2];
|
|
8491
|
+
}
|
|
8492
|
+
value += '\''; // closing quote
|
|
8493
|
+
return [length_2 + 1, ['P_Symbol', value]];
|
|
8494
|
+
}
|
|
8495
|
+
if (P_symbolRegExp.test(value)) {
|
|
8496
|
+
var initialPosition = position;
|
|
8497
|
+
position += 1;
|
|
8498
|
+
var char = input[position];
|
|
8499
|
+
while (char && P_symbolRegExp.test(char)) {
|
|
8500
|
+
value += char;
|
|
8501
|
+
position += 1;
|
|
8502
|
+
char = input[position];
|
|
8503
|
+
}
|
|
8504
|
+
return [position - initialPosition, ['P_Symbol', value]];
|
|
8505
|
+
}
|
|
8506
|
+
return NO_MATCH;
|
|
8072
8507
|
};
|
|
8073
8508
|
var tokenizeP_FnShorthand = function (input, position) {
|
|
8074
8509
|
if (input.slice(position, position + 2) !== '#(')
|
|
@@ -8080,16 +8515,16 @@ var tokenizeP_ReservedSymbol = function (input, position) {
|
|
|
8080
8515
|
try {
|
|
8081
8516
|
for (var _b = __values(Object.entries(polishReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8082
8517
|
var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
|
|
8083
|
-
var
|
|
8084
|
-
var nextChar = input[position +
|
|
8518
|
+
var length_3 = reservedName.length;
|
|
8519
|
+
var nextChar = input[position + length_3];
|
|
8085
8520
|
if (nextChar && P_symbolRegExp.test(nextChar)) {
|
|
8086
8521
|
continue;
|
|
8087
8522
|
}
|
|
8088
|
-
var symbol = input.substring(position, position +
|
|
8523
|
+
var symbol = input.substring(position, position + length_3);
|
|
8089
8524
|
if (symbol === reservedName) {
|
|
8090
8525
|
if (forbidden)
|
|
8091
8526
|
throw new LitsError("".concat(symbol, " is forbidden!"), undefined);
|
|
8092
|
-
return [
|
|
8527
|
+
return [length_3, ['P_ReservedSymbol', reservedName]];
|
|
8093
8528
|
}
|
|
8094
8529
|
}
|
|
8095
8530
|
}
|
|
@@ -8117,11 +8552,11 @@ var tokenizeP_Modifier = function (input, position) {
|
|
|
8117
8552
|
try {
|
|
8118
8553
|
for (var modifierNames_1 = __values(modifierNames), modifierNames_1_1 = modifierNames_1.next(); !modifierNames_1_1.done; modifierNames_1_1 = modifierNames_1.next()) {
|
|
8119
8554
|
var modifierName = modifierNames_1_1.value;
|
|
8120
|
-
var
|
|
8121
|
-
var charAfterModifier = input[position +
|
|
8122
|
-
if (input.substring(position, position +
|
|
8555
|
+
var length_4 = modifierName.length;
|
|
8556
|
+
var charAfterModifier = input[position + length_4];
|
|
8557
|
+
if (input.substring(position, position + length_4) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
|
|
8123
8558
|
var value = modifierName;
|
|
8124
|
-
return [
|
|
8559
|
+
return [length_4, ['P_Modifier', value]];
|
|
8125
8560
|
}
|
|
8126
8561
|
}
|
|
8127
8562
|
}
|
|
@@ -8174,244 +8609,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
|
|
|
8174
8609
|
tokenizeP_CollectionAccessor,
|
|
8175
8610
|
], false);
|
|
8176
8611
|
|
|
8177
|
-
var algebraicReservedNamesRecord = {
|
|
8178
|
-
'true': { value: true },
|
|
8179
|
-
'false': { value: false },
|
|
8180
|
-
'nil': { value: null },
|
|
8181
|
-
'null': { value: null },
|
|
8182
|
-
'def': { value: null, forbidden: true },
|
|
8183
|
-
'defs': { value: null, forbidden: true },
|
|
8184
|
-
'let': { value: null, forbidden: true },
|
|
8185
|
-
'if-let': { value: null, forbidden: true },
|
|
8186
|
-
'when-let': { value: null, forbidden: true },
|
|
8187
|
-
'when-first': { value: null, forbidden: true },
|
|
8188
|
-
'fn': { value: null, forbidden: true },
|
|
8189
|
-
'defn': { value: null, forbidden: true },
|
|
8190
|
-
'defns': { value: null, forbidden: true },
|
|
8191
|
-
'try': { value: null, forbidden: true },
|
|
8192
|
-
'recur': { value: null, forbidden: true },
|
|
8193
|
-
'loop': { value: null, forbidden: true },
|
|
8194
|
-
'time!': { value: null, forbidden: true },
|
|
8195
|
-
'doseq': { value: null, forbidden: true },
|
|
8196
|
-
'for': { value: null, forbidden: true },
|
|
8197
|
-
};
|
|
8198
|
-
|
|
8199
|
-
var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
|
|
8200
|
-
var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
|
|
8201
|
-
var whitespaceRegExp = /\s/;
|
|
8202
|
-
var tokenizeA_Whitespace = function (input, position) {
|
|
8203
|
-
var char = input[position];
|
|
8204
|
-
if (!char || !whitespaceRegExp.test(char)) {
|
|
8205
|
-
return NO_MATCH;
|
|
8206
|
-
}
|
|
8207
|
-
var value = char;
|
|
8208
|
-
position += 1;
|
|
8209
|
-
char = input[position];
|
|
8210
|
-
while (char && whitespaceRegExp.test(char)) {
|
|
8211
|
-
value += char;
|
|
8212
|
-
position += 1;
|
|
8213
|
-
char = input[position];
|
|
8214
|
-
}
|
|
8215
|
-
return [value.length, ['A_Whitespace', value]];
|
|
8216
|
-
};
|
|
8217
|
-
var decimalNumberRegExp = /\d/;
|
|
8218
|
-
var octalNumberRegExp = /[0-7]/;
|
|
8219
|
-
var hexNumberRegExp = /[0-9a-f]/i;
|
|
8220
|
-
var binaryNumberRegExp = /[01]/;
|
|
8221
|
-
var firstCharRegExp = /[0-9.]/;
|
|
8222
|
-
var tokenizeA_Number = function (input, position) {
|
|
8223
|
-
var type = 'decimal';
|
|
8224
|
-
var firstChar = input[position];
|
|
8225
|
-
if (!firstCharRegExp.test(firstChar))
|
|
8226
|
-
return NO_MATCH;
|
|
8227
|
-
var hasDecimals = firstChar === '.';
|
|
8228
|
-
var i;
|
|
8229
|
-
for (i = position + 1; i < input.length; i += 1) {
|
|
8230
|
-
var char = input[i];
|
|
8231
|
-
if ((i === position + 1 && firstChar === '0')) {
|
|
8232
|
-
if (char === 'b' || char === 'B') {
|
|
8233
|
-
type = 'binary';
|
|
8234
|
-
continue;
|
|
8235
|
-
}
|
|
8236
|
-
if (char === 'o' || char === 'O') {
|
|
8237
|
-
type = 'octal';
|
|
8238
|
-
continue;
|
|
8239
|
-
}
|
|
8240
|
-
if (char === 'x' || char === 'X') {
|
|
8241
|
-
type = 'hex';
|
|
8242
|
-
continue;
|
|
8243
|
-
}
|
|
8244
|
-
}
|
|
8245
|
-
if (type === 'decimal') {
|
|
8246
|
-
if (hasDecimals) {
|
|
8247
|
-
if (!decimalNumberRegExp.test(char)) {
|
|
8248
|
-
break;
|
|
8249
|
-
}
|
|
8250
|
-
}
|
|
8251
|
-
else if (char !== '.' && !decimalNumberRegExp.test(char)) {
|
|
8252
|
-
break;
|
|
8253
|
-
}
|
|
8254
|
-
}
|
|
8255
|
-
if (type === 'binary' && !binaryNumberRegExp.test(char)) {
|
|
8256
|
-
break;
|
|
8257
|
-
}
|
|
8258
|
-
if (type === 'octal' && !octalNumberRegExp.test(char)) {
|
|
8259
|
-
break;
|
|
8260
|
-
}
|
|
8261
|
-
if (type === 'hex' && !hexNumberRegExp.test(char)) {
|
|
8262
|
-
break;
|
|
8263
|
-
}
|
|
8264
|
-
if (char === '.') {
|
|
8265
|
-
var nextChar = input[i + 1];
|
|
8266
|
-
if (typeof nextChar === 'string' && !decimalNumberRegExp.test(nextChar))
|
|
8267
|
-
break;
|
|
8268
|
-
}
|
|
8269
|
-
if (type === 'decimal' && hasDecimals) {
|
|
8270
|
-
if (!decimalNumberRegExp.test(char))
|
|
8271
|
-
return NO_MATCH;
|
|
8272
|
-
}
|
|
8273
|
-
else if (type === 'binary') {
|
|
8274
|
-
if (!binaryNumberRegExp.test(char))
|
|
8275
|
-
return NO_MATCH;
|
|
8276
|
-
}
|
|
8277
|
-
else if (type === 'octal') {
|
|
8278
|
-
if (!octalNumberRegExp.test(char))
|
|
8279
|
-
return NO_MATCH;
|
|
8280
|
-
}
|
|
8281
|
-
else if (type === 'hex') {
|
|
8282
|
-
if (!hexNumberRegExp.test(char))
|
|
8283
|
-
return NO_MATCH;
|
|
8284
|
-
}
|
|
8285
|
-
else {
|
|
8286
|
-
if (char === '.') {
|
|
8287
|
-
hasDecimals = true;
|
|
8288
|
-
continue;
|
|
8289
|
-
}
|
|
8290
|
-
if (!decimalNumberRegExp.test(char))
|
|
8291
|
-
return NO_MATCH;
|
|
8292
|
-
}
|
|
8293
|
-
}
|
|
8294
|
-
var length = i - position;
|
|
8295
|
-
var value = input.substring(position, i);
|
|
8296
|
-
if ((type !== 'decimal' && length <= 2) || value === '.' || value === '-')
|
|
8297
|
-
return NO_MATCH;
|
|
8298
|
-
return [length, ['A_Number', value]];
|
|
8299
|
-
};
|
|
8300
|
-
var tokenizeA_ReservedSymbolToken = function (input, position) {
|
|
8301
|
-
var e_1, _a;
|
|
8302
|
-
try {
|
|
8303
|
-
for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8304
|
-
var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
|
|
8305
|
-
var length_1 = reservedName.length;
|
|
8306
|
-
var nextChar = input[position + length_1];
|
|
8307
|
-
if (nextChar && identifierRegExp.test(nextChar))
|
|
8308
|
-
continue;
|
|
8309
|
-
var name_1 = input.substring(position, position + length_1);
|
|
8310
|
-
if (name_1 === reservedName) {
|
|
8311
|
-
if (forbidden)
|
|
8312
|
-
throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
|
|
8313
|
-
return [length_1, ['A_ReservedSymbol', reservedName]];
|
|
8314
|
-
}
|
|
8315
|
-
}
|
|
8316
|
-
}
|
|
8317
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8318
|
-
finally {
|
|
8319
|
-
try {
|
|
8320
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8321
|
-
}
|
|
8322
|
-
finally { if (e_1) throw e_1.error; }
|
|
8323
|
-
}
|
|
8324
|
-
return NO_MATCH;
|
|
8325
|
-
};
|
|
8326
|
-
var tokenizeA_Symbol = function (input, position) {
|
|
8327
|
-
var initialPosition = position;
|
|
8328
|
-
var value = input[position];
|
|
8329
|
-
if (!value) {
|
|
8330
|
-
return NO_MATCH;
|
|
8331
|
-
}
|
|
8332
|
-
if (identifierFirstCharacterRegExp.test(value)) {
|
|
8333
|
-
position += 1;
|
|
8334
|
-
var char = input[position];
|
|
8335
|
-
while (char && identifierRegExp.test(char)) {
|
|
8336
|
-
value += char;
|
|
8337
|
-
position += 1;
|
|
8338
|
-
char = input[position];
|
|
8339
|
-
}
|
|
8340
|
-
return [position - initialPosition, ['A_Symbol', value]];
|
|
8341
|
-
}
|
|
8342
|
-
if (value === '\'') {
|
|
8343
|
-
position += 1;
|
|
8344
|
-
var _a = __read(tokenizeP_Symbol(input, position), 2), count = _a[0], pfSymbolToken = _a[1];
|
|
8345
|
-
if (pfSymbolToken === undefined) {
|
|
8346
|
-
return NO_MATCH;
|
|
8347
|
-
}
|
|
8348
|
-
position += count;
|
|
8349
|
-
if (input[position] !== '\'') {
|
|
8350
|
-
return NO_MATCH;
|
|
8351
|
-
}
|
|
8352
|
-
position += 1;
|
|
8353
|
-
var pfValue = pfSymbolToken[1];
|
|
8354
|
-
return [position - initialPosition, ['A_Symbol', pfValue]];
|
|
8355
|
-
}
|
|
8356
|
-
return NO_MATCH;
|
|
8357
|
-
};
|
|
8358
|
-
var tokenizeA_Operator = function (input, position) {
|
|
8359
|
-
var _a;
|
|
8360
|
-
var threeChars = input.slice(position, position + 3);
|
|
8361
|
-
if (position + 2 < input.length && isAlgebraicOperator(threeChars)) {
|
|
8362
|
-
return [3, ['A_Operator', threeChars]];
|
|
8363
|
-
}
|
|
8364
|
-
var twoChars = input.slice(position, position + 2);
|
|
8365
|
-
if (position + 1 < input.length && isAlgebraicOperator(twoChars)) {
|
|
8366
|
-
return [2, ['A_Operator', twoChars]];
|
|
8367
|
-
}
|
|
8368
|
-
var oneChar = (_a = input[position]) !== null && _a !== void 0 ? _a : '';
|
|
8369
|
-
if (isAlgebraicOperator(oneChar)) {
|
|
8370
|
-
return [1, ['A_Operator', oneChar]];
|
|
8371
|
-
}
|
|
8372
|
-
return NO_MATCH;
|
|
8373
|
-
};
|
|
8374
|
-
var tokenizeA_MultiLineComment = function (input, position) {
|
|
8375
|
-
if (input[position] === '/' && input[position + 1] === '*') {
|
|
8376
|
-
var length_2 = 2;
|
|
8377
|
-
var value = '/*';
|
|
8378
|
-
while (input[position + length_2] !== '*' && input[position + length_2 + 1] !== '/' && position + length_2 + 1 < input.length) {
|
|
8379
|
-
value += input[position + length_2];
|
|
8380
|
-
length_2 += 1;
|
|
8381
|
-
}
|
|
8382
|
-
if (position + length_2 + 1 >= input.length) {
|
|
8383
|
-
throw new LitsError('Comment not closed', undefined);
|
|
8384
|
-
}
|
|
8385
|
-
value += '*/';
|
|
8386
|
-
length_2 += 2;
|
|
8387
|
-
return [length_2, ['A_MultiLineComment', value]];
|
|
8388
|
-
}
|
|
8389
|
-
return NO_MATCH;
|
|
8390
|
-
};
|
|
8391
|
-
var tokenizeA_SingleLineComment = function (input, position) {
|
|
8392
|
-
if (input[position] === '/' && input[position + 1] === '/') {
|
|
8393
|
-
var length_3 = 2;
|
|
8394
|
-
var value = '//';
|
|
8395
|
-
while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
|
|
8396
|
-
value += input[position + length_3];
|
|
8397
|
-
length_3 += 1;
|
|
8398
|
-
}
|
|
8399
|
-
return [length_3, ['A_SingleLineComment', value]];
|
|
8400
|
-
}
|
|
8401
|
-
return NO_MATCH;
|
|
8402
|
-
};
|
|
8403
|
-
// All tokenizers, order matters!
|
|
8404
|
-
var algebraicTokenizers = __spreadArray(__spreadArray([
|
|
8405
|
-
tokenizeA_Whitespace,
|
|
8406
|
-
tokenizeA_MultiLineComment,
|
|
8407
|
-
tokenizeA_SingleLineComment
|
|
8408
|
-
], __read(commonTokenizers), false), [
|
|
8409
|
-
tokenizeA_Number,
|
|
8410
|
-
tokenizeA_Operator,
|
|
8411
|
-
tokenizeA_ReservedSymbolToken,
|
|
8412
|
-
tokenizeA_Symbol,
|
|
8413
|
-
], false);
|
|
8414
|
-
|
|
8415
8612
|
var applyCollectionAccessors = function (tokenStream) {
|
|
8416
8613
|
var dotTokenIndex = tokenStream.tokens.findIndex(isP_CollectionAccessorToken);
|
|
8417
8614
|
while (dotTokenIndex >= 0) {
|