@mojir/lits 2.0.15 → 2.0.17
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 +1008 -1516
- package/dist/cli/reference/api.d.ts +5 -5
- package/dist/cli/src/analyze/index.d.ts +0 -2
- package/dist/cli/src/builtin/index.d.ts +3 -10
- package/dist/cli/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -5
- package/dist/cli/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/{src/builtin/specialExpressions/if_not.d.ts → cli/src/builtin/specialExpressions/unless.d.ts} +2 -2
- package/dist/cli/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/cli/src/parser/AlgebraicParser.d.ts +13 -8
- package/dist/cli/src/parser/commonTokenParsers.d.ts +2 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +27 -27
- package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +5 -5
- package/dist/cli/src/tokenizer/common/commonTokenizers.d.ts +3 -2
- package/dist/cli/src/tokenizer/common/commonTokens.d.ts +6 -2
- package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
- package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +4 -8
- package/dist/cli/src/tokenizer/tokens.d.ts +2 -2
- package/dist/index.esm.js +1004 -1514
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1004 -1514
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1004 -1514
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +5 -5
- package/dist/src/analyze/index.d.ts +0 -2
- package/dist/src/builtin/index.d.ts +3 -10
- package/dist/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/functions.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/{when.d.ts → unless.d.ts} +2 -2
- package/dist/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/src/parser/AlgebraicParser.d.ts +13 -8
- package/dist/src/parser/commonTokenParsers.d.ts +2 -1
- package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +27 -27
- package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +5 -5
- package/dist/src/tokenizer/common/commonTokenizers.d.ts +3 -2
- package/dist/src/tokenizer/common/commonTokens.d.ts +6 -2
- package/dist/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
- package/dist/src/tokenizer/polish/polishTokens.d.ts +4 -8
- package/dist/src/tokenizer/tokens.d.ts +2 -2
- package/dist/testFramework.esm.js +631 -1193
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +631 -1193
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
- package/dist/cli/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateSwitchOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/index.d.ts +0 -18
- package/dist/cli/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
- package/dist/cli/src/builtin/specialExpressions/defs.d.ts +0 -5
- package/dist/cli/src/builtin/specialExpressions/if_let.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/if_not.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/when.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/when_first.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/when_let.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/when_not.d.ts +0 -6
- package/dist/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
- package/dist/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
- package/dist/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateSwitchOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/index.d.ts +0 -18
- package/dist/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
- package/dist/src/builtin/specialExpressions/defs.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/if_let.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/when_first.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/when_let.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/when_not.d.ts +0 -6
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.0.
|
|
95
|
+
var version = "2.0.17";
|
|
96
96
|
|
|
97
97
|
var AstNodeType;
|
|
98
98
|
(function (AstNodeType) {
|
|
@@ -288,6 +288,7 @@ var commonSimpleTokenTypes = [
|
|
|
288
288
|
];
|
|
289
289
|
var commomValueTokenTypes = [
|
|
290
290
|
'String',
|
|
291
|
+
'RegexpShorthand',
|
|
291
292
|
];
|
|
292
293
|
function isLParenToken(token) {
|
|
293
294
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
|
|
@@ -361,6 +362,18 @@ function asStringToken(token) {
|
|
|
361
362
|
assertStringToken(token);
|
|
362
363
|
return token;
|
|
363
364
|
}
|
|
365
|
+
function isRegexpShorthandToken(token) {
|
|
366
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
|
|
367
|
+
}
|
|
368
|
+
function assertRegexpShorthandToken(token) {
|
|
369
|
+
if (!isRegexpShorthandToken(token)) {
|
|
370
|
+
throwUnexpectedToken('RegexpShorthand', undefined, token);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function asRegexpShorthandToken(token) {
|
|
374
|
+
assertRegexpShorthandToken(token);
|
|
375
|
+
return token;
|
|
376
|
+
}
|
|
364
377
|
function isAlgebraicNotationToken(token) {
|
|
365
378
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
|
|
366
379
|
}
|
|
@@ -431,29 +444,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
|
|
|
431
444
|
var nonFunctionOperators = [
|
|
432
445
|
'??',
|
|
433
446
|
'&&',
|
|
447
|
+
'||',
|
|
434
448
|
'comment',
|
|
435
449
|
'cond',
|
|
436
|
-
'declared?',
|
|
437
|
-
'if',
|
|
438
|
-
'if_not',
|
|
439
|
-
'||',
|
|
440
|
-
'when',
|
|
441
|
-
'when_not',
|
|
442
|
-
'do',
|
|
443
|
-
'throw',
|
|
444
|
-
'let',
|
|
445
450
|
'def',
|
|
446
|
-
'
|
|
447
|
-
'if_let',
|
|
448
|
-
'when_let',
|
|
449
|
-
'when_first',
|
|
450
|
-
'fn',
|
|
451
|
+
'defined?',
|
|
451
452
|
'defn',
|
|
452
|
-
'
|
|
453
|
-
'try',
|
|
454
|
-
'recur',
|
|
455
|
-
'loop',
|
|
453
|
+
'do',
|
|
456
454
|
'doseq',
|
|
455
|
+
'fn',
|
|
456
|
+
'if',
|
|
457
|
+
'let',
|
|
458
|
+
'loop',
|
|
459
|
+
'recur',
|
|
460
|
+
'throw',
|
|
461
|
+
'try',
|
|
462
|
+
'unless',
|
|
457
463
|
'while',
|
|
458
464
|
];
|
|
459
465
|
var nonFunctionOperatorSet = new Set(nonFunctionOperators);
|
|
@@ -472,16 +478,22 @@ var symbolicOperatorSet = new Set(symbolicOperators);
|
|
|
472
478
|
function isSymbolicOperator(operator) {
|
|
473
479
|
return symbolicOperatorSet.has(operator);
|
|
474
480
|
}
|
|
475
|
-
function isA_SymbolToken(token) {
|
|
476
|
-
|
|
481
|
+
function isA_SymbolToken(token, symbolName) {
|
|
482
|
+
if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_Symbol') {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
if (symbolName && token[1] !== symbolName) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
return true;
|
|
477
489
|
}
|
|
478
|
-
function assertA_SymbolToken(token) {
|
|
479
|
-
if (!isA_SymbolToken(token)) {
|
|
490
|
+
function assertA_SymbolToken(token, symbolName) {
|
|
491
|
+
if (!isA_SymbolToken(token, symbolName)) {
|
|
480
492
|
throwUnexpectedToken('A_Symbol', undefined, token);
|
|
481
493
|
}
|
|
482
494
|
}
|
|
483
|
-
function asA_SymbolToken(token) {
|
|
484
|
-
assertA_SymbolToken(token);
|
|
495
|
+
function asA_SymbolToken(token, symbolName) {
|
|
496
|
+
assertA_SymbolToken(token, symbolName);
|
|
485
497
|
return token;
|
|
486
498
|
}
|
|
487
499
|
function isA_BinaryOperatorToken(token) {
|
|
@@ -518,9 +530,10 @@ function isA_OperatorToken(token, operatorName) {
|
|
|
518
530
|
}
|
|
519
531
|
function assertA_OperatorToken(token, operatorName) {
|
|
520
532
|
if (!isA_OperatorToken(token, operatorName)) {
|
|
521
|
-
{
|
|
533
|
+
if (operatorName) {
|
|
522
534
|
throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
|
|
523
535
|
}
|
|
536
|
+
throwUnexpectedToken('A_Operator', operatorName, token);
|
|
524
537
|
}
|
|
525
538
|
}
|
|
526
539
|
function isA_WhitespaceToken(token) {
|
|
@@ -543,7 +556,6 @@ var polishOnlyValueTokenTypes = [
|
|
|
543
556
|
'P_StringShorthand',
|
|
544
557
|
'P_Symbol',
|
|
545
558
|
'P_ReservedSymbol',
|
|
546
|
-
'P_RegexpShorthand',
|
|
547
559
|
'P_CollectionAccessor',
|
|
548
560
|
'P_Comment',
|
|
549
561
|
'P_Whitespace',
|
|
@@ -581,18 +593,6 @@ function isP_ReservedSymbolToken(token) {
|
|
|
581
593
|
function isP_ModifierToken(token) {
|
|
582
594
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
|
|
583
595
|
}
|
|
584
|
-
function isP_RegexpShorthandToken(token) {
|
|
585
|
-
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
|
|
586
|
-
}
|
|
587
|
-
function assertP_RegexpShorthandToken(token) {
|
|
588
|
-
if (!isP_RegexpShorthandToken(token)) {
|
|
589
|
-
throwUnexpectedToken('P_RegexpShorthand', undefined, token);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function asP_RegexpShorthandToken(token) {
|
|
593
|
-
assertP_RegexpShorthandToken(token);
|
|
594
|
-
return token;
|
|
595
|
-
}
|
|
596
596
|
function isP_FnShorthandToken(token) {
|
|
597
597
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
|
|
598
598
|
}
|
|
@@ -764,7 +764,7 @@ var specialExpressionCommentRemovers = {
|
|
|
764
764
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
765
765
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
766
766
|
},
|
|
767
|
-
'
|
|
767
|
+
'defined?': function (node, removeOptions) {
|
|
768
768
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
769
769
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
770
770
|
},
|
|
@@ -773,11 +773,6 @@ var specialExpressionCommentRemovers = {
|
|
|
773
773
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
774
774
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
775
775
|
},
|
|
776
|
-
'defns': function (_node, _removeOptions) { },
|
|
777
|
-
'defs': function (node, removeOptions) {
|
|
778
|
-
removeOptions.removeCommenNodesFromArray(node.p);
|
|
779
|
-
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
780
|
-
},
|
|
781
776
|
'do': function (node, removeOptions) {
|
|
782
777
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
783
778
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
@@ -785,12 +780,11 @@ var specialExpressionCommentRemovers = {
|
|
|
785
780
|
'doseq': function (_node, _removeOptions) { },
|
|
786
781
|
'fn': function (_node, _removeOptions) { },
|
|
787
782
|
'for': function (_node, _removeOptions) { },
|
|
788
|
-
'if_let': function (_node, _removeOptions) { },
|
|
789
783
|
'if': function (node, removeOptions) {
|
|
790
784
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
791
785
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
792
786
|
},
|
|
793
|
-
'
|
|
787
|
+
'unless': function (node, removeOptions) {
|
|
794
788
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
795
789
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
796
790
|
},
|
|
@@ -819,10 +813,6 @@ var specialExpressionCommentRemovers = {
|
|
|
819
813
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
820
814
|
},
|
|
821
815
|
'try': function (_node, _removeOptions) { },
|
|
822
|
-
'when_first': function (_node, _removeOptions) { },
|
|
823
|
-
'when_let': function (_node, _removeOptions) { },
|
|
824
|
-
'when': function (_node, _removeOptions) { },
|
|
825
|
-
'when_not': function (_node, _removeOptions) { },
|
|
826
816
|
};
|
|
827
817
|
function removeCommentNodesFromSpecialExpression(node, removeOptions) {
|
|
828
818
|
var uncommenter = specialExpressionCommentRemovers[node.n];
|
|
@@ -1950,7 +1940,7 @@ var arrayNormalExpression = {
|
|
|
1950
1940
|
};
|
|
1951
1941
|
|
|
1952
1942
|
var sequenceNormalExpression = {
|
|
1953
|
-
nth: {
|
|
1943
|
+
'nth': {
|
|
1954
1944
|
evaluate: function (params, sourceCodeInfo) {
|
|
1955
1945
|
var _a = __read(params, 2), seq = _a[0], i = _a[1];
|
|
1956
1946
|
var defaultValue = toAny(params[2]);
|
|
@@ -1962,7 +1952,7 @@ var sequenceNormalExpression = {
|
|
|
1962
1952
|
},
|
|
1963
1953
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
1964
1954
|
},
|
|
1965
|
-
filter: {
|
|
1955
|
+
'filter': {
|
|
1966
1956
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1967
1957
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1968
1958
|
var executeFunction = _b.executeFunction;
|
|
@@ -1977,7 +1967,7 @@ var sequenceNormalExpression = {
|
|
|
1977
1967
|
},
|
|
1978
1968
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1979
1969
|
},
|
|
1980
|
-
first: {
|
|
1970
|
+
'first': {
|
|
1981
1971
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1982
1972
|
var _b = __read(_a, 1), array = _b[0];
|
|
1983
1973
|
if (array === null)
|
|
@@ -1987,7 +1977,7 @@ var sequenceNormalExpression = {
|
|
|
1987
1977
|
},
|
|
1988
1978
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1989
1979
|
},
|
|
1990
|
-
last: {
|
|
1980
|
+
'last': {
|
|
1991
1981
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1992
1982
|
var _b = __read(_a, 1), array = _b[0];
|
|
1993
1983
|
if (array === null)
|
|
@@ -1997,7 +1987,7 @@ var sequenceNormalExpression = {
|
|
|
1997
1987
|
},
|
|
1998
1988
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1999
1989
|
},
|
|
2000
|
-
map: {
|
|
1990
|
+
'map': {
|
|
2001
1991
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2002
1992
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2003
1993
|
var executeFunction = _b.executeFunction;
|
|
@@ -2019,7 +2009,7 @@ var sequenceNormalExpression = {
|
|
|
2019
2009
|
},
|
|
2020
2010
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2021
2011
|
},
|
|
2022
|
-
pop: {
|
|
2012
|
+
'pop': {
|
|
2023
2013
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2024
2014
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2025
2015
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2030,7 +2020,7 @@ var sequenceNormalExpression = {
|
|
|
2030
2020
|
},
|
|
2031
2021
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2032
2022
|
},
|
|
2033
|
-
position: {
|
|
2023
|
+
'position': {
|
|
2034
2024
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2035
2025
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2036
2026
|
var executeFunction = _b.executeFunction;
|
|
@@ -2049,7 +2039,7 @@ var sequenceNormalExpression = {
|
|
|
2049
2039
|
},
|
|
2050
2040
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2051
2041
|
},
|
|
2052
|
-
index_of: {
|
|
2042
|
+
'index_of': {
|
|
2053
2043
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2054
2044
|
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2055
2045
|
assertAny(value, sourceCodeInfo);
|
|
@@ -2068,7 +2058,26 @@ var sequenceNormalExpression = {
|
|
|
2068
2058
|
},
|
|
2069
2059
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2070
2060
|
},
|
|
2071
|
-
|
|
2061
|
+
'last_index_of': {
|
|
2062
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2063
|
+
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2064
|
+
assertAny(value, sourceCodeInfo);
|
|
2065
|
+
if (seq === null)
|
|
2066
|
+
return null;
|
|
2067
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2068
|
+
if (typeof seq === 'string') {
|
|
2069
|
+
assertString(value, sourceCodeInfo);
|
|
2070
|
+
var index = seq.lastIndexOf(value);
|
|
2071
|
+
return index !== -1 ? index : null;
|
|
2072
|
+
}
|
|
2073
|
+
else {
|
|
2074
|
+
var index = seq.lastIndexOf(value);
|
|
2075
|
+
return index !== -1 ? index : null;
|
|
2076
|
+
}
|
|
2077
|
+
},
|
|
2078
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2079
|
+
},
|
|
2080
|
+
'push': {
|
|
2072
2081
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2073
2082
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2074
2083
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2082,7 +2091,7 @@ var sequenceNormalExpression = {
|
|
|
2082
2091
|
},
|
|
2083
2092
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2084
2093
|
},
|
|
2085
|
-
reductions: {
|
|
2094
|
+
'reductions': {
|
|
2086
2095
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2087
2096
|
var executeFunction = _a.executeFunction;
|
|
2088
2097
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2143,7 +2152,7 @@ var sequenceNormalExpression = {
|
|
|
2143
2152
|
},
|
|
2144
2153
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2145
2154
|
},
|
|
2146
|
-
reduce: {
|
|
2155
|
+
'reduce': {
|
|
2147
2156
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2148
2157
|
var executeFunction = _a.executeFunction;
|
|
2149
2158
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2190,7 +2199,7 @@ var sequenceNormalExpression = {
|
|
|
2190
2199
|
},
|
|
2191
2200
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2192
2201
|
},
|
|
2193
|
-
reduce_right: {
|
|
2202
|
+
'reduce_right': {
|
|
2194
2203
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2195
2204
|
var executeFunction = _a.executeFunction;
|
|
2196
2205
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2238,7 +2247,7 @@ var sequenceNormalExpression = {
|
|
|
2238
2247
|
},
|
|
2239
2248
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2240
2249
|
},
|
|
2241
|
-
rest: {
|
|
2250
|
+
'rest': {
|
|
2242
2251
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2243
2252
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2244
2253
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2251,7 +2260,7 @@ var sequenceNormalExpression = {
|
|
|
2251
2260
|
},
|
|
2252
2261
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2253
2262
|
},
|
|
2254
|
-
nthrest: {
|
|
2263
|
+
'nthrest': {
|
|
2255
2264
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2256
2265
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2257
2266
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2263,7 +2272,7 @@ var sequenceNormalExpression = {
|
|
|
2263
2272
|
},
|
|
2264
2273
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2265
2274
|
},
|
|
2266
|
-
next: {
|
|
2275
|
+
'next': {
|
|
2267
2276
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2268
2277
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2269
2278
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2278,7 +2287,7 @@ var sequenceNormalExpression = {
|
|
|
2278
2287
|
},
|
|
2279
2288
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2280
2289
|
},
|
|
2281
|
-
nthnext: {
|
|
2290
|
+
'nthnext': {
|
|
2282
2291
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2283
2292
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2284
2293
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2292,7 +2301,7 @@ var sequenceNormalExpression = {
|
|
|
2292
2301
|
},
|
|
2293
2302
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2294
2303
|
},
|
|
2295
|
-
reverse: {
|
|
2304
|
+
'reverse': {
|
|
2296
2305
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2297
2306
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2298
2307
|
if (seq === null)
|
|
@@ -2304,7 +2313,7 @@ var sequenceNormalExpression = {
|
|
|
2304
2313
|
},
|
|
2305
2314
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2306
2315
|
},
|
|
2307
|
-
second: {
|
|
2316
|
+
'second': {
|
|
2308
2317
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2309
2318
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2310
2319
|
if (seq === null)
|
|
@@ -2314,7 +2323,7 @@ var sequenceNormalExpression = {
|
|
|
2314
2323
|
},
|
|
2315
2324
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2316
2325
|
},
|
|
2317
|
-
shift: {
|
|
2326
|
+
'shift': {
|
|
2318
2327
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2319
2328
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2320
2329
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2326,7 +2335,7 @@ var sequenceNormalExpression = {
|
|
|
2326
2335
|
},
|
|
2327
2336
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2328
2337
|
},
|
|
2329
|
-
slice: {
|
|
2338
|
+
'slice': {
|
|
2330
2339
|
evaluate: function (params, sourceCodeInfo) {
|
|
2331
2340
|
var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
|
|
2332
2341
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2340,7 +2349,7 @@ var sequenceNormalExpression = {
|
|
|
2340
2349
|
},
|
|
2341
2350
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
|
|
2342
2351
|
},
|
|
2343
|
-
some: {
|
|
2352
|
+
'some': {
|
|
2344
2353
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2345
2354
|
var _c;
|
|
2346
2355
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2357,7 +2366,7 @@ var sequenceNormalExpression = {
|
|
|
2357
2366
|
},
|
|
2358
2367
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2359
2368
|
},
|
|
2360
|
-
sort: {
|
|
2369
|
+
'sort': {
|
|
2361
2370
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2362
2371
|
var executeFunction = _a.executeFunction;
|
|
2363
2372
|
var _b = __read(params, 1), seq = _b[0];
|
|
@@ -2395,7 +2404,7 @@ var sequenceNormalExpression = {
|
|
|
2395
2404
|
},
|
|
2396
2405
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
2397
2406
|
},
|
|
2398
|
-
sort_by: {
|
|
2407
|
+
'sort_by': {
|
|
2399
2408
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2400
2409
|
var executeFunction = _a.executeFunction;
|
|
2401
2410
|
var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
|
|
@@ -2446,7 +2455,7 @@ var sequenceNormalExpression = {
|
|
|
2446
2455
|
},
|
|
2447
2456
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2448
2457
|
},
|
|
2449
|
-
take: {
|
|
2458
|
+
'take': {
|
|
2450
2459
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2451
2460
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2452
2461
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2456,7 +2465,7 @@ var sequenceNormalExpression = {
|
|
|
2456
2465
|
},
|
|
2457
2466
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2458
2467
|
},
|
|
2459
|
-
take_last: {
|
|
2468
|
+
'take_last': {
|
|
2460
2469
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2461
2470
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2462
2471
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2467,7 +2476,7 @@ var sequenceNormalExpression = {
|
|
|
2467
2476
|
},
|
|
2468
2477
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2469
2478
|
},
|
|
2470
|
-
take_while: {
|
|
2479
|
+
'take_while': {
|
|
2471
2480
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2472
2481
|
var e_1, _c;
|
|
2473
2482
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2495,7 +2504,7 @@ var sequenceNormalExpression = {
|
|
|
2495
2504
|
},
|
|
2496
2505
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2497
2506
|
},
|
|
2498
|
-
drop: {
|
|
2507
|
+
'drop': {
|
|
2499
2508
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2500
2509
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2501
2510
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2505,7 +2514,7 @@ var sequenceNormalExpression = {
|
|
|
2505
2514
|
},
|
|
2506
2515
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2507
2516
|
},
|
|
2508
|
-
drop_last: {
|
|
2517
|
+
'drop_last': {
|
|
2509
2518
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2510
2519
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2511
2520
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2516,7 +2525,7 @@ var sequenceNormalExpression = {
|
|
|
2516
2525
|
},
|
|
2517
2526
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2518
2527
|
},
|
|
2519
|
-
drop_while: {
|
|
2528
|
+
'drop_while': {
|
|
2520
2529
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2521
2530
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2522
2531
|
var executeFunction = _b.executeFunction;
|
|
@@ -2532,7 +2541,7 @@ var sequenceNormalExpression = {
|
|
|
2532
2541
|
},
|
|
2533
2542
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2534
2543
|
},
|
|
2535
|
-
unshift: {
|
|
2544
|
+
'unshift': {
|
|
2536
2545
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2537
2546
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2538
2547
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2546,7 +2555,7 @@ var sequenceNormalExpression = {
|
|
|
2546
2555
|
},
|
|
2547
2556
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2548
2557
|
},
|
|
2549
|
-
distinct: {
|
|
2558
|
+
'distinct': {
|
|
2550
2559
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2551
2560
|
var _b = __read(_a, 1), input = _b[0];
|
|
2552
2561
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2556,9 +2565,9 @@ var sequenceNormalExpression = {
|
|
|
2556
2565
|
},
|
|
2557
2566
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2558
2567
|
},
|
|
2559
|
-
remove: {
|
|
2568
|
+
'remove': {
|
|
2560
2569
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2561
|
-
var _c = __read(_a, 2),
|
|
2570
|
+
var _c = __read(_a, 2), input = _c[0], fn = _c[1];
|
|
2562
2571
|
var executeFunction = _b.executeFunction;
|
|
2563
2572
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2564
2573
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2571,9 +2580,9 @@ var sequenceNormalExpression = {
|
|
|
2571
2580
|
},
|
|
2572
2581
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2573
2582
|
},
|
|
2574
|
-
remove_at: {
|
|
2583
|
+
'remove_at': {
|
|
2575
2584
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2576
|
-
var _b = __read(_a, 2),
|
|
2585
|
+
var _b = __read(_a, 2), input = _b[0], index = _b[1];
|
|
2577
2586
|
assertNumber(index, sourceCodeInfo);
|
|
2578
2587
|
assertSeq(input, sourceCodeInfo);
|
|
2579
2588
|
var intIndex = Math.ceil(index);
|
|
@@ -2588,9 +2597,9 @@ var sequenceNormalExpression = {
|
|
|
2588
2597
|
},
|
|
2589
2598
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2590
2599
|
},
|
|
2591
|
-
split_at: {
|
|
2600
|
+
'split_at': {
|
|
2592
2601
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2593
|
-
var _b = __read(_a, 2),
|
|
2602
|
+
var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
|
|
2594
2603
|
assertNumber(pos, sourceCodeInfo, { finite: true });
|
|
2595
2604
|
var intPos = toNonNegativeInteger(pos);
|
|
2596
2605
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2598,9 +2607,9 @@ var sequenceNormalExpression = {
|
|
|
2598
2607
|
},
|
|
2599
2608
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2600
2609
|
},
|
|
2601
|
-
split_with: {
|
|
2610
|
+
'split_with': {
|
|
2602
2611
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2603
|
-
var _c = __read(_a, 2),
|
|
2612
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2604
2613
|
var executeFunction = _b.executeFunction;
|
|
2605
2614
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2606
2615
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2613,7 +2622,7 @@ var sequenceNormalExpression = {
|
|
|
2613
2622
|
},
|
|
2614
2623
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2615
2624
|
},
|
|
2616
|
-
frequencies: {
|
|
2625
|
+
'frequencies': {
|
|
2617
2626
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2618
2627
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2619
2628
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2629,9 +2638,9 @@ var sequenceNormalExpression = {
|
|
|
2629
2638
|
},
|
|
2630
2639
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2631
2640
|
},
|
|
2632
|
-
group_by: {
|
|
2641
|
+
'group_by': {
|
|
2633
2642
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2634
|
-
var _c = __read(_a, 2),
|
|
2643
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2635
2644
|
var executeFunction = _b.executeFunction;
|
|
2636
2645
|
assertAny(fn, sourceCodeInfo);
|
|
2637
2646
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2647,34 +2656,30 @@ var sequenceNormalExpression = {
|
|
|
2647
2656
|
},
|
|
2648
2657
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2649
2658
|
},
|
|
2650
|
-
partition: {
|
|
2659
|
+
'partition': {
|
|
2651
2660
|
evaluate: function (params, sourceCodeInfo) {
|
|
2652
|
-
var
|
|
2653
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2654
|
-
var
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
: asSeq(params[3], sourceCodeInfo);
|
|
2659
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2660
|
-
var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
|
|
2661
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2662
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2663
|
+
var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2664
|
+
var pad = params.length === 4
|
|
2665
|
+
? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
|
|
2666
|
+
: undefined;
|
|
2661
2667
|
return partition(n, step, seq, pad, sourceCodeInfo);
|
|
2662
2668
|
},
|
|
2663
2669
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
|
|
2664
2670
|
},
|
|
2665
|
-
partition_all: {
|
|
2671
|
+
'partition_all': {
|
|
2666
2672
|
evaluate: function (params, sourceCodeInfo) {
|
|
2667
|
-
var
|
|
2668
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2669
|
-
var
|
|
2670
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2673
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2674
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2675
|
+
var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2671
2676
|
return partition(n, step, seq, [], sourceCodeInfo);
|
|
2672
2677
|
},
|
|
2673
2678
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2674
2679
|
},
|
|
2675
|
-
partition_by: {
|
|
2680
|
+
'partition_by': {
|
|
2676
2681
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2677
|
-
var _c = __read(_a, 2),
|
|
2682
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2678
2683
|
var executeFunction = _b.executeFunction;
|
|
2679
2684
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2680
2685
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2691,7 +2696,88 @@ var sequenceNormalExpression = {
|
|
|
2691
2696
|
}, []);
|
|
2692
2697
|
return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
|
|
2693
2698
|
},
|
|
2694
|
-
validate: function (node) { return assertNumberOfParams(
|
|
2699
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2700
|
+
},
|
|
2701
|
+
'ends_with?': {
|
|
2702
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2703
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2704
|
+
assertSeq(str, sourceCodeInfo);
|
|
2705
|
+
if (typeof str === 'string') {
|
|
2706
|
+
assertString(search, sourceCodeInfo);
|
|
2707
|
+
return str.endsWith(search);
|
|
2708
|
+
}
|
|
2709
|
+
return str.at(-1) === search;
|
|
2710
|
+
},
|
|
2711
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2712
|
+
},
|
|
2713
|
+
'starts_with?': {
|
|
2714
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2715
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2716
|
+
assertSeq(str, sourceCodeInfo);
|
|
2717
|
+
if (typeof str === 'string') {
|
|
2718
|
+
assertString(search, sourceCodeInfo);
|
|
2719
|
+
return str.startsWith(search);
|
|
2720
|
+
}
|
|
2721
|
+
return str[0] === search;
|
|
2722
|
+
},
|
|
2723
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2724
|
+
},
|
|
2725
|
+
'interleave': {
|
|
2726
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2727
|
+
var e_2, _b;
|
|
2728
|
+
var _c = __read(_a), seqs = _c.slice(0);
|
|
2729
|
+
var isStringSeq = typeof seqs[0] === 'string';
|
|
2730
|
+
var seqsArr = isStringSeq
|
|
2731
|
+
? seqs.map(function (seq) {
|
|
2732
|
+
assertString(seq, sourceCodeInfo);
|
|
2733
|
+
if (typeof seq === 'string')
|
|
2734
|
+
return seq.split('');
|
|
2735
|
+
return seq;
|
|
2736
|
+
})
|
|
2737
|
+
: seqs.map(function (seq) {
|
|
2738
|
+
assertArray(seq, sourceCodeInfo);
|
|
2739
|
+
return seq;
|
|
2740
|
+
});
|
|
2741
|
+
var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
|
|
2742
|
+
var result = [];
|
|
2743
|
+
for (var i = 0; i < maxLength; i += 1) {
|
|
2744
|
+
try {
|
|
2745
|
+
for (var seqsArr_1 = (e_2 = void 0, __values(seqsArr)), seqsArr_1_1 = seqsArr_1.next(); !seqsArr_1_1.done; seqsArr_1_1 = seqsArr_1.next()) {
|
|
2746
|
+
var seq = seqsArr_1_1.value;
|
|
2747
|
+
if (i < seq.length)
|
|
2748
|
+
result.push(seq[i]);
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2752
|
+
finally {
|
|
2753
|
+
try {
|
|
2754
|
+
if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
|
|
2755
|
+
}
|
|
2756
|
+
finally { if (e_2) throw e_2.error; }
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
return isStringSeq ? result.join('') : result;
|
|
2760
|
+
},
|
|
2761
|
+
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
2762
|
+
},
|
|
2763
|
+
'interpose': {
|
|
2764
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2765
|
+
var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
|
|
2766
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2767
|
+
if (typeof seq === 'string') {
|
|
2768
|
+
assertString(separator, sourceCodeInfo);
|
|
2769
|
+
return seq.split('').join(separator);
|
|
2770
|
+
}
|
|
2771
|
+
if (seq.length === 0)
|
|
2772
|
+
return [];
|
|
2773
|
+
var result = [];
|
|
2774
|
+
for (var i = 0; i < seq.length - 1; i += 1) {
|
|
2775
|
+
result.push(seq[i], separator);
|
|
2776
|
+
}
|
|
2777
|
+
result.push(seq[seq.length - 1]);
|
|
2778
|
+
return result;
|
|
2779
|
+
},
|
|
2780
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2695
2781
|
},
|
|
2696
2782
|
};
|
|
2697
2783
|
function partition(n, step, seq, pad, sourceCodeInfo) {
|
|
@@ -3854,7 +3940,7 @@ var regexpNormalExpression = {
|
|
|
3854
3940
|
},
|
|
3855
3941
|
match: {
|
|
3856
3942
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3857
|
-
var _b = __read(_a, 2),
|
|
3943
|
+
var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
|
|
3858
3944
|
assertRegularExpression(regexp, sourceCodeInfo);
|
|
3859
3945
|
if (!isString(text))
|
|
3860
3946
|
return null;
|
|
@@ -3870,15 +3956,27 @@ var regexpNormalExpression = {
|
|
|
3870
3956
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3871
3957
|
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
3872
3958
|
assertString(str, sourceCodeInfo);
|
|
3873
|
-
|
|
3959
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
3874
3960
|
assertString(value, sourceCodeInfo);
|
|
3875
|
-
var
|
|
3876
|
-
return str.replace(
|
|
3961
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
|
|
3962
|
+
return str.replace(matcher, value);
|
|
3963
|
+
},
|
|
3964
|
+
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3965
|
+
},
|
|
3966
|
+
replace_all: {
|
|
3967
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
3968
|
+
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
3969
|
+
assertString(str, sourceCodeInfo);
|
|
3970
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
3971
|
+
assertString(value, sourceCodeInfo);
|
|
3972
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
|
|
3973
|
+
return str.replaceAll(matcher, value);
|
|
3877
3974
|
},
|
|
3878
3975
|
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3879
3976
|
},
|
|
3880
3977
|
};
|
|
3881
3978
|
|
|
3979
|
+
var blankRegexp = /^\s*$/;
|
|
3882
3980
|
var stringNormalExpression = {
|
|
3883
3981
|
'subs': {
|
|
3884
3982
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -4036,6 +4134,14 @@ var stringNormalExpression = {
|
|
|
4036
4134
|
},
|
|
4037
4135
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4038
4136
|
},
|
|
4137
|
+
'split_lines': {
|
|
4138
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4139
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4140
|
+
assertString(str, sourceCodeInfo);
|
|
4141
|
+
return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
|
|
4142
|
+
},
|
|
4143
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4144
|
+
},
|
|
4039
4145
|
'pad_left': {
|
|
4040
4146
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4041
4147
|
var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
|
|
@@ -4139,6 +4245,25 @@ var stringNormalExpression = {
|
|
|
4139
4245
|
},
|
|
4140
4246
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4141
4247
|
},
|
|
4248
|
+
'blank?': {
|
|
4249
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4250
|
+
var _b = __read(_a, 1), value = _b[0];
|
|
4251
|
+
if (value === null) {
|
|
4252
|
+
return true;
|
|
4253
|
+
}
|
|
4254
|
+
assertString(value, sourceCodeInfo);
|
|
4255
|
+
return blankRegexp.test(value);
|
|
4256
|
+
},
|
|
4257
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4258
|
+
},
|
|
4259
|
+
'capitalize': {
|
|
4260
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4261
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4262
|
+
assertString(str, sourceCodeInfo);
|
|
4263
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
4264
|
+
},
|
|
4265
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4266
|
+
},
|
|
4142
4267
|
};
|
|
4143
4268
|
var doubleDollarRegexp = /\$\$/g;
|
|
4144
4269
|
function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
|
|
@@ -4412,7 +4537,7 @@ var switchSpecialExpression = {
|
|
|
4412
4537
|
};
|
|
4413
4538
|
|
|
4414
4539
|
var declaredSpecialExpression = {
|
|
4415
|
-
polishParse: getCommonPolishSpecialExpressionParser('
|
|
4540
|
+
polishParse: getCommonPolishSpecialExpressionParser('defined?'),
|
|
4416
4541
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
4417
4542
|
evaluate: function (node, contextStack) {
|
|
4418
4543
|
var lookUpResult = contextStack.lookUp(node.p[0]);
|
|
@@ -4468,9 +4593,7 @@ var defSpecialExpression = {
|
|
|
4468
4593
|
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4469
4594
|
var name = node.p[0].v;
|
|
4470
4595
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4471
|
-
contextStack.
|
|
4472
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4473
|
-
};
|
|
4596
|
+
contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
|
|
4474
4597
|
return null;
|
|
4475
4598
|
},
|
|
4476
4599
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
@@ -4481,47 +4604,7 @@ var defSpecialExpression = {
|
|
|
4481
4604
|
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4482
4605
|
var name = asSymbolNode(node.p[0]).v;
|
|
4483
4606
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4484
|
-
contextStack.
|
|
4485
|
-
return result;
|
|
4486
|
-
},
|
|
4487
|
-
};
|
|
4488
|
-
|
|
4489
|
-
var defsSpecialExpression = {
|
|
4490
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4491
|
-
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4492
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4493
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4494
|
-
var node = {
|
|
4495
|
-
t: AstNodeType.SpecialExpression,
|
|
4496
|
-
n: 'defs',
|
|
4497
|
-
p: params,
|
|
4498
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4499
|
-
};
|
|
4500
|
-
return node;
|
|
4501
|
-
},
|
|
4502
|
-
validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
|
|
4503
|
-
evaluate: function (node, contextStack, _a) {
|
|
4504
|
-
var _b, _c;
|
|
4505
|
-
var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
|
|
4506
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4507
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4508
|
-
assertString(name, sourceCodeInfo);
|
|
4509
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4510
|
-
contextStack.globalContext[name] = {
|
|
4511
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4512
|
-
};
|
|
4513
|
-
return null;
|
|
4514
|
-
},
|
|
4515
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4516
|
-
var _b;
|
|
4517
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4518
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4519
|
-
var subNode = node.p[1];
|
|
4520
|
-
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4521
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4522
|
-
assertString(name, sourceCodeInfo);
|
|
4523
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4524
|
-
contextStack.globalContext[name] = { value: true };
|
|
4607
|
+
contextStack.exportValue(name, true);
|
|
4525
4608
|
return result;
|
|
4526
4609
|
},
|
|
4527
4610
|
};
|
|
@@ -4552,7 +4635,7 @@ var doSpecialExpression = {
|
|
|
4552
4635
|
},
|
|
4553
4636
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4554
4637
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4555
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
4638
|
+
return findUnresolvedIdentifiers(node.p, contextStack.create({}), builtin);
|
|
4556
4639
|
},
|
|
4557
4640
|
};
|
|
4558
4641
|
|
|
@@ -4581,11 +4664,6 @@ function joinAnalyzeResults() {
|
|
|
4581
4664
|
function addAnalyzeResults(target, source) {
|
|
4582
4665
|
source.forEach(function (symbol) { return target.add(symbol); });
|
|
4583
4666
|
}
|
|
4584
|
-
function combinate(arrays) {
|
|
4585
|
-
return arrays.reduce(function (acc, curr) {
|
|
4586
|
-
return acc.flatMap(function (a) { return curr.map(function (c) { return __spreadArray(__spreadArray([], __read(a), false), [c], false); }); });
|
|
4587
|
-
}, [[]]);
|
|
4588
|
-
}
|
|
4589
4667
|
|
|
4590
4668
|
var defnSpecialExpression = {
|
|
4591
4669
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
@@ -4610,7 +4688,7 @@ var defnSpecialExpression = {
|
|
|
4610
4688
|
var _b;
|
|
4611
4689
|
var _c, _d;
|
|
4612
4690
|
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4613
|
-
var name =
|
|
4691
|
+
var name = node.f.v;
|
|
4614
4692
|
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4615
4693
|
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4616
4694
|
var litsFunction = (_b = {},
|
|
@@ -4620,64 +4698,17 @@ var defnSpecialExpression = {
|
|
|
4620
4698
|
_b.n = name,
|
|
4621
4699
|
_b.o = evaluatedFunctionOverloades,
|
|
4622
4700
|
_b);
|
|
4623
|
-
contextStack.
|
|
4701
|
+
contextStack.exportValue(name, litsFunction);
|
|
4624
4702
|
return null;
|
|
4625
4703
|
},
|
|
4626
4704
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4627
4705
|
var _b;
|
|
4628
4706
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4629
|
-
contextStack.
|
|
4707
|
+
contextStack.exportValue(node.f.v, true);
|
|
4630
4708
|
var newContext = (_b = {}, _b[node.f.v] = { value: true }, _b);
|
|
4631
4709
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4632
4710
|
},
|
|
4633
4711
|
};
|
|
4634
|
-
var defnsSpecialExpression = {
|
|
4635
|
-
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4636
|
-
var parseToken = parsers.parseToken;
|
|
4637
|
-
var functionName = parseToken(tokenStream, parseState);
|
|
4638
|
-
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
4639
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4640
|
-
var node = {
|
|
4641
|
-
t: AstNodeType.SpecialExpression,
|
|
4642
|
-
n: 'defns',
|
|
4643
|
-
p: [],
|
|
4644
|
-
f: functionName,
|
|
4645
|
-
o: functionOverloades,
|
|
4646
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4647
|
-
};
|
|
4648
|
-
return node;
|
|
4649
|
-
},
|
|
4650
|
-
validateParameterCount: function () { return undefined; },
|
|
4651
|
-
evaluate: function (node, contextStack, _a) {
|
|
4652
|
-
var _b;
|
|
4653
|
-
var _c, _d;
|
|
4654
|
-
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4655
|
-
var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
|
|
4656
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4657
|
-
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4658
|
-
var litsFunction = (_b = {},
|
|
4659
|
-
_b[FUNCTION_SYMBOL] = true,
|
|
4660
|
-
_b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
|
|
4661
|
-
_b.t = FunctionType.UserDefined,
|
|
4662
|
-
_b.n = name,
|
|
4663
|
-
_b.o = evaluatedFunctionOverloades,
|
|
4664
|
-
_b);
|
|
4665
|
-
contextStack.globalContext[name] = { value: litsFunction };
|
|
4666
|
-
return null;
|
|
4667
|
-
},
|
|
4668
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4669
|
-
var _b;
|
|
4670
|
-
var _c;
|
|
4671
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4672
|
-
var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
|
|
4673
|
-
var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
|
|
4674
|
-
assertString(name, sourceCodeInfo);
|
|
4675
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4676
|
-
contextStack.globalContext[name] = { value: true };
|
|
4677
|
-
var newContext = (_b = {}, _b[name] = { value: true }, _b);
|
|
4678
|
-
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4679
|
-
},
|
|
4680
|
-
};
|
|
4681
4712
|
var fnSpecialExpression = {
|
|
4682
4713
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4683
4714
|
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
@@ -4711,14 +4742,6 @@ var fnSpecialExpression = {
|
|
|
4711
4742
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
|
|
4712
4743
|
},
|
|
4713
4744
|
};
|
|
4714
|
-
function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
|
|
4715
|
-
var _a;
|
|
4716
|
-
var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
|
|
4717
|
-
if (expressionName === 'defn')
|
|
4718
|
-
return (node.f).v;
|
|
4719
|
-
var name = evaluateAstNode(node.f, contextStack);
|
|
4720
|
-
return asString(name, sourceCodeInfo);
|
|
4721
|
-
}
|
|
4722
4745
|
function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
|
|
4723
4746
|
var e_1, _a, e_2, _b;
|
|
4724
4747
|
var evaluatedFunctionOverloades = [];
|
|
@@ -4946,56 +4969,8 @@ var ifSpecialExpression = {
|
|
|
4946
4969
|
},
|
|
4947
4970
|
};
|
|
4948
4971
|
|
|
4949
|
-
var
|
|
4950
|
-
polishParse:
|
|
4951
|
-
var _b, _c;
|
|
4952
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4953
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
4954
|
-
if (bindings.length !== 1) {
|
|
4955
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
4956
|
-
}
|
|
4957
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4958
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4959
|
-
var node = {
|
|
4960
|
-
t: AstNodeType.SpecialExpression,
|
|
4961
|
-
n: 'if_let',
|
|
4962
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
4963
|
-
p: params,
|
|
4964
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4965
|
-
};
|
|
4966
|
-
return node;
|
|
4967
|
-
},
|
|
4968
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
4969
|
-
evaluate: function (node, contextStack, _a) {
|
|
4970
|
-
var _b;
|
|
4971
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
4972
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4973
|
-
var locals = {};
|
|
4974
|
-
var bindingValue = evaluateAstNode(node.b.v, contextStack);
|
|
4975
|
-
if (bindingValue) {
|
|
4976
|
-
locals[node.b.n] = { value: bindingValue };
|
|
4977
|
-
var newContextStack = contextStack.create(locals);
|
|
4978
|
-
var thenForm = asAstNode(node.p[0], sourceCodeInfo);
|
|
4979
|
-
return evaluateAstNode(thenForm, newContextStack);
|
|
4980
|
-
}
|
|
4981
|
-
if (node.p.length === 2) {
|
|
4982
|
-
var elseForm = asAstNode(node.p[1], sourceCodeInfo);
|
|
4983
|
-
return evaluateAstNode(elseForm, contextStack);
|
|
4984
|
-
}
|
|
4985
|
-
return null;
|
|
4986
|
-
},
|
|
4987
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4988
|
-
var _b;
|
|
4989
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4990
|
-
var newContext = (_b = {}, _b[node.b.n] = { value: true }, _b);
|
|
4991
|
-
var bindingResult = findUnresolvedIdentifiers([node.b.v], contextStack, builtin);
|
|
4992
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
4993
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
4994
|
-
},
|
|
4995
|
-
};
|
|
4996
|
-
|
|
4997
|
-
var ifNotSpecialExpression = {
|
|
4998
|
-
polishParse: getCommonPolishSpecialExpressionParser('if_not'),
|
|
4972
|
+
var unlessSpecialExpression = {
|
|
4973
|
+
polishParse: getCommonPolishSpecialExpressionParser('unless'),
|
|
4999
4974
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
5000
4975
|
evaluate: function (node, contextStack, _a) {
|
|
5001
4976
|
var _b;
|
|
@@ -5020,55 +4995,39 @@ var ifNotSpecialExpression = {
|
|
|
5020
4995
|
|
|
5021
4996
|
var letSpecialExpression = {
|
|
5022
4997
|
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5023
|
-
var parseBindings = _a.parseBindings
|
|
4998
|
+
var parseBindings = _a.parseBindings;
|
|
5024
4999
|
var bindings = parseBindings(tokenStream, parseState);
|
|
5025
|
-
|
|
5000
|
+
// const params = parseTokensUntilClosingBracket(tokenStream, parseState)
|
|
5026
5001
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5027
5002
|
var node = {
|
|
5028
5003
|
t: AstNodeType.SpecialExpression,
|
|
5029
5004
|
n: 'let',
|
|
5030
|
-
p:
|
|
5005
|
+
p: [],
|
|
5031
5006
|
bs: bindings,
|
|
5032
5007
|
token: getTokenDebugData(firstToken) && firstToken,
|
|
5033
5008
|
};
|
|
5034
5009
|
return node;
|
|
5035
5010
|
},
|
|
5036
|
-
validateParameterCount: function () { return
|
|
5011
|
+
validateParameterCount: function (node) { return assertNumberOfParams(0, node); },
|
|
5037
5012
|
evaluate: function (node, contextStack, _a) {
|
|
5038
|
-
var e_1, _b
|
|
5013
|
+
var e_1, _b;
|
|
5039
5014
|
var evaluateAstNode = _a.evaluateAstNode;
|
|
5040
|
-
var locals = {};
|
|
5041
|
-
var newContextStack = contextStack.create(locals);
|
|
5042
5015
|
try {
|
|
5043
|
-
for (var
|
|
5044
|
-
var binding =
|
|
5016
|
+
for (var _c = __values(node.bs), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5017
|
+
var binding = _d.value;
|
|
5045
5018
|
var bindingValueNode = binding.v;
|
|
5046
|
-
var bindingValue = evaluateAstNode(bindingValueNode,
|
|
5047
|
-
|
|
5019
|
+
var bindingValue = evaluateAstNode(bindingValueNode, contextStack);
|
|
5020
|
+
contextStack.addValue(binding.n, bindingValue);
|
|
5048
5021
|
}
|
|
5049
5022
|
}
|
|
5050
5023
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5051
5024
|
finally {
|
|
5052
5025
|
try {
|
|
5053
|
-
if (
|
|
5026
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5054
5027
|
}
|
|
5055
5028
|
finally { if (e_1) throw e_1.error; }
|
|
5056
5029
|
}
|
|
5057
|
-
|
|
5058
|
-
try {
|
|
5059
|
-
for (var _f = __values(node.p), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
5060
|
-
var astNode = _g.value;
|
|
5061
|
-
result = evaluateAstNode(astNode, newContextStack);
|
|
5062
|
-
}
|
|
5063
|
-
}
|
|
5064
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
5065
|
-
finally {
|
|
5066
|
-
try {
|
|
5067
|
-
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
|
|
5068
|
-
}
|
|
5069
|
-
finally { if (e_2) throw e_2.error; }
|
|
5070
|
-
}
|
|
5071
|
-
return result;
|
|
5030
|
+
return null;
|
|
5072
5031
|
},
|
|
5073
5032
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5074
5033
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
@@ -5078,11 +5037,10 @@ var letSpecialExpression = {
|
|
|
5078
5037
|
context[name] = { value: true };
|
|
5079
5038
|
return context;
|
|
5080
5039
|
}, {});
|
|
5081
|
-
var bindingContext = {};
|
|
5082
5040
|
var bindingResults = node.bs.map(function (bindingNode) {
|
|
5083
5041
|
var valueNode = bindingNode.v;
|
|
5084
|
-
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack
|
|
5085
|
-
|
|
5042
|
+
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack, builtin);
|
|
5043
|
+
contextStack.addValue(bindingNode.n, { value: true });
|
|
5086
5044
|
return bindingsResult;
|
|
5087
5045
|
});
|
|
5088
5046
|
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
@@ -5533,9 +5491,10 @@ var trySpecialExpression = {
|
|
|
5533
5491
|
return evaluateAstNode(tryExpressions[0], contextStack);
|
|
5534
5492
|
}
|
|
5535
5493
|
catch (error) {
|
|
5536
|
-
var newContext =
|
|
5537
|
-
_b
|
|
5538
|
-
|
|
5494
|
+
var newContext = errorNode
|
|
5495
|
+
? (_b = {},
|
|
5496
|
+
_b[errorNode.v] = { value: asAny(error, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo) },
|
|
5497
|
+
_b) : {};
|
|
5539
5498
|
return evaluateAstNode(catchExpression, contextStack.create(newContext));
|
|
5540
5499
|
}
|
|
5541
5500
|
},
|
|
@@ -5544,199 +5503,15 @@ var trySpecialExpression = {
|
|
|
5544
5503
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5545
5504
|
var tryExpressions = node.p, catchExpression = node.ce, errorNode = node.e;
|
|
5546
5505
|
var tryResult = findUnresolvedIdentifiers(tryExpressions, contextStack, builtin);
|
|
5547
|
-
var newContext =
|
|
5548
|
-
_b
|
|
5549
|
-
|
|
5506
|
+
var newContext = errorNode
|
|
5507
|
+
? (_b = {},
|
|
5508
|
+
_b[errorNode.v] = { value: true },
|
|
5509
|
+
_b) : {};
|
|
5550
5510
|
var catchResult = findUnresolvedIdentifiers([catchExpression], contextStack.create(newContext), builtin);
|
|
5551
5511
|
return joinAnalyzeResults(tryResult, catchResult);
|
|
5552
5512
|
},
|
|
5553
5513
|
};
|
|
5554
5514
|
|
|
5555
|
-
var whenSpecialExpression = {
|
|
5556
|
-
polishParse: getCommonPolishSpecialExpressionParser('when'),
|
|
5557
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5558
|
-
evaluate: function (node, contextStack, _a) {
|
|
5559
|
-
var e_1, _b;
|
|
5560
|
-
var _c;
|
|
5561
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5562
|
-
var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
|
|
5563
|
-
assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5564
|
-
if (!evaluateAstNode(whenExpression, contextStack))
|
|
5565
|
-
return null;
|
|
5566
|
-
var result = null;
|
|
5567
|
-
try {
|
|
5568
|
-
for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
|
|
5569
|
-
var form = body_1_1.value;
|
|
5570
|
-
result = evaluateAstNode(form, contextStack);
|
|
5571
|
-
}
|
|
5572
|
-
}
|
|
5573
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5574
|
-
finally {
|
|
5575
|
-
try {
|
|
5576
|
-
if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
|
|
5577
|
-
}
|
|
5578
|
-
finally { if (e_1) throw e_1.error; }
|
|
5579
|
-
}
|
|
5580
|
-
return result;
|
|
5581
|
-
},
|
|
5582
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5583
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5584
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5585
|
-
},
|
|
5586
|
-
};
|
|
5587
|
-
|
|
5588
|
-
var whenFirstSpecialExpression = {
|
|
5589
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5590
|
-
var _b, _c;
|
|
5591
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5592
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5593
|
-
if (bindings.length !== 1) {
|
|
5594
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5595
|
-
}
|
|
5596
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5597
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5598
|
-
var node = {
|
|
5599
|
-
t: AstNodeType.SpecialExpression,
|
|
5600
|
-
n: 'when_first',
|
|
5601
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5602
|
-
p: params,
|
|
5603
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5604
|
-
};
|
|
5605
|
-
return node;
|
|
5606
|
-
},
|
|
5607
|
-
validateParameterCount: function () { return undefined; },
|
|
5608
|
-
evaluate: function (node, contextStack, _a) {
|
|
5609
|
-
var e_1, _b;
|
|
5610
|
-
var _c;
|
|
5611
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5612
|
-
var locals = {};
|
|
5613
|
-
var binding = node.b;
|
|
5614
|
-
var evaluatedBindingForm = evaluateAstNode(binding.v, contextStack);
|
|
5615
|
-
if (!isSeq(evaluatedBindingForm)) {
|
|
5616
|
-
throw new LitsError("Expected undefined or a sequence, got ".concat(valueToString(evaluatedBindingForm)), (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5617
|
-
}
|
|
5618
|
-
if (evaluatedBindingForm.length === 0)
|
|
5619
|
-
return null;
|
|
5620
|
-
var bindingValue = toAny(evaluatedBindingForm[0]);
|
|
5621
|
-
locals[binding.n] = { value: bindingValue };
|
|
5622
|
-
var newContextStack = contextStack.create(locals);
|
|
5623
|
-
var result = null;
|
|
5624
|
-
try {
|
|
5625
|
-
for (var _d = __values(node.p), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
5626
|
-
var form = _e.value;
|
|
5627
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5631
|
-
finally {
|
|
5632
|
-
try {
|
|
5633
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
5634
|
-
}
|
|
5635
|
-
finally { if (e_1) throw e_1.error; }
|
|
5636
|
-
}
|
|
5637
|
-
return result;
|
|
5638
|
-
},
|
|
5639
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5640
|
-
var _b;
|
|
5641
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5642
|
-
var binding = node.b;
|
|
5643
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5644
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5645
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5646
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5647
|
-
},
|
|
5648
|
-
};
|
|
5649
|
-
|
|
5650
|
-
var whenLetSpecialExpression = {
|
|
5651
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5652
|
-
var _b, _c;
|
|
5653
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5654
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5655
|
-
if (bindings.length !== 1) {
|
|
5656
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5657
|
-
}
|
|
5658
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5659
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5660
|
-
var node = {
|
|
5661
|
-
t: AstNodeType.SpecialExpression,
|
|
5662
|
-
n: 'when_let',
|
|
5663
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5664
|
-
p: params,
|
|
5665
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5666
|
-
};
|
|
5667
|
-
return node;
|
|
5668
|
-
},
|
|
5669
|
-
validateParameterCount: function () { return undefined; },
|
|
5670
|
-
evaluate: function (node, contextStack, _a) {
|
|
5671
|
-
var e_1, _b;
|
|
5672
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5673
|
-
var binding = node.b;
|
|
5674
|
-
var locals = {};
|
|
5675
|
-
var bindingValue = evaluateAstNode(binding.v, contextStack);
|
|
5676
|
-
if (!bindingValue)
|
|
5677
|
-
return null;
|
|
5678
|
-
locals[binding.n] = { value: bindingValue };
|
|
5679
|
-
var newContextStack = contextStack.create(locals);
|
|
5680
|
-
var result = null;
|
|
5681
|
-
try {
|
|
5682
|
-
for (var _c = __values(node.p), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5683
|
-
var form = _d.value;
|
|
5684
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5685
|
-
}
|
|
5686
|
-
}
|
|
5687
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5688
|
-
finally {
|
|
5689
|
-
try {
|
|
5690
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5691
|
-
}
|
|
5692
|
-
finally { if (e_1) throw e_1.error; }
|
|
5693
|
-
}
|
|
5694
|
-
return result;
|
|
5695
|
-
},
|
|
5696
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5697
|
-
var _b;
|
|
5698
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5699
|
-
var binding = node.b;
|
|
5700
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5701
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5702
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5703
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5704
|
-
},
|
|
5705
|
-
};
|
|
5706
|
-
|
|
5707
|
-
var whenNotSpecialExpression = {
|
|
5708
|
-
polishParse: getCommonPolishSpecialExpressionParser('when_not'),
|
|
5709
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5710
|
-
evaluate: function (node, contextStack, _a) {
|
|
5711
|
-
var e_1, _b;
|
|
5712
|
-
var _c;
|
|
5713
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5714
|
-
var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
|
|
5715
|
-
assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5716
|
-
if (evaluateAstNode(whenExpression, contextStack))
|
|
5717
|
-
return null;
|
|
5718
|
-
var result = null;
|
|
5719
|
-
try {
|
|
5720
|
-
for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
|
|
5721
|
-
var form = body_1_1.value;
|
|
5722
|
-
result = evaluateAstNode(form, contextStack);
|
|
5723
|
-
}
|
|
5724
|
-
}
|
|
5725
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5726
|
-
finally {
|
|
5727
|
-
try {
|
|
5728
|
-
if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
|
|
5729
|
-
}
|
|
5730
|
-
finally { if (e_1) throw e_1.error; }
|
|
5731
|
-
}
|
|
5732
|
-
return result;
|
|
5733
|
-
},
|
|
5734
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5735
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5736
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5737
|
-
},
|
|
5738
|
-
};
|
|
5739
|
-
|
|
5740
5515
|
var specialExpressions = {
|
|
5741
5516
|
'&&': andSpecialExpression,
|
|
5742
5517
|
'comment': commentSpecialExpression,
|
|
@@ -5744,26 +5519,19 @@ var specialExpressions = {
|
|
|
5744
5519
|
'switch': switchSpecialExpression,
|
|
5745
5520
|
'def': defSpecialExpression,
|
|
5746
5521
|
'defn': defnSpecialExpression,
|
|
5747
|
-
'defns': defnsSpecialExpression,
|
|
5748
|
-
'defs': defsSpecialExpression,
|
|
5749
5522
|
'do': doSpecialExpression,
|
|
5750
5523
|
'doseq': doseqSpecialExpression,
|
|
5751
5524
|
'for': forSpecialExpression,
|
|
5752
5525
|
'fn': fnSpecialExpression,
|
|
5753
5526
|
'if': ifSpecialExpression,
|
|
5754
|
-
'
|
|
5755
|
-
'if_not': ifNotSpecialExpression,
|
|
5527
|
+
'unless': unlessSpecialExpression,
|
|
5756
5528
|
'let': letSpecialExpression,
|
|
5757
5529
|
'loop': loopSpecialExpression,
|
|
5758
5530
|
'||': orSpecialExpression,
|
|
5759
5531
|
'recur': recurSpecialExpression,
|
|
5760
5532
|
'throw': throwSpecialExpression,
|
|
5761
5533
|
'try': trySpecialExpression,
|
|
5762
|
-
'
|
|
5763
|
-
'when_first': whenFirstSpecialExpression,
|
|
5764
|
-
'when_let': whenLetSpecialExpression,
|
|
5765
|
-
'when_not': whenNotSpecialExpression,
|
|
5766
|
-
'declared?': declaredSpecialExpression,
|
|
5534
|
+
'defined?': declaredSpecialExpression,
|
|
5767
5535
|
'??': qqSpecialExpression,
|
|
5768
5536
|
};
|
|
5769
5537
|
Object.keys(specialExpressions).forEach(function (key) {
|
|
@@ -5785,8 +5553,8 @@ function isContextEntry(value) {
|
|
|
5785
5553
|
var ContextStackImpl = /** @class */ (function () {
|
|
5786
5554
|
function ContextStackImpl(_a) {
|
|
5787
5555
|
var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
|
|
5788
|
-
this.contexts = contexts;
|
|
5789
5556
|
this.globalContext = asNonUndefined(contexts[0]);
|
|
5557
|
+
this.contexts = contexts;
|
|
5790
5558
|
this.values = hostValues;
|
|
5791
5559
|
this.lazyValues = lazyHostValues;
|
|
5792
5560
|
this.nativeJsFunctions = nativeJsFunctions;
|
|
@@ -5802,6 +5570,34 @@ var ContextStackImpl = /** @class */ (function () {
|
|
|
5802
5570
|
contextStack.globalContext = globalContext;
|
|
5803
5571
|
return contextStack;
|
|
5804
5572
|
};
|
|
5573
|
+
ContextStackImpl.prototype.exportValue = function (name, value) {
|
|
5574
|
+
if (this.globalContext[name]) {
|
|
5575
|
+
throw new Error("Cannot redefine exported value \"".concat(name, "\""));
|
|
5576
|
+
}
|
|
5577
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5578
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5579
|
+
}
|
|
5580
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5581
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5582
|
+
}
|
|
5583
|
+
this.globalContext[name] = { value: value };
|
|
5584
|
+
};
|
|
5585
|
+
ContextStackImpl.prototype.addValue = function (name, value) {
|
|
5586
|
+
var currentContext = this.contexts[0];
|
|
5587
|
+
if (!currentContext) {
|
|
5588
|
+
throw new Error('No context to add value to');
|
|
5589
|
+
}
|
|
5590
|
+
if (currentContext[name]) {
|
|
5591
|
+
throw new Error("Cannot redefine value \"".concat(name, "\""));
|
|
5592
|
+
}
|
|
5593
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5594
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5595
|
+
}
|
|
5596
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5597
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5598
|
+
}
|
|
5599
|
+
currentContext[name] = { value: toAny(value) };
|
|
5600
|
+
};
|
|
5805
5601
|
ContextStackImpl.prototype.clone = function () {
|
|
5806
5602
|
// eslint-disable-next-line ts/no-unsafe-argument
|
|
5807
5603
|
return new ContextStackImpl(JSON.parse(JSON.stringify({
|
|
@@ -5931,7 +5727,7 @@ function createContextStack(params) {
|
|
|
5931
5727
|
return acc;
|
|
5932
5728
|
}, {}),
|
|
5933
5729
|
});
|
|
5934
|
-
return contextStack;
|
|
5730
|
+
return contextStack.create({});
|
|
5935
5731
|
}
|
|
5936
5732
|
|
|
5937
5733
|
var _a$2;
|
|
@@ -6243,7 +6039,14 @@ function evaluateNumberAsFunction(fn, params, sourceCodeInfo) {
|
|
|
6243
6039
|
|
|
6244
6040
|
var findUnresolvedIdentifiers = function (ast, contextStack, builtin) {
|
|
6245
6041
|
var e_1, _a;
|
|
6246
|
-
var astNodes = Array.isArray(ast)
|
|
6042
|
+
var astNodes = Array.isArray(ast)
|
|
6043
|
+
? ast
|
|
6044
|
+
: [{
|
|
6045
|
+
t: AstNodeType.SpecialExpression,
|
|
6046
|
+
n: 'do',
|
|
6047
|
+
p: ast.b,
|
|
6048
|
+
token: undefined,
|
|
6049
|
+
}];
|
|
6247
6050
|
var unresolvedIdentifiers = new Set();
|
|
6248
6051
|
try {
|
|
6249
6052
|
for (var astNodes_1 = __values(astNodes), astNodes_1_1 = astNodes_1.next(); !astNodes_1_1.done; astNodes_1_1 = astNodes_1.next()) {
|
|
@@ -6315,537 +6118,9 @@ function findUnresolvedIdentifiersInAstNode(astNode, contextStack, builtin) {
|
|
|
6315
6118
|
}
|
|
6316
6119
|
}
|
|
6317
6120
|
|
|
6318
|
-
var calculateAndOutcomes = function (_a) {
|
|
6319
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6320
|
-
return combinateAstNodes(astNode.p)
|
|
6321
|
-
.map(function (p) { return ({
|
|
6322
|
-
n: '&&',
|
|
6323
|
-
t: AstNodeType.SpecialExpression,
|
|
6324
|
-
p: p,
|
|
6325
|
-
token: astNode.token,
|
|
6326
|
-
}); });
|
|
6327
|
-
};
|
|
6328
|
-
|
|
6329
|
-
var calculateCondOutcomes = function (_a) {
|
|
6330
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, isAstComputable = _a.isAstComputable;
|
|
6331
|
-
var testNodes = arrayToPairs(astNode.p).map(function (_a) {
|
|
6332
|
-
var _b = __read(_a, 1), t = _b[0];
|
|
6333
|
-
return t;
|
|
6334
|
-
});
|
|
6335
|
-
if (isAstComputable(testNodes)) {
|
|
6336
|
-
return combinate(arrayToPairs(astNode.p)
|
|
6337
|
-
// Create a list of ast nodes from the test and form of each condition
|
|
6338
|
-
.reduce(function (acc, _a) {
|
|
6339
|
-
var _b = __read(_a, 2), test = _b[0], form = _b[1];
|
|
6340
|
-
acc.push(calculatePossibleAstNodes(test), calculatePossibleAstNodes(form));
|
|
6341
|
-
return acc;
|
|
6342
|
-
}, []))
|
|
6343
|
-
// Create a new CondNode for each combination of test and form outcomes
|
|
6344
|
-
.map(function (conditionAsts) { return (__assign(__assign({}, astNode), { c: arrayToPairs(conditionAsts).map(function (_a) {
|
|
6345
|
-
var _b = __read(_a, 2), t = _b[0], f = _b[1];
|
|
6346
|
-
return ({ t: t, f: f });
|
|
6347
|
-
}) })); });
|
|
6348
|
-
}
|
|
6349
|
-
return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p).flatMap(function (_a) {
|
|
6350
|
-
var _b = __read(_a, 2); _b[0]; var form = _b[1];
|
|
6351
|
-
return calculatePossibleAstNodes(form);
|
|
6352
|
-
})), false), [
|
|
6353
|
-
nilNode,
|
|
6354
|
-
], false);
|
|
6355
|
-
};
|
|
6356
|
-
|
|
6357
|
-
var trueNode = { t: AstNodeType.ReservedSymbol, v: 'true', token: undefined, p: [], n: undefined };
|
|
6358
|
-
var falseNode = { t: AstNodeType.ReservedSymbol, v: 'false', token: undefined, p: [], n: undefined };
|
|
6359
|
-
var calculateDeclaredOutcomes = function (_a) {
|
|
6360
|
-
var astNode = _a.astNode, isAstComputable = _a.isAstComputable;
|
|
6361
|
-
if (isAstComputable(astNode.p))
|
|
6362
|
-
return [trueNode];
|
|
6363
|
-
return [trueNode, falseNode];
|
|
6364
|
-
};
|
|
6365
|
-
|
|
6366
|
-
var calculateDefOutcomes = function (_a) {
|
|
6367
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6368
|
-
var nameNode = asSymbolNode(astNode.p[0]);
|
|
6369
|
-
var valueNode = astNode.p[1];
|
|
6370
|
-
addGlobalIdentifier(nameNode.v);
|
|
6371
|
-
return calculatePossibleAstNodes(valueNode)
|
|
6372
|
-
.map(function (node) { return (__assign(__assign({}, astNode), { p: [nameNode, node] })); });
|
|
6373
|
-
};
|
|
6374
|
-
|
|
6375
|
-
var calculateDefsOutcomes = function (_a) {
|
|
6376
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6377
|
-
return combinateAstNodes(astNode.p)
|
|
6378
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6379
|
-
};
|
|
6380
|
-
|
|
6381
|
-
var calculateDoOutcomes = function (_a) {
|
|
6382
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6383
|
-
return combinateAstNodes(astNode.p).map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6384
|
-
};
|
|
6385
|
-
|
|
6386
|
-
function calculateFunctionOverloadOutcomes(combinateAstNodes, functionOverloads) {
|
|
6387
|
-
return combinate(functionOverloads
|
|
6388
|
-
// For each overload, calculate the possible outcomes for each parameter
|
|
6389
|
-
.map(function (functionOverload) {
|
|
6390
|
-
var _a;
|
|
6391
|
-
return combinateAstNodes(functionOverload.b, [
|
|
6392
|
-
functionOverload.as.m,
|
|
6393
|
-
functionOverload.as.b.map(function (bindingNode) { return bindingNode.n; }),
|
|
6394
|
-
(_a = functionOverload.as.r) !== null && _a !== void 0 ? _a : [],
|
|
6395
|
-
].flat())
|
|
6396
|
-
// For each combination of parameter outcomes, create a new overload
|
|
6397
|
-
.map(function (body) { return (__assign(__assign({}, functionOverload), { b: body })); });
|
|
6398
|
-
}));
|
|
6399
|
-
}
|
|
6400
|
-
var calculateDefnOutcomes = function (_a) {
|
|
6401
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6402
|
-
addGlobalIdentifier(astNode.f.v);
|
|
6403
|
-
// astNode.o is an array of overloads
|
|
6404
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6405
|
-
};
|
|
6406
|
-
var calculateDefnsOutcomes = function (_a) {
|
|
6407
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes;
|
|
6408
|
-
// astNode.o is an array of overloads
|
|
6409
|
-
return calculatePossibleAstNodes(astNode.f).flatMap(function (functionName) {
|
|
6410
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { f: functionName, o: functionOverloads })); });
|
|
6411
|
-
});
|
|
6412
|
-
};
|
|
6413
|
-
var calculateFnOutcomes = function (_a) {
|
|
6414
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6415
|
-
// astNode.o is an array of overloads
|
|
6416
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6417
|
-
};
|
|
6418
|
-
|
|
6419
|
-
var calculateIfLetOutcomes = function (_a) {
|
|
6420
|
-
var _b;
|
|
6421
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6422
|
-
var bindingNode = astNode.b;
|
|
6423
|
-
var thenBranch = astNode.p[0];
|
|
6424
|
-
var elseBranch = (_b = astNode.p[1]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6425
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6426
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6427
|
-
}
|
|
6428
|
-
var newIdentifier = bindingNode.n;
|
|
6429
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6430
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6431
|
-
.flatMap(function (b) { return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6432
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); }); });
|
|
6433
|
-
};
|
|
6434
|
-
|
|
6435
|
-
var calculateIfNotOutcomes = function (_a) {
|
|
6436
|
-
var _b;
|
|
6437
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6438
|
-
var condition = astNode.p[0];
|
|
6439
|
-
var thenBranch = astNode.p[1];
|
|
6440
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6441
|
-
if (isAstComputable(condition)) {
|
|
6442
|
-
return combinateAstNodes(astNode.p)
|
|
6443
|
-
.map(function (p) { return ({
|
|
6444
|
-
n: 'if_not',
|
|
6445
|
-
t: astNode.t,
|
|
6446
|
-
p: p,
|
|
6447
|
-
token: astNode.token,
|
|
6448
|
-
}); });
|
|
6449
|
-
}
|
|
6450
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6451
|
-
};
|
|
6452
|
-
|
|
6453
|
-
var calculateIfOutcomes = function (_a) {
|
|
6454
|
-
var _b;
|
|
6455
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6456
|
-
var condition = astNode.p[0];
|
|
6457
|
-
var thenBranch = astNode.p[1];
|
|
6458
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6459
|
-
if (isAstComputable(condition)) {
|
|
6460
|
-
return combinateAstNodes(astNode.p)
|
|
6461
|
-
.map(function (p) { return ({
|
|
6462
|
-
n: 'if',
|
|
6463
|
-
t: astNode.t,
|
|
6464
|
-
p: p,
|
|
6465
|
-
token: astNode.token,
|
|
6466
|
-
}); });
|
|
6467
|
-
}
|
|
6468
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6469
|
-
};
|
|
6470
|
-
|
|
6471
|
-
var calculateLetOutcomes = function (_a) {
|
|
6472
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6473
|
-
try {
|
|
6474
|
-
// check bindings, if any binding value cannot be calculated, convert the whole let to a do-expression
|
|
6475
|
-
if (!isAstComputable(astNode.bs.map(function (b) { return calculatePossibleAstNodes(b.v); })))
|
|
6476
|
-
throw new Error('Could not calculate binding value');
|
|
6477
|
-
}
|
|
6478
|
-
catch (_b) {
|
|
6479
|
-
var doNodes = combinateAstNodes(astNode.p)
|
|
6480
|
-
.map(function (p) {
|
|
6481
|
-
return {
|
|
6482
|
-
n: 'do',
|
|
6483
|
-
t: AstNodeType.SpecialExpression,
|
|
6484
|
-
p: p,
|
|
6485
|
-
token: astNode.token,
|
|
6486
|
-
};
|
|
6487
|
-
});
|
|
6488
|
-
return doNodes;
|
|
6489
|
-
}
|
|
6490
|
-
var newIdentifiers = astNode.bs.map(function (bindingNode) { return bindingNode.n; });
|
|
6491
|
-
var letNodes = combinate(astNode.bs.map(function (bindingNode) {
|
|
6492
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6493
|
-
.map(function (bindingValues) { return (__assign(__assign({}, bindingNode), { v: bindingValues })); });
|
|
6494
|
-
}))
|
|
6495
|
-
.flatMap(function (bindingNodes) { return combinate(astNode.p.map(function (p) { return calculatePossibleAstNodes(p, newIdentifiers); }))
|
|
6496
|
-
.map(function (p) {
|
|
6497
|
-
return {
|
|
6498
|
-
n: 'let',
|
|
6499
|
-
bs: bindingNodes,
|
|
6500
|
-
t: AstNodeType.SpecialExpression,
|
|
6501
|
-
p: p,
|
|
6502
|
-
token: astNode.token,
|
|
6503
|
-
};
|
|
6504
|
-
}); });
|
|
6505
|
-
return letNodes;
|
|
6506
|
-
};
|
|
6507
|
-
|
|
6508
|
-
var calculateForOutcomes = function (_a) {
|
|
6509
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6510
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6511
|
-
throw new Error('Could not calculate for loop, not deterministic');
|
|
6512
|
-
return [astNode];
|
|
6513
|
-
};
|
|
6514
|
-
var calculateDoSeqOutcomes = function (_a) {
|
|
6515
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6516
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6517
|
-
throw new Error('Could not calculate doSeq node, not deterministic');
|
|
6518
|
-
return [astNode];
|
|
6519
|
-
};
|
|
6520
|
-
function isDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6521
|
-
var e_1, _a;
|
|
6522
|
-
try {
|
|
6523
|
-
for (var _b = __values(astNode.l), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6524
|
-
var _d = _c.value, b = _d.b, l = _d.l, wn = _d.wn, we = _d.we;
|
|
6525
|
-
if (l && l.some(function (_a) {
|
|
6526
|
-
var v = _a.v;
|
|
6527
|
-
return !astIsDeterministic(calculatePossibleAstNodes, v);
|
|
6528
|
-
}))
|
|
6529
|
-
return false;
|
|
6530
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, b.v))
|
|
6531
|
-
return false;
|
|
6532
|
-
if (wn && !astIsDeterministic(calculatePossibleAstNodes, wn))
|
|
6533
|
-
return false;
|
|
6534
|
-
if (we && !astIsDeterministic(calculatePossibleAstNodes, we))
|
|
6535
|
-
return false;
|
|
6536
|
-
}
|
|
6537
|
-
}
|
|
6538
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6539
|
-
finally {
|
|
6540
|
-
try {
|
|
6541
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6542
|
-
}
|
|
6543
|
-
finally { if (e_1) throw e_1.error; }
|
|
6544
|
-
}
|
|
6545
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, astNode.p[0]))
|
|
6546
|
-
return false;
|
|
6547
|
-
return true;
|
|
6548
|
-
}
|
|
6549
|
-
function astIsDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6550
|
-
return calculatePossibleAstNodes(astNode).length === 1;
|
|
6551
|
-
}
|
|
6552
|
-
|
|
6553
|
-
var calculateOrOutcomes = function (_a) {
|
|
6554
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6555
|
-
return combinateAstNodes(astNode.p)
|
|
6556
|
-
.map(function (p) { return ({
|
|
6557
|
-
n: '||',
|
|
6558
|
-
t: AstNodeType.SpecialExpression,
|
|
6559
|
-
p: p,
|
|
6560
|
-
token: astNode.token,
|
|
6561
|
-
}); });
|
|
6562
|
-
};
|
|
6563
|
-
|
|
6564
|
-
var calculateQqOutcomes = function (_a) {
|
|
6565
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6566
|
-
if (!isAstComputable(astNode.p[0]))
|
|
6567
|
-
throw new Error('First argument of ?? not computable');
|
|
6568
|
-
return combinateAstNodes(astNode.p)
|
|
6569
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6570
|
-
};
|
|
6571
|
-
|
|
6572
|
-
var calculateThrowOutcomes = function (_a) {
|
|
6573
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6574
|
-
return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
|
|
6575
|
-
};
|
|
6576
|
-
|
|
6577
|
-
var calculateTryOutcomes = function (_a) {
|
|
6578
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6579
|
-
var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
|
|
6580
|
-
if (node.n === 'throw') {
|
|
6581
|
-
acc.throws.push(node.p[0]);
|
|
6582
|
-
}
|
|
6583
|
-
else {
|
|
6584
|
-
acc.vals.push(node);
|
|
6585
|
-
}
|
|
6586
|
-
return acc;
|
|
6587
|
-
}, { vals: [], throws: [] }), vals = _b.vals, throws = _b.throws;
|
|
6588
|
-
var catches = throws.flatMap(function (throwNode) {
|
|
6589
|
-
var letNode = {
|
|
6590
|
-
t: AstNodeType.SpecialExpression,
|
|
6591
|
-
n: 'let',
|
|
6592
|
-
bs: [{
|
|
6593
|
-
t: AstNodeType.Binding,
|
|
6594
|
-
n: astNode.e.v,
|
|
6595
|
-
v: throwNode,
|
|
6596
|
-
token: undefined,
|
|
6597
|
-
p: [],
|
|
6598
|
-
}],
|
|
6599
|
-
p: [astNode.ce],
|
|
6600
|
-
token: undefined,
|
|
6601
|
-
};
|
|
6602
|
-
return calculatePossibleAstNodes(letNode);
|
|
6603
|
-
});
|
|
6604
|
-
return __spreadArray(__spreadArray([], __read(vals), false), __read(catches), false);
|
|
6605
|
-
};
|
|
6606
|
-
|
|
6607
|
-
var calculateWhenFirstOutcomes = function (_a) {
|
|
6608
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6609
|
-
var bindingNode = astNode.b;
|
|
6610
|
-
if (!isAstComputable(bindingNode.v))
|
|
6611
|
-
throw new Error('Could not calculate binding value');
|
|
6612
|
-
var newIdentifier = bindingNode.n;
|
|
6613
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6614
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6615
|
-
.flatMap(function (b) {
|
|
6616
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6617
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6618
|
-
});
|
|
6619
|
-
};
|
|
6620
|
-
|
|
6621
|
-
var calculateWhenLetOutcomes = function (_a) {
|
|
6622
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6623
|
-
var bindingNode = astNode.b;
|
|
6624
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6625
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(astNode.p)
|
|
6626
|
-
.map(function (p) { return ({
|
|
6627
|
-
n: 'do',
|
|
6628
|
-
t: astNode.t,
|
|
6629
|
-
p: p,
|
|
6630
|
-
token: astNode.token,
|
|
6631
|
-
}); })), false), [
|
|
6632
|
-
nilNode,
|
|
6633
|
-
], false);
|
|
6634
|
-
}
|
|
6635
|
-
var newIdentifier = bindingNode.n;
|
|
6636
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6637
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6638
|
-
.flatMap(function (b) {
|
|
6639
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6640
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6641
|
-
});
|
|
6642
|
-
};
|
|
6643
|
-
|
|
6644
|
-
var calculateWhenNotOutcomes = function (_a) {
|
|
6645
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6646
|
-
var condition = astNode.p[0];
|
|
6647
|
-
if (isAstComputable(condition)) {
|
|
6648
|
-
return combinateAstNodes(astNode.p)
|
|
6649
|
-
.map(function (p) { return ({
|
|
6650
|
-
n: 'when_not',
|
|
6651
|
-
t: astNode.t,
|
|
6652
|
-
p: p,
|
|
6653
|
-
token: astNode.token,
|
|
6654
|
-
}); });
|
|
6655
|
-
}
|
|
6656
|
-
var body = astNode.p.slice(1);
|
|
6657
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6658
|
-
.map(function (p) { return ({
|
|
6659
|
-
n: 'do',
|
|
6660
|
-
t: astNode.t,
|
|
6661
|
-
p: p,
|
|
6662
|
-
token: astNode.token,
|
|
6663
|
-
}); })), false), [
|
|
6664
|
-
nilNode,
|
|
6665
|
-
], false);
|
|
6666
|
-
};
|
|
6667
|
-
|
|
6668
|
-
var calculateWhenOutcomes = function (_a) {
|
|
6669
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6670
|
-
var condition = astNode.p[0];
|
|
6671
|
-
if (isAstComputable(condition)) {
|
|
6672
|
-
return combinateAstNodes(astNode.p)
|
|
6673
|
-
.map(function (p) { return ({
|
|
6674
|
-
n: 'when',
|
|
6675
|
-
t: astNode.t,
|
|
6676
|
-
p: p,
|
|
6677
|
-
token: astNode.token,
|
|
6678
|
-
}); });
|
|
6679
|
-
}
|
|
6680
|
-
var body = astNode.p.slice(1);
|
|
6681
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6682
|
-
.map(function (p) { return ({
|
|
6683
|
-
n: 'do',
|
|
6684
|
-
t: astNode.t,
|
|
6685
|
-
p: p,
|
|
6686
|
-
token: astNode.token,
|
|
6687
|
-
}); })), false), [
|
|
6688
|
-
nilNode,
|
|
6689
|
-
], false);
|
|
6690
|
-
};
|
|
6691
|
-
|
|
6692
|
-
var calculateRecurOutcomes = function (_a) {
|
|
6693
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6694
|
-
return combinateAstNodes(astNode.p)
|
|
6695
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6696
|
-
};
|
|
6697
|
-
|
|
6698
|
-
var calculateCommentOutcomes = function (_a) {
|
|
6699
|
-
var nilNode = _a.nilNode;
|
|
6700
|
-
return [nilNode];
|
|
6701
|
-
};
|
|
6702
|
-
|
|
6703
|
-
var calculateLoopOutcomes = function (_a) {
|
|
6704
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6705
|
-
return combinateAstNodes(astNode.p, astNode.bs.map(function (bindingNode) { return bindingNode.n; }))
|
|
6706
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6707
|
-
};
|
|
6708
|
-
|
|
6709
|
-
var calculateSwitchOutcomes = function (_a) {
|
|
6710
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6711
|
-
// TODO be smarter about this
|
|
6712
|
-
return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p.slice(1)).flatMap(function (_a) {
|
|
6713
|
-
var _b = __read(_a, 2); _b[0]; var form = _b[1];
|
|
6714
|
-
return calculatePossibleAstNodes(form);
|
|
6715
|
-
})), false), [
|
|
6716
|
-
nilNode,
|
|
6717
|
-
], false);
|
|
6718
|
-
};
|
|
6719
|
-
|
|
6720
|
-
var specialExpressionCalculator = {
|
|
6721
|
-
'&&': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6722
|
-
'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6723
|
-
'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6724
|
-
'switch': function (astNode, helperOptions) { return calculateSwitchOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6725
|
-
'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6726
|
-
'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6727
|
-
'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6728
|
-
'defns': function (astNode, helperOptions) { return calculateDefnsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6729
|
-
'defs': function (astNode, helperOptions) { return calculateDefsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6730
|
-
'do': function (astNode, helperOptions) { return calculateDoOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6731
|
-
'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6732
|
-
'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6733
|
-
'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6734
|
-
'if_let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6735
|
-
'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6736
|
-
'if_not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6737
|
-
'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6738
|
-
'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6739
|
-
'||': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6740
|
-
'??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6741
|
-
'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6742
|
-
'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6743
|
-
'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6744
|
-
'when_first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6745
|
-
'when_let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6746
|
-
'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6747
|
-
'when_not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6748
|
-
};
|
|
6749
|
-
|
|
6750
|
-
function calculateOutcomes(contextStack, astNodes) {
|
|
6751
|
-
// First, we try to calculate outcomes for the whole astNodes array.
|
|
6752
|
-
// If that fails, we try to calculate outcomes for the array without the first element.
|
|
6753
|
-
// If that fails, we try to calculate outcomes for the array without the first two elements.
|
|
6754
|
-
// And so on.
|
|
6755
|
-
// This makes it possible to calculate outcomes for e.g.
|
|
6756
|
-
// (write! x) x
|
|
6757
|
-
// Problems occur for e.g.
|
|
6758
|
-
// (def x 1) (write! x) x
|
|
6759
|
-
// This should output [1], but since (write! x) fails to calculate outcomes, we get null.
|
|
6760
|
-
// Ok, but not optimal
|
|
6761
|
-
// The contract is that when an array is returned, it must be correct.
|
|
6762
|
-
// But returning null (indicating that the calculation failed) is always a way out.
|
|
6763
|
-
for (var i = 0; i < astNodes.length; i++) {
|
|
6764
|
-
var usingAstNode = astNodes.slice(i);
|
|
6765
|
-
var outcomes = calculateOutcomesInner(contextStack, usingAstNode);
|
|
6766
|
-
if (outcomes !== null)
|
|
6767
|
-
return outcomes;
|
|
6768
|
-
}
|
|
6769
|
-
return null;
|
|
6770
|
-
}
|
|
6771
|
-
function calculateOutcomesInner(contextStack, astNodes) {
|
|
6772
|
-
var e_1, _a;
|
|
6773
|
-
var possibleAsts = calculatePossibleAsts(contextStack.clone(), astNodes);
|
|
6774
|
-
if (possibleAsts === null)
|
|
6775
|
-
return null;
|
|
6776
|
-
var outcomes = [];
|
|
6777
|
-
try {
|
|
6778
|
-
for (var possibleAsts_1 = __values(possibleAsts), possibleAsts_1_1 = possibleAsts_1.next(); !possibleAsts_1_1.done; possibleAsts_1_1 = possibleAsts_1.next()) {
|
|
6779
|
-
var possibleAst = possibleAsts_1_1.value;
|
|
6780
|
-
var unresolvedIdentifiers = findUnresolvedIdentifiers(possibleAst, contextStack.clone(), builtin);
|
|
6781
|
-
if (unresolvedIdentifiers.size !== 0)
|
|
6782
|
-
return null;
|
|
6783
|
-
var ast = {
|
|
6784
|
-
b: possibleAst,
|
|
6785
|
-
hasDebugData: true,
|
|
6786
|
-
};
|
|
6787
|
-
try {
|
|
6788
|
-
outcomes.push(evaluate(ast, contextStack.clone()));
|
|
6789
|
-
}
|
|
6790
|
-
catch (e) {
|
|
6791
|
-
outcomes.push(e);
|
|
6792
|
-
}
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6795
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6796
|
-
finally {
|
|
6797
|
-
try {
|
|
6798
|
-
if (possibleAsts_1_1 && !possibleAsts_1_1.done && (_a = possibleAsts_1.return)) _a.call(possibleAsts_1);
|
|
6799
|
-
}
|
|
6800
|
-
finally { if (e_1) throw e_1.error; }
|
|
6801
|
-
}
|
|
6802
|
-
return outcomes;
|
|
6803
|
-
}
|
|
6804
|
-
function calculatePossibleAsts(contextStack, astNodes) {
|
|
6805
|
-
var possibleAsts;
|
|
6806
|
-
try {
|
|
6807
|
-
possibleAsts = combinate(astNodes.map(function (astNode) { return calculatePossibleAstNodes(contextStack, astNode); }));
|
|
6808
|
-
}
|
|
6809
|
-
catch (e) {
|
|
6810
|
-
return null;
|
|
6811
|
-
}
|
|
6812
|
-
return possibleAsts;
|
|
6813
|
-
}
|
|
6814
|
-
var nilNode = { t: AstNodeType.ReservedSymbol, v: 'nil', token: undefined, p: [], n: undefined };
|
|
6815
|
-
function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
|
|
6816
|
-
var newContext = newIndentifiers
|
|
6817
|
-
? newIndentifiers.reduce(function (acc, identity) {
|
|
6818
|
-
acc[identity] = { value: null };
|
|
6819
|
-
return acc;
|
|
6820
|
-
}, {})
|
|
6821
|
-
: undefined;
|
|
6822
|
-
var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
|
|
6823
|
-
if (astNode.t === AstNodeType.NormalExpression) {
|
|
6824
|
-
return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
|
|
6825
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6826
|
-
}
|
|
6827
|
-
else if (astNode.t === AstNodeType.SpecialExpression) {
|
|
6828
|
-
var helperOptions = {
|
|
6829
|
-
nilNode: nilNode,
|
|
6830
|
-
calculatePossibleAstNodes: function (node, identifiers) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); },
|
|
6831
|
-
combinateAstNodes: function (nodes, identifiers) {
|
|
6832
|
-
return combinate(nodes.map(function (node) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); }));
|
|
6833
|
-
},
|
|
6834
|
-
isAstComputable: function (node) {
|
|
6835
|
-
return calculateOutcomesInner(newContextStack, Array.isArray(node) ? node.flat() : [node]) !== null;
|
|
6836
|
-
},
|
|
6837
|
-
addGlobalIdentifier: function (name) { return newContextStack.globalContext[name] = { value: null }; },
|
|
6838
|
-
};
|
|
6839
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
6840
|
-
return specialExpressionCalculator[astNode.n](astNode, helperOptions);
|
|
6841
|
-
}
|
|
6842
|
-
return [astNode];
|
|
6843
|
-
}
|
|
6844
|
-
|
|
6845
6121
|
function analyze(ast, params) {
|
|
6846
6122
|
return {
|
|
6847
6123
|
unresolvedIdentifiers: findUnresolvedIdentifiers(ast, createContextStack(params), builtin),
|
|
6848
|
-
outcomes: calculateOutcomes(createContextStack(params), ast.b),
|
|
6849
6124
|
};
|
|
6850
6125
|
}
|
|
6851
6126
|
|
|
@@ -6968,6 +6243,33 @@ function parseString(tokenStream, parseState) {
|
|
|
6968
6243
|
token: getTokenDebugData(tkn) && tkn,
|
|
6969
6244
|
};
|
|
6970
6245
|
}
|
|
6246
|
+
function parseRegexpShorthand(tokenStream, parseState) {
|
|
6247
|
+
var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
6248
|
+
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
6249
|
+
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
6250
|
+
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
6251
|
+
var stringNode = {
|
|
6252
|
+
t: AstNodeType.String,
|
|
6253
|
+
v: regexpString,
|
|
6254
|
+
p: [],
|
|
6255
|
+
n: undefined,
|
|
6256
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6257
|
+
};
|
|
6258
|
+
var optionsNode = {
|
|
6259
|
+
t: AstNodeType.String,
|
|
6260
|
+
v: optionsString,
|
|
6261
|
+
p: [],
|
|
6262
|
+
n: undefined,
|
|
6263
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6264
|
+
};
|
|
6265
|
+
var node = {
|
|
6266
|
+
t: AstNodeType.NormalExpression,
|
|
6267
|
+
n: 'regexp',
|
|
6268
|
+
p: [stringNode, optionsNode],
|
|
6269
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6270
|
+
};
|
|
6271
|
+
return node;
|
|
6272
|
+
}
|
|
6971
6273
|
|
|
6972
6274
|
var exponentiationPrecedence = 10;
|
|
6973
6275
|
var binaryFunctionalOperatorPrecedence = 1;
|
|
@@ -7109,6 +6411,12 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7109
6411
|
this.tokenStream = tokenStream;
|
|
7110
6412
|
this.parseState = parseState;
|
|
7111
6413
|
}
|
|
6414
|
+
AlgebraicParser.prototype.peek = function () {
|
|
6415
|
+
return this.tokenStream.tokens[this.parseState.position];
|
|
6416
|
+
};
|
|
6417
|
+
AlgebraicParser.prototype.peekAhead = function (count) {
|
|
6418
|
+
return this.tokenStream.tokens[this.parseState.position + count];
|
|
6419
|
+
};
|
|
7112
6420
|
AlgebraicParser.prototype.advance = function () {
|
|
7113
6421
|
this.parseState.position += 1;
|
|
7114
6422
|
};
|
|
@@ -7127,38 +6435,45 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7127
6435
|
var _a;
|
|
7128
6436
|
if (precedence === void 0) { precedence = 0; }
|
|
7129
6437
|
var firstToken = this.peek();
|
|
7130
|
-
if (isA_SymbolToken(firstToken) && firstToken[1] === 'def') {
|
|
7131
|
-
return this.parseDef(firstToken);
|
|
7132
|
-
}
|
|
7133
|
-
else if (isA_SymbolToken(firstToken) && firstToken[1] === 'defn') {
|
|
7134
|
-
return this.parseDefn(firstToken);
|
|
7135
|
-
}
|
|
7136
6438
|
var left;
|
|
7137
|
-
if (isA_SymbolToken(firstToken)
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
6439
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6440
|
+
switch (firstToken[1]) {
|
|
6441
|
+
case 'let':
|
|
6442
|
+
return this.parseLet(firstToken);
|
|
6443
|
+
case 'if':
|
|
6444
|
+
case 'unless':
|
|
6445
|
+
left = this.parseIfOrUnless(firstToken);
|
|
6446
|
+
break;
|
|
6447
|
+
case 'cond':
|
|
6448
|
+
left = this.parseCond(firstToken);
|
|
6449
|
+
break;
|
|
6450
|
+
case 'switch':
|
|
6451
|
+
left = this.parseSwitch(firstToken);
|
|
6452
|
+
break;
|
|
6453
|
+
case 'for':
|
|
6454
|
+
case 'doseq':
|
|
6455
|
+
left = this.parseForOrDoseq(firstToken);
|
|
6456
|
+
break;
|
|
6457
|
+
case 'do':
|
|
6458
|
+
left = this.parseDo(firstToken);
|
|
6459
|
+
break;
|
|
6460
|
+
case 'loop':
|
|
6461
|
+
left = this.parseLoop(firstToken);
|
|
6462
|
+
break;
|
|
6463
|
+
case 'try':
|
|
6464
|
+
left = this.parseTry(firstToken);
|
|
6465
|
+
break;
|
|
6466
|
+
}
|
|
7145
6467
|
}
|
|
7146
|
-
else if (
|
|
7147
|
-
|
|
6468
|
+
else if (isA_ReservedSymbolToken(firstToken, 'function')) {
|
|
6469
|
+
return this.parseFunction(firstToken);
|
|
7148
6470
|
}
|
|
7149
|
-
else {
|
|
7150
|
-
|
|
6471
|
+
else if (isA_ReservedSymbolToken(firstToken, 'export')) {
|
|
6472
|
+
return this.parseExport(firstToken);
|
|
7151
6473
|
}
|
|
6474
|
+
left || (left = this.parseOperand());
|
|
7152
6475
|
var operator = this.peek();
|
|
7153
|
-
while (!this.
|
|
7154
|
-
&& !isA_OperatorToken(operator, ',')
|
|
7155
|
-
&& !isA_OperatorToken(operator, ';')
|
|
7156
|
-
&& !isRBracketToken(operator)
|
|
7157
|
-
&& !isA_ReservedSymbolToken(operator, 'else')
|
|
7158
|
-
&& !isA_ReservedSymbolToken(operator, 'then')
|
|
7159
|
-
&& !isA_ReservedSymbolToken(operator, 'end')
|
|
7160
|
-
&& !isA_ReservedSymbolToken(operator, 'case')
|
|
7161
|
-
&& !isRParenToken(operator)) {
|
|
6476
|
+
while (!this.isAtExpressionEnd()) {
|
|
7162
6477
|
if (isA_BinaryOperatorToken(operator)) {
|
|
7163
6478
|
var name_1 = operator[1];
|
|
7164
6479
|
var newPrecedece = getPrecedence(name_1);
|
|
@@ -7287,10 +6602,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7287
6602
|
case 'String':
|
|
7288
6603
|
return parseString(this.tokenStream, this.parseState);
|
|
7289
6604
|
case 'A_Symbol': {
|
|
6605
|
+
var positionBefore = this.parseState.position;
|
|
6606
|
+
var lamdaFunction = this.parseLambdaFunction();
|
|
6607
|
+
if (lamdaFunction) {
|
|
6608
|
+
return lamdaFunction;
|
|
6609
|
+
}
|
|
6610
|
+
this.parseState.position = positionBefore;
|
|
7290
6611
|
return parseSymbol(this.tokenStream, this.parseState);
|
|
7291
6612
|
}
|
|
7292
6613
|
case 'A_ReservedSymbol':
|
|
7293
6614
|
return parseReservedSymbol(this.tokenStream, this.parseState);
|
|
6615
|
+
case 'RegexpShorthand':
|
|
6616
|
+
return parseRegexpShorthand(this.tokenStream, this.parseState);
|
|
7294
6617
|
case 'PolNotation': {
|
|
7295
6618
|
this.parseState.algebraic = false;
|
|
7296
6619
|
var astNodes = [];
|
|
@@ -7411,12 +6734,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7411
6734
|
case '??':
|
|
7412
6735
|
case '&&':
|
|
7413
6736
|
case 'comment':
|
|
7414
|
-
case '
|
|
7415
|
-
case 'if_not':
|
|
6737
|
+
case 'defined?':
|
|
7416
6738
|
case '||':
|
|
7417
|
-
case '
|
|
7418
|
-
case 'when_not':
|
|
7419
|
-
case 'do':
|
|
6739
|
+
case 'recur':
|
|
7420
6740
|
case 'throw': {
|
|
7421
6741
|
var node = {
|
|
7422
6742
|
t: AstNodeType.SpecialExpression,
|
|
@@ -7427,18 +6747,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7427
6747
|
builtin.specialExpressions[node.n].validateParameterCount(node);
|
|
7428
6748
|
return node;
|
|
7429
6749
|
}
|
|
7430
|
-
case 'let':
|
|
7431
|
-
return this.parseLet(symbol, params);
|
|
7432
|
-
case 'defs':
|
|
7433
|
-
case 'if_let':
|
|
7434
|
-
case 'when_let':
|
|
7435
|
-
case 'when_first':
|
|
7436
6750
|
case 'fn':
|
|
7437
|
-
case '
|
|
7438
|
-
case '
|
|
7439
|
-
case 'recur':
|
|
7440
|
-
case 'loop':
|
|
7441
|
-
case 'doseq':
|
|
6751
|
+
case 'def':
|
|
6752
|
+
case 'defn':
|
|
7442
6753
|
throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
|
|
7443
6754
|
default:
|
|
7444
6755
|
throw new Error("Unknown special expression: ".concat(name_2));
|
|
@@ -7457,6 +6768,11 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7457
6768
|
};
|
|
7458
6769
|
AlgebraicParser.prototype.parseLambdaFunction = function () {
|
|
7459
6770
|
var firstToken = this.peek();
|
|
6771
|
+
if (isLParenToken(firstToken)
|
|
6772
|
+
&& isA_SymbolToken(this.peekAhead(1))
|
|
6773
|
+
&& isA_OperatorToken(this.peekAhead(2), '=>')) {
|
|
6774
|
+
return null;
|
|
6775
|
+
}
|
|
7460
6776
|
try {
|
|
7461
6777
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
7462
6778
|
if (!isA_OperatorToken(this.peek(), '=>')) {
|
|
@@ -7482,6 +6798,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7482
6798
|
};
|
|
7483
6799
|
AlgebraicParser.prototype.parseFunctionArguments = function () {
|
|
7484
6800
|
var _a, _b, _c, _d, _e;
|
|
6801
|
+
var firstToken = this.peek();
|
|
6802
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6803
|
+
this.advance();
|
|
6804
|
+
return {
|
|
6805
|
+
functionArguments: {
|
|
6806
|
+
m: [firstToken[1]],
|
|
6807
|
+
b: [],
|
|
6808
|
+
r: undefined,
|
|
6809
|
+
},
|
|
6810
|
+
arity: 1,
|
|
6811
|
+
};
|
|
6812
|
+
}
|
|
7485
6813
|
this.advance();
|
|
7486
6814
|
var rest = false;
|
|
7487
6815
|
var letBindingObject;
|
|
@@ -7600,36 +6928,146 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7600
6928
|
};
|
|
7601
6929
|
return node;
|
|
7602
6930
|
};
|
|
7603
|
-
AlgebraicParser.prototype.parseLet = function (
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
6931
|
+
AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
|
|
6932
|
+
if (optionalSemicolon === void 0) { optionalSemicolon = false; }
|
|
6933
|
+
this.advance();
|
|
6934
|
+
var letSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6935
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
6936
|
+
this.advance();
|
|
6937
|
+
var value = this.parseExpression();
|
|
6938
|
+
if (!optionalSemicolon) {
|
|
6939
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
7611
6940
|
}
|
|
7612
|
-
var letBindings = arrayToPairs(letObject.p);
|
|
7613
|
-
var expression = params[1];
|
|
7614
6941
|
return {
|
|
7615
6942
|
t: AstNodeType.SpecialExpression,
|
|
7616
6943
|
n: 'let',
|
|
7617
|
-
p: [
|
|
7618
|
-
|
|
7619
|
-
bs: letBindings.map(function (pair) {
|
|
7620
|
-
var key = pair[0];
|
|
7621
|
-
var value = pair[1];
|
|
7622
|
-
return {
|
|
6944
|
+
p: [],
|
|
6945
|
+
bs: [{
|
|
7623
6946
|
t: AstNodeType.Binding,
|
|
7624
|
-
n:
|
|
6947
|
+
n: letSymbol.v,
|
|
7625
6948
|
v: value,
|
|
7626
6949
|
p: [],
|
|
7627
|
-
token: getTokenDebugData(
|
|
7628
|
-
}
|
|
7629
|
-
|
|
6950
|
+
token: getTokenDebugData(token) && token,
|
|
6951
|
+
}],
|
|
6952
|
+
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
6953
|
+
};
|
|
6954
|
+
};
|
|
6955
|
+
AlgebraicParser.prototype.parseDo = function (token) {
|
|
6956
|
+
this.advance();
|
|
6957
|
+
var expressions = [];
|
|
6958
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
6959
|
+
expressions.push(this.parseExpression());
|
|
6960
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6961
|
+
this.advance();
|
|
6962
|
+
}
|
|
6963
|
+
}
|
|
6964
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6965
|
+
this.advance();
|
|
6966
|
+
return {
|
|
6967
|
+
t: AstNodeType.SpecialExpression,
|
|
6968
|
+
n: 'do',
|
|
6969
|
+
p: expressions,
|
|
6970
|
+
token: getTokenDebugData(token) && token,
|
|
6971
|
+
};
|
|
6972
|
+
};
|
|
6973
|
+
AlgebraicParser.prototype.parseLoop = function (token) {
|
|
6974
|
+
var _a;
|
|
6975
|
+
this.advance();
|
|
6976
|
+
assertLParenToken(this.peek());
|
|
6977
|
+
this.advance();
|
|
6978
|
+
var bindingNodes = [];
|
|
6979
|
+
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
6980
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6981
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
6982
|
+
this.advance();
|
|
6983
|
+
var value = this.parseExpression();
|
|
6984
|
+
bindingNodes.push({
|
|
6985
|
+
t: AstNodeType.Binding,
|
|
6986
|
+
n: symbol.v,
|
|
6987
|
+
v: value,
|
|
6988
|
+
p: [],
|
|
6989
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
6990
|
+
});
|
|
6991
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
6992
|
+
this.advance();
|
|
6993
|
+
}
|
|
6994
|
+
}
|
|
6995
|
+
if (bindingNodes.length === 0) {
|
|
6996
|
+
throw new LitsError('Expected binding', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
6997
|
+
}
|
|
6998
|
+
assertRParenToken(this.peek());
|
|
6999
|
+
this.advance();
|
|
7000
|
+
var params = [];
|
|
7001
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7002
|
+
params.push(this.parseExpression());
|
|
7003
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7004
|
+
this.advance();
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7008
|
+
this.advance();
|
|
7009
|
+
return {
|
|
7010
|
+
t: AstNodeType.SpecialExpression,
|
|
7011
|
+
n: 'loop',
|
|
7012
|
+
p: params,
|
|
7013
|
+
bs: bindingNodes,
|
|
7014
|
+
token: getTokenDebugData(token) && token,
|
|
7015
|
+
};
|
|
7016
|
+
};
|
|
7017
|
+
AlgebraicParser.prototype.parseTry = function (token) {
|
|
7018
|
+
this.advance();
|
|
7019
|
+
var tryExpressions = [];
|
|
7020
|
+
while (!this.isAtEnd() && !isA_SymbolToken(this.peek(), 'catch')) {
|
|
7021
|
+
tryExpressions.push(this.parseExpression());
|
|
7022
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7023
|
+
this.advance();
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
var tryExpression = tryExpressions.length === 1
|
|
7027
|
+
? tryExpressions[0]
|
|
7028
|
+
: {
|
|
7029
|
+
t: AstNodeType.SpecialExpression,
|
|
7030
|
+
n: 'do',
|
|
7031
|
+
p: tryExpressions,
|
|
7032
|
+
token: getTokenDebugData(token) && token,
|
|
7033
|
+
};
|
|
7034
|
+
assertA_SymbolToken(this.peek(), 'catch');
|
|
7035
|
+
this.advance();
|
|
7036
|
+
var errorSymbol;
|
|
7037
|
+
if (isLParenToken(this.peek())) {
|
|
7038
|
+
this.advance();
|
|
7039
|
+
errorSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7040
|
+
assertRParenToken(this.peek());
|
|
7041
|
+
this.advance();
|
|
7042
|
+
}
|
|
7043
|
+
var catchExpressions = [];
|
|
7044
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7045
|
+
catchExpressions.push(this.parseExpression());
|
|
7046
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7047
|
+
this.advance();
|
|
7048
|
+
}
|
|
7049
|
+
}
|
|
7050
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7051
|
+
this.advance();
|
|
7052
|
+
var catchExpression = catchExpressions.length === 1
|
|
7053
|
+
? catchExpressions[0]
|
|
7054
|
+
: {
|
|
7055
|
+
t: AstNodeType.SpecialExpression,
|
|
7056
|
+
n: 'do',
|
|
7057
|
+
p: catchExpressions,
|
|
7058
|
+
token: getTokenDebugData(token) && token,
|
|
7059
|
+
};
|
|
7060
|
+
return {
|
|
7061
|
+
t: AstNodeType.SpecialExpression,
|
|
7062
|
+
n: 'try',
|
|
7063
|
+
p: [tryExpression],
|
|
7064
|
+
ce: catchExpression,
|
|
7065
|
+
e: errorSymbol,
|
|
7066
|
+
token: getTokenDebugData(token) && token,
|
|
7630
7067
|
};
|
|
7631
7068
|
};
|
|
7632
|
-
AlgebraicParser.prototype.
|
|
7069
|
+
AlgebraicParser.prototype.parseForOrDoseq = function (token) {
|
|
7070
|
+
var isDoseq = token[1] === 'doseq';
|
|
7633
7071
|
this.advance();
|
|
7634
7072
|
assertLParenToken(this.peek());
|
|
7635
7073
|
this.advance();
|
|
@@ -7649,7 +7087,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7649
7087
|
this.advance();
|
|
7650
7088
|
return {
|
|
7651
7089
|
t: AstNodeType.SpecialExpression,
|
|
7652
|
-
n: 'for',
|
|
7090
|
+
n: isDoseq ? 'doseq' : 'for',
|
|
7653
7091
|
p: [expression],
|
|
7654
7092
|
token: getTokenDebugData(token) && token,
|
|
7655
7093
|
l: forLoopBindings,
|
|
@@ -7669,33 +7107,26 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7669
7107
|
}
|
|
7670
7108
|
var modifiers = [];
|
|
7671
7109
|
var token = this.peek();
|
|
7672
|
-
if (!isA_SymbolToken(token)
|
|
7110
|
+
if (!isA_SymbolToken(token, 'let')
|
|
7111
|
+
&& !isA_ReservedSymbolToken(token, 'when')
|
|
7112
|
+
&& !isA_ReservedSymbolToken(token, 'while')) {
|
|
7673
7113
|
throw new LitsError('Expected symbol let, when or while', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7674
7114
|
}
|
|
7675
7115
|
var letBindings;
|
|
7676
7116
|
if (token[1] === 'let') {
|
|
7677
7117
|
modifiers.push('&let');
|
|
7678
7118
|
letBindings = [];
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
return {
|
|
7685
|
-
t: AstNodeType.Binding,
|
|
7686
|
-
n: key.v,
|
|
7687
|
-
v: value,
|
|
7688
|
-
p: [],
|
|
7689
|
-
token: getTokenDebugData(key.token) && key.token,
|
|
7690
|
-
};
|
|
7691
|
-
});
|
|
7119
|
+
while (isA_SymbolToken(token, 'let')) {
|
|
7120
|
+
var letNode = this.parseLet(token, true);
|
|
7121
|
+
letBindings.push(letNode.bs[0]);
|
|
7122
|
+
token = this.peek();
|
|
7123
|
+
}
|
|
7692
7124
|
}
|
|
7693
7125
|
token = this.peek();
|
|
7694
7126
|
var whenNode;
|
|
7695
7127
|
var whileNode;
|
|
7696
|
-
while (
|
|
7697
|
-
|
|
7698
|
-
|| (token[1] === 'while' && !modifiers.includes('&while')))) {
|
|
7128
|
+
while (isA_ReservedSymbolToken(token, 'when')
|
|
7129
|
+
|| isA_ReservedSymbolToken(token, 'while')) {
|
|
7699
7130
|
this.advance();
|
|
7700
7131
|
if (token[1] === 'when') {
|
|
7701
7132
|
modifiers.push('&when');
|
|
@@ -7738,7 +7169,8 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7738
7169
|
};
|
|
7739
7170
|
return node;
|
|
7740
7171
|
};
|
|
7741
|
-
AlgebraicParser.prototype.
|
|
7172
|
+
AlgebraicParser.prototype.parseIfOrUnless = function (token) {
|
|
7173
|
+
var isUnless = token[1] === 'unless';
|
|
7742
7174
|
this.advance();
|
|
7743
7175
|
var condition = this.parseExpression();
|
|
7744
7176
|
assertA_ReservedSymbolToken(this.peek(), 'then');
|
|
@@ -7787,7 +7219,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7787
7219
|
}
|
|
7788
7220
|
return {
|
|
7789
7221
|
t: AstNodeType.SpecialExpression,
|
|
7790
|
-
n: 'if',
|
|
7222
|
+
n: isUnless ? 'unless' : 'if',
|
|
7791
7223
|
p: params,
|
|
7792
7224
|
token: getTokenDebugData(token) && token,
|
|
7793
7225
|
};
|
|
@@ -7872,20 +7304,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7872
7304
|
token: getTokenDebugData(token) && token,
|
|
7873
7305
|
};
|
|
7874
7306
|
};
|
|
7875
|
-
AlgebraicParser.prototype.
|
|
7876
|
-
this.advance();
|
|
7877
|
-
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7878
|
-
assertA_OperatorToken(this.peek(), '=');
|
|
7879
|
-
this.advance();
|
|
7880
|
-
var value = this.parseExpression();
|
|
7881
|
-
return {
|
|
7882
|
-
t: AstNodeType.SpecialExpression,
|
|
7883
|
-
n: 'def',
|
|
7884
|
-
p: [symbol, value],
|
|
7885
|
-
token: getTokenDebugData(token) && token,
|
|
7886
|
-
};
|
|
7887
|
-
};
|
|
7888
|
-
AlgebraicParser.prototype.parseDefn = function (token) {
|
|
7307
|
+
AlgebraicParser.prototype.parseFunction = function (token) {
|
|
7889
7308
|
this.advance();
|
|
7890
7309
|
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7891
7310
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
@@ -7898,10 +7317,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7898
7317
|
}
|
|
7899
7318
|
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7900
7319
|
this.advance();
|
|
7901
|
-
|
|
7320
|
+
var fnNode = {
|
|
7902
7321
|
t: AstNodeType.SpecialExpression,
|
|
7903
|
-
n: '
|
|
7904
|
-
f: symbol,
|
|
7322
|
+
n: 'fn',
|
|
7905
7323
|
p: [],
|
|
7906
7324
|
o: [{
|
|
7907
7325
|
as: functionArguments,
|
|
@@ -7910,12 +7328,63 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7910
7328
|
}],
|
|
7911
7329
|
token: getTokenDebugData(token) && token,
|
|
7912
7330
|
};
|
|
7331
|
+
return {
|
|
7332
|
+
t: AstNodeType.SpecialExpression,
|
|
7333
|
+
n: 'let',
|
|
7334
|
+
p: [],
|
|
7335
|
+
bs: [{
|
|
7336
|
+
t: AstNodeType.Binding,
|
|
7337
|
+
n: symbol.v,
|
|
7338
|
+
v: fnNode,
|
|
7339
|
+
p: [],
|
|
7340
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
7341
|
+
}],
|
|
7342
|
+
token: getTokenDebugData(token) && token,
|
|
7343
|
+
};
|
|
7913
7344
|
};
|
|
7914
7345
|
AlgebraicParser.prototype.isAtEnd = function () {
|
|
7915
7346
|
return this.parseState.position >= this.tokenStream.tokens.length;
|
|
7916
7347
|
};
|
|
7917
|
-
AlgebraicParser.prototype.
|
|
7918
|
-
|
|
7348
|
+
AlgebraicParser.prototype.isAtExpressionEnd = function () {
|
|
7349
|
+
if (this.isAtEnd()) {
|
|
7350
|
+
return true;
|
|
7351
|
+
}
|
|
7352
|
+
var token = this.peek();
|
|
7353
|
+
if (isA_OperatorToken(token)) {
|
|
7354
|
+
return [';', ','].includes(token[1]);
|
|
7355
|
+
}
|
|
7356
|
+
if (isA_SymbolToken(token)) {
|
|
7357
|
+
return ['catch'].includes(token[1]);
|
|
7358
|
+
}
|
|
7359
|
+
if (isA_ReservedSymbolToken(token)) {
|
|
7360
|
+
return ['else', 'when', 'while', 'then', 'end', 'case'].includes(token[1]);
|
|
7361
|
+
}
|
|
7362
|
+
return false;
|
|
7363
|
+
};
|
|
7364
|
+
AlgebraicParser.prototype.parseExport = function (token) {
|
|
7365
|
+
var _a;
|
|
7366
|
+
this.advance();
|
|
7367
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7368
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7369
|
+
return {
|
|
7370
|
+
t: AstNodeType.SpecialExpression,
|
|
7371
|
+
n: 'def',
|
|
7372
|
+
p: [symbol, symbol],
|
|
7373
|
+
token: getTokenDebugData(token) && token,
|
|
7374
|
+
};
|
|
7375
|
+
}
|
|
7376
|
+
if (!isA_OperatorToken(this.peek(), '=')) {
|
|
7377
|
+
throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7378
|
+
}
|
|
7379
|
+
this.advance();
|
|
7380
|
+
var value = this.parseExpression();
|
|
7381
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
7382
|
+
return {
|
|
7383
|
+
t: AstNodeType.SpecialExpression,
|
|
7384
|
+
n: 'def',
|
|
7385
|
+
p: [symbol, value],
|
|
7386
|
+
token: getTokenDebugData(token) && token,
|
|
7387
|
+
};
|
|
7919
7388
|
};
|
|
7920
7389
|
return AlgebraicParser;
|
|
7921
7390
|
}());
|
|
@@ -7991,33 +7460,6 @@ function parseObjectLitteral(tokenStream, parseState) {
|
|
|
7991
7460
|
assertEvenNumberOfParams(node);
|
|
7992
7461
|
return node;
|
|
7993
7462
|
}
|
|
7994
|
-
function parseRegexpShorthand(tokenStream, parseState) {
|
|
7995
|
-
var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
7996
|
-
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
7997
|
-
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
7998
|
-
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
7999
|
-
var stringNode = {
|
|
8000
|
-
t: AstNodeType.String,
|
|
8001
|
-
v: regexpString,
|
|
8002
|
-
p: [],
|
|
8003
|
-
n: undefined,
|
|
8004
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8005
|
-
};
|
|
8006
|
-
var optionsNode = {
|
|
8007
|
-
t: AstNodeType.String,
|
|
8008
|
-
v: optionsString,
|
|
8009
|
-
p: [],
|
|
8010
|
-
n: undefined,
|
|
8011
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8012
|
-
};
|
|
8013
|
-
var node = {
|
|
8014
|
-
t: AstNodeType.NormalExpression,
|
|
8015
|
-
n: 'regexp',
|
|
8016
|
-
p: [stringNode, optionsNode],
|
|
8017
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8018
|
-
};
|
|
8019
|
-
return node;
|
|
8020
|
-
}
|
|
8021
7463
|
var placeholderRegexp = /^%([1-9]\d?)?$/;
|
|
8022
7464
|
function parseFnShorthand(tokenStream, parseState) {
|
|
8023
7465
|
var _a, _b, _c, _d;
|
|
@@ -8187,7 +7629,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
8187
7629
|
return parseArrayLitteral(tokenStream, parseState);
|
|
8188
7630
|
case 'LBrace':
|
|
8189
7631
|
return parseObjectLitteral(tokenStream, parseState);
|
|
8190
|
-
case '
|
|
7632
|
+
case 'RegexpShorthand':
|
|
8191
7633
|
return parseRegexpShorthand(tokenStream, parseState);
|
|
8192
7634
|
case 'P_FnShorthand':
|
|
8193
7635
|
return parseFnShorthand(tokenStream, parseState);
|
|
@@ -8351,6 +7793,25 @@ var tokenizeString = function (input, position) {
|
|
|
8351
7793
|
value += '"'; // closing quote
|
|
8352
7794
|
return [length + 1, ['String', value]];
|
|
8353
7795
|
};
|
|
7796
|
+
var tokenizeRegexpShorthand = function (input, position) {
|
|
7797
|
+
if (input[position] !== '#')
|
|
7798
|
+
return NO_MATCH;
|
|
7799
|
+
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
7800
|
+
if (!token)
|
|
7801
|
+
return NO_MATCH;
|
|
7802
|
+
position += stringLength + 1;
|
|
7803
|
+
var length = stringLength + 1;
|
|
7804
|
+
var options = '';
|
|
7805
|
+
while (input[position] === 'g' || input[position] === 'i') {
|
|
7806
|
+
if (options.includes(input[position])) {
|
|
7807
|
+
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
7808
|
+
}
|
|
7809
|
+
options += input[position];
|
|
7810
|
+
length += 1;
|
|
7811
|
+
position += 1;
|
|
7812
|
+
}
|
|
7813
|
+
return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
7814
|
+
};
|
|
8354
7815
|
function tokenizeSimpleToken(type, value, input, position) {
|
|
8355
7816
|
if (value === input.slice(position, position + value.length))
|
|
8356
7817
|
return [value.length, [type]];
|
|
@@ -8368,6 +7829,7 @@ var commonTokenizers = [
|
|
|
8368
7829
|
tokenizeLBrace,
|
|
8369
7830
|
tokenizeRBrace,
|
|
8370
7831
|
tokenizeString,
|
|
7832
|
+
tokenizeRegexpShorthand,
|
|
8371
7833
|
];
|
|
8372
7834
|
|
|
8373
7835
|
var validAlgebraicReservedNamesRecord = {
|
|
@@ -8379,17 +7841,13 @@ var validAlgebraicReservedNamesRecord = {
|
|
|
8379
7841
|
else: { value: null, forbidden: false },
|
|
8380
7842
|
end: { value: null, forbidden: false },
|
|
8381
7843
|
case: { value: null, forbidden: false },
|
|
7844
|
+
when: { value: null, forbidden: false },
|
|
7845
|
+
while: { value: null, forbidden: false },
|
|
7846
|
+
function: { value: null, forbidden: false },
|
|
7847
|
+
export: { value: null, forbidden: false },
|
|
8382
7848
|
};
|
|
8383
7849
|
var forbiddenAlgebraicReservedNamesRecord = {
|
|
8384
|
-
if_let: { value: null, forbidden: true },
|
|
8385
|
-
when_let: { value: null, forbidden: true },
|
|
8386
|
-
when_first: { value: null, forbidden: true },
|
|
8387
7850
|
fn: { value: null, forbidden: true },
|
|
8388
|
-
defns: { value: null, forbidden: true },
|
|
8389
|
-
try: { value: null, forbidden: true },
|
|
8390
|
-
recur: { value: null, forbidden: true },
|
|
8391
|
-
loop: { value: null, forbidden: true },
|
|
8392
|
-
doseq: { value: null, forbidden: true },
|
|
8393
7851
|
};
|
|
8394
7852
|
var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
|
|
8395
7853
|
|
|
@@ -8774,25 +8232,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
|
|
|
8774
8232
|
return NO_MATCH;
|
|
8775
8233
|
return [1, ['P_CollectionAccessor', char]];
|
|
8776
8234
|
};
|
|
8777
|
-
var tokenizeP_RegexpShorthand = function (input, position) {
|
|
8778
|
-
if (input[position] !== '#')
|
|
8779
|
-
return NO_MATCH;
|
|
8780
|
-
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
8781
|
-
if (!token)
|
|
8782
|
-
return NO_MATCH;
|
|
8783
|
-
position += stringLength + 1;
|
|
8784
|
-
var length = stringLength + 1;
|
|
8785
|
-
var options = '';
|
|
8786
|
-
while (input[position] === 'g' || input[position] === 'i') {
|
|
8787
|
-
if (options.includes(input[position])) {
|
|
8788
|
-
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
8789
|
-
}
|
|
8790
|
-
options += input[position];
|
|
8791
|
-
length += 1;
|
|
8792
|
-
position += 1;
|
|
8793
|
-
}
|
|
8794
|
-
return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
8795
|
-
};
|
|
8796
8235
|
// All tokenizers, order matters!
|
|
8797
8236
|
var polishTokenizers = __spreadArray(__spreadArray([
|
|
8798
8237
|
tokenizeP_Whitespace,
|
|
@@ -8803,7 +8242,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
|
|
|
8803
8242
|
tokenizeP_ReservedSymbol,
|
|
8804
8243
|
tokenizeP_Modifier,
|
|
8805
8244
|
tokenizeP_Symbol,
|
|
8806
|
-
tokenizeP_RegexpShorthand,
|
|
8807
8245
|
tokenizeP_FnShorthand,
|
|
8808
8246
|
tokenizeP_CollectionAccessor,
|
|
8809
8247
|
], false);
|
|
@@ -10088,7 +9526,7 @@ var arrayReference = {
|
|
|
10088
9526
|
description: 'Takes a nested array $x and flattens it.',
|
|
10089
9527
|
examples: [
|
|
10090
9528
|
'(flatten [1 2 [3 4] 5])',
|
|
10091
|
-
"\n(let [foo :bar]\n
|
|
9529
|
+
"\n(let [foo :bar])\n(flatten\n [1\n \" 2 A \"\n [foo [4 [:ABC]]] 6])",
|
|
10092
9530
|
'(flatten 12)',
|
|
10093
9531
|
],
|
|
10094
9532
|
},
|
|
@@ -10122,7 +9560,7 @@ var arrayReference = {
|
|
|
10122
9560
|
};
|
|
10123
9561
|
|
|
10124
9562
|
var sequenceReference = {
|
|
10125
|
-
nth: {
|
|
9563
|
+
'nth': {
|
|
10126
9564
|
title: 'nth',
|
|
10127
9565
|
category: 'Sequence',
|
|
10128
9566
|
linkName: 'nth',
|
|
@@ -10158,7 +9596,7 @@ var sequenceReference = {
|
|
|
10158
9596
|
'(nth nil 1 "Default value")',
|
|
10159
9597
|
],
|
|
10160
9598
|
},
|
|
10161
|
-
push: {
|
|
9599
|
+
'push': {
|
|
10162
9600
|
title: 'push',
|
|
10163
9601
|
category: 'Sequence',
|
|
10164
9602
|
linkName: 'push',
|
|
@@ -10188,7 +9626,7 @@ var sequenceReference = {
|
|
|
10188
9626
|
'(def l [1 2 3]) (push l 4) l',
|
|
10189
9627
|
],
|
|
10190
9628
|
},
|
|
10191
|
-
pop: {
|
|
9629
|
+
'pop': {
|
|
10192
9630
|
title: 'pop',
|
|
10193
9631
|
category: 'Sequence',
|
|
10194
9632
|
linkName: 'pop',
|
|
@@ -10211,7 +9649,7 @@ var sequenceReference = {
|
|
|
10211
9649
|
'(pop [])',
|
|
10212
9650
|
],
|
|
10213
9651
|
},
|
|
10214
|
-
unshift: {
|
|
9652
|
+
'unshift': {
|
|
10215
9653
|
title: 'unshift',
|
|
10216
9654
|
category: 'Sequence',
|
|
10217
9655
|
linkName: 'unshift',
|
|
@@ -10240,7 +9678,7 @@ var sequenceReference = {
|
|
|
10240
9678
|
"\n(def l [1 2 3])\n(unshift l 4)\nl",
|
|
10241
9679
|
],
|
|
10242
9680
|
},
|
|
10243
|
-
shift: {
|
|
9681
|
+
'shift': {
|
|
10244
9682
|
title: 'shift',
|
|
10245
9683
|
category: 'Sequence',
|
|
10246
9684
|
linkName: 'shift',
|
|
@@ -10264,7 +9702,7 @@ var sequenceReference = {
|
|
|
10264
9702
|
'(shift [])',
|
|
10265
9703
|
],
|
|
10266
9704
|
},
|
|
10267
|
-
slice: {
|
|
9705
|
+
'slice': {
|
|
10268
9706
|
title: 'slice',
|
|
10269
9707
|
category: 'Sequence',
|
|
10270
9708
|
linkName: 'slice',
|
|
@@ -10298,7 +9736,7 @@ var sequenceReference = {
|
|
|
10298
9736
|
'(slice [1 2 3 4 5] 2)',
|
|
10299
9737
|
],
|
|
10300
9738
|
},
|
|
10301
|
-
reductions: {
|
|
9739
|
+
'reductions': {
|
|
10302
9740
|
title: 'reductions',
|
|
10303
9741
|
category: 'Sequence',
|
|
10304
9742
|
linkName: 'reductions',
|
|
@@ -10330,7 +9768,7 @@ var sequenceReference = {
|
|
|
10330
9768
|
"\n(reductions\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
10331
9769
|
],
|
|
10332
9770
|
},
|
|
10333
|
-
reduce: {
|
|
9771
|
+
'reduce': {
|
|
10334
9772
|
title: 'reduce',
|
|
10335
9773
|
category: 'Sequence',
|
|
10336
9774
|
linkName: 'reduce',
|
|
@@ -10360,7 +9798,7 @@ var sequenceReference = {
|
|
|
10360
9798
|
"\n(reduce\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
10361
9799
|
],
|
|
10362
9800
|
},
|
|
10363
|
-
reduce_right: {
|
|
9801
|
+
'reduce_right': {
|
|
10364
9802
|
title: 'reduce_right',
|
|
10365
9803
|
category: 'Sequence',
|
|
10366
9804
|
linkName: 'reduce_right',
|
|
@@ -10388,7 +9826,7 @@ var sequenceReference = {
|
|
|
10388
9826
|
'(reduce_right str [:A :B :C] "")',
|
|
10389
9827
|
],
|
|
10390
9828
|
},
|
|
10391
|
-
map: {
|
|
9829
|
+
'map': {
|
|
10392
9830
|
title: 'map',
|
|
10393
9831
|
category: 'Sequence',
|
|
10394
9832
|
linkName: 'map',
|
|
@@ -10413,7 +9851,7 @@ var sequenceReference = {
|
|
|
10413
9851
|
'(map [1 2 3] inc)',
|
|
10414
9852
|
],
|
|
10415
9853
|
},
|
|
10416
|
-
filter: {
|
|
9854
|
+
'filter': {
|
|
10417
9855
|
title: 'filter',
|
|
10418
9856
|
category: 'Sequence',
|
|
10419
9857
|
linkName: 'filter',
|
|
@@ -10437,7 +9875,7 @@ var sequenceReference = {
|
|
|
10437
9875
|
"\n(filter\n[5 10 15 20]\n (fn [x] (> x 10)))",
|
|
10438
9876
|
],
|
|
10439
9877
|
},
|
|
10440
|
-
position: {
|
|
9878
|
+
'position': {
|
|
10441
9879
|
title: 'position',
|
|
10442
9880
|
category: 'Sequence',
|
|
10443
9881
|
linkName: 'position',
|
|
@@ -10464,7 +9902,7 @@ var sequenceReference = {
|
|
|
10464
9902
|
"\n(position\n (fn [x] (> x 100))\n nil)",
|
|
10465
9903
|
],
|
|
10466
9904
|
},
|
|
10467
|
-
index_of: {
|
|
9905
|
+
'index_of': {
|
|
10468
9906
|
title: 'index_of',
|
|
10469
9907
|
category: 'Sequence',
|
|
10470
9908
|
linkName: 'index_of',
|
|
@@ -10491,7 +9929,34 @@ var sequenceReference = {
|
|
|
10491
9929
|
'(index_of nil 1)',
|
|
10492
9930
|
],
|
|
10493
9931
|
},
|
|
10494
|
-
|
|
9932
|
+
'last_index_of': {
|
|
9933
|
+
title: 'last_index_of',
|
|
9934
|
+
category: 'Sequence',
|
|
9935
|
+
linkName: 'last_index_of',
|
|
9936
|
+
clojureDocs: null,
|
|
9937
|
+
returns: {
|
|
9938
|
+
type: ['number', 'null'],
|
|
9939
|
+
},
|
|
9940
|
+
args: {
|
|
9941
|
+
seq: {
|
|
9942
|
+
type: ['sequence', 'null'],
|
|
9943
|
+
},
|
|
9944
|
+
x: {
|
|
9945
|
+
type: 'any',
|
|
9946
|
+
},
|
|
9947
|
+
},
|
|
9948
|
+
variants: [
|
|
9949
|
+
{ argumentNames: ['seq', 'x'] },
|
|
9950
|
+
],
|
|
9951
|
+
description: 'Returns the last index of $x in $seq. If element is not present in $seq `nil` is returned.',
|
|
9952
|
+
examples: [
|
|
9953
|
+
'(last_index_of ["Albert" "Mojir" 160 [1 2]] "Mojir")',
|
|
9954
|
+
'(last_index_of [5 10 15 20] 15)',
|
|
9955
|
+
'(last_index_of [5 10 15 20] 1)',
|
|
9956
|
+
'(last_index_of nil 1)',
|
|
9957
|
+
],
|
|
9958
|
+
},
|
|
9959
|
+
'some': {
|
|
10495
9960
|
title: 'some',
|
|
10496
9961
|
category: 'Sequence',
|
|
10497
9962
|
linkName: 'some',
|
|
@@ -10518,7 +9983,7 @@ var sequenceReference = {
|
|
|
10518
9983
|
"\n(some\n nil\n (fn [x] (> x 10)))",
|
|
10519
9984
|
],
|
|
10520
9985
|
},
|
|
10521
|
-
reverse: {
|
|
9986
|
+
'reverse': {
|
|
10522
9987
|
title: 'reverse',
|
|
10523
9988
|
category: 'Sequence',
|
|
10524
9989
|
linkName: 'reverse',
|
|
@@ -10541,7 +10006,7 @@ var sequenceReference = {
|
|
|
10541
10006
|
'(reverse nil)',
|
|
10542
10007
|
],
|
|
10543
10008
|
},
|
|
10544
|
-
first: {
|
|
10009
|
+
'first': {
|
|
10545
10010
|
title: 'first',
|
|
10546
10011
|
category: 'Sequence',
|
|
10547
10012
|
linkName: 'first',
|
|
@@ -10563,7 +10028,7 @@ var sequenceReference = {
|
|
|
10563
10028
|
'(first nil)',
|
|
10564
10029
|
],
|
|
10565
10030
|
},
|
|
10566
|
-
second: {
|
|
10031
|
+
'second': {
|
|
10567
10032
|
title: 'second',
|
|
10568
10033
|
category: 'Sequence',
|
|
10569
10034
|
linkName: 'second',
|
|
@@ -10586,7 +10051,7 @@ var sequenceReference = {
|
|
|
10586
10051
|
'(second nil)',
|
|
10587
10052
|
],
|
|
10588
10053
|
},
|
|
10589
|
-
last: {
|
|
10054
|
+
'last': {
|
|
10590
10055
|
title: 'last',
|
|
10591
10056
|
category: 'Sequence',
|
|
10592
10057
|
linkName: 'last',
|
|
@@ -10610,7 +10075,7 @@ var sequenceReference = {
|
|
|
10610
10075
|
'(last nil)',
|
|
10611
10076
|
],
|
|
10612
10077
|
},
|
|
10613
|
-
rest: {
|
|
10078
|
+
'rest': {
|
|
10614
10079
|
title: 'rest',
|
|
10615
10080
|
category: 'Sequence',
|
|
10616
10081
|
linkName: 'rest',
|
|
@@ -10635,7 +10100,7 @@ var sequenceReference = {
|
|
|
10635
10100
|
'(rest "")',
|
|
10636
10101
|
],
|
|
10637
10102
|
},
|
|
10638
|
-
nthrest: {
|
|
10103
|
+
'nthrest': {
|
|
10639
10104
|
title: 'nthrest',
|
|
10640
10105
|
category: 'Sequence',
|
|
10641
10106
|
linkName: 'nthrest',
|
|
@@ -10663,7 +10128,7 @@ var sequenceReference = {
|
|
|
10663
10128
|
'(nthrest "" 0)',
|
|
10664
10129
|
],
|
|
10665
10130
|
},
|
|
10666
|
-
next: {
|
|
10131
|
+
'next': {
|
|
10667
10132
|
title: 'next',
|
|
10668
10133
|
category: 'Sequence',
|
|
10669
10134
|
linkName: 'next',
|
|
@@ -10688,7 +10153,7 @@ var sequenceReference = {
|
|
|
10688
10153
|
'(next "")',
|
|
10689
10154
|
],
|
|
10690
10155
|
},
|
|
10691
|
-
nthnext: {
|
|
10156
|
+
'nthnext': {
|
|
10692
10157
|
title: 'nthnext',
|
|
10693
10158
|
category: 'Sequence',
|
|
10694
10159
|
linkName: 'nthnext',
|
|
@@ -10716,7 +10181,7 @@ var sequenceReference = {
|
|
|
10716
10181
|
'(nthnext "" 0)',
|
|
10717
10182
|
],
|
|
10718
10183
|
},
|
|
10719
|
-
take: {
|
|
10184
|
+
'take': {
|
|
10720
10185
|
title: 'take',
|
|
10721
10186
|
category: 'Sequence',
|
|
10722
10187
|
linkName: 'take',
|
|
@@ -10742,7 +10207,7 @@ var sequenceReference = {
|
|
|
10742
10207
|
'(take 50 "Albert")',
|
|
10743
10208
|
],
|
|
10744
10209
|
},
|
|
10745
|
-
take_last: {
|
|
10210
|
+
'take_last': {
|
|
10746
10211
|
title: 'take_last',
|
|
10747
10212
|
category: 'Sequence',
|
|
10748
10213
|
linkName: 'take_last',
|
|
@@ -10766,7 +10231,7 @@ var sequenceReference = {
|
|
|
10766
10231
|
'(take_last 0 [1 2 3 4 5])',
|
|
10767
10232
|
],
|
|
10768
10233
|
},
|
|
10769
|
-
take_while: {
|
|
10234
|
+
'take_while': {
|
|
10770
10235
|
title: 'take_while',
|
|
10771
10236
|
category: 'Sequence',
|
|
10772
10237
|
linkName: 'take_while',
|
|
@@ -10790,7 +10255,7 @@ var sequenceReference = {
|
|
|
10790
10255
|
"\n(take_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10791
10256
|
],
|
|
10792
10257
|
},
|
|
10793
|
-
drop: {
|
|
10258
|
+
'drop': {
|
|
10794
10259
|
title: 'drop',
|
|
10795
10260
|
category: 'Sequence',
|
|
10796
10261
|
linkName: 'drop',
|
|
@@ -10816,7 +10281,7 @@ var sequenceReference = {
|
|
|
10816
10281
|
'(drop "Albert" 50)',
|
|
10817
10282
|
],
|
|
10818
10283
|
},
|
|
10819
|
-
drop_last: {
|
|
10284
|
+
'drop_last': {
|
|
10820
10285
|
title: 'drop_last',
|
|
10821
10286
|
category: 'Sequence',
|
|
10822
10287
|
linkName: 'drop_last',
|
|
@@ -10840,7 +10305,7 @@ var sequenceReference = {
|
|
|
10840
10305
|
'(drop_last [1 2 3 4 5] 0)',
|
|
10841
10306
|
],
|
|
10842
10307
|
},
|
|
10843
|
-
drop_while: {
|
|
10308
|
+
'drop_while': {
|
|
10844
10309
|
title: 'drop_while',
|
|
10845
10310
|
category: 'Sequence',
|
|
10846
10311
|
linkName: 'drop_while',
|
|
@@ -10864,7 +10329,7 @@ var sequenceReference = {
|
|
|
10864
10329
|
"\n(drop_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10865
10330
|
],
|
|
10866
10331
|
},
|
|
10867
|
-
sort: {
|
|
10332
|
+
'sort': {
|
|
10868
10333
|
title: 'sort',
|
|
10869
10334
|
category: 'Sequence',
|
|
10870
10335
|
linkName: 'sort',
|
|
@@ -10891,7 +10356,7 @@ var sequenceReference = {
|
|
|
10891
10356
|
"\n(sort\n [3 1 2]\n (fn [a b] (cond (> a b) -1 (< a b) 1 true -1)))",
|
|
10892
10357
|
],
|
|
10893
10358
|
},
|
|
10894
|
-
sort_by: {
|
|
10359
|
+
'sort_by': {
|
|
10895
10360
|
title: 'sort_by',
|
|
10896
10361
|
category: 'Sequence',
|
|
10897
10362
|
linkName: 'sort_by',
|
|
@@ -10920,7 +10385,7 @@ var sequenceReference = {
|
|
|
10920
10385
|
'(sort_by "Albert" lower_case #(compare %2 %1))',
|
|
10921
10386
|
],
|
|
10922
10387
|
},
|
|
10923
|
-
distinct: {
|
|
10388
|
+
'distinct': {
|
|
10924
10389
|
title: 'distinct',
|
|
10925
10390
|
category: 'Sequence',
|
|
10926
10391
|
linkName: 'distinct',
|
|
@@ -10943,7 +10408,7 @@ var sequenceReference = {
|
|
|
10943
10408
|
'(distinct "")',
|
|
10944
10409
|
],
|
|
10945
10410
|
},
|
|
10946
|
-
remove: {
|
|
10411
|
+
'remove': {
|
|
10947
10412
|
title: 'remove',
|
|
10948
10413
|
category: 'Sequence',
|
|
10949
10414
|
linkName: 'remove',
|
|
@@ -10967,7 +10432,7 @@ var sequenceReference = {
|
|
|
10967
10432
|
'(remove "Albert Mojir" #(has? "aoueiyAOUEIY" %1))',
|
|
10968
10433
|
],
|
|
10969
10434
|
},
|
|
10970
|
-
remove_at: {
|
|
10435
|
+
'remove_at': {
|
|
10971
10436
|
title: 'remove_at',
|
|
10972
10437
|
category: 'Sequence',
|
|
10973
10438
|
linkName: 'remove_at',
|
|
@@ -10993,7 +10458,7 @@ var sequenceReference = {
|
|
|
10993
10458
|
'(remove_at "Albert Mojir" 6)',
|
|
10994
10459
|
],
|
|
10995
10460
|
},
|
|
10996
|
-
split_at: {
|
|
10461
|
+
'split_at': {
|
|
10997
10462
|
title: 'split_at',
|
|
10998
10463
|
category: 'Sequence',
|
|
10999
10464
|
linkName: 'split_at',
|
|
@@ -11018,7 +10483,7 @@ var sequenceReference = {
|
|
|
11018
10483
|
'(split_at "Albert" 2)',
|
|
11019
10484
|
],
|
|
11020
10485
|
},
|
|
11021
|
-
split_with: {
|
|
10486
|
+
'split_with': {
|
|
11022
10487
|
title: 'split_with',
|
|
11023
10488
|
category: 'Sequence',
|
|
11024
10489
|
linkName: 'split_with',
|
|
@@ -11043,7 +10508,7 @@ var sequenceReference = {
|
|
|
11043
10508
|
'(split_with "Albert" #(<= %1 :Z))',
|
|
11044
10509
|
],
|
|
11045
10510
|
},
|
|
11046
|
-
frequencies: {
|
|
10511
|
+
'frequencies': {
|
|
11047
10512
|
title: 'frequencies',
|
|
11048
10513
|
category: 'Sequence',
|
|
11049
10514
|
linkName: 'frequencies',
|
|
@@ -11064,7 +10529,7 @@ var sequenceReference = {
|
|
|
11064
10529
|
'(frequencies "Pneumonoultramicroscopicsilicovolcanoconiosis")',
|
|
11065
10530
|
],
|
|
11066
10531
|
},
|
|
11067
|
-
group_by: {
|
|
10532
|
+
'group_by': {
|
|
11068
10533
|
title: 'group_by',
|
|
11069
10534
|
category: 'Sequence',
|
|
11070
10535
|
linkName: 'group_by',
|
|
@@ -11088,7 +10553,7 @@ var sequenceReference = {
|
|
|
11088
10553
|
'(group_by "Albert Mojir" (fn [char] (if (has? "aoueiAOUEI" char) "vowel" "other")))',
|
|
11089
10554
|
],
|
|
11090
10555
|
},
|
|
11091
|
-
partition: {
|
|
10556
|
+
'partition': {
|
|
11092
10557
|
title: 'partition',
|
|
11093
10558
|
category: 'Sequence',
|
|
11094
10559
|
linkName: 'partition',
|
|
@@ -11105,67 +10570,175 @@ var sequenceReference = {
|
|
|
11105
10570
|
step: {
|
|
11106
10571
|
type: 'number',
|
|
11107
10572
|
},
|
|
11108
|
-
pad: {
|
|
11109
|
-
type: 'array',
|
|
10573
|
+
pad: {
|
|
10574
|
+
type: 'array',
|
|
10575
|
+
},
|
|
10576
|
+
},
|
|
10577
|
+
variants: [
|
|
10578
|
+
{ argumentNames: ['seq', 'n'] },
|
|
10579
|
+
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10580
|
+
{ argumentNames: ['seq', 'n', 'step', 'pad'] },
|
|
10581
|
+
],
|
|
10582
|
+
description: 'Returns an array of sequences of $n items each, at offsets $step apart. If $step is not supplied, defaults to $n. If a $pad array is supplied, use its elements as necessary to complete last partition upto $n items. In case there are not enough padding elements, return a partition with less than $n items.',
|
|
10583
|
+
examples: [
|
|
10584
|
+
'(partition (range 20) 4)',
|
|
10585
|
+
'(partition (range 22) 4)',
|
|
10586
|
+
'(partition (range 20) 4 6)',
|
|
10587
|
+
'(partition (range 20) 4 3)',
|
|
10588
|
+
'(partition (range 20) 3 6 [:a])',
|
|
10589
|
+
'(partition (range 20) 4 6 [:a])',
|
|
10590
|
+
'(partition (range 20) 4 6 [:a :b :c :d])',
|
|
10591
|
+
'(partition [:a :b :c :d :e :f] 3 1)',
|
|
10592
|
+
'(partition [1 2 3 4] 10)',
|
|
10593
|
+
'(partition [1 2 3 4] 10 10)',
|
|
10594
|
+
'(partition [1 2 3 4] 10 10 [])',
|
|
10595
|
+
'(partition [1 2 3 4] 10 10 nil)',
|
|
10596
|
+
'(partition "superfragilistic" 5)',
|
|
10597
|
+
'(partition "superfragilistic" 5 5 nil)',
|
|
10598
|
+
'(def foo [5 6 7 8]) (partition foo 2 1 foo)',
|
|
10599
|
+
],
|
|
10600
|
+
},
|
|
10601
|
+
'partition_all': {
|
|
10602
|
+
title: 'partition_all',
|
|
10603
|
+
category: 'Sequence',
|
|
10604
|
+
linkName: 'partition_all',
|
|
10605
|
+
returns: {
|
|
10606
|
+
type: 'sequence',
|
|
10607
|
+
},
|
|
10608
|
+
args: {
|
|
10609
|
+
seq: {
|
|
10610
|
+
type: 'sequence',
|
|
10611
|
+
},
|
|
10612
|
+
n: {
|
|
10613
|
+
type: 'number',
|
|
10614
|
+
},
|
|
10615
|
+
step: {
|
|
10616
|
+
type: 'number',
|
|
10617
|
+
},
|
|
10618
|
+
},
|
|
10619
|
+
variants: [
|
|
10620
|
+
{ argumentNames: ['seq', 'n'] },
|
|
10621
|
+
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10622
|
+
],
|
|
10623
|
+
description: 'Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.',
|
|
10624
|
+
examples: [
|
|
10625
|
+
'(partition_all [0 1 2 3 4 5 6 7 8 9] 4)',
|
|
10626
|
+
'(partition [0 1 2 3 4 5 6 7 8 9] 4)',
|
|
10627
|
+
'(partition_all [0 1 2 3 4 5 6 7 8 9] 2 4)',
|
|
10628
|
+
],
|
|
10629
|
+
},
|
|
10630
|
+
'partition_by': {
|
|
10631
|
+
title: 'partition_by',
|
|
10632
|
+
category: 'Sequence',
|
|
10633
|
+
linkName: 'partition_by',
|
|
10634
|
+
returns: {
|
|
10635
|
+
type: 'sequence',
|
|
10636
|
+
},
|
|
10637
|
+
args: {
|
|
10638
|
+
seq: {
|
|
10639
|
+
type: 'sequence',
|
|
10640
|
+
},
|
|
10641
|
+
fn: {
|
|
10642
|
+
type: 'function',
|
|
10643
|
+
},
|
|
10644
|
+
},
|
|
10645
|
+
variants: [
|
|
10646
|
+
{ argumentNames: ['seq', 'fn'] },
|
|
10647
|
+
],
|
|
10648
|
+
description: 'Applies $fn to each value in $seq, splitting it each time $fn returns a new value. Returns an array of sequences.',
|
|
10649
|
+
examples: [
|
|
10650
|
+
'(partition_by [1 2 3 4 5] #(== 3 %1))',
|
|
10651
|
+
'(partition_by [1 1 1 2 2 3 3] odd?)',
|
|
10652
|
+
'(partition_by "Leeeeeerrroyyy" identity)',
|
|
10653
|
+
],
|
|
10654
|
+
},
|
|
10655
|
+
'starts_with?': {
|
|
10656
|
+
title: 'starts_with?',
|
|
10657
|
+
category: 'Sequence',
|
|
10658
|
+
linkName: 'starts_with-question',
|
|
10659
|
+
clojureDocs: null,
|
|
10660
|
+
returns: {
|
|
10661
|
+
type: 'boolean',
|
|
10662
|
+
},
|
|
10663
|
+
args: {
|
|
10664
|
+
seq: {
|
|
10665
|
+
type: 'sequence',
|
|
10666
|
+
},
|
|
10667
|
+
prefix: {
|
|
10668
|
+
type: 'sequence',
|
|
10669
|
+
},
|
|
10670
|
+
},
|
|
10671
|
+
variants: [
|
|
10672
|
+
{ argumentNames: ['seq', 'prefix'] },
|
|
10673
|
+
],
|
|
10674
|
+
description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',
|
|
10675
|
+
examples: [
|
|
10676
|
+
'(starts_with? [1 2 3 4 5] 1)',
|
|
10677
|
+
'(starts_with? [1 2 3 4 5] [1])',
|
|
10678
|
+
'(starts_with? "Albert" "Al")',
|
|
10679
|
+
'(starts_with? "Albert" "al")',
|
|
10680
|
+
],
|
|
10681
|
+
},
|
|
10682
|
+
'ends_with?': {
|
|
10683
|
+
title: 'ends_with?',
|
|
10684
|
+
category: 'Sequence',
|
|
10685
|
+
linkName: 'ends_with-question',
|
|
10686
|
+
clojureDocs: null,
|
|
10687
|
+
returns: {
|
|
10688
|
+
type: 'boolean',
|
|
10689
|
+
},
|
|
10690
|
+
args: {
|
|
10691
|
+
seq: {
|
|
10692
|
+
type: 'sequence',
|
|
10693
|
+
},
|
|
10694
|
+
suffix: {
|
|
10695
|
+
type: 'sequence',
|
|
11110
10696
|
},
|
|
11111
10697
|
},
|
|
11112
10698
|
variants: [
|
|
11113
|
-
{ argumentNames: ['seq', '
|
|
11114
|
-
{ argumentNames: ['seq', 'n', 'step'] },
|
|
11115
|
-
{ argumentNames: ['seq', 'n', 'step', 'pad'] },
|
|
10699
|
+
{ argumentNames: ['seq', 'suffix'] },
|
|
11116
10700
|
],
|
|
11117
|
-
description: 'Returns
|
|
10701
|
+
description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',
|
|
11118
10702
|
examples: [
|
|
11119
|
-
'(
|
|
11120
|
-
'(
|
|
11121
|
-
'(
|
|
11122
|
-
'(
|
|
11123
|
-
'(partition (range 20) 3 6 [:a])',
|
|
11124
|
-
'(partition (range 20) 4 6 [:a])',
|
|
11125
|
-
'(partition (range 20) 4 6 [:a :b :c :d])',
|
|
11126
|
-
'(partition [:a :b :c :d :e :f] 3 1)',
|
|
11127
|
-
'(partition [1 2 3 4] 10)',
|
|
11128
|
-
'(partition [1 2 3 4] 10 10)',
|
|
11129
|
-
'(partition [1 2 3 4] 10 10 [])',
|
|
11130
|
-
'(partition [1 2 3 4] 10 10 nil)',
|
|
11131
|
-
'(partition "superfragilistic" 5)',
|
|
11132
|
-
'(partition "superfragilistic" 5 5 nil)',
|
|
11133
|
-
'(def foo [5 6 7 8]) (partition foo 2 1 foo)',
|
|
10703
|
+
'(ends_with? [1 2 3 4 5] 5)',
|
|
10704
|
+
'(ends_with? [1 2 3 4 5] [5])',
|
|
10705
|
+
'(ends_with? "Albert" "rt")',
|
|
10706
|
+
'(ends_with? "Albert" "RT")',
|
|
11134
10707
|
],
|
|
11135
10708
|
},
|
|
11136
|
-
|
|
11137
|
-
title: '
|
|
10709
|
+
'interleave': {
|
|
10710
|
+
title: 'interleave',
|
|
11138
10711
|
category: 'Sequence',
|
|
11139
|
-
linkName: '
|
|
10712
|
+
linkName: 'interleave',
|
|
10713
|
+
clojureDocs: null,
|
|
11140
10714
|
returns: {
|
|
11141
10715
|
type: 'sequence',
|
|
11142
10716
|
},
|
|
11143
10717
|
args: {
|
|
11144
|
-
|
|
10718
|
+
seqs: {
|
|
11145
10719
|
type: 'sequence',
|
|
11146
|
-
|
|
11147
|
-
n: {
|
|
11148
|
-
type: 'number',
|
|
11149
|
-
},
|
|
11150
|
-
step: {
|
|
11151
|
-
type: 'number',
|
|
10720
|
+
array: true,
|
|
11152
10721
|
},
|
|
11153
10722
|
},
|
|
11154
10723
|
variants: [
|
|
11155
|
-
{ argumentNames: ['
|
|
11156
|
-
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10724
|
+
{ argumentNames: ['seqs'] },
|
|
11157
10725
|
],
|
|
11158
|
-
description: 'Returns
|
|
10726
|
+
description: 'Returns a sequence of the first item from each of the $seqs, then the second item from each of the $seqs, until all items from the shortest seq are exhausted.',
|
|
11159
10727
|
examples: [
|
|
11160
|
-
'(
|
|
11161
|
-
'(
|
|
11162
|
-
'(
|
|
10728
|
+
'(interleave [1 2 3] [4 5 6])',
|
|
10729
|
+
'(interleave [1 2 3] [4 5 6] [7 8 9])',
|
|
10730
|
+
'(interleave [1 2 3] [4 5 6] [7 8])',
|
|
10731
|
+
'(interleave [1 2 3] [4 5 6] [7])',
|
|
10732
|
+
'(interleave [1 2 3] [4 5 6] [])',
|
|
10733
|
+
'(interleave [1 2 3] [])',
|
|
10734
|
+
'(interleave [])',
|
|
11163
10735
|
],
|
|
11164
10736
|
},
|
|
11165
|
-
|
|
11166
|
-
title: '
|
|
10737
|
+
'interpose': {
|
|
10738
|
+
title: 'interpose',
|
|
11167
10739
|
category: 'Sequence',
|
|
11168
|
-
linkName: '
|
|
10740
|
+
linkName: 'interpose',
|
|
10741
|
+
clojureDocs: null,
|
|
11169
10742
|
returns: {
|
|
11170
10743
|
type: 'sequence',
|
|
11171
10744
|
},
|
|
@@ -11173,18 +10746,18 @@ var sequenceReference = {
|
|
|
11173
10746
|
seq: {
|
|
11174
10747
|
type: 'sequence',
|
|
11175
10748
|
},
|
|
11176
|
-
|
|
11177
|
-
type: '
|
|
10749
|
+
separator: {
|
|
10750
|
+
type: 'any',
|
|
11178
10751
|
},
|
|
11179
10752
|
},
|
|
11180
10753
|
variants: [
|
|
11181
|
-
{ argumentNames: ['seq', '
|
|
10754
|
+
{ argumentNames: ['seq', 'separator'] },
|
|
11182
10755
|
],
|
|
11183
|
-
description: '
|
|
10756
|
+
description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',
|
|
11184
10757
|
examples: [
|
|
11185
|
-
'(
|
|
11186
|
-
'(
|
|
11187
|
-
'(
|
|
10758
|
+
'(interpose :a [1 2 3 4 5])',
|
|
10759
|
+
'(interpose " " ["Albert" "Mojir" "Nina"])',
|
|
10760
|
+
'(interpose "." "Albert")',
|
|
11188
10761
|
],
|
|
11189
10762
|
},
|
|
11190
10763
|
};
|
|
@@ -13781,12 +13354,12 @@ var regularExpressionReference = {
|
|
|
13781
13354
|
],
|
|
13782
13355
|
description: "Matches $s against regular expression $r.\nIf $s is a string and matches the regular expression, a `match`-array is returned, otherwise `nil` is returned.",
|
|
13783
13356
|
examples: [
|
|
13784
|
-
'(match (regexp "^\\s*(.*)$")
|
|
13785
|
-
'(match
|
|
13786
|
-
'(match
|
|
13787
|
-
'(match #"albert"i
|
|
13788
|
-
'(match #"albert"i
|
|
13789
|
-
'(match #"albert"i
|
|
13357
|
+
'(match " A string" (regexp "^\\s*(.*)$"))',
|
|
13358
|
+
'(match "My name is Albert" #"albert"i)',
|
|
13359
|
+
'(match "My name is Ben" #"albert"i)',
|
|
13360
|
+
'(match nil #"albert"i)',
|
|
13361
|
+
'(match 1 #"albert"i)',
|
|
13362
|
+
'(match {} #"albert"i)',
|
|
13790
13363
|
],
|
|
13791
13364
|
},
|
|
13792
13365
|
replace: {
|
|
@@ -13803,7 +13376,7 @@ var regularExpressionReference = {
|
|
|
13803
13376
|
type: 'string',
|
|
13804
13377
|
},
|
|
13805
13378
|
r: {
|
|
13806
|
-
type: 'regexp',
|
|
13379
|
+
type: ['regexp', 'string'],
|
|
13807
13380
|
},
|
|
13808
13381
|
x: {
|
|
13809
13382
|
type: 'string',
|
|
@@ -13812,13 +13385,49 @@ var regularExpressionReference = {
|
|
|
13812
13385
|
variants: [
|
|
13813
13386
|
{ argumentNames: ['s', 'r', 'x'] },
|
|
13814
13387
|
],
|
|
13815
|
-
description: 'Returns a new string with
|
|
13388
|
+
description: 'Returns a new string with first match of regular expression $r replaced by $x.',
|
|
13816
13389
|
examples: [
|
|
13817
|
-
'(replace "Duck"
|
|
13390
|
+
'(replace "Duck duck" "u" :i)',
|
|
13391
|
+
'(replace "Duck duck" (regexp :u) :i)',
|
|
13392
|
+
'(replace "abcABC" (regexp :a "i") "-")',
|
|
13818
13393
|
'(replace "abcABC" (regexp :a "gi") "-")',
|
|
13394
|
+
'(replace "abcABC" #"a"i "-")',
|
|
13819
13395
|
'(replace "abcABC" #"a"gi "-")',
|
|
13820
13396
|
],
|
|
13821
13397
|
},
|
|
13398
|
+
replace_all: {
|
|
13399
|
+
title: 'replace_all',
|
|
13400
|
+
category: 'Regular expression',
|
|
13401
|
+
linkName: 'replace_all',
|
|
13402
|
+
clojureDocs: null,
|
|
13403
|
+
returns: {
|
|
13404
|
+
type: 'any',
|
|
13405
|
+
array: true,
|
|
13406
|
+
},
|
|
13407
|
+
args: {
|
|
13408
|
+
s: {
|
|
13409
|
+
type: 'string',
|
|
13410
|
+
},
|
|
13411
|
+
r: {
|
|
13412
|
+
type: ['regexp', 'string'],
|
|
13413
|
+
},
|
|
13414
|
+
x: {
|
|
13415
|
+
type: 'string',
|
|
13416
|
+
},
|
|
13417
|
+
},
|
|
13418
|
+
variants: [
|
|
13419
|
+
{ argumentNames: ['s', 'r', 'x'] },
|
|
13420
|
+
],
|
|
13421
|
+
description: 'Returns a new string with all matches of regular expression $r replaced by $x.',
|
|
13422
|
+
examples: [
|
|
13423
|
+
'(replace_all "Duck duck" "u" :i)',
|
|
13424
|
+
'(replace_all "Duck duck" (regexp :u) :i)',
|
|
13425
|
+
'(replace_all "abcABC" (regexp :a "i") "-")',
|
|
13426
|
+
'(replace_all "abcABC" (regexp :a "gi") "-")',
|
|
13427
|
+
'(replace_all "abcABC" #"a"i "-")',
|
|
13428
|
+
'(replace_all "abcABC" #"a"gi "-")',
|
|
13429
|
+
],
|
|
13430
|
+
},
|
|
13822
13431
|
};
|
|
13823
13432
|
|
|
13824
13433
|
var specialExpressionsReference = {
|
|
@@ -13897,32 +13506,6 @@ var specialExpressionsReference = {
|
|
|
13897
13506
|
'(def a (object :x 10 :y true :z "A string"))',
|
|
13898
13507
|
],
|
|
13899
13508
|
},
|
|
13900
|
-
'defs': {
|
|
13901
|
-
title: 'defs',
|
|
13902
|
-
category: 'Special expression',
|
|
13903
|
-
linkName: 'defs',
|
|
13904
|
-
clojureDocs: null,
|
|
13905
|
-
returns: {
|
|
13906
|
-
type: 'any',
|
|
13907
|
-
},
|
|
13908
|
-
args: {
|
|
13909
|
-
name: {
|
|
13910
|
-
type: '*expression',
|
|
13911
|
-
},
|
|
13912
|
-
value: {
|
|
13913
|
-
type: '*expression',
|
|
13914
|
-
},
|
|
13915
|
-
},
|
|
13916
|
-
variants: [
|
|
13917
|
-
{ argumentNames: ['name', 'value'] },
|
|
13918
|
-
],
|
|
13919
|
-
description: "\nCreates a variable with name set to $name evaluated and value set to $value.\n\nIf a variable with name $name is already defined, an error is thrown.",
|
|
13920
|
-
examples: [
|
|
13921
|
-
'(defs :a :b)',
|
|
13922
|
-
"\n(defs (str :a :1) (object :x 10 :y true :z \"A string\"))\na1",
|
|
13923
|
-
"\n(defs :a :b)\n(defs a :c)\nb",
|
|
13924
|
-
],
|
|
13925
|
-
},
|
|
13926
13509
|
'let': {
|
|
13927
13510
|
title: 'let',
|
|
13928
13511
|
category: 'Special expression',
|
|
@@ -13935,97 +13518,12 @@ var specialExpressionsReference = {
|
|
|
13935
13518
|
type: '*binding',
|
|
13936
13519
|
rest: true,
|
|
13937
13520
|
},
|
|
13938
|
-
expressions: {
|
|
13939
|
-
type: '*expression',
|
|
13940
|
-
rest: true,
|
|
13941
|
-
},
|
|
13942
|
-
},
|
|
13943
|
-
variants: [
|
|
13944
|
-
{ argumentNames: ['bindings', 'expressions'] },
|
|
13945
|
-
],
|
|
13946
|
-
description: "\nBinds local variables. The variables lives only within $expressions.\nIt returns evaluation of the last expression in $expressions.",
|
|
13947
|
-
examples: ["\n (let [a (+ 1 2 3 4) \n b (* 1 2 3 4)]\n (write! a b))"],
|
|
13948
|
-
},
|
|
13949
|
-
'if_let': {
|
|
13950
|
-
title: 'if_let',
|
|
13951
|
-
category: 'Special expression',
|
|
13952
|
-
linkName: 'if_let',
|
|
13953
|
-
returns: {
|
|
13954
|
-
type: 'any',
|
|
13955
|
-
},
|
|
13956
|
-
args: {
|
|
13957
|
-
'binding': {
|
|
13958
|
-
type: '*binding',
|
|
13959
|
-
},
|
|
13960
|
-
'then-expr': {
|
|
13961
|
-
type: '*expression',
|
|
13962
|
-
},
|
|
13963
|
-
'else-expr': {
|
|
13964
|
-
type: '*expression',
|
|
13965
|
-
},
|
|
13966
|
-
},
|
|
13967
|
-
variants: [
|
|
13968
|
-
{ argumentNames: ['binding', 'then-expr'] },
|
|
13969
|
-
{ argumentNames: ['binding', 'then-expr', 'else-expr'] },
|
|
13970
|
-
],
|
|
13971
|
-
description: "\nBinds one local variable. If it evaluates to a truthy value\n$then-expr is executed with the variable accessable.\nIf the bound variable evaluates to false, the $else-expr is evaluated\n(without variable accessable).",
|
|
13972
|
-
examples: [
|
|
13973
|
-
"\n(if_let [a (> (count \"Albert\") 4)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
13974
|
-
"\n(if_let [a (> (count \"Albert\") 10)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
13975
|
-
],
|
|
13976
|
-
},
|
|
13977
|
-
'when_let': {
|
|
13978
|
-
title: 'when_let',
|
|
13979
|
-
category: 'Special expression',
|
|
13980
|
-
linkName: 'when_let',
|
|
13981
|
-
returns: {
|
|
13982
|
-
type: 'any',
|
|
13983
|
-
},
|
|
13984
|
-
args: {
|
|
13985
|
-
binding: {
|
|
13986
|
-
type: '*binding',
|
|
13987
|
-
},
|
|
13988
|
-
expressions: {
|
|
13989
|
-
type: '*expression',
|
|
13990
|
-
rest: true,
|
|
13991
|
-
},
|
|
13992
|
-
},
|
|
13993
|
-
variants: [
|
|
13994
|
-
{ argumentNames: ['binding', 'expressions'] },
|
|
13995
|
-
],
|
|
13996
|
-
description: "\nBinds one local variable. If it evaluates to a truthy value\n$expressions is executed with the variable accessable.\nIf the bound variable evaluates to a falsy value, `nil` is returned.",
|
|
13997
|
-
examples: [
|
|
13998
|
-
"\n(when_let [a (> (count \"Albert\") 4)]\n (write! a))",
|
|
13999
|
-
],
|
|
14000
|
-
},
|
|
14001
|
-
'when_first': {
|
|
14002
|
-
title: 'when_first',
|
|
14003
|
-
category: 'Special expression',
|
|
14004
|
-
linkName: 'when_first',
|
|
14005
|
-
returns: {
|
|
14006
|
-
type: 'any',
|
|
14007
|
-
},
|
|
14008
|
-
args: {
|
|
14009
|
-
binding: {
|
|
14010
|
-
type: '*binding',
|
|
14011
|
-
rest: true,
|
|
14012
|
-
},
|
|
14013
|
-
expressions: {
|
|
14014
|
-
type: '*expression',
|
|
14015
|
-
rest: true,
|
|
14016
|
-
},
|
|
14017
13521
|
},
|
|
14018
13522
|
variants: [
|
|
14019
|
-
{ argumentNames: ['
|
|
14020
|
-
],
|
|
14021
|
-
description: 'When the binding value in $binding is a non empty sequence, the first element of that sequence (instead of the sequence itself) is bound to the variable.',
|
|
14022
|
-
examples: [
|
|
14023
|
-
"\n(when_first [x [1 2 3]]\n (write! x)\n x)",
|
|
14024
|
-
"\n(when_first [x \"Albert\"]\n (write! x)\n x)",
|
|
14025
|
-
"\n(when_first [x [0]]\n (write! x)\n x)",
|
|
14026
|
-
"\n(when_first [x [nil]]\n (write! x)\n x)",
|
|
14027
|
-
"\n(when_first [x []]\n (write! x)\n x)",
|
|
13523
|
+
{ argumentNames: ['bindings'] },
|
|
14028
13524
|
],
|
|
13525
|
+
description: "\nBinds local variables.",
|
|
13526
|
+
examples: ["\n(let [a (+ 1 2 3 4) \n b (* 1 2 3 4)])\n(write! a b)"],
|
|
14029
13527
|
},
|
|
14030
13528
|
'fn': {
|
|
14031
13529
|
title: 'fn',
|
|
@@ -14081,36 +13579,6 @@ var specialExpressionsReference = {
|
|
|
14081
13579
|
"\n(defn sumOfSquares [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
14082
13580
|
],
|
|
14083
13581
|
},
|
|
14084
|
-
'defns': {
|
|
14085
|
-
title: 'defns',
|
|
14086
|
-
category: 'Special expression',
|
|
14087
|
-
linkName: 'defns',
|
|
14088
|
-
clojureDocs: null,
|
|
14089
|
-
returns: {
|
|
14090
|
-
type: 'function',
|
|
14091
|
-
},
|
|
14092
|
-
args: {
|
|
14093
|
-
name: {
|
|
14094
|
-
type: '*expression',
|
|
14095
|
-
},
|
|
14096
|
-
args: {
|
|
14097
|
-
type: '*arguments',
|
|
14098
|
-
},
|
|
14099
|
-
expressions: {
|
|
14100
|
-
type: '*expression',
|
|
14101
|
-
rest: true,
|
|
14102
|
-
},
|
|
14103
|
-
},
|
|
14104
|
-
variants: [
|
|
14105
|
-
{ argumentNames: ['name', 'args', 'expressions'] },
|
|
14106
|
-
],
|
|
14107
|
-
description: 'Creates a named global function with its name set to $name evaluated. When called, evaluation of the last expression in the body is returned.',
|
|
14108
|
-
examples: [
|
|
14109
|
-
"\n(defns \"hyp\" [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\nhyp",
|
|
14110
|
-
"\n(defns\n (str :h :y :p)\n [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\n(hyp 3 4)",
|
|
14111
|
-
"\n(defns \"sumOfSquares\" [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
14112
|
-
],
|
|
14113
|
-
},
|
|
14114
13582
|
'try': {
|
|
14115
13583
|
title: 'try',
|
|
14116
13584
|
category: 'Special expression',
|
|
@@ -14189,10 +13657,11 @@ var specialExpressionsReference = {
|
|
|
14189
13657
|
'(if false (write! "TRUE"))',
|
|
14190
13658
|
],
|
|
14191
13659
|
},
|
|
14192
|
-
'
|
|
14193
|
-
title: '
|
|
13660
|
+
'unless': {
|
|
13661
|
+
title: 'unless',
|
|
14194
13662
|
category: 'Special expression',
|
|
14195
|
-
linkName: '
|
|
13663
|
+
linkName: 'unless',
|
|
13664
|
+
clojureDocs: 'if-not',
|
|
14196
13665
|
returns: {
|
|
14197
13666
|
type: 'any',
|
|
14198
13667
|
},
|
|
@@ -14213,10 +13682,10 @@ var specialExpressionsReference = {
|
|
|
14213
13682
|
],
|
|
14214
13683
|
description: 'Either $then-expr or $else-expr branch is taken. $then-expr is selected when $test is falsy. If $test is truthy $else-expr is executed, if no $else-expr exists, `nil` is returned.',
|
|
14215
13684
|
examples: [
|
|
14216
|
-
'(
|
|
14217
|
-
'(
|
|
14218
|
-
'(
|
|
14219
|
-
'(
|
|
13685
|
+
'(unless true (write! "TRUE") (write! "FALSE"))',
|
|
13686
|
+
'(unless false (write! "TRUE") (write! "FALSE"))',
|
|
13687
|
+
'(unless true (write! "TRUE"))',
|
|
13688
|
+
'(unless false (write! "TRUE"))',
|
|
14220
13689
|
],
|
|
14221
13690
|
},
|
|
14222
13691
|
'cond': {
|
|
@@ -14266,60 +13735,6 @@ var specialExpressionsReference = {
|
|
|
14266
13735
|
"\n(switch 3\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
|
|
14267
13736
|
],
|
|
14268
13737
|
},
|
|
14269
|
-
'when': {
|
|
14270
|
-
title: 'when',
|
|
14271
|
-
category: 'Special expression',
|
|
14272
|
-
linkName: 'when',
|
|
14273
|
-
returns: {
|
|
14274
|
-
type: 'any',
|
|
14275
|
-
},
|
|
14276
|
-
args: {
|
|
14277
|
-
test: {
|
|
14278
|
-
type: '*expression',
|
|
14279
|
-
},
|
|
14280
|
-
expressions: {
|
|
14281
|
-
type: '*expression',
|
|
14282
|
-
rest: true,
|
|
14283
|
-
},
|
|
14284
|
-
},
|
|
14285
|
-
variants: [
|
|
14286
|
-
{ argumentNames: ['test', 'expressions'] },
|
|
14287
|
-
],
|
|
14288
|
-
description: "If $test yields a thruthy value, the expressions are evaluated\nand the value returned by the last expression is returned.\nOtherwise, if $test yields a falsy value, the expressions are not evaluated,\nand `nil` is returned. If no $expressions are provided, `nil` is returned.",
|
|
14289
|
-
examples: [
|
|
14290
|
-
"(when true\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14291
|
-
"(when false\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14292
|
-
'(when true)',
|
|
14293
|
-
'(when false)',
|
|
14294
|
-
],
|
|
14295
|
-
},
|
|
14296
|
-
'when_not': {
|
|
14297
|
-
title: 'when_not',
|
|
14298
|
-
category: 'Special expression',
|
|
14299
|
-
linkName: 'when_not',
|
|
14300
|
-
returns: {
|
|
14301
|
-
type: 'any',
|
|
14302
|
-
},
|
|
14303
|
-
args: {
|
|
14304
|
-
test: {
|
|
14305
|
-
type: '*expression',
|
|
14306
|
-
},
|
|
14307
|
-
expressions: {
|
|
14308
|
-
type: '*expression',
|
|
14309
|
-
rest: true,
|
|
14310
|
-
},
|
|
14311
|
-
},
|
|
14312
|
-
variants: [
|
|
14313
|
-
{ argumentNames: ['test', 'expressions'] },
|
|
14314
|
-
],
|
|
14315
|
-
description: "If $test yields a falsy value, the expressions are evaluated\nand the value returned by the last `expression` is returned.\nOtherwise, if $test yields a truthy value, the $expressions are not evaluated,\nand `nil` is returned. If no `expression` is provided, `nil` is returned.",
|
|
14316
|
-
examples: [
|
|
14317
|
-
'(when_not true (write! "Hi") (write! "There"))',
|
|
14318
|
-
'(when_not false (write! "Hi") (write! "There"))',
|
|
14319
|
-
'(when_not true)',
|
|
14320
|
-
'(when_not false)',
|
|
14321
|
-
],
|
|
14322
|
-
},
|
|
14323
13738
|
'comment': {
|
|
14324
13739
|
title: 'comment',
|
|
14325
13740
|
category: 'Special expression',
|
|
@@ -14379,9 +13794,9 @@ var specialExpressionsReference = {
|
|
|
14379
13794
|
],
|
|
14380
13795
|
description: 'Recursevly calls enclosing function or loop with its evaluated $expressions.',
|
|
14381
13796
|
examples: [
|
|
14382
|
-
"\n(defn foo [n]\n (write! n)\n (
|
|
14383
|
-
"\n(\n (fn [n]\n (write! n)\n (
|
|
14384
|
-
"\n(\n loop [n 3]\n (write! n)\n (
|
|
13797
|
+
"\n(defn foo [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n(foo 3)",
|
|
13798
|
+
"\n(\n (fn [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n 3)",
|
|
13799
|
+
"\n(\n loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
14385
13800
|
],
|
|
14386
13801
|
},
|
|
14387
13802
|
'loop': {
|
|
@@ -14406,7 +13821,7 @@ var specialExpressionsReference = {
|
|
|
14406
13821
|
],
|
|
14407
13822
|
description: 'Executes $expressions with initial $bindings. The $bindings will be replaced with the recur parameters for subsequent recursions.',
|
|
14408
13823
|
examples: [
|
|
14409
|
-
"\n(loop [n 3]\n (write! n)\n (
|
|
13824
|
+
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
14410
13825
|
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))\n n))",
|
|
14411
13826
|
],
|
|
14412
13827
|
},
|
|
@@ -14465,10 +13880,10 @@ var specialExpressionsReference = {
|
|
|
14465
13880
|
"\n(for\n [x [1 2 3] y [1 2 3] z [1 2 3]\n &while (<= x y)]\n \n [x y z])",
|
|
14466
13881
|
],
|
|
14467
13882
|
},
|
|
14468
|
-
'
|
|
14469
|
-
title: '
|
|
13883
|
+
'defined?': {
|
|
13884
|
+
title: 'defined?',
|
|
14470
13885
|
category: 'Special expression',
|
|
14471
|
-
linkName: '
|
|
13886
|
+
linkName: 'defined-question',
|
|
14472
13887
|
returns: {
|
|
14473
13888
|
type: 'boolean',
|
|
14474
13889
|
},
|
|
@@ -14482,11 +13897,11 @@ var specialExpressionsReference = {
|
|
|
14482
13897
|
],
|
|
14483
13898
|
description: 'Returns `true` if $n is a declared variable or a builtin function, otherwise `false`.',
|
|
14484
13899
|
examples: [
|
|
14485
|
-
'(
|
|
14486
|
-
"\n(def foo :foo)\n(
|
|
14487
|
-
'(
|
|
14488
|
-
"\n(def foo nil)\n(
|
|
14489
|
-
'(
|
|
13900
|
+
'(defined? foo)',
|
|
13901
|
+
"\n(def foo :foo)\n(defined? foo)",
|
|
13902
|
+
'(defined? +)',
|
|
13903
|
+
"\n(def foo nil)\n(defined? foo)",
|
|
13904
|
+
'(defined? if)',
|
|
14490
13905
|
],
|
|
14491
13906
|
},
|
|
14492
13907
|
'??': {
|
|
@@ -14832,6 +14247,30 @@ var stringReference = {
|
|
|
14832
14247
|
'(map number (split "0123456789" "" 5))',
|
|
14833
14248
|
],
|
|
14834
14249
|
},
|
|
14250
|
+
'split_lines': {
|
|
14251
|
+
title: 'split_lines',
|
|
14252
|
+
category: 'String',
|
|
14253
|
+
linkName: 'split_lines',
|
|
14254
|
+
clojureDocs: null,
|
|
14255
|
+
returns: {
|
|
14256
|
+
type: 'string',
|
|
14257
|
+
},
|
|
14258
|
+
args: {
|
|
14259
|
+
s: {
|
|
14260
|
+
type: 'string',
|
|
14261
|
+
},
|
|
14262
|
+
},
|
|
14263
|
+
variants: [
|
|
14264
|
+
{ argumentNames: ['s'] },
|
|
14265
|
+
],
|
|
14266
|
+
description: 'Divides $s into an array of substrings, each representing a line.',
|
|
14267
|
+
examples: [
|
|
14268
|
+
'(split_lines "Albert\nMojir\n")',
|
|
14269
|
+
'(split_lines "Albert\n\nMojir")',
|
|
14270
|
+
'(split_lines "Albert\nMojir\n\n")',
|
|
14271
|
+
'(split_lines "")',
|
|
14272
|
+
],
|
|
14273
|
+
},
|
|
14835
14274
|
'template': {
|
|
14836
14275
|
title: 'template',
|
|
14837
14276
|
category: 'String',
|
|
@@ -15048,6 +14487,55 @@ var stringReference = {
|
|
|
15048
14487
|
'(++)',
|
|
15049
14488
|
],
|
|
15050
14489
|
},
|
|
14490
|
+
'capitalize': {
|
|
14491
|
+
title: 'capitalize',
|
|
14492
|
+
category: 'String',
|
|
14493
|
+
linkName: 'capitalize',
|
|
14494
|
+
clojureDocs: 'clojure.string/capitalize',
|
|
14495
|
+
returns: {
|
|
14496
|
+
type: 'string',
|
|
14497
|
+
},
|
|
14498
|
+
args: {
|
|
14499
|
+
s: {
|
|
14500
|
+
type: 'string',
|
|
14501
|
+
},
|
|
14502
|
+
},
|
|
14503
|
+
variants: [
|
|
14504
|
+
{ argumentNames: ['s'] },
|
|
14505
|
+
],
|
|
14506
|
+
description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',
|
|
14507
|
+
examples: [
|
|
14508
|
+
'(capitalize "albert")',
|
|
14509
|
+
'(capitalize "ALBERT")',
|
|
14510
|
+
'(capitalize "aLBERT")',
|
|
14511
|
+
'(capitalize "")',
|
|
14512
|
+
],
|
|
14513
|
+
},
|
|
14514
|
+
'blank?': {
|
|
14515
|
+
title: 'blank?',
|
|
14516
|
+
category: 'String',
|
|
14517
|
+
linkName: 'blank-question',
|
|
14518
|
+
clojureDocs: 'clojure.string/blank_q',
|
|
14519
|
+
returns: {
|
|
14520
|
+
type: 'boolean',
|
|
14521
|
+
},
|
|
14522
|
+
args: {
|
|
14523
|
+
s: {
|
|
14524
|
+
type: ['string', 'null'],
|
|
14525
|
+
},
|
|
14526
|
+
},
|
|
14527
|
+
variants: [
|
|
14528
|
+
{ argumentNames: ['s'] },
|
|
14529
|
+
],
|
|
14530
|
+
description: 'Returns true if $s is null or only contains whitespace characters.',
|
|
14531
|
+
examples: [
|
|
14532
|
+
'(blank? "")',
|
|
14533
|
+
'(blank? null)',
|
|
14534
|
+
'(blank? "\n")',
|
|
14535
|
+
'(blank? " ")',
|
|
14536
|
+
'(blank? ".")',
|
|
14537
|
+
],
|
|
14538
|
+
},
|
|
15051
14539
|
};
|
|
15052
14540
|
|
|
15053
14541
|
var bitwiseReference = { '<<': {
|
|
@@ -15599,6 +15087,7 @@ var api = {
|
|
|
15599
15087
|
'filter',
|
|
15600
15088
|
'position',
|
|
15601
15089
|
'index_of',
|
|
15090
|
+
'last_index_of',
|
|
15602
15091
|
'some',
|
|
15603
15092
|
'reverse',
|
|
15604
15093
|
'first',
|
|
@@ -15626,6 +15115,10 @@ var api = {
|
|
|
15626
15115
|
'partition',
|
|
15627
15116
|
'partition_all',
|
|
15628
15117
|
'partition_by',
|
|
15118
|
+
'starts_with?',
|
|
15119
|
+
'ends_with?',
|
|
15120
|
+
'interleave',
|
|
15121
|
+
'interpose',
|
|
15629
15122
|
],
|
|
15630
15123
|
math: [
|
|
15631
15124
|
'+',
|
|
@@ -15746,34 +15239,28 @@ var api = {
|
|
|
15746
15239
|
'regexp',
|
|
15747
15240
|
'match',
|
|
15748
15241
|
'replace',
|
|
15242
|
+
'replace_all',
|
|
15749
15243
|
],
|
|
15750
15244
|
specialExpressions: [
|
|
15751
15245
|
'&&',
|
|
15752
15246
|
'||',
|
|
15753
15247
|
'def',
|
|
15754
|
-
'defs',
|
|
15755
15248
|
'let',
|
|
15756
|
-
'if_let',
|
|
15757
|
-
'when_let',
|
|
15758
|
-
'when_first',
|
|
15759
15249
|
'fn',
|
|
15760
15250
|
'defn',
|
|
15761
|
-
'defns',
|
|
15762
15251
|
'try',
|
|
15763
15252
|
'throw',
|
|
15764
15253
|
'if',
|
|
15765
|
-
'
|
|
15254
|
+
'unless',
|
|
15766
15255
|
'cond',
|
|
15767
15256
|
'switch',
|
|
15768
|
-
'when',
|
|
15769
|
-
'when_not',
|
|
15770
15257
|
'comment',
|
|
15771
15258
|
'do',
|
|
15772
15259
|
'recur',
|
|
15773
15260
|
'loop',
|
|
15774
15261
|
'doseq',
|
|
15775
15262
|
'for',
|
|
15776
|
-
'
|
|
15263
|
+
'defined?',
|
|
15777
15264
|
'??',
|
|
15778
15265
|
],
|
|
15779
15266
|
string: [
|
|
@@ -15789,6 +15276,7 @@ var api = {
|
|
|
15789
15276
|
'pad_left',
|
|
15790
15277
|
'pad_right',
|
|
15791
15278
|
'split',
|
|
15279
|
+
'split_lines',
|
|
15792
15280
|
'template',
|
|
15793
15281
|
'to_char_code',
|
|
15794
15282
|
'from_char_code',
|
|
@@ -15798,6 +15286,8 @@ var api = {
|
|
|
15798
15286
|
'decode_uri_component',
|
|
15799
15287
|
'join',
|
|
15800
15288
|
'++',
|
|
15289
|
+
'capitalize',
|
|
15290
|
+
'blank?',
|
|
15801
15291
|
],
|
|
15802
15292
|
bitwise: [
|
|
15803
15293
|
'<<',
|
|
@@ -16303,7 +15793,9 @@ function getCliFunctionSignature(fmt, _a) {
|
|
|
16303
15793
|
function getClojureDocsLink(functionName, clojureDocs) {
|
|
16304
15794
|
var path = clojureDocs === null ? null : clojureDocs !== null && clojureDocs !== void 0 ? clojureDocs : functionName.replaceAll('_', '-').replace('?', '_q');
|
|
16305
15795
|
return path
|
|
16306
|
-
?
|
|
15796
|
+
? path.startsWith('clojure.')
|
|
15797
|
+
? "https://clojuredocs.org/".concat(path)
|
|
15798
|
+
: "https://clojuredocs.org/clojure.core/".concat(path)
|
|
16307
15799
|
: null;
|
|
16308
15800
|
}
|
|
16309
15801
|
|