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