@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/index.js
CHANGED
|
@@ -283,6 +283,7 @@ var commonSimpleTokenTypes = [
|
|
|
283
283
|
];
|
|
284
284
|
var commomValueTokenTypes = [
|
|
285
285
|
'String',
|
|
286
|
+
'RegexpShorthand',
|
|
286
287
|
];
|
|
287
288
|
function isLParenToken(token) {
|
|
288
289
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
|
|
@@ -356,6 +357,18 @@ function asStringToken(token) {
|
|
|
356
357
|
assertStringToken(token);
|
|
357
358
|
return token;
|
|
358
359
|
}
|
|
360
|
+
function isRegexpShorthandToken(token) {
|
|
361
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
|
|
362
|
+
}
|
|
363
|
+
function assertRegexpShorthandToken(token) {
|
|
364
|
+
if (!isRegexpShorthandToken(token)) {
|
|
365
|
+
throwUnexpectedToken('RegexpShorthand', undefined, token);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function asRegexpShorthandToken(token) {
|
|
369
|
+
assertRegexpShorthandToken(token);
|
|
370
|
+
return token;
|
|
371
|
+
}
|
|
359
372
|
function isAlgebraicNotationToken(token) {
|
|
360
373
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
|
|
361
374
|
}
|
|
@@ -426,29 +439,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
|
|
|
426
439
|
var nonFunctionOperators = [
|
|
427
440
|
'??',
|
|
428
441
|
'&&',
|
|
442
|
+
'||',
|
|
429
443
|
'comment',
|
|
430
444
|
'cond',
|
|
431
|
-
'declared?',
|
|
432
|
-
'if',
|
|
433
|
-
'if_not',
|
|
434
|
-
'||',
|
|
435
|
-
'when',
|
|
436
|
-
'when_not',
|
|
437
|
-
'do',
|
|
438
|
-
'throw',
|
|
439
|
-
'let',
|
|
440
445
|
'def',
|
|
441
|
-
'
|
|
442
|
-
'if_let',
|
|
443
|
-
'when_let',
|
|
444
|
-
'when_first',
|
|
445
|
-
'fn',
|
|
446
|
+
'defined?',
|
|
446
447
|
'defn',
|
|
447
|
-
'
|
|
448
|
-
'try',
|
|
449
|
-
'recur',
|
|
450
|
-
'loop',
|
|
448
|
+
'do',
|
|
451
449
|
'doseq',
|
|
450
|
+
'fn',
|
|
451
|
+
'if',
|
|
452
|
+
'let',
|
|
453
|
+
'loop',
|
|
454
|
+
'recur',
|
|
455
|
+
'throw',
|
|
456
|
+
'try',
|
|
457
|
+
'unless',
|
|
452
458
|
'while',
|
|
453
459
|
];
|
|
454
460
|
var nonFunctionOperatorSet = new Set(nonFunctionOperators);
|
|
@@ -467,16 +473,22 @@ var symbolicOperatorSet = new Set(symbolicOperators);
|
|
|
467
473
|
function isSymbolicOperator(operator) {
|
|
468
474
|
return symbolicOperatorSet.has(operator);
|
|
469
475
|
}
|
|
470
|
-
function isA_SymbolToken(token) {
|
|
471
|
-
|
|
476
|
+
function isA_SymbolToken(token, symbolName) {
|
|
477
|
+
if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_Symbol') {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (symbolName && token[1] !== symbolName) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
return true;
|
|
472
484
|
}
|
|
473
|
-
function assertA_SymbolToken(token) {
|
|
474
|
-
if (!isA_SymbolToken(token)) {
|
|
485
|
+
function assertA_SymbolToken(token, symbolName) {
|
|
486
|
+
if (!isA_SymbolToken(token, symbolName)) {
|
|
475
487
|
throwUnexpectedToken('A_Symbol', undefined, token);
|
|
476
488
|
}
|
|
477
489
|
}
|
|
478
|
-
function asA_SymbolToken(token) {
|
|
479
|
-
assertA_SymbolToken(token);
|
|
490
|
+
function asA_SymbolToken(token, symbolName) {
|
|
491
|
+
assertA_SymbolToken(token, symbolName);
|
|
480
492
|
return token;
|
|
481
493
|
}
|
|
482
494
|
function isA_BinaryOperatorToken(token) {
|
|
@@ -513,9 +525,10 @@ function isA_OperatorToken(token, operatorName) {
|
|
|
513
525
|
}
|
|
514
526
|
function assertA_OperatorToken(token, operatorName) {
|
|
515
527
|
if (!isA_OperatorToken(token, operatorName)) {
|
|
516
|
-
{
|
|
528
|
+
if (operatorName) {
|
|
517
529
|
throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
|
|
518
530
|
}
|
|
531
|
+
throwUnexpectedToken('A_Operator', operatorName, token);
|
|
519
532
|
}
|
|
520
533
|
}
|
|
521
534
|
function isA_WhitespaceToken(token) {
|
|
@@ -538,7 +551,6 @@ var polishOnlyValueTokenTypes = [
|
|
|
538
551
|
'P_StringShorthand',
|
|
539
552
|
'P_Symbol',
|
|
540
553
|
'P_ReservedSymbol',
|
|
541
|
-
'P_RegexpShorthand',
|
|
542
554
|
'P_CollectionAccessor',
|
|
543
555
|
'P_Comment',
|
|
544
556
|
'P_Whitespace',
|
|
@@ -576,18 +588,6 @@ function isP_ReservedSymbolToken(token) {
|
|
|
576
588
|
function isP_ModifierToken(token) {
|
|
577
589
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
|
|
578
590
|
}
|
|
579
|
-
function isP_RegexpShorthandToken(token) {
|
|
580
|
-
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
|
|
581
|
-
}
|
|
582
|
-
function assertP_RegexpShorthandToken(token) {
|
|
583
|
-
if (!isP_RegexpShorthandToken(token)) {
|
|
584
|
-
throwUnexpectedToken('P_RegexpShorthand', undefined, token);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
function asP_RegexpShorthandToken(token) {
|
|
588
|
-
assertP_RegexpShorthandToken(token);
|
|
589
|
-
return token;
|
|
590
|
-
}
|
|
591
591
|
function isP_FnShorthandToken(token) {
|
|
592
592
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
|
|
593
593
|
}
|
|
@@ -759,7 +759,7 @@ var specialExpressionCommentRemovers = {
|
|
|
759
759
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
760
760
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
761
761
|
},
|
|
762
|
-
'
|
|
762
|
+
'defined?': function (node, removeOptions) {
|
|
763
763
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
764
764
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
765
765
|
},
|
|
@@ -768,11 +768,6 @@ var specialExpressionCommentRemovers = {
|
|
|
768
768
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
769
769
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
770
770
|
},
|
|
771
|
-
'defns': function (_node, _removeOptions) { },
|
|
772
|
-
'defs': function (node, removeOptions) {
|
|
773
|
-
removeOptions.removeCommenNodesFromArray(node.p);
|
|
774
|
-
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
775
|
-
},
|
|
776
771
|
'do': function (node, removeOptions) {
|
|
777
772
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
778
773
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
@@ -780,12 +775,11 @@ var specialExpressionCommentRemovers = {
|
|
|
780
775
|
'doseq': function (_node, _removeOptions) { },
|
|
781
776
|
'fn': function (_node, _removeOptions) { },
|
|
782
777
|
'for': function (_node, _removeOptions) { },
|
|
783
|
-
'if_let': function (_node, _removeOptions) { },
|
|
784
778
|
'if': function (node, removeOptions) {
|
|
785
779
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
786
780
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
787
781
|
},
|
|
788
|
-
'
|
|
782
|
+
'unless': function (node, removeOptions) {
|
|
789
783
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
790
784
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
791
785
|
},
|
|
@@ -814,10 +808,6 @@ var specialExpressionCommentRemovers = {
|
|
|
814
808
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
815
809
|
},
|
|
816
810
|
'try': function (_node, _removeOptions) { },
|
|
817
|
-
'when_first': function (_node, _removeOptions) { },
|
|
818
|
-
'when_let': function (_node, _removeOptions) { },
|
|
819
|
-
'when': function (_node, _removeOptions) { },
|
|
820
|
-
'when_not': function (_node, _removeOptions) { },
|
|
821
811
|
};
|
|
822
812
|
function removeCommentNodesFromSpecialExpression(node, removeOptions) {
|
|
823
813
|
var uncommenter = specialExpressionCommentRemovers[node.n];
|
|
@@ -1982,7 +1972,7 @@ var arrayNormalExpression = {
|
|
|
1982
1972
|
};
|
|
1983
1973
|
|
|
1984
1974
|
var sequenceNormalExpression = {
|
|
1985
|
-
nth: {
|
|
1975
|
+
'nth': {
|
|
1986
1976
|
evaluate: function (params, sourceCodeInfo) {
|
|
1987
1977
|
var _a = __read(params, 2), seq = _a[0], i = _a[1];
|
|
1988
1978
|
var defaultValue = toAny(params[2]);
|
|
@@ -1994,7 +1984,7 @@ var sequenceNormalExpression = {
|
|
|
1994
1984
|
},
|
|
1995
1985
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
1996
1986
|
},
|
|
1997
|
-
filter: {
|
|
1987
|
+
'filter': {
|
|
1998
1988
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1999
1989
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2000
1990
|
var executeFunction = _b.executeFunction;
|
|
@@ -2009,7 +1999,7 @@ var sequenceNormalExpression = {
|
|
|
2009
1999
|
},
|
|
2010
2000
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2011
2001
|
},
|
|
2012
|
-
first: {
|
|
2002
|
+
'first': {
|
|
2013
2003
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2014
2004
|
var _b = __read(_a, 1), array = _b[0];
|
|
2015
2005
|
if (array === null)
|
|
@@ -2019,7 +2009,7 @@ var sequenceNormalExpression = {
|
|
|
2019
2009
|
},
|
|
2020
2010
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2021
2011
|
},
|
|
2022
|
-
last: {
|
|
2012
|
+
'last': {
|
|
2023
2013
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2024
2014
|
var _b = __read(_a, 1), array = _b[0];
|
|
2025
2015
|
if (array === null)
|
|
@@ -2029,7 +2019,7 @@ var sequenceNormalExpression = {
|
|
|
2029
2019
|
},
|
|
2030
2020
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2031
2021
|
},
|
|
2032
|
-
map: {
|
|
2022
|
+
'map': {
|
|
2033
2023
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2034
2024
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2035
2025
|
var executeFunction = _b.executeFunction;
|
|
@@ -2051,7 +2041,7 @@ var sequenceNormalExpression = {
|
|
|
2051
2041
|
},
|
|
2052
2042
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2053
2043
|
},
|
|
2054
|
-
pop: {
|
|
2044
|
+
'pop': {
|
|
2055
2045
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2056
2046
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2057
2047
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2062,7 +2052,7 @@ var sequenceNormalExpression = {
|
|
|
2062
2052
|
},
|
|
2063
2053
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2064
2054
|
},
|
|
2065
|
-
position: {
|
|
2055
|
+
'position': {
|
|
2066
2056
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2067
2057
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2068
2058
|
var executeFunction = _b.executeFunction;
|
|
@@ -2081,7 +2071,7 @@ var sequenceNormalExpression = {
|
|
|
2081
2071
|
},
|
|
2082
2072
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2083
2073
|
},
|
|
2084
|
-
index_of: {
|
|
2074
|
+
'index_of': {
|
|
2085
2075
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2086
2076
|
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2087
2077
|
assertAny(value, sourceCodeInfo);
|
|
@@ -2100,7 +2090,26 @@ var sequenceNormalExpression = {
|
|
|
2100
2090
|
},
|
|
2101
2091
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2102
2092
|
},
|
|
2103
|
-
|
|
2093
|
+
'last_index_of': {
|
|
2094
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2095
|
+
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2096
|
+
assertAny(value, sourceCodeInfo);
|
|
2097
|
+
if (seq === null)
|
|
2098
|
+
return null;
|
|
2099
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2100
|
+
if (typeof seq === 'string') {
|
|
2101
|
+
assertString(value, sourceCodeInfo);
|
|
2102
|
+
var index = seq.lastIndexOf(value);
|
|
2103
|
+
return index !== -1 ? index : null;
|
|
2104
|
+
}
|
|
2105
|
+
else {
|
|
2106
|
+
var index = seq.lastIndexOf(value);
|
|
2107
|
+
return index !== -1 ? index : null;
|
|
2108
|
+
}
|
|
2109
|
+
},
|
|
2110
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2111
|
+
},
|
|
2112
|
+
'push': {
|
|
2104
2113
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2105
2114
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2106
2115
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2114,7 +2123,7 @@ var sequenceNormalExpression = {
|
|
|
2114
2123
|
},
|
|
2115
2124
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2116
2125
|
},
|
|
2117
|
-
reductions: {
|
|
2126
|
+
'reductions': {
|
|
2118
2127
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2119
2128
|
var executeFunction = _a.executeFunction;
|
|
2120
2129
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2175,7 +2184,7 @@ var sequenceNormalExpression = {
|
|
|
2175
2184
|
},
|
|
2176
2185
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2177
2186
|
},
|
|
2178
|
-
reduce: {
|
|
2187
|
+
'reduce': {
|
|
2179
2188
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2180
2189
|
var executeFunction = _a.executeFunction;
|
|
2181
2190
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2222,7 +2231,7 @@ var sequenceNormalExpression = {
|
|
|
2222
2231
|
},
|
|
2223
2232
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2224
2233
|
},
|
|
2225
|
-
reduce_right: {
|
|
2234
|
+
'reduce_right': {
|
|
2226
2235
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2227
2236
|
var executeFunction = _a.executeFunction;
|
|
2228
2237
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2270,7 +2279,7 @@ var sequenceNormalExpression = {
|
|
|
2270
2279
|
},
|
|
2271
2280
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2272
2281
|
},
|
|
2273
|
-
rest: {
|
|
2282
|
+
'rest': {
|
|
2274
2283
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2275
2284
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2276
2285
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2283,7 +2292,7 @@ var sequenceNormalExpression = {
|
|
|
2283
2292
|
},
|
|
2284
2293
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2285
2294
|
},
|
|
2286
|
-
nthrest: {
|
|
2295
|
+
'nthrest': {
|
|
2287
2296
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2288
2297
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2289
2298
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2295,7 +2304,7 @@ var sequenceNormalExpression = {
|
|
|
2295
2304
|
},
|
|
2296
2305
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2297
2306
|
},
|
|
2298
|
-
next: {
|
|
2307
|
+
'next': {
|
|
2299
2308
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2300
2309
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2301
2310
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2310,7 +2319,7 @@ var sequenceNormalExpression = {
|
|
|
2310
2319
|
},
|
|
2311
2320
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2312
2321
|
},
|
|
2313
|
-
nthnext: {
|
|
2322
|
+
'nthnext': {
|
|
2314
2323
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2315
2324
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2316
2325
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2324,7 +2333,7 @@ var sequenceNormalExpression = {
|
|
|
2324
2333
|
},
|
|
2325
2334
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2326
2335
|
},
|
|
2327
|
-
reverse: {
|
|
2336
|
+
'reverse': {
|
|
2328
2337
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2329
2338
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2330
2339
|
if (seq === null)
|
|
@@ -2336,7 +2345,7 @@ var sequenceNormalExpression = {
|
|
|
2336
2345
|
},
|
|
2337
2346
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2338
2347
|
},
|
|
2339
|
-
second: {
|
|
2348
|
+
'second': {
|
|
2340
2349
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2341
2350
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2342
2351
|
if (seq === null)
|
|
@@ -2346,7 +2355,7 @@ var sequenceNormalExpression = {
|
|
|
2346
2355
|
},
|
|
2347
2356
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2348
2357
|
},
|
|
2349
|
-
shift: {
|
|
2358
|
+
'shift': {
|
|
2350
2359
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2351
2360
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2352
2361
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2358,7 +2367,7 @@ var sequenceNormalExpression = {
|
|
|
2358
2367
|
},
|
|
2359
2368
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2360
2369
|
},
|
|
2361
|
-
slice: {
|
|
2370
|
+
'slice': {
|
|
2362
2371
|
evaluate: function (params, sourceCodeInfo) {
|
|
2363
2372
|
var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
|
|
2364
2373
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2372,7 +2381,7 @@ var sequenceNormalExpression = {
|
|
|
2372
2381
|
},
|
|
2373
2382
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
|
|
2374
2383
|
},
|
|
2375
|
-
some: {
|
|
2384
|
+
'some': {
|
|
2376
2385
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2377
2386
|
var _c;
|
|
2378
2387
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2389,7 +2398,7 @@ var sequenceNormalExpression = {
|
|
|
2389
2398
|
},
|
|
2390
2399
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2391
2400
|
},
|
|
2392
|
-
sort: {
|
|
2401
|
+
'sort': {
|
|
2393
2402
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2394
2403
|
var executeFunction = _a.executeFunction;
|
|
2395
2404
|
var _b = __read(params, 1), seq = _b[0];
|
|
@@ -2427,7 +2436,7 @@ var sequenceNormalExpression = {
|
|
|
2427
2436
|
},
|
|
2428
2437
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
2429
2438
|
},
|
|
2430
|
-
sort_by: {
|
|
2439
|
+
'sort_by': {
|
|
2431
2440
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2432
2441
|
var executeFunction = _a.executeFunction;
|
|
2433
2442
|
var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
|
|
@@ -2478,7 +2487,7 @@ var sequenceNormalExpression = {
|
|
|
2478
2487
|
},
|
|
2479
2488
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2480
2489
|
},
|
|
2481
|
-
take: {
|
|
2490
|
+
'take': {
|
|
2482
2491
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2483
2492
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2484
2493
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2488,7 +2497,7 @@ var sequenceNormalExpression = {
|
|
|
2488
2497
|
},
|
|
2489
2498
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2490
2499
|
},
|
|
2491
|
-
take_last: {
|
|
2500
|
+
'take_last': {
|
|
2492
2501
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2493
2502
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2494
2503
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2499,7 +2508,7 @@ var sequenceNormalExpression = {
|
|
|
2499
2508
|
},
|
|
2500
2509
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2501
2510
|
},
|
|
2502
|
-
take_while: {
|
|
2511
|
+
'take_while': {
|
|
2503
2512
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2504
2513
|
var e_1, _c;
|
|
2505
2514
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2527,7 +2536,7 @@ var sequenceNormalExpression = {
|
|
|
2527
2536
|
},
|
|
2528
2537
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2529
2538
|
},
|
|
2530
|
-
drop: {
|
|
2539
|
+
'drop': {
|
|
2531
2540
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2532
2541
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2533
2542
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2537,7 +2546,7 @@ var sequenceNormalExpression = {
|
|
|
2537
2546
|
},
|
|
2538
2547
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2539
2548
|
},
|
|
2540
|
-
drop_last: {
|
|
2549
|
+
'drop_last': {
|
|
2541
2550
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2542
2551
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2543
2552
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2548,7 +2557,7 @@ var sequenceNormalExpression = {
|
|
|
2548
2557
|
},
|
|
2549
2558
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2550
2559
|
},
|
|
2551
|
-
drop_while: {
|
|
2560
|
+
'drop_while': {
|
|
2552
2561
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2553
2562
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2554
2563
|
var executeFunction = _b.executeFunction;
|
|
@@ -2564,7 +2573,7 @@ var sequenceNormalExpression = {
|
|
|
2564
2573
|
},
|
|
2565
2574
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2566
2575
|
},
|
|
2567
|
-
unshift: {
|
|
2576
|
+
'unshift': {
|
|
2568
2577
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2569
2578
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2570
2579
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2578,7 +2587,7 @@ var sequenceNormalExpression = {
|
|
|
2578
2587
|
},
|
|
2579
2588
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2580
2589
|
},
|
|
2581
|
-
distinct: {
|
|
2590
|
+
'distinct': {
|
|
2582
2591
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2583
2592
|
var _b = __read(_a, 1), input = _b[0];
|
|
2584
2593
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2588,9 +2597,9 @@ var sequenceNormalExpression = {
|
|
|
2588
2597
|
},
|
|
2589
2598
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2590
2599
|
},
|
|
2591
|
-
remove: {
|
|
2600
|
+
'remove': {
|
|
2592
2601
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2593
|
-
var _c = __read(_a, 2),
|
|
2602
|
+
var _c = __read(_a, 2), input = _c[0], fn = _c[1];
|
|
2594
2603
|
var executeFunction = _b.executeFunction;
|
|
2595
2604
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2596
2605
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2603,9 +2612,9 @@ var sequenceNormalExpression = {
|
|
|
2603
2612
|
},
|
|
2604
2613
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2605
2614
|
},
|
|
2606
|
-
remove_at: {
|
|
2615
|
+
'remove_at': {
|
|
2607
2616
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2608
|
-
var _b = __read(_a, 2),
|
|
2617
|
+
var _b = __read(_a, 2), input = _b[0], index = _b[1];
|
|
2609
2618
|
assertNumber(index, sourceCodeInfo);
|
|
2610
2619
|
assertSeq(input, sourceCodeInfo);
|
|
2611
2620
|
var intIndex = Math.ceil(index);
|
|
@@ -2620,9 +2629,9 @@ var sequenceNormalExpression = {
|
|
|
2620
2629
|
},
|
|
2621
2630
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2622
2631
|
},
|
|
2623
|
-
split_at: {
|
|
2632
|
+
'split_at': {
|
|
2624
2633
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2625
|
-
var _b = __read(_a, 2),
|
|
2634
|
+
var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
|
|
2626
2635
|
assertNumber(pos, sourceCodeInfo, { finite: true });
|
|
2627
2636
|
var intPos = toNonNegativeInteger(pos);
|
|
2628
2637
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2630,9 +2639,9 @@ var sequenceNormalExpression = {
|
|
|
2630
2639
|
},
|
|
2631
2640
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2632
2641
|
},
|
|
2633
|
-
split_with: {
|
|
2642
|
+
'split_with': {
|
|
2634
2643
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2635
|
-
var _c = __read(_a, 2),
|
|
2644
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2636
2645
|
var executeFunction = _b.executeFunction;
|
|
2637
2646
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2638
2647
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2645,7 +2654,7 @@ var sequenceNormalExpression = {
|
|
|
2645
2654
|
},
|
|
2646
2655
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2647
2656
|
},
|
|
2648
|
-
frequencies: {
|
|
2657
|
+
'frequencies': {
|
|
2649
2658
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2650
2659
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2651
2660
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2661,9 +2670,9 @@ var sequenceNormalExpression = {
|
|
|
2661
2670
|
},
|
|
2662
2671
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2663
2672
|
},
|
|
2664
|
-
group_by: {
|
|
2673
|
+
'group_by': {
|
|
2665
2674
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2666
|
-
var _c = __read(_a, 2),
|
|
2675
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2667
2676
|
var executeFunction = _b.executeFunction;
|
|
2668
2677
|
assertAny(fn, sourceCodeInfo);
|
|
2669
2678
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2679,34 +2688,30 @@ var sequenceNormalExpression = {
|
|
|
2679
2688
|
},
|
|
2680
2689
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2681
2690
|
},
|
|
2682
|
-
partition: {
|
|
2691
|
+
'partition': {
|
|
2683
2692
|
evaluate: function (params, sourceCodeInfo) {
|
|
2684
|
-
var
|
|
2685
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2686
|
-
var
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
: asSeq(params[3], sourceCodeInfo);
|
|
2691
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2692
|
-
var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
|
|
2693
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2694
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2695
|
+
var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2696
|
+
var pad = params.length === 4
|
|
2697
|
+
? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
|
|
2698
|
+
: undefined;
|
|
2693
2699
|
return partition(n, step, seq, pad, sourceCodeInfo);
|
|
2694
2700
|
},
|
|
2695
2701
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
|
|
2696
2702
|
},
|
|
2697
|
-
partition_all: {
|
|
2703
|
+
'partition_all': {
|
|
2698
2704
|
evaluate: function (params, sourceCodeInfo) {
|
|
2699
|
-
var
|
|
2700
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2701
|
-
var
|
|
2702
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2705
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2706
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2707
|
+
var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2703
2708
|
return partition(n, step, seq, [], sourceCodeInfo);
|
|
2704
2709
|
},
|
|
2705
2710
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2706
2711
|
},
|
|
2707
|
-
partition_by: {
|
|
2712
|
+
'partition_by': {
|
|
2708
2713
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2709
|
-
var _c = __read(_a, 2),
|
|
2714
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2710
2715
|
var executeFunction = _b.executeFunction;
|
|
2711
2716
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2712
2717
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2723,7 +2728,88 @@ var sequenceNormalExpression = {
|
|
|
2723
2728
|
}, []);
|
|
2724
2729
|
return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
|
|
2725
2730
|
},
|
|
2726
|
-
validate: function (node) { return assertNumberOfParams(
|
|
2731
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2732
|
+
},
|
|
2733
|
+
'ends_with?': {
|
|
2734
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2735
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2736
|
+
assertSeq(str, sourceCodeInfo);
|
|
2737
|
+
if (typeof str === 'string') {
|
|
2738
|
+
assertString(search, sourceCodeInfo);
|
|
2739
|
+
return str.endsWith(search);
|
|
2740
|
+
}
|
|
2741
|
+
return str.at(-1) === search;
|
|
2742
|
+
},
|
|
2743
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2744
|
+
},
|
|
2745
|
+
'starts_with?': {
|
|
2746
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2747
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2748
|
+
assertSeq(str, sourceCodeInfo);
|
|
2749
|
+
if (typeof str === 'string') {
|
|
2750
|
+
assertString(search, sourceCodeInfo);
|
|
2751
|
+
return str.startsWith(search);
|
|
2752
|
+
}
|
|
2753
|
+
return str[0] === search;
|
|
2754
|
+
},
|
|
2755
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2756
|
+
},
|
|
2757
|
+
'interleave': {
|
|
2758
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2759
|
+
var e_2, _b;
|
|
2760
|
+
var _c = __read(_a), seqs = _c.slice(0);
|
|
2761
|
+
var isStringSeq = typeof seqs[0] === 'string';
|
|
2762
|
+
var seqsArr = isStringSeq
|
|
2763
|
+
? seqs.map(function (seq) {
|
|
2764
|
+
assertString(seq, sourceCodeInfo);
|
|
2765
|
+
if (typeof seq === 'string')
|
|
2766
|
+
return seq.split('');
|
|
2767
|
+
return seq;
|
|
2768
|
+
})
|
|
2769
|
+
: seqs.map(function (seq) {
|
|
2770
|
+
assertArray(seq, sourceCodeInfo);
|
|
2771
|
+
return seq;
|
|
2772
|
+
});
|
|
2773
|
+
var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
|
|
2774
|
+
var result = [];
|
|
2775
|
+
for (var i = 0; i < maxLength; i += 1) {
|
|
2776
|
+
try {
|
|
2777
|
+
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()) {
|
|
2778
|
+
var seq = seqsArr_1_1.value;
|
|
2779
|
+
if (i < seq.length)
|
|
2780
|
+
result.push(seq[i]);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2784
|
+
finally {
|
|
2785
|
+
try {
|
|
2786
|
+
if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
|
|
2787
|
+
}
|
|
2788
|
+
finally { if (e_2) throw e_2.error; }
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
return isStringSeq ? result.join('') : result;
|
|
2792
|
+
},
|
|
2793
|
+
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
2794
|
+
},
|
|
2795
|
+
'interpose': {
|
|
2796
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2797
|
+
var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
|
|
2798
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2799
|
+
if (typeof seq === 'string') {
|
|
2800
|
+
assertString(separator, sourceCodeInfo);
|
|
2801
|
+
return seq.split('').join(separator);
|
|
2802
|
+
}
|
|
2803
|
+
if (seq.length === 0)
|
|
2804
|
+
return [];
|
|
2805
|
+
var result = [];
|
|
2806
|
+
for (var i = 0; i < seq.length - 1; i += 1) {
|
|
2807
|
+
result.push(seq[i], separator);
|
|
2808
|
+
}
|
|
2809
|
+
result.push(seq[seq.length - 1]);
|
|
2810
|
+
return result;
|
|
2811
|
+
},
|
|
2812
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2727
2813
|
},
|
|
2728
2814
|
};
|
|
2729
2815
|
function partition(n, step, seq, pad, sourceCodeInfo) {
|
|
@@ -3886,7 +3972,7 @@ var regexpNormalExpression = {
|
|
|
3886
3972
|
},
|
|
3887
3973
|
match: {
|
|
3888
3974
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3889
|
-
var _b = __read(_a, 2),
|
|
3975
|
+
var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
|
|
3890
3976
|
assertRegularExpression(regexp, sourceCodeInfo);
|
|
3891
3977
|
if (!isString(text))
|
|
3892
3978
|
return null;
|
|
@@ -3902,15 +3988,27 @@ var regexpNormalExpression = {
|
|
|
3902
3988
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3903
3989
|
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
3904
3990
|
assertString(str, sourceCodeInfo);
|
|
3905
|
-
|
|
3991
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
3906
3992
|
assertString(value, sourceCodeInfo);
|
|
3907
|
-
var
|
|
3908
|
-
return str.replace(
|
|
3993
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
|
|
3994
|
+
return str.replace(matcher, value);
|
|
3995
|
+
},
|
|
3996
|
+
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3997
|
+
},
|
|
3998
|
+
replace_all: {
|
|
3999
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4000
|
+
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
4001
|
+
assertString(str, sourceCodeInfo);
|
|
4002
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
4003
|
+
assertString(value, sourceCodeInfo);
|
|
4004
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
|
|
4005
|
+
return str.replaceAll(matcher, value);
|
|
3909
4006
|
},
|
|
3910
4007
|
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3911
4008
|
},
|
|
3912
4009
|
};
|
|
3913
4010
|
|
|
4011
|
+
var blankRegexp = /^\s*$/;
|
|
3914
4012
|
var stringNormalExpression = {
|
|
3915
4013
|
'subs': {
|
|
3916
4014
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -4068,6 +4166,14 @@ var stringNormalExpression = {
|
|
|
4068
4166
|
},
|
|
4069
4167
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4070
4168
|
},
|
|
4169
|
+
'split_lines': {
|
|
4170
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4171
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4172
|
+
assertString(str, sourceCodeInfo);
|
|
4173
|
+
return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
|
|
4174
|
+
},
|
|
4175
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4176
|
+
},
|
|
4071
4177
|
'pad_left': {
|
|
4072
4178
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4073
4179
|
var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
|
|
@@ -4171,6 +4277,25 @@ var stringNormalExpression = {
|
|
|
4171
4277
|
},
|
|
4172
4278
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4173
4279
|
},
|
|
4280
|
+
'blank?': {
|
|
4281
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4282
|
+
var _b = __read(_a, 1), value = _b[0];
|
|
4283
|
+
if (value === null) {
|
|
4284
|
+
return true;
|
|
4285
|
+
}
|
|
4286
|
+
assertString(value, sourceCodeInfo);
|
|
4287
|
+
return blankRegexp.test(value);
|
|
4288
|
+
},
|
|
4289
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4290
|
+
},
|
|
4291
|
+
'capitalize': {
|
|
4292
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4293
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4294
|
+
assertString(str, sourceCodeInfo);
|
|
4295
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
4296
|
+
},
|
|
4297
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4298
|
+
},
|
|
4174
4299
|
};
|
|
4175
4300
|
var doubleDollarRegexp = /\$\$/g;
|
|
4176
4301
|
function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
|
|
@@ -4444,7 +4569,7 @@ var switchSpecialExpression = {
|
|
|
4444
4569
|
};
|
|
4445
4570
|
|
|
4446
4571
|
var declaredSpecialExpression = {
|
|
4447
|
-
polishParse: getCommonPolishSpecialExpressionParser('
|
|
4572
|
+
polishParse: getCommonPolishSpecialExpressionParser('defined?'),
|
|
4448
4573
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
4449
4574
|
evaluate: function (node, contextStack) {
|
|
4450
4575
|
var lookUpResult = contextStack.lookUp(node.p[0]);
|
|
@@ -4500,9 +4625,7 @@ var defSpecialExpression = {
|
|
|
4500
4625
|
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4501
4626
|
var name = node.p[0].v;
|
|
4502
4627
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4503
|
-
contextStack.
|
|
4504
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4505
|
-
};
|
|
4628
|
+
contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
|
|
4506
4629
|
return null;
|
|
4507
4630
|
},
|
|
4508
4631
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
@@ -4513,47 +4636,7 @@ var defSpecialExpression = {
|
|
|
4513
4636
|
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4514
4637
|
var name = asSymbolNode(node.p[0]).v;
|
|
4515
4638
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4516
|
-
contextStack.
|
|
4517
|
-
return result;
|
|
4518
|
-
},
|
|
4519
|
-
};
|
|
4520
|
-
|
|
4521
|
-
var defsSpecialExpression = {
|
|
4522
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4523
|
-
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4524
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4525
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4526
|
-
var node = {
|
|
4527
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
4528
|
-
n: 'defs',
|
|
4529
|
-
p: params,
|
|
4530
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4531
|
-
};
|
|
4532
|
-
return node;
|
|
4533
|
-
},
|
|
4534
|
-
validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
|
|
4535
|
-
evaluate: function (node, contextStack, _a) {
|
|
4536
|
-
var _b, _c;
|
|
4537
|
-
var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
|
|
4538
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4539
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4540
|
-
assertString(name, sourceCodeInfo);
|
|
4541
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4542
|
-
contextStack.globalContext[name] = {
|
|
4543
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4544
|
-
};
|
|
4545
|
-
return null;
|
|
4546
|
-
},
|
|
4547
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4548
|
-
var _b;
|
|
4549
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4550
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4551
|
-
var subNode = node.p[1];
|
|
4552
|
-
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4553
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4554
|
-
assertString(name, sourceCodeInfo);
|
|
4555
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4556
|
-
contextStack.globalContext[name] = { value: true };
|
|
4639
|
+
contextStack.exportValue(name, true);
|
|
4557
4640
|
return result;
|
|
4558
4641
|
},
|
|
4559
4642
|
};
|
|
@@ -4584,7 +4667,7 @@ var doSpecialExpression = {
|
|
|
4584
4667
|
},
|
|
4585
4668
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4586
4669
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4587
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
4670
|
+
return findUnresolvedIdentifiers(node.p, contextStack.create({}), builtin);
|
|
4588
4671
|
},
|
|
4589
4672
|
};
|
|
4590
4673
|
|
|
@@ -4613,11 +4696,6 @@ function joinAnalyzeResults() {
|
|
|
4613
4696
|
function addAnalyzeResults(target, source) {
|
|
4614
4697
|
source.forEach(function (symbol) { return target.add(symbol); });
|
|
4615
4698
|
}
|
|
4616
|
-
function combinate(arrays) {
|
|
4617
|
-
return arrays.reduce(function (acc, curr) {
|
|
4618
|
-
return acc.flatMap(function (a) { return curr.map(function (c) { return __spreadArray(__spreadArray([], __read(a), false), [c], false); }); });
|
|
4619
|
-
}, [[]]);
|
|
4620
|
-
}
|
|
4621
4699
|
|
|
4622
4700
|
var defnSpecialExpression = {
|
|
4623
4701
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
@@ -4642,7 +4720,7 @@ var defnSpecialExpression = {
|
|
|
4642
4720
|
var _b;
|
|
4643
4721
|
var _c, _d;
|
|
4644
4722
|
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4645
|
-
var name =
|
|
4723
|
+
var name = node.f.v;
|
|
4646
4724
|
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4647
4725
|
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4648
4726
|
var litsFunction = (_b = {},
|
|
@@ -4652,64 +4730,17 @@ var defnSpecialExpression = {
|
|
|
4652
4730
|
_b.n = name,
|
|
4653
4731
|
_b.o = evaluatedFunctionOverloades,
|
|
4654
4732
|
_b);
|
|
4655
|
-
contextStack.
|
|
4733
|
+
contextStack.exportValue(name, litsFunction);
|
|
4656
4734
|
return null;
|
|
4657
4735
|
},
|
|
4658
4736
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4659
4737
|
var _b;
|
|
4660
4738
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4661
|
-
contextStack.
|
|
4739
|
+
contextStack.exportValue(node.f.v, true);
|
|
4662
4740
|
var newContext = (_b = {}, _b[node.f.v] = { value: true }, _b);
|
|
4663
4741
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4664
4742
|
},
|
|
4665
4743
|
};
|
|
4666
|
-
var defnsSpecialExpression = {
|
|
4667
|
-
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4668
|
-
var parseToken = parsers.parseToken;
|
|
4669
|
-
var functionName = parseToken(tokenStream, parseState);
|
|
4670
|
-
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
4671
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4672
|
-
var node = {
|
|
4673
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
4674
|
-
n: 'defns',
|
|
4675
|
-
p: [],
|
|
4676
|
-
f: functionName,
|
|
4677
|
-
o: functionOverloades,
|
|
4678
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4679
|
-
};
|
|
4680
|
-
return node;
|
|
4681
|
-
},
|
|
4682
|
-
validateParameterCount: function () { return undefined; },
|
|
4683
|
-
evaluate: function (node, contextStack, _a) {
|
|
4684
|
-
var _b;
|
|
4685
|
-
var _c, _d;
|
|
4686
|
-
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4687
|
-
var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
|
|
4688
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4689
|
-
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4690
|
-
var litsFunction = (_b = {},
|
|
4691
|
-
_b[FUNCTION_SYMBOL] = true,
|
|
4692
|
-
_b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
|
|
4693
|
-
_b.t = exports.FunctionType.UserDefined,
|
|
4694
|
-
_b.n = name,
|
|
4695
|
-
_b.o = evaluatedFunctionOverloades,
|
|
4696
|
-
_b);
|
|
4697
|
-
contextStack.globalContext[name] = { value: litsFunction };
|
|
4698
|
-
return null;
|
|
4699
|
-
},
|
|
4700
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4701
|
-
var _b;
|
|
4702
|
-
var _c;
|
|
4703
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4704
|
-
var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
|
|
4705
|
-
var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
|
|
4706
|
-
assertString(name, sourceCodeInfo);
|
|
4707
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4708
|
-
contextStack.globalContext[name] = { value: true };
|
|
4709
|
-
var newContext = (_b = {}, _b[name] = { value: true }, _b);
|
|
4710
|
-
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4711
|
-
},
|
|
4712
|
-
};
|
|
4713
4744
|
var fnSpecialExpression = {
|
|
4714
4745
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4715
4746
|
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
@@ -4743,14 +4774,6 @@ var fnSpecialExpression = {
|
|
|
4743
4774
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
|
|
4744
4775
|
},
|
|
4745
4776
|
};
|
|
4746
|
-
function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
|
|
4747
|
-
var _a;
|
|
4748
|
-
var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
|
|
4749
|
-
if (expressionName === 'defn')
|
|
4750
|
-
return (node.f).v;
|
|
4751
|
-
var name = evaluateAstNode(node.f, contextStack);
|
|
4752
|
-
return asString(name, sourceCodeInfo);
|
|
4753
|
-
}
|
|
4754
4777
|
function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
|
|
4755
4778
|
var e_1, _a, e_2, _b;
|
|
4756
4779
|
var evaluatedFunctionOverloades = [];
|
|
@@ -4978,56 +5001,8 @@ var ifSpecialExpression = {
|
|
|
4978
5001
|
},
|
|
4979
5002
|
};
|
|
4980
5003
|
|
|
4981
|
-
var
|
|
4982
|
-
polishParse:
|
|
4983
|
-
var _b, _c;
|
|
4984
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4985
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
4986
|
-
if (bindings.length !== 1) {
|
|
4987
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
4988
|
-
}
|
|
4989
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4990
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4991
|
-
var node = {
|
|
4992
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
4993
|
-
n: 'if_let',
|
|
4994
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
4995
|
-
p: params,
|
|
4996
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4997
|
-
};
|
|
4998
|
-
return node;
|
|
4999
|
-
},
|
|
5000
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
5001
|
-
evaluate: function (node, contextStack, _a) {
|
|
5002
|
-
var _b;
|
|
5003
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5004
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
5005
|
-
var locals = {};
|
|
5006
|
-
var bindingValue = evaluateAstNode(node.b.v, contextStack);
|
|
5007
|
-
if (bindingValue) {
|
|
5008
|
-
locals[node.b.n] = { value: bindingValue };
|
|
5009
|
-
var newContextStack = contextStack.create(locals);
|
|
5010
|
-
var thenForm = asAstNode(node.p[0], sourceCodeInfo);
|
|
5011
|
-
return evaluateAstNode(thenForm, newContextStack);
|
|
5012
|
-
}
|
|
5013
|
-
if (node.p.length === 2) {
|
|
5014
|
-
var elseForm = asAstNode(node.p[1], sourceCodeInfo);
|
|
5015
|
-
return evaluateAstNode(elseForm, contextStack);
|
|
5016
|
-
}
|
|
5017
|
-
return null;
|
|
5018
|
-
},
|
|
5019
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5020
|
-
var _b;
|
|
5021
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5022
|
-
var newContext = (_b = {}, _b[node.b.n] = { value: true }, _b);
|
|
5023
|
-
var bindingResult = findUnresolvedIdentifiers([node.b.v], contextStack, builtin);
|
|
5024
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5025
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5026
|
-
},
|
|
5027
|
-
};
|
|
5028
|
-
|
|
5029
|
-
var ifNotSpecialExpression = {
|
|
5030
|
-
polishParse: getCommonPolishSpecialExpressionParser('if_not'),
|
|
5004
|
+
var unlessSpecialExpression = {
|
|
5005
|
+
polishParse: getCommonPolishSpecialExpressionParser('unless'),
|
|
5031
5006
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
5032
5007
|
evaluate: function (node, contextStack, _a) {
|
|
5033
5008
|
var _b;
|
|
@@ -5052,55 +5027,39 @@ var ifNotSpecialExpression = {
|
|
|
5052
5027
|
|
|
5053
5028
|
var letSpecialExpression = {
|
|
5054
5029
|
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5055
|
-
var parseBindings = _a.parseBindings
|
|
5030
|
+
var parseBindings = _a.parseBindings;
|
|
5056
5031
|
var bindings = parseBindings(tokenStream, parseState);
|
|
5057
|
-
|
|
5032
|
+
// const params = parseTokensUntilClosingBracket(tokenStream, parseState)
|
|
5058
5033
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5059
5034
|
var node = {
|
|
5060
5035
|
t: exports.AstNodeType.SpecialExpression,
|
|
5061
5036
|
n: 'let',
|
|
5062
|
-
p:
|
|
5037
|
+
p: [],
|
|
5063
5038
|
bs: bindings,
|
|
5064
5039
|
token: getTokenDebugData(firstToken) && firstToken,
|
|
5065
5040
|
};
|
|
5066
5041
|
return node;
|
|
5067
5042
|
},
|
|
5068
|
-
validateParameterCount: function () { return
|
|
5043
|
+
validateParameterCount: function (node) { return assertNumberOfParams(0, node); },
|
|
5069
5044
|
evaluate: function (node, contextStack, _a) {
|
|
5070
|
-
var e_1, _b
|
|
5045
|
+
var e_1, _b;
|
|
5071
5046
|
var evaluateAstNode = _a.evaluateAstNode;
|
|
5072
|
-
var locals = {};
|
|
5073
|
-
var newContextStack = contextStack.create(locals);
|
|
5074
5047
|
try {
|
|
5075
|
-
for (var
|
|
5076
|
-
var binding =
|
|
5048
|
+
for (var _c = __values(node.bs), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5049
|
+
var binding = _d.value;
|
|
5077
5050
|
var bindingValueNode = binding.v;
|
|
5078
|
-
var bindingValue = evaluateAstNode(bindingValueNode,
|
|
5079
|
-
|
|
5051
|
+
var bindingValue = evaluateAstNode(bindingValueNode, contextStack);
|
|
5052
|
+
contextStack.addValue(binding.n, bindingValue);
|
|
5080
5053
|
}
|
|
5081
5054
|
}
|
|
5082
5055
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5083
5056
|
finally {
|
|
5084
5057
|
try {
|
|
5085
|
-
if (
|
|
5058
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5086
5059
|
}
|
|
5087
5060
|
finally { if (e_1) throw e_1.error; }
|
|
5088
5061
|
}
|
|
5089
|
-
|
|
5090
|
-
try {
|
|
5091
|
-
for (var _f = __values(node.p), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
5092
|
-
var astNode = _g.value;
|
|
5093
|
-
result = evaluateAstNode(astNode, newContextStack);
|
|
5094
|
-
}
|
|
5095
|
-
}
|
|
5096
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
5097
|
-
finally {
|
|
5098
|
-
try {
|
|
5099
|
-
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
|
|
5100
|
-
}
|
|
5101
|
-
finally { if (e_2) throw e_2.error; }
|
|
5102
|
-
}
|
|
5103
|
-
return result;
|
|
5062
|
+
return null;
|
|
5104
5063
|
},
|
|
5105
5064
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5106
5065
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
@@ -5110,11 +5069,10 @@ var letSpecialExpression = {
|
|
|
5110
5069
|
context[name] = { value: true };
|
|
5111
5070
|
return context;
|
|
5112
5071
|
}, {});
|
|
5113
|
-
var bindingContext = {};
|
|
5114
5072
|
var bindingResults = node.bs.map(function (bindingNode) {
|
|
5115
5073
|
var valueNode = bindingNode.v;
|
|
5116
|
-
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack
|
|
5117
|
-
|
|
5074
|
+
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack, builtin);
|
|
5075
|
+
contextStack.addValue(bindingNode.n, { value: true });
|
|
5118
5076
|
return bindingsResult;
|
|
5119
5077
|
});
|
|
5120
5078
|
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
@@ -5565,9 +5523,10 @@ var trySpecialExpression = {
|
|
|
5565
5523
|
return evaluateAstNode(tryExpressions[0], contextStack);
|
|
5566
5524
|
}
|
|
5567
5525
|
catch (error) {
|
|
5568
|
-
var newContext =
|
|
5569
|
-
_b
|
|
5570
|
-
|
|
5526
|
+
var newContext = errorNode
|
|
5527
|
+
? (_b = {},
|
|
5528
|
+
_b[errorNode.v] = { value: asAny(error, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo) },
|
|
5529
|
+
_b) : {};
|
|
5571
5530
|
return evaluateAstNode(catchExpression, contextStack.create(newContext));
|
|
5572
5531
|
}
|
|
5573
5532
|
},
|
|
@@ -5576,199 +5535,15 @@ var trySpecialExpression = {
|
|
|
5576
5535
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5577
5536
|
var tryExpressions = node.p, catchExpression = node.ce, errorNode = node.e;
|
|
5578
5537
|
var tryResult = findUnresolvedIdentifiers(tryExpressions, contextStack, builtin);
|
|
5579
|
-
var newContext =
|
|
5580
|
-
_b
|
|
5581
|
-
|
|
5538
|
+
var newContext = errorNode
|
|
5539
|
+
? (_b = {},
|
|
5540
|
+
_b[errorNode.v] = { value: true },
|
|
5541
|
+
_b) : {};
|
|
5582
5542
|
var catchResult = findUnresolvedIdentifiers([catchExpression], contextStack.create(newContext), builtin);
|
|
5583
5543
|
return joinAnalyzeResults(tryResult, catchResult);
|
|
5584
5544
|
},
|
|
5585
5545
|
};
|
|
5586
5546
|
|
|
5587
|
-
var whenSpecialExpression = {
|
|
5588
|
-
polishParse: getCommonPolishSpecialExpressionParser('when'),
|
|
5589
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5590
|
-
evaluate: function (node, contextStack, _a) {
|
|
5591
|
-
var e_1, _b;
|
|
5592
|
-
var _c;
|
|
5593
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5594
|
-
var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
|
|
5595
|
-
assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5596
|
-
if (!evaluateAstNode(whenExpression, contextStack))
|
|
5597
|
-
return null;
|
|
5598
|
-
var result = null;
|
|
5599
|
-
try {
|
|
5600
|
-
for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
|
|
5601
|
-
var form = body_1_1.value;
|
|
5602
|
-
result = evaluateAstNode(form, contextStack);
|
|
5603
|
-
}
|
|
5604
|
-
}
|
|
5605
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5606
|
-
finally {
|
|
5607
|
-
try {
|
|
5608
|
-
if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
|
|
5609
|
-
}
|
|
5610
|
-
finally { if (e_1) throw e_1.error; }
|
|
5611
|
-
}
|
|
5612
|
-
return result;
|
|
5613
|
-
},
|
|
5614
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5615
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5616
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5617
|
-
},
|
|
5618
|
-
};
|
|
5619
|
-
|
|
5620
|
-
var whenFirstSpecialExpression = {
|
|
5621
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5622
|
-
var _b, _c;
|
|
5623
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5624
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5625
|
-
if (bindings.length !== 1) {
|
|
5626
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5627
|
-
}
|
|
5628
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5629
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5630
|
-
var node = {
|
|
5631
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
5632
|
-
n: 'when_first',
|
|
5633
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5634
|
-
p: params,
|
|
5635
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5636
|
-
};
|
|
5637
|
-
return node;
|
|
5638
|
-
},
|
|
5639
|
-
validateParameterCount: function () { return undefined; },
|
|
5640
|
-
evaluate: function (node, contextStack, _a) {
|
|
5641
|
-
var e_1, _b;
|
|
5642
|
-
var _c;
|
|
5643
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5644
|
-
var locals = {};
|
|
5645
|
-
var binding = node.b;
|
|
5646
|
-
var evaluatedBindingForm = evaluateAstNode(binding.v, contextStack);
|
|
5647
|
-
if (!isSeq(evaluatedBindingForm)) {
|
|
5648
|
-
throw new LitsError("Expected undefined or a sequence, got ".concat(valueToString(evaluatedBindingForm)), (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5649
|
-
}
|
|
5650
|
-
if (evaluatedBindingForm.length === 0)
|
|
5651
|
-
return null;
|
|
5652
|
-
var bindingValue = toAny(evaluatedBindingForm[0]);
|
|
5653
|
-
locals[binding.n] = { value: bindingValue };
|
|
5654
|
-
var newContextStack = contextStack.create(locals);
|
|
5655
|
-
var result = null;
|
|
5656
|
-
try {
|
|
5657
|
-
for (var _d = __values(node.p), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
5658
|
-
var form = _e.value;
|
|
5659
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5660
|
-
}
|
|
5661
|
-
}
|
|
5662
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5663
|
-
finally {
|
|
5664
|
-
try {
|
|
5665
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
5666
|
-
}
|
|
5667
|
-
finally { if (e_1) throw e_1.error; }
|
|
5668
|
-
}
|
|
5669
|
-
return result;
|
|
5670
|
-
},
|
|
5671
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5672
|
-
var _b;
|
|
5673
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5674
|
-
var binding = node.b;
|
|
5675
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5676
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5677
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5678
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5679
|
-
},
|
|
5680
|
-
};
|
|
5681
|
-
|
|
5682
|
-
var whenLetSpecialExpression = {
|
|
5683
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5684
|
-
var _b, _c;
|
|
5685
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5686
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5687
|
-
if (bindings.length !== 1) {
|
|
5688
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5689
|
-
}
|
|
5690
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5691
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5692
|
-
var node = {
|
|
5693
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
5694
|
-
n: 'when_let',
|
|
5695
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5696
|
-
p: params,
|
|
5697
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5698
|
-
};
|
|
5699
|
-
return node;
|
|
5700
|
-
},
|
|
5701
|
-
validateParameterCount: function () { return undefined; },
|
|
5702
|
-
evaluate: function (node, contextStack, _a) {
|
|
5703
|
-
var e_1, _b;
|
|
5704
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5705
|
-
var binding = node.b;
|
|
5706
|
-
var locals = {};
|
|
5707
|
-
var bindingValue = evaluateAstNode(binding.v, contextStack);
|
|
5708
|
-
if (!bindingValue)
|
|
5709
|
-
return null;
|
|
5710
|
-
locals[binding.n] = { value: bindingValue };
|
|
5711
|
-
var newContextStack = contextStack.create(locals);
|
|
5712
|
-
var result = null;
|
|
5713
|
-
try {
|
|
5714
|
-
for (var _c = __values(node.p), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5715
|
-
var form = _d.value;
|
|
5716
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5717
|
-
}
|
|
5718
|
-
}
|
|
5719
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5720
|
-
finally {
|
|
5721
|
-
try {
|
|
5722
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5723
|
-
}
|
|
5724
|
-
finally { if (e_1) throw e_1.error; }
|
|
5725
|
-
}
|
|
5726
|
-
return result;
|
|
5727
|
-
},
|
|
5728
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5729
|
-
var _b;
|
|
5730
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5731
|
-
var binding = node.b;
|
|
5732
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5733
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5734
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5735
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5736
|
-
},
|
|
5737
|
-
};
|
|
5738
|
-
|
|
5739
|
-
var whenNotSpecialExpression = {
|
|
5740
|
-
polishParse: getCommonPolishSpecialExpressionParser('when_not'),
|
|
5741
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5742
|
-
evaluate: function (node, contextStack, _a) {
|
|
5743
|
-
var e_1, _b;
|
|
5744
|
-
var _c;
|
|
5745
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5746
|
-
var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
|
|
5747
|
-
assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5748
|
-
if (evaluateAstNode(whenExpression, contextStack))
|
|
5749
|
-
return null;
|
|
5750
|
-
var result = null;
|
|
5751
|
-
try {
|
|
5752
|
-
for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
|
|
5753
|
-
var form = body_1_1.value;
|
|
5754
|
-
result = evaluateAstNode(form, contextStack);
|
|
5755
|
-
}
|
|
5756
|
-
}
|
|
5757
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5758
|
-
finally {
|
|
5759
|
-
try {
|
|
5760
|
-
if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
|
|
5761
|
-
}
|
|
5762
|
-
finally { if (e_1) throw e_1.error; }
|
|
5763
|
-
}
|
|
5764
|
-
return result;
|
|
5765
|
-
},
|
|
5766
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5767
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5768
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5769
|
-
},
|
|
5770
|
-
};
|
|
5771
|
-
|
|
5772
5547
|
var specialExpressions = {
|
|
5773
5548
|
'&&': andSpecialExpression,
|
|
5774
5549
|
'comment': commentSpecialExpression,
|
|
@@ -5776,26 +5551,19 @@ var specialExpressions = {
|
|
|
5776
5551
|
'switch': switchSpecialExpression,
|
|
5777
5552
|
'def': defSpecialExpression,
|
|
5778
5553
|
'defn': defnSpecialExpression,
|
|
5779
|
-
'defns': defnsSpecialExpression,
|
|
5780
|
-
'defs': defsSpecialExpression,
|
|
5781
5554
|
'do': doSpecialExpression,
|
|
5782
5555
|
'doseq': doseqSpecialExpression,
|
|
5783
5556
|
'for': forSpecialExpression,
|
|
5784
5557
|
'fn': fnSpecialExpression,
|
|
5785
5558
|
'if': ifSpecialExpression,
|
|
5786
|
-
'
|
|
5787
|
-
'if_not': ifNotSpecialExpression,
|
|
5559
|
+
'unless': unlessSpecialExpression,
|
|
5788
5560
|
'let': letSpecialExpression,
|
|
5789
5561
|
'loop': loopSpecialExpression,
|
|
5790
5562
|
'||': orSpecialExpression,
|
|
5791
5563
|
'recur': recurSpecialExpression,
|
|
5792
5564
|
'throw': throwSpecialExpression,
|
|
5793
5565
|
'try': trySpecialExpression,
|
|
5794
|
-
'
|
|
5795
|
-
'when_first': whenFirstSpecialExpression,
|
|
5796
|
-
'when_let': whenLetSpecialExpression,
|
|
5797
|
-
'when_not': whenNotSpecialExpression,
|
|
5798
|
-
'declared?': declaredSpecialExpression,
|
|
5566
|
+
'defined?': declaredSpecialExpression,
|
|
5799
5567
|
'??': qqSpecialExpression,
|
|
5800
5568
|
};
|
|
5801
5569
|
Object.keys(specialExpressions).forEach(function (key) {
|
|
@@ -5817,8 +5585,8 @@ function isContextEntry(value) {
|
|
|
5817
5585
|
var ContextStackImpl = /** @class */ (function () {
|
|
5818
5586
|
function ContextStackImpl(_a) {
|
|
5819
5587
|
var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
|
|
5820
|
-
this.contexts = contexts;
|
|
5821
5588
|
this.globalContext = asNonUndefined(contexts[0]);
|
|
5589
|
+
this.contexts = contexts;
|
|
5822
5590
|
this.values = hostValues;
|
|
5823
5591
|
this.lazyValues = lazyHostValues;
|
|
5824
5592
|
this.nativeJsFunctions = nativeJsFunctions;
|
|
@@ -5834,6 +5602,34 @@ var ContextStackImpl = /** @class */ (function () {
|
|
|
5834
5602
|
contextStack.globalContext = globalContext;
|
|
5835
5603
|
return contextStack;
|
|
5836
5604
|
};
|
|
5605
|
+
ContextStackImpl.prototype.exportValue = function (name, value) {
|
|
5606
|
+
if (this.globalContext[name]) {
|
|
5607
|
+
throw new Error("Cannot redefine exported value \"".concat(name, "\""));
|
|
5608
|
+
}
|
|
5609
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5610
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5611
|
+
}
|
|
5612
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5613
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5614
|
+
}
|
|
5615
|
+
this.globalContext[name] = { value: value };
|
|
5616
|
+
};
|
|
5617
|
+
ContextStackImpl.prototype.addValue = function (name, value) {
|
|
5618
|
+
var currentContext = this.contexts[0];
|
|
5619
|
+
if (!currentContext) {
|
|
5620
|
+
throw new Error('No context to add value to');
|
|
5621
|
+
}
|
|
5622
|
+
if (currentContext[name]) {
|
|
5623
|
+
throw new Error("Cannot redefine value \"".concat(name, "\""));
|
|
5624
|
+
}
|
|
5625
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5626
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5627
|
+
}
|
|
5628
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5629
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5630
|
+
}
|
|
5631
|
+
currentContext[name] = { value: toAny(value) };
|
|
5632
|
+
};
|
|
5837
5633
|
ContextStackImpl.prototype.clone = function () {
|
|
5838
5634
|
// eslint-disable-next-line ts/no-unsafe-argument
|
|
5839
5635
|
return new ContextStackImpl(JSON.parse(JSON.stringify({
|
|
@@ -5963,7 +5759,7 @@ function createContextStack(params) {
|
|
|
5963
5759
|
return acc;
|
|
5964
5760
|
}, {}),
|
|
5965
5761
|
});
|
|
5966
|
-
return contextStack;
|
|
5762
|
+
return contextStack.create({});
|
|
5967
5763
|
}
|
|
5968
5764
|
|
|
5969
5765
|
var _a$1;
|
|
@@ -6275,7 +6071,14 @@ function evaluateNumberAsFunction(fn, params, sourceCodeInfo) {
|
|
|
6275
6071
|
|
|
6276
6072
|
var findUnresolvedIdentifiers = function (ast, contextStack, builtin) {
|
|
6277
6073
|
var e_1, _a;
|
|
6278
|
-
var astNodes = Array.isArray(ast)
|
|
6074
|
+
var astNodes = Array.isArray(ast)
|
|
6075
|
+
? ast
|
|
6076
|
+
: [{
|
|
6077
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
6078
|
+
n: 'do',
|
|
6079
|
+
p: ast.b,
|
|
6080
|
+
token: undefined,
|
|
6081
|
+
}];
|
|
6279
6082
|
var unresolvedIdentifiers = new Set();
|
|
6280
6083
|
try {
|
|
6281
6084
|
for (var astNodes_1 = __values(astNodes), astNodes_1_1 = astNodes_1.next(); !astNodes_1_1.done; astNodes_1_1 = astNodes_1.next()) {
|
|
@@ -6347,537 +6150,9 @@ function findUnresolvedIdentifiersInAstNode(astNode, contextStack, builtin) {
|
|
|
6347
6150
|
}
|
|
6348
6151
|
}
|
|
6349
6152
|
|
|
6350
|
-
var calculateAndOutcomes = function (_a) {
|
|
6351
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6352
|
-
return combinateAstNodes(astNode.p)
|
|
6353
|
-
.map(function (p) { return ({
|
|
6354
|
-
n: '&&',
|
|
6355
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
6356
|
-
p: p,
|
|
6357
|
-
token: astNode.token,
|
|
6358
|
-
}); });
|
|
6359
|
-
};
|
|
6360
|
-
|
|
6361
|
-
var calculateCondOutcomes = function (_a) {
|
|
6362
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, isAstComputable = _a.isAstComputable;
|
|
6363
|
-
var testNodes = arrayToPairs(astNode.p).map(function (_a) {
|
|
6364
|
-
var _b = __read(_a, 1), t = _b[0];
|
|
6365
|
-
return t;
|
|
6366
|
-
});
|
|
6367
|
-
if (isAstComputable(testNodes)) {
|
|
6368
|
-
return combinate(arrayToPairs(astNode.p)
|
|
6369
|
-
// Create a list of ast nodes from the test and form of each condition
|
|
6370
|
-
.reduce(function (acc, _a) {
|
|
6371
|
-
var _b = __read(_a, 2), test = _b[0], form = _b[1];
|
|
6372
|
-
acc.push(calculatePossibleAstNodes(test), calculatePossibleAstNodes(form));
|
|
6373
|
-
return acc;
|
|
6374
|
-
}, []))
|
|
6375
|
-
// Create a new CondNode for each combination of test and form outcomes
|
|
6376
|
-
.map(function (conditionAsts) { return (__assign(__assign({}, astNode), { c: arrayToPairs(conditionAsts).map(function (_a) {
|
|
6377
|
-
var _b = __read(_a, 2), t = _b[0], f = _b[1];
|
|
6378
|
-
return ({ t: t, f: f });
|
|
6379
|
-
}) })); });
|
|
6380
|
-
}
|
|
6381
|
-
return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p).flatMap(function (_a) {
|
|
6382
|
-
var _b = __read(_a, 2); _b[0]; var form = _b[1];
|
|
6383
|
-
return calculatePossibleAstNodes(form);
|
|
6384
|
-
})), false), [
|
|
6385
|
-
nilNode,
|
|
6386
|
-
], false);
|
|
6387
|
-
};
|
|
6388
|
-
|
|
6389
|
-
var trueNode = { t: exports.AstNodeType.ReservedSymbol, v: 'true', token: undefined, p: [], n: undefined };
|
|
6390
|
-
var falseNode = { t: exports.AstNodeType.ReservedSymbol, v: 'false', token: undefined, p: [], n: undefined };
|
|
6391
|
-
var calculateDeclaredOutcomes = function (_a) {
|
|
6392
|
-
var astNode = _a.astNode, isAstComputable = _a.isAstComputable;
|
|
6393
|
-
if (isAstComputable(astNode.p))
|
|
6394
|
-
return [trueNode];
|
|
6395
|
-
return [trueNode, falseNode];
|
|
6396
|
-
};
|
|
6397
|
-
|
|
6398
|
-
var calculateDefOutcomes = function (_a) {
|
|
6399
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6400
|
-
var nameNode = asSymbolNode(astNode.p[0]);
|
|
6401
|
-
var valueNode = astNode.p[1];
|
|
6402
|
-
addGlobalIdentifier(nameNode.v);
|
|
6403
|
-
return calculatePossibleAstNodes(valueNode)
|
|
6404
|
-
.map(function (node) { return (__assign(__assign({}, astNode), { p: [nameNode, node] })); });
|
|
6405
|
-
};
|
|
6406
|
-
|
|
6407
|
-
var calculateDefsOutcomes = function (_a) {
|
|
6408
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6409
|
-
return combinateAstNodes(astNode.p)
|
|
6410
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6411
|
-
};
|
|
6412
|
-
|
|
6413
|
-
var calculateDoOutcomes = function (_a) {
|
|
6414
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6415
|
-
return combinateAstNodes(astNode.p).map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6416
|
-
};
|
|
6417
|
-
|
|
6418
|
-
function calculateFunctionOverloadOutcomes(combinateAstNodes, functionOverloads) {
|
|
6419
|
-
return combinate(functionOverloads
|
|
6420
|
-
// For each overload, calculate the possible outcomes for each parameter
|
|
6421
|
-
.map(function (functionOverload) {
|
|
6422
|
-
var _a;
|
|
6423
|
-
return combinateAstNodes(functionOverload.b, [
|
|
6424
|
-
functionOverload.as.m,
|
|
6425
|
-
functionOverload.as.b.map(function (bindingNode) { return bindingNode.n; }),
|
|
6426
|
-
(_a = functionOverload.as.r) !== null && _a !== void 0 ? _a : [],
|
|
6427
|
-
].flat())
|
|
6428
|
-
// For each combination of parameter outcomes, create a new overload
|
|
6429
|
-
.map(function (body) { return (__assign(__assign({}, functionOverload), { b: body })); });
|
|
6430
|
-
}));
|
|
6431
|
-
}
|
|
6432
|
-
var calculateDefnOutcomes = function (_a) {
|
|
6433
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6434
|
-
addGlobalIdentifier(astNode.f.v);
|
|
6435
|
-
// astNode.o is an array of overloads
|
|
6436
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6437
|
-
};
|
|
6438
|
-
var calculateDefnsOutcomes = function (_a) {
|
|
6439
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes;
|
|
6440
|
-
// astNode.o is an array of overloads
|
|
6441
|
-
return calculatePossibleAstNodes(astNode.f).flatMap(function (functionName) {
|
|
6442
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { f: functionName, o: functionOverloads })); });
|
|
6443
|
-
});
|
|
6444
|
-
};
|
|
6445
|
-
var calculateFnOutcomes = function (_a) {
|
|
6446
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6447
|
-
// astNode.o is an array of overloads
|
|
6448
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6449
|
-
};
|
|
6450
|
-
|
|
6451
|
-
var calculateIfLetOutcomes = function (_a) {
|
|
6452
|
-
var _b;
|
|
6453
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6454
|
-
var bindingNode = astNode.b;
|
|
6455
|
-
var thenBranch = astNode.p[0];
|
|
6456
|
-
var elseBranch = (_b = astNode.p[1]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6457
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6458
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6459
|
-
}
|
|
6460
|
-
var newIdentifier = bindingNode.n;
|
|
6461
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6462
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6463
|
-
.flatMap(function (b) { return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6464
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); }); });
|
|
6465
|
-
};
|
|
6466
|
-
|
|
6467
|
-
var calculateIfNotOutcomes = function (_a) {
|
|
6468
|
-
var _b;
|
|
6469
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6470
|
-
var condition = astNode.p[0];
|
|
6471
|
-
var thenBranch = astNode.p[1];
|
|
6472
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6473
|
-
if (isAstComputable(condition)) {
|
|
6474
|
-
return combinateAstNodes(astNode.p)
|
|
6475
|
-
.map(function (p) { return ({
|
|
6476
|
-
n: 'if_not',
|
|
6477
|
-
t: astNode.t,
|
|
6478
|
-
p: p,
|
|
6479
|
-
token: astNode.token,
|
|
6480
|
-
}); });
|
|
6481
|
-
}
|
|
6482
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6483
|
-
};
|
|
6484
|
-
|
|
6485
|
-
var calculateIfOutcomes = function (_a) {
|
|
6486
|
-
var _b;
|
|
6487
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6488
|
-
var condition = astNode.p[0];
|
|
6489
|
-
var thenBranch = astNode.p[1];
|
|
6490
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6491
|
-
if (isAstComputable(condition)) {
|
|
6492
|
-
return combinateAstNodes(astNode.p)
|
|
6493
|
-
.map(function (p) { return ({
|
|
6494
|
-
n: 'if',
|
|
6495
|
-
t: astNode.t,
|
|
6496
|
-
p: p,
|
|
6497
|
-
token: astNode.token,
|
|
6498
|
-
}); });
|
|
6499
|
-
}
|
|
6500
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6501
|
-
};
|
|
6502
|
-
|
|
6503
|
-
var calculateLetOutcomes = function (_a) {
|
|
6504
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6505
|
-
try {
|
|
6506
|
-
// check bindings, if any binding value cannot be calculated, convert the whole let to a do-expression
|
|
6507
|
-
if (!isAstComputable(astNode.bs.map(function (b) { return calculatePossibleAstNodes(b.v); })))
|
|
6508
|
-
throw new Error('Could not calculate binding value');
|
|
6509
|
-
}
|
|
6510
|
-
catch (_b) {
|
|
6511
|
-
var doNodes = combinateAstNodes(astNode.p)
|
|
6512
|
-
.map(function (p) {
|
|
6513
|
-
return {
|
|
6514
|
-
n: 'do',
|
|
6515
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
6516
|
-
p: p,
|
|
6517
|
-
token: astNode.token,
|
|
6518
|
-
};
|
|
6519
|
-
});
|
|
6520
|
-
return doNodes;
|
|
6521
|
-
}
|
|
6522
|
-
var newIdentifiers = astNode.bs.map(function (bindingNode) { return bindingNode.n; });
|
|
6523
|
-
var letNodes = combinate(astNode.bs.map(function (bindingNode) {
|
|
6524
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6525
|
-
.map(function (bindingValues) { return (__assign(__assign({}, bindingNode), { v: bindingValues })); });
|
|
6526
|
-
}))
|
|
6527
|
-
.flatMap(function (bindingNodes) { return combinate(astNode.p.map(function (p) { return calculatePossibleAstNodes(p, newIdentifiers); }))
|
|
6528
|
-
.map(function (p) {
|
|
6529
|
-
return {
|
|
6530
|
-
n: 'let',
|
|
6531
|
-
bs: bindingNodes,
|
|
6532
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
6533
|
-
p: p,
|
|
6534
|
-
token: astNode.token,
|
|
6535
|
-
};
|
|
6536
|
-
}); });
|
|
6537
|
-
return letNodes;
|
|
6538
|
-
};
|
|
6539
|
-
|
|
6540
|
-
var calculateForOutcomes = function (_a) {
|
|
6541
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6542
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6543
|
-
throw new Error('Could not calculate for loop, not deterministic');
|
|
6544
|
-
return [astNode];
|
|
6545
|
-
};
|
|
6546
|
-
var calculateDoSeqOutcomes = function (_a) {
|
|
6547
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6548
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6549
|
-
throw new Error('Could not calculate doSeq node, not deterministic');
|
|
6550
|
-
return [astNode];
|
|
6551
|
-
};
|
|
6552
|
-
function isDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6553
|
-
var e_1, _a;
|
|
6554
|
-
try {
|
|
6555
|
-
for (var _b = __values(astNode.l), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6556
|
-
var _d = _c.value, b = _d.b, l = _d.l, wn = _d.wn, we = _d.we;
|
|
6557
|
-
if (l && l.some(function (_a) {
|
|
6558
|
-
var v = _a.v;
|
|
6559
|
-
return !astIsDeterministic(calculatePossibleAstNodes, v);
|
|
6560
|
-
}))
|
|
6561
|
-
return false;
|
|
6562
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, b.v))
|
|
6563
|
-
return false;
|
|
6564
|
-
if (wn && !astIsDeterministic(calculatePossibleAstNodes, wn))
|
|
6565
|
-
return false;
|
|
6566
|
-
if (we && !astIsDeterministic(calculatePossibleAstNodes, we))
|
|
6567
|
-
return false;
|
|
6568
|
-
}
|
|
6569
|
-
}
|
|
6570
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6571
|
-
finally {
|
|
6572
|
-
try {
|
|
6573
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6574
|
-
}
|
|
6575
|
-
finally { if (e_1) throw e_1.error; }
|
|
6576
|
-
}
|
|
6577
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, astNode.p[0]))
|
|
6578
|
-
return false;
|
|
6579
|
-
return true;
|
|
6580
|
-
}
|
|
6581
|
-
function astIsDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6582
|
-
return calculatePossibleAstNodes(astNode).length === 1;
|
|
6583
|
-
}
|
|
6584
|
-
|
|
6585
|
-
var calculateOrOutcomes = function (_a) {
|
|
6586
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6587
|
-
return combinateAstNodes(astNode.p)
|
|
6588
|
-
.map(function (p) { return ({
|
|
6589
|
-
n: '||',
|
|
6590
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
6591
|
-
p: p,
|
|
6592
|
-
token: astNode.token,
|
|
6593
|
-
}); });
|
|
6594
|
-
};
|
|
6595
|
-
|
|
6596
|
-
var calculateQqOutcomes = function (_a) {
|
|
6597
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6598
|
-
if (!isAstComputable(astNode.p[0]))
|
|
6599
|
-
throw new Error('First argument of ?? not computable');
|
|
6600
|
-
return combinateAstNodes(astNode.p)
|
|
6601
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6602
|
-
};
|
|
6603
|
-
|
|
6604
|
-
var calculateThrowOutcomes = function (_a) {
|
|
6605
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6606
|
-
return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
|
|
6607
|
-
};
|
|
6608
|
-
|
|
6609
|
-
var calculateTryOutcomes = function (_a) {
|
|
6610
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6611
|
-
var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
|
|
6612
|
-
if (node.n === 'throw') {
|
|
6613
|
-
acc.throws.push(node.p[0]);
|
|
6614
|
-
}
|
|
6615
|
-
else {
|
|
6616
|
-
acc.vals.push(node);
|
|
6617
|
-
}
|
|
6618
|
-
return acc;
|
|
6619
|
-
}, { vals: [], throws: [] }), vals = _b.vals, throws = _b.throws;
|
|
6620
|
-
var catches = throws.flatMap(function (throwNode) {
|
|
6621
|
-
var letNode = {
|
|
6622
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
6623
|
-
n: 'let',
|
|
6624
|
-
bs: [{
|
|
6625
|
-
t: exports.AstNodeType.Binding,
|
|
6626
|
-
n: astNode.e.v,
|
|
6627
|
-
v: throwNode,
|
|
6628
|
-
token: undefined,
|
|
6629
|
-
p: [],
|
|
6630
|
-
}],
|
|
6631
|
-
p: [astNode.ce],
|
|
6632
|
-
token: undefined,
|
|
6633
|
-
};
|
|
6634
|
-
return calculatePossibleAstNodes(letNode);
|
|
6635
|
-
});
|
|
6636
|
-
return __spreadArray(__spreadArray([], __read(vals), false), __read(catches), false);
|
|
6637
|
-
};
|
|
6638
|
-
|
|
6639
|
-
var calculateWhenFirstOutcomes = function (_a) {
|
|
6640
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6641
|
-
var bindingNode = astNode.b;
|
|
6642
|
-
if (!isAstComputable(bindingNode.v))
|
|
6643
|
-
throw new Error('Could not calculate binding value');
|
|
6644
|
-
var newIdentifier = bindingNode.n;
|
|
6645
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6646
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6647
|
-
.flatMap(function (b) {
|
|
6648
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6649
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6650
|
-
});
|
|
6651
|
-
};
|
|
6652
|
-
|
|
6653
|
-
var calculateWhenLetOutcomes = function (_a) {
|
|
6654
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6655
|
-
var bindingNode = astNode.b;
|
|
6656
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6657
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(astNode.p)
|
|
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
|
-
var newIdentifier = bindingNode.n;
|
|
6668
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6669
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6670
|
-
.flatMap(function (b) {
|
|
6671
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6672
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6673
|
-
});
|
|
6674
|
-
};
|
|
6675
|
-
|
|
6676
|
-
var calculateWhenNotOutcomes = function (_a) {
|
|
6677
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6678
|
-
var condition = astNode.p[0];
|
|
6679
|
-
if (isAstComputable(condition)) {
|
|
6680
|
-
return combinateAstNodes(astNode.p)
|
|
6681
|
-
.map(function (p) { return ({
|
|
6682
|
-
n: 'when_not',
|
|
6683
|
-
t: astNode.t,
|
|
6684
|
-
p: p,
|
|
6685
|
-
token: astNode.token,
|
|
6686
|
-
}); });
|
|
6687
|
-
}
|
|
6688
|
-
var body = astNode.p.slice(1);
|
|
6689
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6690
|
-
.map(function (p) { return ({
|
|
6691
|
-
n: 'do',
|
|
6692
|
-
t: astNode.t,
|
|
6693
|
-
p: p,
|
|
6694
|
-
token: astNode.token,
|
|
6695
|
-
}); })), false), [
|
|
6696
|
-
nilNode,
|
|
6697
|
-
], false);
|
|
6698
|
-
};
|
|
6699
|
-
|
|
6700
|
-
var calculateWhenOutcomes = function (_a) {
|
|
6701
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6702
|
-
var condition = astNode.p[0];
|
|
6703
|
-
if (isAstComputable(condition)) {
|
|
6704
|
-
return combinateAstNodes(astNode.p)
|
|
6705
|
-
.map(function (p) { return ({
|
|
6706
|
-
n: 'when',
|
|
6707
|
-
t: astNode.t,
|
|
6708
|
-
p: p,
|
|
6709
|
-
token: astNode.token,
|
|
6710
|
-
}); });
|
|
6711
|
-
}
|
|
6712
|
-
var body = astNode.p.slice(1);
|
|
6713
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6714
|
-
.map(function (p) { return ({
|
|
6715
|
-
n: 'do',
|
|
6716
|
-
t: astNode.t,
|
|
6717
|
-
p: p,
|
|
6718
|
-
token: astNode.token,
|
|
6719
|
-
}); })), false), [
|
|
6720
|
-
nilNode,
|
|
6721
|
-
], false);
|
|
6722
|
-
};
|
|
6723
|
-
|
|
6724
|
-
var calculateRecurOutcomes = function (_a) {
|
|
6725
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6726
|
-
return combinateAstNodes(astNode.p)
|
|
6727
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6728
|
-
};
|
|
6729
|
-
|
|
6730
|
-
var calculateCommentOutcomes = function (_a) {
|
|
6731
|
-
var nilNode = _a.nilNode;
|
|
6732
|
-
return [nilNode];
|
|
6733
|
-
};
|
|
6734
|
-
|
|
6735
|
-
var calculateLoopOutcomes = function (_a) {
|
|
6736
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6737
|
-
return combinateAstNodes(astNode.p, astNode.bs.map(function (bindingNode) { return bindingNode.n; }))
|
|
6738
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6739
|
-
};
|
|
6740
|
-
|
|
6741
|
-
var calculateSwitchOutcomes = function (_a) {
|
|
6742
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6743
|
-
// TODO be smarter about this
|
|
6744
|
-
return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p.slice(1)).flatMap(function (_a) {
|
|
6745
|
-
var _b = __read(_a, 2); _b[0]; var form = _b[1];
|
|
6746
|
-
return calculatePossibleAstNodes(form);
|
|
6747
|
-
})), false), [
|
|
6748
|
-
nilNode,
|
|
6749
|
-
], false);
|
|
6750
|
-
};
|
|
6751
|
-
|
|
6752
|
-
var specialExpressionCalculator = {
|
|
6753
|
-
'&&': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6754
|
-
'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6755
|
-
'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6756
|
-
'switch': function (astNode, helperOptions) { return calculateSwitchOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6757
|
-
'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6758
|
-
'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6759
|
-
'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6760
|
-
'defns': function (astNode, helperOptions) { return calculateDefnsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6761
|
-
'defs': function (astNode, helperOptions) { return calculateDefsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6762
|
-
'do': function (astNode, helperOptions) { return calculateDoOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6763
|
-
'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6764
|
-
'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6765
|
-
'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6766
|
-
'if_let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6767
|
-
'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6768
|
-
'if_not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6769
|
-
'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6770
|
-
'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6771
|
-
'||': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6772
|
-
'??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6773
|
-
'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6774
|
-
'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6775
|
-
'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6776
|
-
'when_first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6777
|
-
'when_let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6778
|
-
'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6779
|
-
'when_not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6780
|
-
};
|
|
6781
|
-
|
|
6782
|
-
function calculateOutcomes(contextStack, astNodes) {
|
|
6783
|
-
// First, we try to calculate outcomes for the whole astNodes array.
|
|
6784
|
-
// If that fails, we try to calculate outcomes for the array without the first element.
|
|
6785
|
-
// If that fails, we try to calculate outcomes for the array without the first two elements.
|
|
6786
|
-
// And so on.
|
|
6787
|
-
// This makes it possible to calculate outcomes for e.g.
|
|
6788
|
-
// (write! x) x
|
|
6789
|
-
// Problems occur for e.g.
|
|
6790
|
-
// (def x 1) (write! x) x
|
|
6791
|
-
// This should output [1], but since (write! x) fails to calculate outcomes, we get null.
|
|
6792
|
-
// Ok, but not optimal
|
|
6793
|
-
// The contract is that when an array is returned, it must be correct.
|
|
6794
|
-
// But returning null (indicating that the calculation failed) is always a way out.
|
|
6795
|
-
for (var i = 0; i < astNodes.length; i++) {
|
|
6796
|
-
var usingAstNode = astNodes.slice(i);
|
|
6797
|
-
var outcomes = calculateOutcomesInner(contextStack, usingAstNode);
|
|
6798
|
-
if (outcomes !== null)
|
|
6799
|
-
return outcomes;
|
|
6800
|
-
}
|
|
6801
|
-
return null;
|
|
6802
|
-
}
|
|
6803
|
-
function calculateOutcomesInner(contextStack, astNodes) {
|
|
6804
|
-
var e_1, _a;
|
|
6805
|
-
var possibleAsts = calculatePossibleAsts(contextStack.clone(), astNodes);
|
|
6806
|
-
if (possibleAsts === null)
|
|
6807
|
-
return null;
|
|
6808
|
-
var outcomes = [];
|
|
6809
|
-
try {
|
|
6810
|
-
for (var possibleAsts_1 = __values(possibleAsts), possibleAsts_1_1 = possibleAsts_1.next(); !possibleAsts_1_1.done; possibleAsts_1_1 = possibleAsts_1.next()) {
|
|
6811
|
-
var possibleAst = possibleAsts_1_1.value;
|
|
6812
|
-
var unresolvedIdentifiers = findUnresolvedIdentifiers(possibleAst, contextStack.clone(), builtin);
|
|
6813
|
-
if (unresolvedIdentifiers.size !== 0)
|
|
6814
|
-
return null;
|
|
6815
|
-
var ast = {
|
|
6816
|
-
b: possibleAst,
|
|
6817
|
-
hasDebugData: true,
|
|
6818
|
-
};
|
|
6819
|
-
try {
|
|
6820
|
-
outcomes.push(evaluate(ast, contextStack.clone()));
|
|
6821
|
-
}
|
|
6822
|
-
catch (e) {
|
|
6823
|
-
outcomes.push(e);
|
|
6824
|
-
}
|
|
6825
|
-
}
|
|
6826
|
-
}
|
|
6827
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6828
|
-
finally {
|
|
6829
|
-
try {
|
|
6830
|
-
if (possibleAsts_1_1 && !possibleAsts_1_1.done && (_a = possibleAsts_1.return)) _a.call(possibleAsts_1);
|
|
6831
|
-
}
|
|
6832
|
-
finally { if (e_1) throw e_1.error; }
|
|
6833
|
-
}
|
|
6834
|
-
return outcomes;
|
|
6835
|
-
}
|
|
6836
|
-
function calculatePossibleAsts(contextStack, astNodes) {
|
|
6837
|
-
var possibleAsts;
|
|
6838
|
-
try {
|
|
6839
|
-
possibleAsts = combinate(astNodes.map(function (astNode) { return calculatePossibleAstNodes(contextStack, astNode); }));
|
|
6840
|
-
}
|
|
6841
|
-
catch (e) {
|
|
6842
|
-
return null;
|
|
6843
|
-
}
|
|
6844
|
-
return possibleAsts;
|
|
6845
|
-
}
|
|
6846
|
-
var nilNode = { t: exports.AstNodeType.ReservedSymbol, v: 'nil', token: undefined, p: [], n: undefined };
|
|
6847
|
-
function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
|
|
6848
|
-
var newContext = newIndentifiers
|
|
6849
|
-
? newIndentifiers.reduce(function (acc, identity) {
|
|
6850
|
-
acc[identity] = { value: null };
|
|
6851
|
-
return acc;
|
|
6852
|
-
}, {})
|
|
6853
|
-
: undefined;
|
|
6854
|
-
var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
|
|
6855
|
-
if (astNode.t === exports.AstNodeType.NormalExpression) {
|
|
6856
|
-
return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
|
|
6857
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6858
|
-
}
|
|
6859
|
-
else if (astNode.t === exports.AstNodeType.SpecialExpression) {
|
|
6860
|
-
var helperOptions = {
|
|
6861
|
-
nilNode: nilNode,
|
|
6862
|
-
calculatePossibleAstNodes: function (node, identifiers) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); },
|
|
6863
|
-
combinateAstNodes: function (nodes, identifiers) {
|
|
6864
|
-
return combinate(nodes.map(function (node) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); }));
|
|
6865
|
-
},
|
|
6866
|
-
isAstComputable: function (node) {
|
|
6867
|
-
return calculateOutcomesInner(newContextStack, Array.isArray(node) ? node.flat() : [node]) !== null;
|
|
6868
|
-
},
|
|
6869
|
-
addGlobalIdentifier: function (name) { return newContextStack.globalContext[name] = { value: null }; },
|
|
6870
|
-
};
|
|
6871
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
6872
|
-
return specialExpressionCalculator[astNode.n](astNode, helperOptions);
|
|
6873
|
-
}
|
|
6874
|
-
return [astNode];
|
|
6875
|
-
}
|
|
6876
|
-
|
|
6877
6153
|
function analyze(ast, params) {
|
|
6878
6154
|
return {
|
|
6879
6155
|
unresolvedIdentifiers: findUnresolvedIdentifiers(ast, createContextStack(params), builtin),
|
|
6880
|
-
outcomes: calculateOutcomes(createContextStack(params), ast.b),
|
|
6881
6156
|
};
|
|
6882
6157
|
}
|
|
6883
6158
|
|
|
@@ -7000,6 +6275,33 @@ function parseString(tokenStream, parseState) {
|
|
|
7000
6275
|
token: getTokenDebugData(tkn) && tkn,
|
|
7001
6276
|
};
|
|
7002
6277
|
}
|
|
6278
|
+
function parseRegexpShorthand(tokenStream, parseState) {
|
|
6279
|
+
var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
6280
|
+
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
6281
|
+
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
6282
|
+
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
6283
|
+
var stringNode = {
|
|
6284
|
+
t: exports.AstNodeType.String,
|
|
6285
|
+
v: regexpString,
|
|
6286
|
+
p: [],
|
|
6287
|
+
n: undefined,
|
|
6288
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6289
|
+
};
|
|
6290
|
+
var optionsNode = {
|
|
6291
|
+
t: exports.AstNodeType.String,
|
|
6292
|
+
v: optionsString,
|
|
6293
|
+
p: [],
|
|
6294
|
+
n: undefined,
|
|
6295
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6296
|
+
};
|
|
6297
|
+
var node = {
|
|
6298
|
+
t: exports.AstNodeType.NormalExpression,
|
|
6299
|
+
n: 'regexp',
|
|
6300
|
+
p: [stringNode, optionsNode],
|
|
6301
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6302
|
+
};
|
|
6303
|
+
return node;
|
|
6304
|
+
}
|
|
7003
6305
|
|
|
7004
6306
|
var exponentiationPrecedence = 10;
|
|
7005
6307
|
var binaryFunctionalOperatorPrecedence = 1;
|
|
@@ -7141,6 +6443,12 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7141
6443
|
this.tokenStream = tokenStream;
|
|
7142
6444
|
this.parseState = parseState;
|
|
7143
6445
|
}
|
|
6446
|
+
AlgebraicParser.prototype.peek = function () {
|
|
6447
|
+
return this.tokenStream.tokens[this.parseState.position];
|
|
6448
|
+
};
|
|
6449
|
+
AlgebraicParser.prototype.peekAhead = function (count) {
|
|
6450
|
+
return this.tokenStream.tokens[this.parseState.position + count];
|
|
6451
|
+
};
|
|
7144
6452
|
AlgebraicParser.prototype.advance = function () {
|
|
7145
6453
|
this.parseState.position += 1;
|
|
7146
6454
|
};
|
|
@@ -7159,38 +6467,45 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7159
6467
|
var _a;
|
|
7160
6468
|
if (precedence === void 0) { precedence = 0; }
|
|
7161
6469
|
var firstToken = this.peek();
|
|
7162
|
-
if (isA_SymbolToken(firstToken) && firstToken[1] === 'def') {
|
|
7163
|
-
return this.parseDef(firstToken);
|
|
7164
|
-
}
|
|
7165
|
-
else if (isA_SymbolToken(firstToken) && firstToken[1] === 'defn') {
|
|
7166
|
-
return this.parseDefn(firstToken);
|
|
7167
|
-
}
|
|
7168
6470
|
var left;
|
|
7169
|
-
if (isA_SymbolToken(firstToken)
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
6471
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6472
|
+
switch (firstToken[1]) {
|
|
6473
|
+
case 'let':
|
|
6474
|
+
return this.parseLet(firstToken);
|
|
6475
|
+
case 'if':
|
|
6476
|
+
case 'unless':
|
|
6477
|
+
left = this.parseIfOrUnless(firstToken);
|
|
6478
|
+
break;
|
|
6479
|
+
case 'cond':
|
|
6480
|
+
left = this.parseCond(firstToken);
|
|
6481
|
+
break;
|
|
6482
|
+
case 'switch':
|
|
6483
|
+
left = this.parseSwitch(firstToken);
|
|
6484
|
+
break;
|
|
6485
|
+
case 'for':
|
|
6486
|
+
case 'doseq':
|
|
6487
|
+
left = this.parseForOrDoseq(firstToken);
|
|
6488
|
+
break;
|
|
6489
|
+
case 'do':
|
|
6490
|
+
left = this.parseDo(firstToken);
|
|
6491
|
+
break;
|
|
6492
|
+
case 'loop':
|
|
6493
|
+
left = this.parseLoop(firstToken);
|
|
6494
|
+
break;
|
|
6495
|
+
case 'try':
|
|
6496
|
+
left = this.parseTry(firstToken);
|
|
6497
|
+
break;
|
|
6498
|
+
}
|
|
7177
6499
|
}
|
|
7178
|
-
else if (
|
|
7179
|
-
|
|
6500
|
+
else if (isA_ReservedSymbolToken(firstToken, 'function')) {
|
|
6501
|
+
return this.parseFunction(firstToken);
|
|
7180
6502
|
}
|
|
7181
|
-
else {
|
|
7182
|
-
|
|
6503
|
+
else if (isA_ReservedSymbolToken(firstToken, 'export')) {
|
|
6504
|
+
return this.parseExport(firstToken);
|
|
7183
6505
|
}
|
|
6506
|
+
left || (left = this.parseOperand());
|
|
7184
6507
|
var operator = this.peek();
|
|
7185
|
-
while (!this.
|
|
7186
|
-
&& !isA_OperatorToken(operator, ',')
|
|
7187
|
-
&& !isA_OperatorToken(operator, ';')
|
|
7188
|
-
&& !isRBracketToken(operator)
|
|
7189
|
-
&& !isA_ReservedSymbolToken(operator, 'else')
|
|
7190
|
-
&& !isA_ReservedSymbolToken(operator, 'then')
|
|
7191
|
-
&& !isA_ReservedSymbolToken(operator, 'end')
|
|
7192
|
-
&& !isA_ReservedSymbolToken(operator, 'case')
|
|
7193
|
-
&& !isRParenToken(operator)) {
|
|
6508
|
+
while (!this.isAtExpressionEnd()) {
|
|
7194
6509
|
if (isA_BinaryOperatorToken(operator)) {
|
|
7195
6510
|
var name_1 = operator[1];
|
|
7196
6511
|
var newPrecedece = getPrecedence(name_1);
|
|
@@ -7319,10 +6634,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7319
6634
|
case 'String':
|
|
7320
6635
|
return parseString(this.tokenStream, this.parseState);
|
|
7321
6636
|
case 'A_Symbol': {
|
|
6637
|
+
var positionBefore = this.parseState.position;
|
|
6638
|
+
var lamdaFunction = this.parseLambdaFunction();
|
|
6639
|
+
if (lamdaFunction) {
|
|
6640
|
+
return lamdaFunction;
|
|
6641
|
+
}
|
|
6642
|
+
this.parseState.position = positionBefore;
|
|
7322
6643
|
return parseSymbol(this.tokenStream, this.parseState);
|
|
7323
6644
|
}
|
|
7324
6645
|
case 'A_ReservedSymbol':
|
|
7325
6646
|
return parseReservedSymbol(this.tokenStream, this.parseState);
|
|
6647
|
+
case 'RegexpShorthand':
|
|
6648
|
+
return parseRegexpShorthand(this.tokenStream, this.parseState);
|
|
7326
6649
|
case 'PolNotation': {
|
|
7327
6650
|
this.parseState.algebraic = false;
|
|
7328
6651
|
var astNodes = [];
|
|
@@ -7443,12 +6766,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7443
6766
|
case '??':
|
|
7444
6767
|
case '&&':
|
|
7445
6768
|
case 'comment':
|
|
7446
|
-
case '
|
|
7447
|
-
case 'if_not':
|
|
6769
|
+
case 'defined?':
|
|
7448
6770
|
case '||':
|
|
7449
|
-
case '
|
|
7450
|
-
case 'when_not':
|
|
7451
|
-
case 'do':
|
|
6771
|
+
case 'recur':
|
|
7452
6772
|
case 'throw': {
|
|
7453
6773
|
var node = {
|
|
7454
6774
|
t: exports.AstNodeType.SpecialExpression,
|
|
@@ -7459,18 +6779,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7459
6779
|
builtin.specialExpressions[node.n].validateParameterCount(node);
|
|
7460
6780
|
return node;
|
|
7461
6781
|
}
|
|
7462
|
-
case 'let':
|
|
7463
|
-
return this.parseLet(symbol, params);
|
|
7464
|
-
case 'defs':
|
|
7465
|
-
case 'if_let':
|
|
7466
|
-
case 'when_let':
|
|
7467
|
-
case 'when_first':
|
|
7468
6782
|
case 'fn':
|
|
7469
|
-
case '
|
|
7470
|
-
case '
|
|
7471
|
-
case 'recur':
|
|
7472
|
-
case 'loop':
|
|
7473
|
-
case 'doseq':
|
|
6783
|
+
case 'def':
|
|
6784
|
+
case 'defn':
|
|
7474
6785
|
throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
|
|
7475
6786
|
default:
|
|
7476
6787
|
throw new Error("Unknown special expression: ".concat(name_2));
|
|
@@ -7489,6 +6800,11 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7489
6800
|
};
|
|
7490
6801
|
AlgebraicParser.prototype.parseLambdaFunction = function () {
|
|
7491
6802
|
var firstToken = this.peek();
|
|
6803
|
+
if (isLParenToken(firstToken)
|
|
6804
|
+
&& isA_SymbolToken(this.peekAhead(1))
|
|
6805
|
+
&& isA_OperatorToken(this.peekAhead(2), '=>')) {
|
|
6806
|
+
return null;
|
|
6807
|
+
}
|
|
7492
6808
|
try {
|
|
7493
6809
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
7494
6810
|
if (!isA_OperatorToken(this.peek(), '=>')) {
|
|
@@ -7514,6 +6830,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7514
6830
|
};
|
|
7515
6831
|
AlgebraicParser.prototype.parseFunctionArguments = function () {
|
|
7516
6832
|
var _a, _b, _c, _d, _e;
|
|
6833
|
+
var firstToken = this.peek();
|
|
6834
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6835
|
+
this.advance();
|
|
6836
|
+
return {
|
|
6837
|
+
functionArguments: {
|
|
6838
|
+
m: [firstToken[1]],
|
|
6839
|
+
b: [],
|
|
6840
|
+
r: undefined,
|
|
6841
|
+
},
|
|
6842
|
+
arity: 1,
|
|
6843
|
+
};
|
|
6844
|
+
}
|
|
7517
6845
|
this.advance();
|
|
7518
6846
|
var rest = false;
|
|
7519
6847
|
var letBindingObject;
|
|
@@ -7632,36 +6960,146 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7632
6960
|
};
|
|
7633
6961
|
return node;
|
|
7634
6962
|
};
|
|
7635
|
-
AlgebraicParser.prototype.parseLet = function (
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
6963
|
+
AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
|
|
6964
|
+
if (optionalSemicolon === void 0) { optionalSemicolon = false; }
|
|
6965
|
+
this.advance();
|
|
6966
|
+
var letSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6967
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
6968
|
+
this.advance();
|
|
6969
|
+
var value = this.parseExpression();
|
|
6970
|
+
if (!optionalSemicolon) {
|
|
6971
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
7643
6972
|
}
|
|
7644
|
-
var letBindings = arrayToPairs(letObject.p);
|
|
7645
|
-
var expression = params[1];
|
|
7646
6973
|
return {
|
|
7647
6974
|
t: exports.AstNodeType.SpecialExpression,
|
|
7648
6975
|
n: 'let',
|
|
7649
|
-
p: [
|
|
7650
|
-
|
|
7651
|
-
bs: letBindings.map(function (pair) {
|
|
7652
|
-
var key = pair[0];
|
|
7653
|
-
var value = pair[1];
|
|
7654
|
-
return {
|
|
6976
|
+
p: [],
|
|
6977
|
+
bs: [{
|
|
7655
6978
|
t: exports.AstNodeType.Binding,
|
|
7656
|
-
n:
|
|
6979
|
+
n: letSymbol.v,
|
|
7657
6980
|
v: value,
|
|
7658
6981
|
p: [],
|
|
7659
|
-
token: getTokenDebugData(
|
|
7660
|
-
}
|
|
7661
|
-
|
|
6982
|
+
token: getTokenDebugData(token) && token,
|
|
6983
|
+
}],
|
|
6984
|
+
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
6985
|
+
};
|
|
6986
|
+
};
|
|
6987
|
+
AlgebraicParser.prototype.parseDo = function (token) {
|
|
6988
|
+
this.advance();
|
|
6989
|
+
var expressions = [];
|
|
6990
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
6991
|
+
expressions.push(this.parseExpression());
|
|
6992
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6993
|
+
this.advance();
|
|
6994
|
+
}
|
|
6995
|
+
}
|
|
6996
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6997
|
+
this.advance();
|
|
6998
|
+
return {
|
|
6999
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7000
|
+
n: 'do',
|
|
7001
|
+
p: expressions,
|
|
7002
|
+
token: getTokenDebugData(token) && token,
|
|
7003
|
+
};
|
|
7004
|
+
};
|
|
7005
|
+
AlgebraicParser.prototype.parseLoop = function (token) {
|
|
7006
|
+
var _a;
|
|
7007
|
+
this.advance();
|
|
7008
|
+
assertLParenToken(this.peek());
|
|
7009
|
+
this.advance();
|
|
7010
|
+
var bindingNodes = [];
|
|
7011
|
+
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
7012
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7013
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
7014
|
+
this.advance();
|
|
7015
|
+
var value = this.parseExpression();
|
|
7016
|
+
bindingNodes.push({
|
|
7017
|
+
t: exports.AstNodeType.Binding,
|
|
7018
|
+
n: symbol.v,
|
|
7019
|
+
v: value,
|
|
7020
|
+
p: [],
|
|
7021
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
7022
|
+
});
|
|
7023
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
7024
|
+
this.advance();
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
7027
|
+
if (bindingNodes.length === 0) {
|
|
7028
|
+
throw new LitsError('Expected binding', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7029
|
+
}
|
|
7030
|
+
assertRParenToken(this.peek());
|
|
7031
|
+
this.advance();
|
|
7032
|
+
var params = [];
|
|
7033
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7034
|
+
params.push(this.parseExpression());
|
|
7035
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7036
|
+
this.advance();
|
|
7037
|
+
}
|
|
7038
|
+
}
|
|
7039
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7040
|
+
this.advance();
|
|
7041
|
+
return {
|
|
7042
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7043
|
+
n: 'loop',
|
|
7044
|
+
p: params,
|
|
7045
|
+
bs: bindingNodes,
|
|
7046
|
+
token: getTokenDebugData(token) && token,
|
|
7047
|
+
};
|
|
7048
|
+
};
|
|
7049
|
+
AlgebraicParser.prototype.parseTry = function (token) {
|
|
7050
|
+
this.advance();
|
|
7051
|
+
var tryExpressions = [];
|
|
7052
|
+
while (!this.isAtEnd() && !isA_SymbolToken(this.peek(), 'catch')) {
|
|
7053
|
+
tryExpressions.push(this.parseExpression());
|
|
7054
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7055
|
+
this.advance();
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
var tryExpression = tryExpressions.length === 1
|
|
7059
|
+
? tryExpressions[0]
|
|
7060
|
+
: {
|
|
7061
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7062
|
+
n: 'do',
|
|
7063
|
+
p: tryExpressions,
|
|
7064
|
+
token: getTokenDebugData(token) && token,
|
|
7065
|
+
};
|
|
7066
|
+
assertA_SymbolToken(this.peek(), 'catch');
|
|
7067
|
+
this.advance();
|
|
7068
|
+
var errorSymbol;
|
|
7069
|
+
if (isLParenToken(this.peek())) {
|
|
7070
|
+
this.advance();
|
|
7071
|
+
errorSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7072
|
+
assertRParenToken(this.peek());
|
|
7073
|
+
this.advance();
|
|
7074
|
+
}
|
|
7075
|
+
var catchExpressions = [];
|
|
7076
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7077
|
+
catchExpressions.push(this.parseExpression());
|
|
7078
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7079
|
+
this.advance();
|
|
7080
|
+
}
|
|
7081
|
+
}
|
|
7082
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7083
|
+
this.advance();
|
|
7084
|
+
var catchExpression = catchExpressions.length === 1
|
|
7085
|
+
? catchExpressions[0]
|
|
7086
|
+
: {
|
|
7087
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7088
|
+
n: 'do',
|
|
7089
|
+
p: catchExpressions,
|
|
7090
|
+
token: getTokenDebugData(token) && token,
|
|
7091
|
+
};
|
|
7092
|
+
return {
|
|
7093
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7094
|
+
n: 'try',
|
|
7095
|
+
p: [tryExpression],
|
|
7096
|
+
ce: catchExpression,
|
|
7097
|
+
e: errorSymbol,
|
|
7098
|
+
token: getTokenDebugData(token) && token,
|
|
7662
7099
|
};
|
|
7663
7100
|
};
|
|
7664
|
-
AlgebraicParser.prototype.
|
|
7101
|
+
AlgebraicParser.prototype.parseForOrDoseq = function (token) {
|
|
7102
|
+
var isDoseq = token[1] === 'doseq';
|
|
7665
7103
|
this.advance();
|
|
7666
7104
|
assertLParenToken(this.peek());
|
|
7667
7105
|
this.advance();
|
|
@@ -7681,7 +7119,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7681
7119
|
this.advance();
|
|
7682
7120
|
return {
|
|
7683
7121
|
t: exports.AstNodeType.SpecialExpression,
|
|
7684
|
-
n: 'for',
|
|
7122
|
+
n: isDoseq ? 'doseq' : 'for',
|
|
7685
7123
|
p: [expression],
|
|
7686
7124
|
token: getTokenDebugData(token) && token,
|
|
7687
7125
|
l: forLoopBindings,
|
|
@@ -7701,33 +7139,26 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7701
7139
|
}
|
|
7702
7140
|
var modifiers = [];
|
|
7703
7141
|
var token = this.peek();
|
|
7704
|
-
if (!isA_SymbolToken(token)
|
|
7142
|
+
if (!isA_SymbolToken(token, 'let')
|
|
7143
|
+
&& !isA_ReservedSymbolToken(token, 'when')
|
|
7144
|
+
&& !isA_ReservedSymbolToken(token, 'while')) {
|
|
7705
7145
|
throw new LitsError('Expected symbol let, when or while', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7706
7146
|
}
|
|
7707
7147
|
var letBindings;
|
|
7708
7148
|
if (token[1] === 'let') {
|
|
7709
7149
|
modifiers.push('&let');
|
|
7710
7150
|
letBindings = [];
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
return {
|
|
7717
|
-
t: exports.AstNodeType.Binding,
|
|
7718
|
-
n: key.v,
|
|
7719
|
-
v: value,
|
|
7720
|
-
p: [],
|
|
7721
|
-
token: getTokenDebugData(key.token) && key.token,
|
|
7722
|
-
};
|
|
7723
|
-
});
|
|
7151
|
+
while (isA_SymbolToken(token, 'let')) {
|
|
7152
|
+
var letNode = this.parseLet(token, true);
|
|
7153
|
+
letBindings.push(letNode.bs[0]);
|
|
7154
|
+
token = this.peek();
|
|
7155
|
+
}
|
|
7724
7156
|
}
|
|
7725
7157
|
token = this.peek();
|
|
7726
7158
|
var whenNode;
|
|
7727
7159
|
var whileNode;
|
|
7728
|
-
while (
|
|
7729
|
-
|
|
7730
|
-
|| (token[1] === 'while' && !modifiers.includes('&while')))) {
|
|
7160
|
+
while (isA_ReservedSymbolToken(token, 'when')
|
|
7161
|
+
|| isA_ReservedSymbolToken(token, 'while')) {
|
|
7731
7162
|
this.advance();
|
|
7732
7163
|
if (token[1] === 'when') {
|
|
7733
7164
|
modifiers.push('&when');
|
|
@@ -7770,7 +7201,8 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7770
7201
|
};
|
|
7771
7202
|
return node;
|
|
7772
7203
|
};
|
|
7773
|
-
AlgebraicParser.prototype.
|
|
7204
|
+
AlgebraicParser.prototype.parseIfOrUnless = function (token) {
|
|
7205
|
+
var isUnless = token[1] === 'unless';
|
|
7774
7206
|
this.advance();
|
|
7775
7207
|
var condition = this.parseExpression();
|
|
7776
7208
|
assertA_ReservedSymbolToken(this.peek(), 'then');
|
|
@@ -7819,7 +7251,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7819
7251
|
}
|
|
7820
7252
|
return {
|
|
7821
7253
|
t: exports.AstNodeType.SpecialExpression,
|
|
7822
|
-
n: 'if',
|
|
7254
|
+
n: isUnless ? 'unless' : 'if',
|
|
7823
7255
|
p: params,
|
|
7824
7256
|
token: getTokenDebugData(token) && token,
|
|
7825
7257
|
};
|
|
@@ -7904,20 +7336,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7904
7336
|
token: getTokenDebugData(token) && token,
|
|
7905
7337
|
};
|
|
7906
7338
|
};
|
|
7907
|
-
AlgebraicParser.prototype.
|
|
7908
|
-
this.advance();
|
|
7909
|
-
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7910
|
-
assertA_OperatorToken(this.peek(), '=');
|
|
7911
|
-
this.advance();
|
|
7912
|
-
var value = this.parseExpression();
|
|
7913
|
-
return {
|
|
7914
|
-
t: exports.AstNodeType.SpecialExpression,
|
|
7915
|
-
n: 'def',
|
|
7916
|
-
p: [symbol, value],
|
|
7917
|
-
token: getTokenDebugData(token) && token,
|
|
7918
|
-
};
|
|
7919
|
-
};
|
|
7920
|
-
AlgebraicParser.prototype.parseDefn = function (token) {
|
|
7339
|
+
AlgebraicParser.prototype.parseFunction = function (token) {
|
|
7921
7340
|
this.advance();
|
|
7922
7341
|
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7923
7342
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
@@ -7930,10 +7349,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7930
7349
|
}
|
|
7931
7350
|
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7932
7351
|
this.advance();
|
|
7933
|
-
|
|
7352
|
+
var fnNode = {
|
|
7934
7353
|
t: exports.AstNodeType.SpecialExpression,
|
|
7935
|
-
n: '
|
|
7936
|
-
f: symbol,
|
|
7354
|
+
n: 'fn',
|
|
7937
7355
|
p: [],
|
|
7938
7356
|
o: [{
|
|
7939
7357
|
as: functionArguments,
|
|
@@ -7942,12 +7360,63 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7942
7360
|
}],
|
|
7943
7361
|
token: getTokenDebugData(token) && token,
|
|
7944
7362
|
};
|
|
7363
|
+
return {
|
|
7364
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7365
|
+
n: 'let',
|
|
7366
|
+
p: [],
|
|
7367
|
+
bs: [{
|
|
7368
|
+
t: exports.AstNodeType.Binding,
|
|
7369
|
+
n: symbol.v,
|
|
7370
|
+
v: fnNode,
|
|
7371
|
+
p: [],
|
|
7372
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
7373
|
+
}],
|
|
7374
|
+
token: getTokenDebugData(token) && token,
|
|
7375
|
+
};
|
|
7945
7376
|
};
|
|
7946
7377
|
AlgebraicParser.prototype.isAtEnd = function () {
|
|
7947
7378
|
return this.parseState.position >= this.tokenStream.tokens.length;
|
|
7948
7379
|
};
|
|
7949
|
-
AlgebraicParser.prototype.
|
|
7950
|
-
|
|
7380
|
+
AlgebraicParser.prototype.isAtExpressionEnd = function () {
|
|
7381
|
+
if (this.isAtEnd()) {
|
|
7382
|
+
return true;
|
|
7383
|
+
}
|
|
7384
|
+
var token = this.peek();
|
|
7385
|
+
if (isA_OperatorToken(token)) {
|
|
7386
|
+
return [';', ','].includes(token[1]);
|
|
7387
|
+
}
|
|
7388
|
+
if (isA_SymbolToken(token)) {
|
|
7389
|
+
return ['catch'].includes(token[1]);
|
|
7390
|
+
}
|
|
7391
|
+
if (isA_ReservedSymbolToken(token)) {
|
|
7392
|
+
return ['else', 'when', 'while', 'then', 'end', 'case'].includes(token[1]);
|
|
7393
|
+
}
|
|
7394
|
+
return false;
|
|
7395
|
+
};
|
|
7396
|
+
AlgebraicParser.prototype.parseExport = function (token) {
|
|
7397
|
+
var _a;
|
|
7398
|
+
this.advance();
|
|
7399
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7400
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7401
|
+
return {
|
|
7402
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7403
|
+
n: 'def',
|
|
7404
|
+
p: [symbol, symbol],
|
|
7405
|
+
token: getTokenDebugData(token) && token,
|
|
7406
|
+
};
|
|
7407
|
+
}
|
|
7408
|
+
if (!isA_OperatorToken(this.peek(), '=')) {
|
|
7409
|
+
throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7410
|
+
}
|
|
7411
|
+
this.advance();
|
|
7412
|
+
var value = this.parseExpression();
|
|
7413
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
7414
|
+
return {
|
|
7415
|
+
t: exports.AstNodeType.SpecialExpression,
|
|
7416
|
+
n: 'def',
|
|
7417
|
+
p: [symbol, value],
|
|
7418
|
+
token: getTokenDebugData(token) && token,
|
|
7419
|
+
};
|
|
7951
7420
|
};
|
|
7952
7421
|
return AlgebraicParser;
|
|
7953
7422
|
}());
|
|
@@ -8023,33 +7492,6 @@ function parseObjectLitteral(tokenStream, parseState) {
|
|
|
8023
7492
|
assertEvenNumberOfParams(node);
|
|
8024
7493
|
return node;
|
|
8025
7494
|
}
|
|
8026
|
-
function parseRegexpShorthand(tokenStream, parseState) {
|
|
8027
|
-
var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
8028
|
-
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
8029
|
-
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
8030
|
-
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
8031
|
-
var stringNode = {
|
|
8032
|
-
t: exports.AstNodeType.String,
|
|
8033
|
-
v: regexpString,
|
|
8034
|
-
p: [],
|
|
8035
|
-
n: undefined,
|
|
8036
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8037
|
-
};
|
|
8038
|
-
var optionsNode = {
|
|
8039
|
-
t: exports.AstNodeType.String,
|
|
8040
|
-
v: optionsString,
|
|
8041
|
-
p: [],
|
|
8042
|
-
n: undefined,
|
|
8043
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8044
|
-
};
|
|
8045
|
-
var node = {
|
|
8046
|
-
t: exports.AstNodeType.NormalExpression,
|
|
8047
|
-
n: 'regexp',
|
|
8048
|
-
p: [stringNode, optionsNode],
|
|
8049
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
8050
|
-
};
|
|
8051
|
-
return node;
|
|
8052
|
-
}
|
|
8053
7495
|
var placeholderRegexp = /^%([1-9]\d?)?$/;
|
|
8054
7496
|
function parseFnShorthand(tokenStream, parseState) {
|
|
8055
7497
|
var _a, _b, _c, _d;
|
|
@@ -8219,7 +7661,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
8219
7661
|
return parseArrayLitteral(tokenStream, parseState);
|
|
8220
7662
|
case 'LBrace':
|
|
8221
7663
|
return parseObjectLitteral(tokenStream, parseState);
|
|
8222
|
-
case '
|
|
7664
|
+
case 'RegexpShorthand':
|
|
8223
7665
|
return parseRegexpShorthand(tokenStream, parseState);
|
|
8224
7666
|
case 'P_FnShorthand':
|
|
8225
7667
|
return parseFnShorthand(tokenStream, parseState);
|
|
@@ -8383,6 +7825,25 @@ var tokenizeString = function (input, position) {
|
|
|
8383
7825
|
value += '"'; // closing quote
|
|
8384
7826
|
return [length + 1, ['String', value]];
|
|
8385
7827
|
};
|
|
7828
|
+
var tokenizeRegexpShorthand = function (input, position) {
|
|
7829
|
+
if (input[position] !== '#')
|
|
7830
|
+
return NO_MATCH;
|
|
7831
|
+
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
7832
|
+
if (!token)
|
|
7833
|
+
return NO_MATCH;
|
|
7834
|
+
position += stringLength + 1;
|
|
7835
|
+
var length = stringLength + 1;
|
|
7836
|
+
var options = '';
|
|
7837
|
+
while (input[position] === 'g' || input[position] === 'i') {
|
|
7838
|
+
if (options.includes(input[position])) {
|
|
7839
|
+
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
7840
|
+
}
|
|
7841
|
+
options += input[position];
|
|
7842
|
+
length += 1;
|
|
7843
|
+
position += 1;
|
|
7844
|
+
}
|
|
7845
|
+
return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
7846
|
+
};
|
|
8386
7847
|
function tokenizeSimpleToken(type, value, input, position) {
|
|
8387
7848
|
if (value === input.slice(position, position + value.length))
|
|
8388
7849
|
return [value.length, [type]];
|
|
@@ -8400,6 +7861,7 @@ var commonTokenizers = [
|
|
|
8400
7861
|
tokenizeLBrace,
|
|
8401
7862
|
tokenizeRBrace,
|
|
8402
7863
|
tokenizeString,
|
|
7864
|
+
tokenizeRegexpShorthand,
|
|
8403
7865
|
];
|
|
8404
7866
|
|
|
8405
7867
|
var validAlgebraicReservedNamesRecord = {
|
|
@@ -8411,17 +7873,13 @@ var validAlgebraicReservedNamesRecord = {
|
|
|
8411
7873
|
else: { value: null, forbidden: false },
|
|
8412
7874
|
end: { value: null, forbidden: false },
|
|
8413
7875
|
case: { value: null, forbidden: false },
|
|
7876
|
+
when: { value: null, forbidden: false },
|
|
7877
|
+
while: { value: null, forbidden: false },
|
|
7878
|
+
function: { value: null, forbidden: false },
|
|
7879
|
+
export: { value: null, forbidden: false },
|
|
8414
7880
|
};
|
|
8415
7881
|
var forbiddenAlgebraicReservedNamesRecord = {
|
|
8416
|
-
if_let: { value: null, forbidden: true },
|
|
8417
|
-
when_let: { value: null, forbidden: true },
|
|
8418
|
-
when_first: { value: null, forbidden: true },
|
|
8419
7882
|
fn: { value: null, forbidden: true },
|
|
8420
|
-
defns: { value: null, forbidden: true },
|
|
8421
|
-
try: { value: null, forbidden: true },
|
|
8422
|
-
recur: { value: null, forbidden: true },
|
|
8423
|
-
loop: { value: null, forbidden: true },
|
|
8424
|
-
doseq: { value: null, forbidden: true },
|
|
8425
7883
|
};
|
|
8426
7884
|
var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
|
|
8427
7885
|
|
|
@@ -8806,25 +8264,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
|
|
|
8806
8264
|
return NO_MATCH;
|
|
8807
8265
|
return [1, ['P_CollectionAccessor', char]];
|
|
8808
8266
|
};
|
|
8809
|
-
var tokenizeP_RegexpShorthand = function (input, position) {
|
|
8810
|
-
if (input[position] !== '#')
|
|
8811
|
-
return NO_MATCH;
|
|
8812
|
-
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
8813
|
-
if (!token)
|
|
8814
|
-
return NO_MATCH;
|
|
8815
|
-
position += stringLength + 1;
|
|
8816
|
-
var length = stringLength + 1;
|
|
8817
|
-
var options = '';
|
|
8818
|
-
while (input[position] === 'g' || input[position] === 'i') {
|
|
8819
|
-
if (options.includes(input[position])) {
|
|
8820
|
-
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
8821
|
-
}
|
|
8822
|
-
options += input[position];
|
|
8823
|
-
length += 1;
|
|
8824
|
-
position += 1;
|
|
8825
|
-
}
|
|
8826
|
-
return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
8827
|
-
};
|
|
8828
8267
|
// All tokenizers, order matters!
|
|
8829
8268
|
var polishTokenizers = __spreadArray(__spreadArray([
|
|
8830
8269
|
tokenizeP_Whitespace,
|
|
@@ -8835,7 +8274,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
|
|
|
8835
8274
|
tokenizeP_ReservedSymbol,
|
|
8836
8275
|
tokenizeP_Modifier,
|
|
8837
8276
|
tokenizeP_Symbol,
|
|
8838
|
-
tokenizeP_RegexpShorthand,
|
|
8839
8277
|
tokenizeP_FnShorthand,
|
|
8840
8278
|
tokenizeP_CollectionAccessor,
|
|
8841
8279
|
], false);
|
|
@@ -10120,7 +9558,7 @@ var arrayReference = {
|
|
|
10120
9558
|
description: 'Takes a nested array $x and flattens it.',
|
|
10121
9559
|
examples: [
|
|
10122
9560
|
'(flatten [1 2 [3 4] 5])',
|
|
10123
|
-
"\n(let [foo :bar]\n
|
|
9561
|
+
"\n(let [foo :bar])\n(flatten\n [1\n \" 2 A \"\n [foo [4 [:ABC]]] 6])",
|
|
10124
9562
|
'(flatten 12)',
|
|
10125
9563
|
],
|
|
10126
9564
|
},
|
|
@@ -10154,7 +9592,7 @@ var arrayReference = {
|
|
|
10154
9592
|
};
|
|
10155
9593
|
|
|
10156
9594
|
var sequenceReference = {
|
|
10157
|
-
nth: {
|
|
9595
|
+
'nth': {
|
|
10158
9596
|
title: 'nth',
|
|
10159
9597
|
category: 'Sequence',
|
|
10160
9598
|
linkName: 'nth',
|
|
@@ -10190,7 +9628,7 @@ var sequenceReference = {
|
|
|
10190
9628
|
'(nth nil 1 "Default value")',
|
|
10191
9629
|
],
|
|
10192
9630
|
},
|
|
10193
|
-
push: {
|
|
9631
|
+
'push': {
|
|
10194
9632
|
title: 'push',
|
|
10195
9633
|
category: 'Sequence',
|
|
10196
9634
|
linkName: 'push',
|
|
@@ -10220,7 +9658,7 @@ var sequenceReference = {
|
|
|
10220
9658
|
'(def l [1 2 3]) (push l 4) l',
|
|
10221
9659
|
],
|
|
10222
9660
|
},
|
|
10223
|
-
pop: {
|
|
9661
|
+
'pop': {
|
|
10224
9662
|
title: 'pop',
|
|
10225
9663
|
category: 'Sequence',
|
|
10226
9664
|
linkName: 'pop',
|
|
@@ -10243,7 +9681,7 @@ var sequenceReference = {
|
|
|
10243
9681
|
'(pop [])',
|
|
10244
9682
|
],
|
|
10245
9683
|
},
|
|
10246
|
-
unshift: {
|
|
9684
|
+
'unshift': {
|
|
10247
9685
|
title: 'unshift',
|
|
10248
9686
|
category: 'Sequence',
|
|
10249
9687
|
linkName: 'unshift',
|
|
@@ -10272,7 +9710,7 @@ var sequenceReference = {
|
|
|
10272
9710
|
"\n(def l [1 2 3])\n(unshift l 4)\nl",
|
|
10273
9711
|
],
|
|
10274
9712
|
},
|
|
10275
|
-
shift: {
|
|
9713
|
+
'shift': {
|
|
10276
9714
|
title: 'shift',
|
|
10277
9715
|
category: 'Sequence',
|
|
10278
9716
|
linkName: 'shift',
|
|
@@ -10296,7 +9734,7 @@ var sequenceReference = {
|
|
|
10296
9734
|
'(shift [])',
|
|
10297
9735
|
],
|
|
10298
9736
|
},
|
|
10299
|
-
slice: {
|
|
9737
|
+
'slice': {
|
|
10300
9738
|
title: 'slice',
|
|
10301
9739
|
category: 'Sequence',
|
|
10302
9740
|
linkName: 'slice',
|
|
@@ -10330,7 +9768,7 @@ var sequenceReference = {
|
|
|
10330
9768
|
'(slice [1 2 3 4 5] 2)',
|
|
10331
9769
|
],
|
|
10332
9770
|
},
|
|
10333
|
-
reductions: {
|
|
9771
|
+
'reductions': {
|
|
10334
9772
|
title: 'reductions',
|
|
10335
9773
|
category: 'Sequence',
|
|
10336
9774
|
linkName: 'reductions',
|
|
@@ -10362,7 +9800,7 @@ var sequenceReference = {
|
|
|
10362
9800
|
"\n(reductions\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
10363
9801
|
],
|
|
10364
9802
|
},
|
|
10365
|
-
reduce: {
|
|
9803
|
+
'reduce': {
|
|
10366
9804
|
title: 'reduce',
|
|
10367
9805
|
category: 'Sequence',
|
|
10368
9806
|
linkName: 'reduce',
|
|
@@ -10392,7 +9830,7 @@ var sequenceReference = {
|
|
|
10392
9830
|
"\n(reduce\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
10393
9831
|
],
|
|
10394
9832
|
},
|
|
10395
|
-
reduce_right: {
|
|
9833
|
+
'reduce_right': {
|
|
10396
9834
|
title: 'reduce_right',
|
|
10397
9835
|
category: 'Sequence',
|
|
10398
9836
|
linkName: 'reduce_right',
|
|
@@ -10420,7 +9858,7 @@ var sequenceReference = {
|
|
|
10420
9858
|
'(reduce_right str [:A :B :C] "")',
|
|
10421
9859
|
],
|
|
10422
9860
|
},
|
|
10423
|
-
map: {
|
|
9861
|
+
'map': {
|
|
10424
9862
|
title: 'map',
|
|
10425
9863
|
category: 'Sequence',
|
|
10426
9864
|
linkName: 'map',
|
|
@@ -10445,7 +9883,7 @@ var sequenceReference = {
|
|
|
10445
9883
|
'(map [1 2 3] inc)',
|
|
10446
9884
|
],
|
|
10447
9885
|
},
|
|
10448
|
-
filter: {
|
|
9886
|
+
'filter': {
|
|
10449
9887
|
title: 'filter',
|
|
10450
9888
|
category: 'Sequence',
|
|
10451
9889
|
linkName: 'filter',
|
|
@@ -10469,7 +9907,7 @@ var sequenceReference = {
|
|
|
10469
9907
|
"\n(filter\n[5 10 15 20]\n (fn [x] (> x 10)))",
|
|
10470
9908
|
],
|
|
10471
9909
|
},
|
|
10472
|
-
position: {
|
|
9910
|
+
'position': {
|
|
10473
9911
|
title: 'position',
|
|
10474
9912
|
category: 'Sequence',
|
|
10475
9913
|
linkName: 'position',
|
|
@@ -10496,7 +9934,7 @@ var sequenceReference = {
|
|
|
10496
9934
|
"\n(position\n (fn [x] (> x 100))\n nil)",
|
|
10497
9935
|
],
|
|
10498
9936
|
},
|
|
10499
|
-
index_of: {
|
|
9937
|
+
'index_of': {
|
|
10500
9938
|
title: 'index_of',
|
|
10501
9939
|
category: 'Sequence',
|
|
10502
9940
|
linkName: 'index_of',
|
|
@@ -10523,7 +9961,34 @@ var sequenceReference = {
|
|
|
10523
9961
|
'(index_of nil 1)',
|
|
10524
9962
|
],
|
|
10525
9963
|
},
|
|
10526
|
-
|
|
9964
|
+
'last_index_of': {
|
|
9965
|
+
title: 'last_index_of',
|
|
9966
|
+
category: 'Sequence',
|
|
9967
|
+
linkName: 'last_index_of',
|
|
9968
|
+
clojureDocs: null,
|
|
9969
|
+
returns: {
|
|
9970
|
+
type: ['number', 'null'],
|
|
9971
|
+
},
|
|
9972
|
+
args: {
|
|
9973
|
+
seq: {
|
|
9974
|
+
type: ['sequence', 'null'],
|
|
9975
|
+
},
|
|
9976
|
+
x: {
|
|
9977
|
+
type: 'any',
|
|
9978
|
+
},
|
|
9979
|
+
},
|
|
9980
|
+
variants: [
|
|
9981
|
+
{ argumentNames: ['seq', 'x'] },
|
|
9982
|
+
],
|
|
9983
|
+
description: 'Returns the last index of $x in $seq. If element is not present in $seq `nil` is returned.',
|
|
9984
|
+
examples: [
|
|
9985
|
+
'(last_index_of ["Albert" "Mojir" 160 [1 2]] "Mojir")',
|
|
9986
|
+
'(last_index_of [5 10 15 20] 15)',
|
|
9987
|
+
'(last_index_of [5 10 15 20] 1)',
|
|
9988
|
+
'(last_index_of nil 1)',
|
|
9989
|
+
],
|
|
9990
|
+
},
|
|
9991
|
+
'some': {
|
|
10527
9992
|
title: 'some',
|
|
10528
9993
|
category: 'Sequence',
|
|
10529
9994
|
linkName: 'some',
|
|
@@ -10550,7 +10015,7 @@ var sequenceReference = {
|
|
|
10550
10015
|
"\n(some\n nil\n (fn [x] (> x 10)))",
|
|
10551
10016
|
],
|
|
10552
10017
|
},
|
|
10553
|
-
reverse: {
|
|
10018
|
+
'reverse': {
|
|
10554
10019
|
title: 'reverse',
|
|
10555
10020
|
category: 'Sequence',
|
|
10556
10021
|
linkName: 'reverse',
|
|
@@ -10573,7 +10038,7 @@ var sequenceReference = {
|
|
|
10573
10038
|
'(reverse nil)',
|
|
10574
10039
|
],
|
|
10575
10040
|
},
|
|
10576
|
-
first: {
|
|
10041
|
+
'first': {
|
|
10577
10042
|
title: 'first',
|
|
10578
10043
|
category: 'Sequence',
|
|
10579
10044
|
linkName: 'first',
|
|
@@ -10595,7 +10060,7 @@ var sequenceReference = {
|
|
|
10595
10060
|
'(first nil)',
|
|
10596
10061
|
],
|
|
10597
10062
|
},
|
|
10598
|
-
second: {
|
|
10063
|
+
'second': {
|
|
10599
10064
|
title: 'second',
|
|
10600
10065
|
category: 'Sequence',
|
|
10601
10066
|
linkName: 'second',
|
|
@@ -10618,7 +10083,7 @@ var sequenceReference = {
|
|
|
10618
10083
|
'(second nil)',
|
|
10619
10084
|
],
|
|
10620
10085
|
},
|
|
10621
|
-
last: {
|
|
10086
|
+
'last': {
|
|
10622
10087
|
title: 'last',
|
|
10623
10088
|
category: 'Sequence',
|
|
10624
10089
|
linkName: 'last',
|
|
@@ -10642,7 +10107,7 @@ var sequenceReference = {
|
|
|
10642
10107
|
'(last nil)',
|
|
10643
10108
|
],
|
|
10644
10109
|
},
|
|
10645
|
-
rest: {
|
|
10110
|
+
'rest': {
|
|
10646
10111
|
title: 'rest',
|
|
10647
10112
|
category: 'Sequence',
|
|
10648
10113
|
linkName: 'rest',
|
|
@@ -10667,7 +10132,7 @@ var sequenceReference = {
|
|
|
10667
10132
|
'(rest "")',
|
|
10668
10133
|
],
|
|
10669
10134
|
},
|
|
10670
|
-
nthrest: {
|
|
10135
|
+
'nthrest': {
|
|
10671
10136
|
title: 'nthrest',
|
|
10672
10137
|
category: 'Sequence',
|
|
10673
10138
|
linkName: 'nthrest',
|
|
@@ -10695,7 +10160,7 @@ var sequenceReference = {
|
|
|
10695
10160
|
'(nthrest "" 0)',
|
|
10696
10161
|
],
|
|
10697
10162
|
},
|
|
10698
|
-
next: {
|
|
10163
|
+
'next': {
|
|
10699
10164
|
title: 'next',
|
|
10700
10165
|
category: 'Sequence',
|
|
10701
10166
|
linkName: 'next',
|
|
@@ -10720,7 +10185,7 @@ var sequenceReference = {
|
|
|
10720
10185
|
'(next "")',
|
|
10721
10186
|
],
|
|
10722
10187
|
},
|
|
10723
|
-
nthnext: {
|
|
10188
|
+
'nthnext': {
|
|
10724
10189
|
title: 'nthnext',
|
|
10725
10190
|
category: 'Sequence',
|
|
10726
10191
|
linkName: 'nthnext',
|
|
@@ -10748,7 +10213,7 @@ var sequenceReference = {
|
|
|
10748
10213
|
'(nthnext "" 0)',
|
|
10749
10214
|
],
|
|
10750
10215
|
},
|
|
10751
|
-
take: {
|
|
10216
|
+
'take': {
|
|
10752
10217
|
title: 'take',
|
|
10753
10218
|
category: 'Sequence',
|
|
10754
10219
|
linkName: 'take',
|
|
@@ -10774,7 +10239,7 @@ var sequenceReference = {
|
|
|
10774
10239
|
'(take 50 "Albert")',
|
|
10775
10240
|
],
|
|
10776
10241
|
},
|
|
10777
|
-
take_last: {
|
|
10242
|
+
'take_last': {
|
|
10778
10243
|
title: 'take_last',
|
|
10779
10244
|
category: 'Sequence',
|
|
10780
10245
|
linkName: 'take_last',
|
|
@@ -10798,7 +10263,7 @@ var sequenceReference = {
|
|
|
10798
10263
|
'(take_last 0 [1 2 3 4 5])',
|
|
10799
10264
|
],
|
|
10800
10265
|
},
|
|
10801
|
-
take_while: {
|
|
10266
|
+
'take_while': {
|
|
10802
10267
|
title: 'take_while',
|
|
10803
10268
|
category: 'Sequence',
|
|
10804
10269
|
linkName: 'take_while',
|
|
@@ -10822,7 +10287,7 @@ var sequenceReference = {
|
|
|
10822
10287
|
"\n(take_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10823
10288
|
],
|
|
10824
10289
|
},
|
|
10825
|
-
drop: {
|
|
10290
|
+
'drop': {
|
|
10826
10291
|
title: 'drop',
|
|
10827
10292
|
category: 'Sequence',
|
|
10828
10293
|
linkName: 'drop',
|
|
@@ -10848,7 +10313,7 @@ var sequenceReference = {
|
|
|
10848
10313
|
'(drop "Albert" 50)',
|
|
10849
10314
|
],
|
|
10850
10315
|
},
|
|
10851
|
-
drop_last: {
|
|
10316
|
+
'drop_last': {
|
|
10852
10317
|
title: 'drop_last',
|
|
10853
10318
|
category: 'Sequence',
|
|
10854
10319
|
linkName: 'drop_last',
|
|
@@ -10872,7 +10337,7 @@ var sequenceReference = {
|
|
|
10872
10337
|
'(drop_last [1 2 3 4 5] 0)',
|
|
10873
10338
|
],
|
|
10874
10339
|
},
|
|
10875
|
-
drop_while: {
|
|
10340
|
+
'drop_while': {
|
|
10876
10341
|
title: 'drop_while',
|
|
10877
10342
|
category: 'Sequence',
|
|
10878
10343
|
linkName: 'drop_while',
|
|
@@ -10896,7 +10361,7 @@ var sequenceReference = {
|
|
|
10896
10361
|
"\n(drop_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10897
10362
|
],
|
|
10898
10363
|
},
|
|
10899
|
-
sort: {
|
|
10364
|
+
'sort': {
|
|
10900
10365
|
title: 'sort',
|
|
10901
10366
|
category: 'Sequence',
|
|
10902
10367
|
linkName: 'sort',
|
|
@@ -10923,7 +10388,7 @@ var sequenceReference = {
|
|
|
10923
10388
|
"\n(sort\n [3 1 2]\n (fn [a b] (cond (> a b) -1 (< a b) 1 true -1)))",
|
|
10924
10389
|
],
|
|
10925
10390
|
},
|
|
10926
|
-
sort_by: {
|
|
10391
|
+
'sort_by': {
|
|
10927
10392
|
title: 'sort_by',
|
|
10928
10393
|
category: 'Sequence',
|
|
10929
10394
|
linkName: 'sort_by',
|
|
@@ -10952,7 +10417,7 @@ var sequenceReference = {
|
|
|
10952
10417
|
'(sort_by "Albert" lower_case #(compare %2 %1))',
|
|
10953
10418
|
],
|
|
10954
10419
|
},
|
|
10955
|
-
distinct: {
|
|
10420
|
+
'distinct': {
|
|
10956
10421
|
title: 'distinct',
|
|
10957
10422
|
category: 'Sequence',
|
|
10958
10423
|
linkName: 'distinct',
|
|
@@ -10975,7 +10440,7 @@ var sequenceReference = {
|
|
|
10975
10440
|
'(distinct "")',
|
|
10976
10441
|
],
|
|
10977
10442
|
},
|
|
10978
|
-
remove: {
|
|
10443
|
+
'remove': {
|
|
10979
10444
|
title: 'remove',
|
|
10980
10445
|
category: 'Sequence',
|
|
10981
10446
|
linkName: 'remove',
|
|
@@ -10999,7 +10464,7 @@ var sequenceReference = {
|
|
|
10999
10464
|
'(remove "Albert Mojir" #(has? "aoueiyAOUEIY" %1))',
|
|
11000
10465
|
],
|
|
11001
10466
|
},
|
|
11002
|
-
remove_at: {
|
|
10467
|
+
'remove_at': {
|
|
11003
10468
|
title: 'remove_at',
|
|
11004
10469
|
category: 'Sequence',
|
|
11005
10470
|
linkName: 'remove_at',
|
|
@@ -11025,7 +10490,7 @@ var sequenceReference = {
|
|
|
11025
10490
|
'(remove_at "Albert Mojir" 6)',
|
|
11026
10491
|
],
|
|
11027
10492
|
},
|
|
11028
|
-
split_at: {
|
|
10493
|
+
'split_at': {
|
|
11029
10494
|
title: 'split_at',
|
|
11030
10495
|
category: 'Sequence',
|
|
11031
10496
|
linkName: 'split_at',
|
|
@@ -11050,7 +10515,7 @@ var sequenceReference = {
|
|
|
11050
10515
|
'(split_at "Albert" 2)',
|
|
11051
10516
|
],
|
|
11052
10517
|
},
|
|
11053
|
-
split_with: {
|
|
10518
|
+
'split_with': {
|
|
11054
10519
|
title: 'split_with',
|
|
11055
10520
|
category: 'Sequence',
|
|
11056
10521
|
linkName: 'split_with',
|
|
@@ -11075,7 +10540,7 @@ var sequenceReference = {
|
|
|
11075
10540
|
'(split_with "Albert" #(<= %1 :Z))',
|
|
11076
10541
|
],
|
|
11077
10542
|
},
|
|
11078
|
-
frequencies: {
|
|
10543
|
+
'frequencies': {
|
|
11079
10544
|
title: 'frequencies',
|
|
11080
10545
|
category: 'Sequence',
|
|
11081
10546
|
linkName: 'frequencies',
|
|
@@ -11096,7 +10561,7 @@ var sequenceReference = {
|
|
|
11096
10561
|
'(frequencies "Pneumonoultramicroscopicsilicovolcanoconiosis")',
|
|
11097
10562
|
],
|
|
11098
10563
|
},
|
|
11099
|
-
group_by: {
|
|
10564
|
+
'group_by': {
|
|
11100
10565
|
title: 'group_by',
|
|
11101
10566
|
category: 'Sequence',
|
|
11102
10567
|
linkName: 'group_by',
|
|
@@ -11120,7 +10585,7 @@ var sequenceReference = {
|
|
|
11120
10585
|
'(group_by "Albert Mojir" (fn [char] (if (has? "aoueiAOUEI" char) "vowel" "other")))',
|
|
11121
10586
|
],
|
|
11122
10587
|
},
|
|
11123
|
-
partition: {
|
|
10588
|
+
'partition': {
|
|
11124
10589
|
title: 'partition',
|
|
11125
10590
|
category: 'Sequence',
|
|
11126
10591
|
linkName: 'partition',
|
|
@@ -11137,67 +10602,175 @@ var sequenceReference = {
|
|
|
11137
10602
|
step: {
|
|
11138
10603
|
type: 'number',
|
|
11139
10604
|
},
|
|
11140
|
-
pad: {
|
|
11141
|
-
type: 'array',
|
|
10605
|
+
pad: {
|
|
10606
|
+
type: 'array',
|
|
10607
|
+
},
|
|
10608
|
+
},
|
|
10609
|
+
variants: [
|
|
10610
|
+
{ argumentNames: ['seq', 'n'] },
|
|
10611
|
+
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10612
|
+
{ argumentNames: ['seq', 'n', 'step', 'pad'] },
|
|
10613
|
+
],
|
|
10614
|
+
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.',
|
|
10615
|
+
examples: [
|
|
10616
|
+
'(partition (range 20) 4)',
|
|
10617
|
+
'(partition (range 22) 4)',
|
|
10618
|
+
'(partition (range 20) 4 6)',
|
|
10619
|
+
'(partition (range 20) 4 3)',
|
|
10620
|
+
'(partition (range 20) 3 6 [:a])',
|
|
10621
|
+
'(partition (range 20) 4 6 [:a])',
|
|
10622
|
+
'(partition (range 20) 4 6 [:a :b :c :d])',
|
|
10623
|
+
'(partition [:a :b :c :d :e :f] 3 1)',
|
|
10624
|
+
'(partition [1 2 3 4] 10)',
|
|
10625
|
+
'(partition [1 2 3 4] 10 10)',
|
|
10626
|
+
'(partition [1 2 3 4] 10 10 [])',
|
|
10627
|
+
'(partition [1 2 3 4] 10 10 nil)',
|
|
10628
|
+
'(partition "superfragilistic" 5)',
|
|
10629
|
+
'(partition "superfragilistic" 5 5 nil)',
|
|
10630
|
+
'(def foo [5 6 7 8]) (partition foo 2 1 foo)',
|
|
10631
|
+
],
|
|
10632
|
+
},
|
|
10633
|
+
'partition_all': {
|
|
10634
|
+
title: 'partition_all',
|
|
10635
|
+
category: 'Sequence',
|
|
10636
|
+
linkName: 'partition_all',
|
|
10637
|
+
returns: {
|
|
10638
|
+
type: 'sequence',
|
|
10639
|
+
},
|
|
10640
|
+
args: {
|
|
10641
|
+
seq: {
|
|
10642
|
+
type: 'sequence',
|
|
10643
|
+
},
|
|
10644
|
+
n: {
|
|
10645
|
+
type: 'number',
|
|
10646
|
+
},
|
|
10647
|
+
step: {
|
|
10648
|
+
type: 'number',
|
|
10649
|
+
},
|
|
10650
|
+
},
|
|
10651
|
+
variants: [
|
|
10652
|
+
{ argumentNames: ['seq', 'n'] },
|
|
10653
|
+
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10654
|
+
],
|
|
10655
|
+
description: 'Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.',
|
|
10656
|
+
examples: [
|
|
10657
|
+
'(partition_all [0 1 2 3 4 5 6 7 8 9] 4)',
|
|
10658
|
+
'(partition [0 1 2 3 4 5 6 7 8 9] 4)',
|
|
10659
|
+
'(partition_all [0 1 2 3 4 5 6 7 8 9] 2 4)',
|
|
10660
|
+
],
|
|
10661
|
+
},
|
|
10662
|
+
'partition_by': {
|
|
10663
|
+
title: 'partition_by',
|
|
10664
|
+
category: 'Sequence',
|
|
10665
|
+
linkName: 'partition_by',
|
|
10666
|
+
returns: {
|
|
10667
|
+
type: 'sequence',
|
|
10668
|
+
},
|
|
10669
|
+
args: {
|
|
10670
|
+
seq: {
|
|
10671
|
+
type: 'sequence',
|
|
10672
|
+
},
|
|
10673
|
+
fn: {
|
|
10674
|
+
type: 'function',
|
|
10675
|
+
},
|
|
10676
|
+
},
|
|
10677
|
+
variants: [
|
|
10678
|
+
{ argumentNames: ['seq', 'fn'] },
|
|
10679
|
+
],
|
|
10680
|
+
description: 'Applies $fn to each value in $seq, splitting it each time $fn returns a new value. Returns an array of sequences.',
|
|
10681
|
+
examples: [
|
|
10682
|
+
'(partition_by [1 2 3 4 5] #(== 3 %1))',
|
|
10683
|
+
'(partition_by [1 1 1 2 2 3 3] odd?)',
|
|
10684
|
+
'(partition_by "Leeeeeerrroyyy" identity)',
|
|
10685
|
+
],
|
|
10686
|
+
},
|
|
10687
|
+
'starts_with?': {
|
|
10688
|
+
title: 'starts_with?',
|
|
10689
|
+
category: 'Sequence',
|
|
10690
|
+
linkName: 'starts_with-question',
|
|
10691
|
+
clojureDocs: null,
|
|
10692
|
+
returns: {
|
|
10693
|
+
type: 'boolean',
|
|
10694
|
+
},
|
|
10695
|
+
args: {
|
|
10696
|
+
seq: {
|
|
10697
|
+
type: 'sequence',
|
|
10698
|
+
},
|
|
10699
|
+
prefix: {
|
|
10700
|
+
type: 'sequence',
|
|
10701
|
+
},
|
|
10702
|
+
},
|
|
10703
|
+
variants: [
|
|
10704
|
+
{ argumentNames: ['seq', 'prefix'] },
|
|
10705
|
+
],
|
|
10706
|
+
description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',
|
|
10707
|
+
examples: [
|
|
10708
|
+
'(starts_with? [1 2 3 4 5] 1)',
|
|
10709
|
+
'(starts_with? [1 2 3 4 5] [1])',
|
|
10710
|
+
'(starts_with? "Albert" "Al")',
|
|
10711
|
+
'(starts_with? "Albert" "al")',
|
|
10712
|
+
],
|
|
10713
|
+
},
|
|
10714
|
+
'ends_with?': {
|
|
10715
|
+
title: 'ends_with?',
|
|
10716
|
+
category: 'Sequence',
|
|
10717
|
+
linkName: 'ends_with-question',
|
|
10718
|
+
clojureDocs: null,
|
|
10719
|
+
returns: {
|
|
10720
|
+
type: 'boolean',
|
|
10721
|
+
},
|
|
10722
|
+
args: {
|
|
10723
|
+
seq: {
|
|
10724
|
+
type: 'sequence',
|
|
10725
|
+
},
|
|
10726
|
+
suffix: {
|
|
10727
|
+
type: 'sequence',
|
|
11142
10728
|
},
|
|
11143
10729
|
},
|
|
11144
10730
|
variants: [
|
|
11145
|
-
{ argumentNames: ['seq', '
|
|
11146
|
-
{ argumentNames: ['seq', 'n', 'step'] },
|
|
11147
|
-
{ argumentNames: ['seq', 'n', 'step', 'pad'] },
|
|
10731
|
+
{ argumentNames: ['seq', 'suffix'] },
|
|
11148
10732
|
],
|
|
11149
|
-
description: 'Returns
|
|
10733
|
+
description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',
|
|
11150
10734
|
examples: [
|
|
11151
|
-
'(
|
|
11152
|
-
'(
|
|
11153
|
-
'(
|
|
11154
|
-
'(
|
|
11155
|
-
'(partition (range 20) 3 6 [:a])',
|
|
11156
|
-
'(partition (range 20) 4 6 [:a])',
|
|
11157
|
-
'(partition (range 20) 4 6 [:a :b :c :d])',
|
|
11158
|
-
'(partition [:a :b :c :d :e :f] 3 1)',
|
|
11159
|
-
'(partition [1 2 3 4] 10)',
|
|
11160
|
-
'(partition [1 2 3 4] 10 10)',
|
|
11161
|
-
'(partition [1 2 3 4] 10 10 [])',
|
|
11162
|
-
'(partition [1 2 3 4] 10 10 nil)',
|
|
11163
|
-
'(partition "superfragilistic" 5)',
|
|
11164
|
-
'(partition "superfragilistic" 5 5 nil)',
|
|
11165
|
-
'(def foo [5 6 7 8]) (partition foo 2 1 foo)',
|
|
10735
|
+
'(ends_with? [1 2 3 4 5] 5)',
|
|
10736
|
+
'(ends_with? [1 2 3 4 5] [5])',
|
|
10737
|
+
'(ends_with? "Albert" "rt")',
|
|
10738
|
+
'(ends_with? "Albert" "RT")',
|
|
11166
10739
|
],
|
|
11167
10740
|
},
|
|
11168
|
-
|
|
11169
|
-
title: '
|
|
10741
|
+
'interleave': {
|
|
10742
|
+
title: 'interleave',
|
|
11170
10743
|
category: 'Sequence',
|
|
11171
|
-
linkName: '
|
|
10744
|
+
linkName: 'interleave',
|
|
10745
|
+
clojureDocs: null,
|
|
11172
10746
|
returns: {
|
|
11173
10747
|
type: 'sequence',
|
|
11174
10748
|
},
|
|
11175
10749
|
args: {
|
|
11176
|
-
|
|
10750
|
+
seqs: {
|
|
11177
10751
|
type: 'sequence',
|
|
11178
|
-
|
|
11179
|
-
n: {
|
|
11180
|
-
type: 'number',
|
|
11181
|
-
},
|
|
11182
|
-
step: {
|
|
11183
|
-
type: 'number',
|
|
10752
|
+
array: true,
|
|
11184
10753
|
},
|
|
11185
10754
|
},
|
|
11186
10755
|
variants: [
|
|
11187
|
-
{ argumentNames: ['
|
|
11188
|
-
{ argumentNames: ['seq', 'n', 'step'] },
|
|
10756
|
+
{ argumentNames: ['seqs'] },
|
|
11189
10757
|
],
|
|
11190
|
-
description: 'Returns
|
|
10758
|
+
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.',
|
|
11191
10759
|
examples: [
|
|
11192
|
-
'(
|
|
11193
|
-
'(
|
|
11194
|
-
'(
|
|
10760
|
+
'(interleave [1 2 3] [4 5 6])',
|
|
10761
|
+
'(interleave [1 2 3] [4 5 6] [7 8 9])',
|
|
10762
|
+
'(interleave [1 2 3] [4 5 6] [7 8])',
|
|
10763
|
+
'(interleave [1 2 3] [4 5 6] [7])',
|
|
10764
|
+
'(interleave [1 2 3] [4 5 6] [])',
|
|
10765
|
+
'(interleave [1 2 3] [])',
|
|
10766
|
+
'(interleave [])',
|
|
11195
10767
|
],
|
|
11196
10768
|
},
|
|
11197
|
-
|
|
11198
|
-
title: '
|
|
10769
|
+
'interpose': {
|
|
10770
|
+
title: 'interpose',
|
|
11199
10771
|
category: 'Sequence',
|
|
11200
|
-
linkName: '
|
|
10772
|
+
linkName: 'interpose',
|
|
10773
|
+
clojureDocs: null,
|
|
11201
10774
|
returns: {
|
|
11202
10775
|
type: 'sequence',
|
|
11203
10776
|
},
|
|
@@ -11205,18 +10778,18 @@ var sequenceReference = {
|
|
|
11205
10778
|
seq: {
|
|
11206
10779
|
type: 'sequence',
|
|
11207
10780
|
},
|
|
11208
|
-
|
|
11209
|
-
type: '
|
|
10781
|
+
separator: {
|
|
10782
|
+
type: 'any',
|
|
11210
10783
|
},
|
|
11211
10784
|
},
|
|
11212
10785
|
variants: [
|
|
11213
|
-
{ argumentNames: ['seq', '
|
|
10786
|
+
{ argumentNames: ['seq', 'separator'] },
|
|
11214
10787
|
],
|
|
11215
|
-
description: '
|
|
10788
|
+
description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',
|
|
11216
10789
|
examples: [
|
|
11217
|
-
'(
|
|
11218
|
-
'(
|
|
11219
|
-
'(
|
|
10790
|
+
'(interpose :a [1 2 3 4 5])',
|
|
10791
|
+
'(interpose " " ["Albert" "Mojir" "Nina"])',
|
|
10792
|
+
'(interpose "." "Albert")',
|
|
11220
10793
|
],
|
|
11221
10794
|
},
|
|
11222
10795
|
};
|
|
@@ -13813,12 +13386,12 @@ var regularExpressionReference = {
|
|
|
13813
13386
|
],
|
|
13814
13387
|
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.",
|
|
13815
13388
|
examples: [
|
|
13816
|
-
'(match (regexp "^\\s*(.*)$")
|
|
13817
|
-
'(match
|
|
13818
|
-
'(match
|
|
13819
|
-
'(match #"albert"i
|
|
13820
|
-
'(match #"albert"i
|
|
13821
|
-
'(match #"albert"i
|
|
13389
|
+
'(match " A string" (regexp "^\\s*(.*)$"))',
|
|
13390
|
+
'(match "My name is Albert" #"albert"i)',
|
|
13391
|
+
'(match "My name is Ben" #"albert"i)',
|
|
13392
|
+
'(match nil #"albert"i)',
|
|
13393
|
+
'(match 1 #"albert"i)',
|
|
13394
|
+
'(match {} #"albert"i)',
|
|
13822
13395
|
],
|
|
13823
13396
|
},
|
|
13824
13397
|
replace: {
|
|
@@ -13835,7 +13408,7 @@ var regularExpressionReference = {
|
|
|
13835
13408
|
type: 'string',
|
|
13836
13409
|
},
|
|
13837
13410
|
r: {
|
|
13838
|
-
type: 'regexp',
|
|
13411
|
+
type: ['regexp', 'string'],
|
|
13839
13412
|
},
|
|
13840
13413
|
x: {
|
|
13841
13414
|
type: 'string',
|
|
@@ -13844,13 +13417,49 @@ var regularExpressionReference = {
|
|
|
13844
13417
|
variants: [
|
|
13845
13418
|
{ argumentNames: ['s', 'r', 'x'] },
|
|
13846
13419
|
],
|
|
13847
|
-
description: 'Returns a new string with
|
|
13420
|
+
description: 'Returns a new string with first match of regular expression $r replaced by $x.',
|
|
13848
13421
|
examples: [
|
|
13849
|
-
'(replace "Duck"
|
|
13422
|
+
'(replace "Duck duck" "u" :i)',
|
|
13423
|
+
'(replace "Duck duck" (regexp :u) :i)',
|
|
13424
|
+
'(replace "abcABC" (regexp :a "i") "-")',
|
|
13850
13425
|
'(replace "abcABC" (regexp :a "gi") "-")',
|
|
13426
|
+
'(replace "abcABC" #"a"i "-")',
|
|
13851
13427
|
'(replace "abcABC" #"a"gi "-")',
|
|
13852
13428
|
],
|
|
13853
13429
|
},
|
|
13430
|
+
replace_all: {
|
|
13431
|
+
title: 'replace_all',
|
|
13432
|
+
category: 'Regular expression',
|
|
13433
|
+
linkName: 'replace_all',
|
|
13434
|
+
clojureDocs: null,
|
|
13435
|
+
returns: {
|
|
13436
|
+
type: 'any',
|
|
13437
|
+
array: true,
|
|
13438
|
+
},
|
|
13439
|
+
args: {
|
|
13440
|
+
s: {
|
|
13441
|
+
type: 'string',
|
|
13442
|
+
},
|
|
13443
|
+
r: {
|
|
13444
|
+
type: ['regexp', 'string'],
|
|
13445
|
+
},
|
|
13446
|
+
x: {
|
|
13447
|
+
type: 'string',
|
|
13448
|
+
},
|
|
13449
|
+
},
|
|
13450
|
+
variants: [
|
|
13451
|
+
{ argumentNames: ['s', 'r', 'x'] },
|
|
13452
|
+
],
|
|
13453
|
+
description: 'Returns a new string with all matches of regular expression $r replaced by $x.',
|
|
13454
|
+
examples: [
|
|
13455
|
+
'(replace_all "Duck duck" "u" :i)',
|
|
13456
|
+
'(replace_all "Duck duck" (regexp :u) :i)',
|
|
13457
|
+
'(replace_all "abcABC" (regexp :a "i") "-")',
|
|
13458
|
+
'(replace_all "abcABC" (regexp :a "gi") "-")',
|
|
13459
|
+
'(replace_all "abcABC" #"a"i "-")',
|
|
13460
|
+
'(replace_all "abcABC" #"a"gi "-")',
|
|
13461
|
+
],
|
|
13462
|
+
},
|
|
13854
13463
|
};
|
|
13855
13464
|
|
|
13856
13465
|
var specialExpressionsReference = {
|
|
@@ -13929,32 +13538,6 @@ var specialExpressionsReference = {
|
|
|
13929
13538
|
'(def a (object :x 10 :y true :z "A string"))',
|
|
13930
13539
|
],
|
|
13931
13540
|
},
|
|
13932
|
-
'defs': {
|
|
13933
|
-
title: 'defs',
|
|
13934
|
-
category: 'Special expression',
|
|
13935
|
-
linkName: 'defs',
|
|
13936
|
-
clojureDocs: null,
|
|
13937
|
-
returns: {
|
|
13938
|
-
type: 'any',
|
|
13939
|
-
},
|
|
13940
|
-
args: {
|
|
13941
|
-
name: {
|
|
13942
|
-
type: '*expression',
|
|
13943
|
-
},
|
|
13944
|
-
value: {
|
|
13945
|
-
type: '*expression',
|
|
13946
|
-
},
|
|
13947
|
-
},
|
|
13948
|
-
variants: [
|
|
13949
|
-
{ argumentNames: ['name', 'value'] },
|
|
13950
|
-
],
|
|
13951
|
-
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.",
|
|
13952
|
-
examples: [
|
|
13953
|
-
'(defs :a :b)',
|
|
13954
|
-
"\n(defs (str :a :1) (object :x 10 :y true :z \"A string\"))\na1",
|
|
13955
|
-
"\n(defs :a :b)\n(defs a :c)\nb",
|
|
13956
|
-
],
|
|
13957
|
-
},
|
|
13958
13541
|
'let': {
|
|
13959
13542
|
title: 'let',
|
|
13960
13543
|
category: 'Special expression',
|
|
@@ -13967,97 +13550,12 @@ var specialExpressionsReference = {
|
|
|
13967
13550
|
type: '*binding',
|
|
13968
13551
|
rest: true,
|
|
13969
13552
|
},
|
|
13970
|
-
expressions: {
|
|
13971
|
-
type: '*expression',
|
|
13972
|
-
rest: true,
|
|
13973
|
-
},
|
|
13974
|
-
},
|
|
13975
|
-
variants: [
|
|
13976
|
-
{ argumentNames: ['bindings', 'expressions'] },
|
|
13977
|
-
],
|
|
13978
|
-
description: "\nBinds local variables. The variables lives only within $expressions.\nIt returns evaluation of the last expression in $expressions.",
|
|
13979
|
-
examples: ["\n (let [a (+ 1 2 3 4) \n b (* 1 2 3 4)]\n (write! a b))"],
|
|
13980
|
-
},
|
|
13981
|
-
'if_let': {
|
|
13982
|
-
title: 'if_let',
|
|
13983
|
-
category: 'Special expression',
|
|
13984
|
-
linkName: 'if_let',
|
|
13985
|
-
returns: {
|
|
13986
|
-
type: 'any',
|
|
13987
|
-
},
|
|
13988
|
-
args: {
|
|
13989
|
-
'binding': {
|
|
13990
|
-
type: '*binding',
|
|
13991
|
-
},
|
|
13992
|
-
'then-expr': {
|
|
13993
|
-
type: '*expression',
|
|
13994
|
-
},
|
|
13995
|
-
'else-expr': {
|
|
13996
|
-
type: '*expression',
|
|
13997
|
-
},
|
|
13998
|
-
},
|
|
13999
|
-
variants: [
|
|
14000
|
-
{ argumentNames: ['binding', 'then-expr'] },
|
|
14001
|
-
{ argumentNames: ['binding', 'then-expr', 'else-expr'] },
|
|
14002
|
-
],
|
|
14003
|
-
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).",
|
|
14004
|
-
examples: [
|
|
14005
|
-
"\n(if_let [a (> (count \"Albert\") 4)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
14006
|
-
"\n(if_let [a (> (count \"Albert\") 10)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
14007
|
-
],
|
|
14008
|
-
},
|
|
14009
|
-
'when_let': {
|
|
14010
|
-
title: 'when_let',
|
|
14011
|
-
category: 'Special expression',
|
|
14012
|
-
linkName: 'when_let',
|
|
14013
|
-
returns: {
|
|
14014
|
-
type: 'any',
|
|
14015
|
-
},
|
|
14016
|
-
args: {
|
|
14017
|
-
binding: {
|
|
14018
|
-
type: '*binding',
|
|
14019
|
-
},
|
|
14020
|
-
expressions: {
|
|
14021
|
-
type: '*expression',
|
|
14022
|
-
rest: true,
|
|
14023
|
-
},
|
|
14024
|
-
},
|
|
14025
|
-
variants: [
|
|
14026
|
-
{ argumentNames: ['binding', 'expressions'] },
|
|
14027
|
-
],
|
|
14028
|
-
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.",
|
|
14029
|
-
examples: [
|
|
14030
|
-
"\n(when_let [a (> (count \"Albert\") 4)]\n (write! a))",
|
|
14031
|
-
],
|
|
14032
|
-
},
|
|
14033
|
-
'when_first': {
|
|
14034
|
-
title: 'when_first',
|
|
14035
|
-
category: 'Special expression',
|
|
14036
|
-
linkName: 'when_first',
|
|
14037
|
-
returns: {
|
|
14038
|
-
type: 'any',
|
|
14039
|
-
},
|
|
14040
|
-
args: {
|
|
14041
|
-
binding: {
|
|
14042
|
-
type: '*binding',
|
|
14043
|
-
rest: true,
|
|
14044
|
-
},
|
|
14045
|
-
expressions: {
|
|
14046
|
-
type: '*expression',
|
|
14047
|
-
rest: true,
|
|
14048
|
-
},
|
|
14049
13553
|
},
|
|
14050
13554
|
variants: [
|
|
14051
|
-
{ argumentNames: ['
|
|
14052
|
-
],
|
|
14053
|
-
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.',
|
|
14054
|
-
examples: [
|
|
14055
|
-
"\n(when_first [x [1 2 3]]\n (write! x)\n x)",
|
|
14056
|
-
"\n(when_first [x \"Albert\"]\n (write! x)\n x)",
|
|
14057
|
-
"\n(when_first [x [0]]\n (write! x)\n x)",
|
|
14058
|
-
"\n(when_first [x [nil]]\n (write! x)\n x)",
|
|
14059
|
-
"\n(when_first [x []]\n (write! x)\n x)",
|
|
13555
|
+
{ argumentNames: ['bindings'] },
|
|
14060
13556
|
],
|
|
13557
|
+
description: "\nBinds local variables.",
|
|
13558
|
+
examples: ["\n(let [a (+ 1 2 3 4) \n b (* 1 2 3 4)])\n(write! a b)"],
|
|
14061
13559
|
},
|
|
14062
13560
|
'fn': {
|
|
14063
13561
|
title: 'fn',
|
|
@@ -14113,36 +13611,6 @@ var specialExpressionsReference = {
|
|
|
14113
13611
|
"\n(defn sumOfSquares [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
14114
13612
|
],
|
|
14115
13613
|
},
|
|
14116
|
-
'defns': {
|
|
14117
|
-
title: 'defns',
|
|
14118
|
-
category: 'Special expression',
|
|
14119
|
-
linkName: 'defns',
|
|
14120
|
-
clojureDocs: null,
|
|
14121
|
-
returns: {
|
|
14122
|
-
type: 'function',
|
|
14123
|
-
},
|
|
14124
|
-
args: {
|
|
14125
|
-
name: {
|
|
14126
|
-
type: '*expression',
|
|
14127
|
-
},
|
|
14128
|
-
args: {
|
|
14129
|
-
type: '*arguments',
|
|
14130
|
-
},
|
|
14131
|
-
expressions: {
|
|
14132
|
-
type: '*expression',
|
|
14133
|
-
rest: true,
|
|
14134
|
-
},
|
|
14135
|
-
},
|
|
14136
|
-
variants: [
|
|
14137
|
-
{ argumentNames: ['name', 'args', 'expressions'] },
|
|
14138
|
-
],
|
|
14139
|
-
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.',
|
|
14140
|
-
examples: [
|
|
14141
|
-
"\n(defns \"hyp\" [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\nhyp",
|
|
14142
|
-
"\n(defns\n (str :h :y :p)\n [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\n(hyp 3 4)",
|
|
14143
|
-
"\n(defns \"sumOfSquares\" [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
14144
|
-
],
|
|
14145
|
-
},
|
|
14146
13614
|
'try': {
|
|
14147
13615
|
title: 'try',
|
|
14148
13616
|
category: 'Special expression',
|
|
@@ -14221,10 +13689,11 @@ var specialExpressionsReference = {
|
|
|
14221
13689
|
'(if false (write! "TRUE"))',
|
|
14222
13690
|
],
|
|
14223
13691
|
},
|
|
14224
|
-
'
|
|
14225
|
-
title: '
|
|
13692
|
+
'unless': {
|
|
13693
|
+
title: 'unless',
|
|
14226
13694
|
category: 'Special expression',
|
|
14227
|
-
linkName: '
|
|
13695
|
+
linkName: 'unless',
|
|
13696
|
+
clojureDocs: 'if-not',
|
|
14228
13697
|
returns: {
|
|
14229
13698
|
type: 'any',
|
|
14230
13699
|
},
|
|
@@ -14245,10 +13714,10 @@ var specialExpressionsReference = {
|
|
|
14245
13714
|
],
|
|
14246
13715
|
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.',
|
|
14247
13716
|
examples: [
|
|
14248
|
-
'(
|
|
14249
|
-
'(
|
|
14250
|
-
'(
|
|
14251
|
-
'(
|
|
13717
|
+
'(unless true (write! "TRUE") (write! "FALSE"))',
|
|
13718
|
+
'(unless false (write! "TRUE") (write! "FALSE"))',
|
|
13719
|
+
'(unless true (write! "TRUE"))',
|
|
13720
|
+
'(unless false (write! "TRUE"))',
|
|
14252
13721
|
],
|
|
14253
13722
|
},
|
|
14254
13723
|
'cond': {
|
|
@@ -14298,60 +13767,6 @@ var specialExpressionsReference = {
|
|
|
14298
13767
|
"\n(switch 3\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
|
|
14299
13768
|
],
|
|
14300
13769
|
},
|
|
14301
|
-
'when': {
|
|
14302
|
-
title: 'when',
|
|
14303
|
-
category: 'Special expression',
|
|
14304
|
-
linkName: 'when',
|
|
14305
|
-
returns: {
|
|
14306
|
-
type: 'any',
|
|
14307
|
-
},
|
|
14308
|
-
args: {
|
|
14309
|
-
test: {
|
|
14310
|
-
type: '*expression',
|
|
14311
|
-
},
|
|
14312
|
-
expressions: {
|
|
14313
|
-
type: '*expression',
|
|
14314
|
-
rest: true,
|
|
14315
|
-
},
|
|
14316
|
-
},
|
|
14317
|
-
variants: [
|
|
14318
|
-
{ argumentNames: ['test', 'expressions'] },
|
|
14319
|
-
],
|
|
14320
|
-
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.",
|
|
14321
|
-
examples: [
|
|
14322
|
-
"(when true\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14323
|
-
"(when false\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14324
|
-
'(when true)',
|
|
14325
|
-
'(when false)',
|
|
14326
|
-
],
|
|
14327
|
-
},
|
|
14328
|
-
'when_not': {
|
|
14329
|
-
title: 'when_not',
|
|
14330
|
-
category: 'Special expression',
|
|
14331
|
-
linkName: 'when_not',
|
|
14332
|
-
returns: {
|
|
14333
|
-
type: 'any',
|
|
14334
|
-
},
|
|
14335
|
-
args: {
|
|
14336
|
-
test: {
|
|
14337
|
-
type: '*expression',
|
|
14338
|
-
},
|
|
14339
|
-
expressions: {
|
|
14340
|
-
type: '*expression',
|
|
14341
|
-
rest: true,
|
|
14342
|
-
},
|
|
14343
|
-
},
|
|
14344
|
-
variants: [
|
|
14345
|
-
{ argumentNames: ['test', 'expressions'] },
|
|
14346
|
-
],
|
|
14347
|
-
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.",
|
|
14348
|
-
examples: [
|
|
14349
|
-
'(when_not true (write! "Hi") (write! "There"))',
|
|
14350
|
-
'(when_not false (write! "Hi") (write! "There"))',
|
|
14351
|
-
'(when_not true)',
|
|
14352
|
-
'(when_not false)',
|
|
14353
|
-
],
|
|
14354
|
-
},
|
|
14355
13770
|
'comment': {
|
|
14356
13771
|
title: 'comment',
|
|
14357
13772
|
category: 'Special expression',
|
|
@@ -14411,9 +13826,9 @@ var specialExpressionsReference = {
|
|
|
14411
13826
|
],
|
|
14412
13827
|
description: 'Recursevly calls enclosing function or loop with its evaluated $expressions.',
|
|
14413
13828
|
examples: [
|
|
14414
|
-
"\n(defn foo [n]\n (write! n)\n (
|
|
14415
|
-
"\n(\n (fn [n]\n (write! n)\n (
|
|
14416
|
-
"\n(\n loop [n 3]\n (write! n)\n (
|
|
13829
|
+
"\n(defn foo [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n(foo 3)",
|
|
13830
|
+
"\n(\n (fn [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n 3)",
|
|
13831
|
+
"\n(\n loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
14417
13832
|
],
|
|
14418
13833
|
},
|
|
14419
13834
|
'loop': {
|
|
@@ -14438,7 +13853,7 @@ var specialExpressionsReference = {
|
|
|
14438
13853
|
],
|
|
14439
13854
|
description: 'Executes $expressions with initial $bindings. The $bindings will be replaced with the recur parameters for subsequent recursions.',
|
|
14440
13855
|
examples: [
|
|
14441
|
-
"\n(loop [n 3]\n (write! n)\n (
|
|
13856
|
+
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
14442
13857
|
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))\n n))",
|
|
14443
13858
|
],
|
|
14444
13859
|
},
|
|
@@ -14497,10 +13912,10 @@ var specialExpressionsReference = {
|
|
|
14497
13912
|
"\n(for\n [x [1 2 3] y [1 2 3] z [1 2 3]\n &while (<= x y)]\n \n [x y z])",
|
|
14498
13913
|
],
|
|
14499
13914
|
},
|
|
14500
|
-
'
|
|
14501
|
-
title: '
|
|
13915
|
+
'defined?': {
|
|
13916
|
+
title: 'defined?',
|
|
14502
13917
|
category: 'Special expression',
|
|
14503
|
-
linkName: '
|
|
13918
|
+
linkName: 'defined-question',
|
|
14504
13919
|
returns: {
|
|
14505
13920
|
type: 'boolean',
|
|
14506
13921
|
},
|
|
@@ -14514,11 +13929,11 @@ var specialExpressionsReference = {
|
|
|
14514
13929
|
],
|
|
14515
13930
|
description: 'Returns `true` if $n is a declared variable or a builtin function, otherwise `false`.',
|
|
14516
13931
|
examples: [
|
|
14517
|
-
'(
|
|
14518
|
-
"\n(def foo :foo)\n(
|
|
14519
|
-
'(
|
|
14520
|
-
"\n(def foo nil)\n(
|
|
14521
|
-
'(
|
|
13932
|
+
'(defined? foo)',
|
|
13933
|
+
"\n(def foo :foo)\n(defined? foo)",
|
|
13934
|
+
'(defined? +)',
|
|
13935
|
+
"\n(def foo nil)\n(defined? foo)",
|
|
13936
|
+
'(defined? if)',
|
|
14522
13937
|
],
|
|
14523
13938
|
},
|
|
14524
13939
|
'??': {
|
|
@@ -14864,6 +14279,30 @@ var stringReference = {
|
|
|
14864
14279
|
'(map number (split "0123456789" "" 5))',
|
|
14865
14280
|
],
|
|
14866
14281
|
},
|
|
14282
|
+
'split_lines': {
|
|
14283
|
+
title: 'split_lines',
|
|
14284
|
+
category: 'String',
|
|
14285
|
+
linkName: 'split_lines',
|
|
14286
|
+
clojureDocs: null,
|
|
14287
|
+
returns: {
|
|
14288
|
+
type: 'string',
|
|
14289
|
+
},
|
|
14290
|
+
args: {
|
|
14291
|
+
s: {
|
|
14292
|
+
type: 'string',
|
|
14293
|
+
},
|
|
14294
|
+
},
|
|
14295
|
+
variants: [
|
|
14296
|
+
{ argumentNames: ['s'] },
|
|
14297
|
+
],
|
|
14298
|
+
description: 'Divides $s into an array of substrings, each representing a line.',
|
|
14299
|
+
examples: [
|
|
14300
|
+
'(split_lines "Albert\nMojir\n")',
|
|
14301
|
+
'(split_lines "Albert\n\nMojir")',
|
|
14302
|
+
'(split_lines "Albert\nMojir\n\n")',
|
|
14303
|
+
'(split_lines "")',
|
|
14304
|
+
],
|
|
14305
|
+
},
|
|
14867
14306
|
'template': {
|
|
14868
14307
|
title: 'template',
|
|
14869
14308
|
category: 'String',
|
|
@@ -15080,6 +14519,55 @@ var stringReference = {
|
|
|
15080
14519
|
'(++)',
|
|
15081
14520
|
],
|
|
15082
14521
|
},
|
|
14522
|
+
'capitalize': {
|
|
14523
|
+
title: 'capitalize',
|
|
14524
|
+
category: 'String',
|
|
14525
|
+
linkName: 'capitalize',
|
|
14526
|
+
clojureDocs: 'clojure.string/capitalize',
|
|
14527
|
+
returns: {
|
|
14528
|
+
type: 'string',
|
|
14529
|
+
},
|
|
14530
|
+
args: {
|
|
14531
|
+
s: {
|
|
14532
|
+
type: 'string',
|
|
14533
|
+
},
|
|
14534
|
+
},
|
|
14535
|
+
variants: [
|
|
14536
|
+
{ argumentNames: ['s'] },
|
|
14537
|
+
],
|
|
14538
|
+
description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',
|
|
14539
|
+
examples: [
|
|
14540
|
+
'(capitalize "albert")',
|
|
14541
|
+
'(capitalize "ALBERT")',
|
|
14542
|
+
'(capitalize "aLBERT")',
|
|
14543
|
+
'(capitalize "")',
|
|
14544
|
+
],
|
|
14545
|
+
},
|
|
14546
|
+
'blank?': {
|
|
14547
|
+
title: 'blank?',
|
|
14548
|
+
category: 'String',
|
|
14549
|
+
linkName: 'blank-question',
|
|
14550
|
+
clojureDocs: 'clojure.string/blank_q',
|
|
14551
|
+
returns: {
|
|
14552
|
+
type: 'boolean',
|
|
14553
|
+
},
|
|
14554
|
+
args: {
|
|
14555
|
+
s: {
|
|
14556
|
+
type: ['string', 'null'],
|
|
14557
|
+
},
|
|
14558
|
+
},
|
|
14559
|
+
variants: [
|
|
14560
|
+
{ argumentNames: ['s'] },
|
|
14561
|
+
],
|
|
14562
|
+
description: 'Returns true if $s is null or only contains whitespace characters.',
|
|
14563
|
+
examples: [
|
|
14564
|
+
'(blank? "")',
|
|
14565
|
+
'(blank? null)',
|
|
14566
|
+
'(blank? "\n")',
|
|
14567
|
+
'(blank? " ")',
|
|
14568
|
+
'(blank? ".")',
|
|
14569
|
+
],
|
|
14570
|
+
},
|
|
15083
14571
|
};
|
|
15084
14572
|
|
|
15085
14573
|
var bitwiseReference = { '<<': {
|
|
@@ -15643,6 +15131,7 @@ var api = {
|
|
|
15643
15131
|
'filter',
|
|
15644
15132
|
'position',
|
|
15645
15133
|
'index_of',
|
|
15134
|
+
'last_index_of',
|
|
15646
15135
|
'some',
|
|
15647
15136
|
'reverse',
|
|
15648
15137
|
'first',
|
|
@@ -15670,6 +15159,10 @@ var api = {
|
|
|
15670
15159
|
'partition',
|
|
15671
15160
|
'partition_all',
|
|
15672
15161
|
'partition_by',
|
|
15162
|
+
'starts_with?',
|
|
15163
|
+
'ends_with?',
|
|
15164
|
+
'interleave',
|
|
15165
|
+
'interpose',
|
|
15673
15166
|
],
|
|
15674
15167
|
math: [
|
|
15675
15168
|
'+',
|
|
@@ -15790,34 +15283,28 @@ var api = {
|
|
|
15790
15283
|
'regexp',
|
|
15791
15284
|
'match',
|
|
15792
15285
|
'replace',
|
|
15286
|
+
'replace_all',
|
|
15793
15287
|
],
|
|
15794
15288
|
specialExpressions: [
|
|
15795
15289
|
'&&',
|
|
15796
15290
|
'||',
|
|
15797
15291
|
'def',
|
|
15798
|
-
'defs',
|
|
15799
15292
|
'let',
|
|
15800
|
-
'if_let',
|
|
15801
|
-
'when_let',
|
|
15802
|
-
'when_first',
|
|
15803
15293
|
'fn',
|
|
15804
15294
|
'defn',
|
|
15805
|
-
'defns',
|
|
15806
15295
|
'try',
|
|
15807
15296
|
'throw',
|
|
15808
15297
|
'if',
|
|
15809
|
-
'
|
|
15298
|
+
'unless',
|
|
15810
15299
|
'cond',
|
|
15811
15300
|
'switch',
|
|
15812
|
-
'when',
|
|
15813
|
-
'when_not',
|
|
15814
15301
|
'comment',
|
|
15815
15302
|
'do',
|
|
15816
15303
|
'recur',
|
|
15817
15304
|
'loop',
|
|
15818
15305
|
'doseq',
|
|
15819
15306
|
'for',
|
|
15820
|
-
'
|
|
15307
|
+
'defined?',
|
|
15821
15308
|
'??',
|
|
15822
15309
|
],
|
|
15823
15310
|
string: [
|
|
@@ -15833,6 +15320,7 @@ var api = {
|
|
|
15833
15320
|
'pad_left',
|
|
15834
15321
|
'pad_right',
|
|
15835
15322
|
'split',
|
|
15323
|
+
'split_lines',
|
|
15836
15324
|
'template',
|
|
15837
15325
|
'to_char_code',
|
|
15838
15326
|
'from_char_code',
|
|
@@ -15842,6 +15330,8 @@ var api = {
|
|
|
15842
15330
|
'decode_uri_component',
|
|
15843
15331
|
'join',
|
|
15844
15332
|
'++',
|
|
15333
|
+
'capitalize',
|
|
15334
|
+
'blank?',
|
|
15845
15335
|
],
|
|
15846
15336
|
bitwise: [
|
|
15847
15337
|
'<<',
|