@mojir/lits 2.0.16 → 2.0.18
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 +667 -380
- package/dist/cli/reference/api.d.ts +5 -5
- package/dist/cli/src/builtin/index.d.ts +0 -2
- package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -5
- package/dist/cli/src/parser/AlgebraicParser.d.ts +6 -6
- package/dist/cli/src/parser/commonTokenParsers.d.ts +2 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
- package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
- 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 +663 -378
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +663 -378
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +663 -378
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +5 -5
- package/dist/src/builtin/index.d.ts +0 -2
- package/dist/src/builtin/specialExpressions/functions.d.ts +0 -5
- package/dist/src/parser/AlgebraicParser.d.ts +6 -6
- package/dist/src/parser/commonTokenParsers.d.ts +2 -1
- package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
- package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
- 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 +361 -271
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +361 -271
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/src/builtin/specialExpressions/defs.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/defs.d.ts +0 -5
package/dist/index.esm.js
CHANGED
|
@@ -281,6 +281,7 @@ var commonSimpleTokenTypes = [
|
|
|
281
281
|
];
|
|
282
282
|
var commomValueTokenTypes = [
|
|
283
283
|
'String',
|
|
284
|
+
'RegexpShorthand',
|
|
284
285
|
];
|
|
285
286
|
function isLParenToken(token) {
|
|
286
287
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
|
|
@@ -354,6 +355,18 @@ function asStringToken(token) {
|
|
|
354
355
|
assertStringToken(token);
|
|
355
356
|
return token;
|
|
356
357
|
}
|
|
358
|
+
function isRegexpShorthandToken(token) {
|
|
359
|
+
return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
|
|
360
|
+
}
|
|
361
|
+
function assertRegexpShorthandToken(token) {
|
|
362
|
+
if (!isRegexpShorthandToken(token)) {
|
|
363
|
+
throwUnexpectedToken('RegexpShorthand', undefined, token);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function asRegexpShorthandToken(token) {
|
|
367
|
+
assertRegexpShorthandToken(token);
|
|
368
|
+
return token;
|
|
369
|
+
}
|
|
357
370
|
function isAlgebraicNotationToken(token) {
|
|
358
371
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
|
|
359
372
|
}
|
|
@@ -424,24 +437,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
|
|
|
424
437
|
var nonFunctionOperators = [
|
|
425
438
|
'??',
|
|
426
439
|
'&&',
|
|
440
|
+
'||',
|
|
427
441
|
'comment',
|
|
428
442
|
'cond',
|
|
443
|
+
'def',
|
|
429
444
|
'defined?',
|
|
430
|
-
'
|
|
431
|
-
'unless',
|
|
432
|
-
'||',
|
|
445
|
+
'defn',
|
|
433
446
|
'do',
|
|
434
|
-
'
|
|
435
|
-
'let',
|
|
436
|
-
'def',
|
|
437
|
-
'defs',
|
|
447
|
+
'doseq',
|
|
438
448
|
'fn',
|
|
439
|
-
'
|
|
440
|
-
'
|
|
441
|
-
'try',
|
|
442
|
-
'recur',
|
|
449
|
+
'if',
|
|
450
|
+
'let',
|
|
443
451
|
'loop',
|
|
444
|
-
'
|
|
452
|
+
'recur',
|
|
453
|
+
'throw',
|
|
454
|
+
'try',
|
|
455
|
+
'unless',
|
|
445
456
|
'while',
|
|
446
457
|
];
|
|
447
458
|
var nonFunctionOperatorSet = new Set(nonFunctionOperators);
|
|
@@ -512,9 +523,10 @@ function isA_OperatorToken(token, operatorName) {
|
|
|
512
523
|
}
|
|
513
524
|
function assertA_OperatorToken(token, operatorName) {
|
|
514
525
|
if (!isA_OperatorToken(token, operatorName)) {
|
|
515
|
-
{
|
|
526
|
+
if (operatorName) {
|
|
516
527
|
throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
|
|
517
528
|
}
|
|
529
|
+
throwUnexpectedToken('A_Operator', operatorName, token);
|
|
518
530
|
}
|
|
519
531
|
}
|
|
520
532
|
function isA_WhitespaceToken(token) {
|
|
@@ -537,7 +549,6 @@ var polishOnlyValueTokenTypes = [
|
|
|
537
549
|
'P_StringShorthand',
|
|
538
550
|
'P_Symbol',
|
|
539
551
|
'P_ReservedSymbol',
|
|
540
|
-
'P_RegexpShorthand',
|
|
541
552
|
'P_CollectionAccessor',
|
|
542
553
|
'P_Comment',
|
|
543
554
|
'P_Whitespace',
|
|
@@ -575,18 +586,6 @@ function isP_ReservedSymbolToken(token) {
|
|
|
575
586
|
function isP_ModifierToken(token) {
|
|
576
587
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
|
|
577
588
|
}
|
|
578
|
-
function isP_RegexpShorthandToken(token) {
|
|
579
|
-
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
|
|
580
|
-
}
|
|
581
|
-
function assertP_RegexpShorthandToken(token) {
|
|
582
|
-
if (!isP_RegexpShorthandToken(token)) {
|
|
583
|
-
throwUnexpectedToken('P_RegexpShorthand', undefined, token);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
function asP_RegexpShorthandToken(token) {
|
|
587
|
-
assertP_RegexpShorthandToken(token);
|
|
588
|
-
return token;
|
|
589
|
-
}
|
|
590
589
|
function isP_FnShorthandToken(token) {
|
|
591
590
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
|
|
592
591
|
}
|
|
@@ -767,11 +766,6 @@ var specialExpressionCommentRemovers = {
|
|
|
767
766
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
768
767
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
769
768
|
},
|
|
770
|
-
'defns': function (_node, _removeOptions) { },
|
|
771
|
-
'defs': function (node, removeOptions) {
|
|
772
|
-
removeOptions.removeCommenNodesFromArray(node.p);
|
|
773
|
-
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
774
|
-
},
|
|
775
769
|
'do': function (node, removeOptions) {
|
|
776
770
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
777
771
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
@@ -1976,7 +1970,7 @@ var arrayNormalExpression = {
|
|
|
1976
1970
|
};
|
|
1977
1971
|
|
|
1978
1972
|
var sequenceNormalExpression = {
|
|
1979
|
-
nth: {
|
|
1973
|
+
'nth': {
|
|
1980
1974
|
evaluate: function (params, sourceCodeInfo) {
|
|
1981
1975
|
var _a = __read(params, 2), seq = _a[0], i = _a[1];
|
|
1982
1976
|
var defaultValue = toAny(params[2]);
|
|
@@ -1988,7 +1982,7 @@ var sequenceNormalExpression = {
|
|
|
1988
1982
|
},
|
|
1989
1983
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
1990
1984
|
},
|
|
1991
|
-
filter: {
|
|
1985
|
+
'filter': {
|
|
1992
1986
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1993
1987
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1994
1988
|
var executeFunction = _b.executeFunction;
|
|
@@ -2003,7 +1997,7 @@ var sequenceNormalExpression = {
|
|
|
2003
1997
|
},
|
|
2004
1998
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2005
1999
|
},
|
|
2006
|
-
first: {
|
|
2000
|
+
'first': {
|
|
2007
2001
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2008
2002
|
var _b = __read(_a, 1), array = _b[0];
|
|
2009
2003
|
if (array === null)
|
|
@@ -2013,7 +2007,7 @@ var sequenceNormalExpression = {
|
|
|
2013
2007
|
},
|
|
2014
2008
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2015
2009
|
},
|
|
2016
|
-
last: {
|
|
2010
|
+
'last': {
|
|
2017
2011
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2018
2012
|
var _b = __read(_a, 1), array = _b[0];
|
|
2019
2013
|
if (array === null)
|
|
@@ -2023,7 +2017,7 @@ var sequenceNormalExpression = {
|
|
|
2023
2017
|
},
|
|
2024
2018
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2025
2019
|
},
|
|
2026
|
-
map: {
|
|
2020
|
+
'map': {
|
|
2027
2021
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2028
2022
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2029
2023
|
var executeFunction = _b.executeFunction;
|
|
@@ -2045,7 +2039,7 @@ var sequenceNormalExpression = {
|
|
|
2045
2039
|
},
|
|
2046
2040
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2047
2041
|
},
|
|
2048
|
-
pop: {
|
|
2042
|
+
'pop': {
|
|
2049
2043
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2050
2044
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2051
2045
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2056,7 +2050,7 @@ var sequenceNormalExpression = {
|
|
|
2056
2050
|
},
|
|
2057
2051
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2058
2052
|
},
|
|
2059
|
-
position: {
|
|
2053
|
+
'position': {
|
|
2060
2054
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2061
2055
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2062
2056
|
var executeFunction = _b.executeFunction;
|
|
@@ -2075,7 +2069,7 @@ var sequenceNormalExpression = {
|
|
|
2075
2069
|
},
|
|
2076
2070
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2077
2071
|
},
|
|
2078
|
-
index_of: {
|
|
2072
|
+
'index_of': {
|
|
2079
2073
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2080
2074
|
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2081
2075
|
assertAny(value, sourceCodeInfo);
|
|
@@ -2094,7 +2088,26 @@ var sequenceNormalExpression = {
|
|
|
2094
2088
|
},
|
|
2095
2089
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2096
2090
|
},
|
|
2097
|
-
|
|
2091
|
+
'last_index_of': {
|
|
2092
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2093
|
+
var _b = __read(_a, 2), seq = _b[0], value = _b[1];
|
|
2094
|
+
assertAny(value, sourceCodeInfo);
|
|
2095
|
+
if (seq === null)
|
|
2096
|
+
return null;
|
|
2097
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2098
|
+
if (typeof seq === 'string') {
|
|
2099
|
+
assertString(value, sourceCodeInfo);
|
|
2100
|
+
var index = seq.lastIndexOf(value);
|
|
2101
|
+
return index !== -1 ? index : null;
|
|
2102
|
+
}
|
|
2103
|
+
else {
|
|
2104
|
+
var index = seq.lastIndexOf(value);
|
|
2105
|
+
return index !== -1 ? index : null;
|
|
2106
|
+
}
|
|
2107
|
+
},
|
|
2108
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2109
|
+
},
|
|
2110
|
+
'push': {
|
|
2098
2111
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2099
2112
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2100
2113
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2108,7 +2121,7 @@ var sequenceNormalExpression = {
|
|
|
2108
2121
|
},
|
|
2109
2122
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2110
2123
|
},
|
|
2111
|
-
reductions: {
|
|
2124
|
+
'reductions': {
|
|
2112
2125
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2113
2126
|
var executeFunction = _a.executeFunction;
|
|
2114
2127
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2169,7 +2182,7 @@ var sequenceNormalExpression = {
|
|
|
2169
2182
|
},
|
|
2170
2183
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2171
2184
|
},
|
|
2172
|
-
reduce: {
|
|
2185
|
+
'reduce': {
|
|
2173
2186
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2174
2187
|
var executeFunction = _a.executeFunction;
|
|
2175
2188
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2216,7 +2229,7 @@ var sequenceNormalExpression = {
|
|
|
2216
2229
|
},
|
|
2217
2230
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2218
2231
|
},
|
|
2219
|
-
reduce_right: {
|
|
2232
|
+
'reduce_right': {
|
|
2220
2233
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2221
2234
|
var executeFunction = _a.executeFunction;
|
|
2222
2235
|
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
@@ -2264,7 +2277,7 @@ var sequenceNormalExpression = {
|
|
|
2264
2277
|
},
|
|
2265
2278
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2266
2279
|
},
|
|
2267
|
-
rest: {
|
|
2280
|
+
'rest': {
|
|
2268
2281
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2269
2282
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2270
2283
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2277,7 +2290,7 @@ var sequenceNormalExpression = {
|
|
|
2277
2290
|
},
|
|
2278
2291
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2279
2292
|
},
|
|
2280
|
-
nthrest: {
|
|
2293
|
+
'nthrest': {
|
|
2281
2294
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2282
2295
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2283
2296
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2289,7 +2302,7 @@ var sequenceNormalExpression = {
|
|
|
2289
2302
|
},
|
|
2290
2303
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2291
2304
|
},
|
|
2292
|
-
next: {
|
|
2305
|
+
'next': {
|
|
2293
2306
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2294
2307
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2295
2308
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2304,7 +2317,7 @@ var sequenceNormalExpression = {
|
|
|
2304
2317
|
},
|
|
2305
2318
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2306
2319
|
},
|
|
2307
|
-
nthnext: {
|
|
2320
|
+
'nthnext': {
|
|
2308
2321
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2309
2322
|
var _b = __read(_a, 2), seq = _b[0], count = _b[1];
|
|
2310
2323
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2318,7 +2331,7 @@ var sequenceNormalExpression = {
|
|
|
2318
2331
|
},
|
|
2319
2332
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2320
2333
|
},
|
|
2321
|
-
reverse: {
|
|
2334
|
+
'reverse': {
|
|
2322
2335
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2323
2336
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2324
2337
|
if (seq === null)
|
|
@@ -2330,7 +2343,7 @@ var sequenceNormalExpression = {
|
|
|
2330
2343
|
},
|
|
2331
2344
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2332
2345
|
},
|
|
2333
|
-
second: {
|
|
2346
|
+
'second': {
|
|
2334
2347
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2335
2348
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2336
2349
|
if (seq === null)
|
|
@@ -2340,7 +2353,7 @@ var sequenceNormalExpression = {
|
|
|
2340
2353
|
},
|
|
2341
2354
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2342
2355
|
},
|
|
2343
|
-
shift: {
|
|
2356
|
+
'shift': {
|
|
2344
2357
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2345
2358
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2346
2359
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2352,7 +2365,7 @@ var sequenceNormalExpression = {
|
|
|
2352
2365
|
},
|
|
2353
2366
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2354
2367
|
},
|
|
2355
|
-
slice: {
|
|
2368
|
+
'slice': {
|
|
2356
2369
|
evaluate: function (params, sourceCodeInfo) {
|
|
2357
2370
|
var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
|
|
2358
2371
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2366,7 +2379,7 @@ var sequenceNormalExpression = {
|
|
|
2366
2379
|
},
|
|
2367
2380
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
|
|
2368
2381
|
},
|
|
2369
|
-
some: {
|
|
2382
|
+
'some': {
|
|
2370
2383
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2371
2384
|
var _c;
|
|
2372
2385
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2383,7 +2396,7 @@ var sequenceNormalExpression = {
|
|
|
2383
2396
|
},
|
|
2384
2397
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2385
2398
|
},
|
|
2386
|
-
sort: {
|
|
2399
|
+
'sort': {
|
|
2387
2400
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2388
2401
|
var executeFunction = _a.executeFunction;
|
|
2389
2402
|
var _b = __read(params, 1), seq = _b[0];
|
|
@@ -2421,7 +2434,7 @@ var sequenceNormalExpression = {
|
|
|
2421
2434
|
},
|
|
2422
2435
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
2423
2436
|
},
|
|
2424
|
-
sort_by: {
|
|
2437
|
+
'sort_by': {
|
|
2425
2438
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
2426
2439
|
var executeFunction = _a.executeFunction;
|
|
2427
2440
|
var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
|
|
@@ -2472,7 +2485,7 @@ var sequenceNormalExpression = {
|
|
|
2472
2485
|
},
|
|
2473
2486
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2474
2487
|
},
|
|
2475
|
-
take: {
|
|
2488
|
+
'take': {
|
|
2476
2489
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2477
2490
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2478
2491
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2482,7 +2495,7 @@ var sequenceNormalExpression = {
|
|
|
2482
2495
|
},
|
|
2483
2496
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2484
2497
|
},
|
|
2485
|
-
take_last: {
|
|
2498
|
+
'take_last': {
|
|
2486
2499
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2487
2500
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2488
2501
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2493,7 +2506,7 @@ var sequenceNormalExpression = {
|
|
|
2493
2506
|
},
|
|
2494
2507
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2495
2508
|
},
|
|
2496
|
-
take_while: {
|
|
2509
|
+
'take_while': {
|
|
2497
2510
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2498
2511
|
var e_1, _c;
|
|
2499
2512
|
var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
|
|
@@ -2521,7 +2534,7 @@ var sequenceNormalExpression = {
|
|
|
2521
2534
|
},
|
|
2522
2535
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2523
2536
|
},
|
|
2524
|
-
drop: {
|
|
2537
|
+
'drop': {
|
|
2525
2538
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2526
2539
|
var _b = __read(_a, 2), input = _b[0], n = _b[1];
|
|
2527
2540
|
assertNumber(n, sourceCodeInfo);
|
|
@@ -2531,7 +2544,7 @@ var sequenceNormalExpression = {
|
|
|
2531
2544
|
},
|
|
2532
2545
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2533
2546
|
},
|
|
2534
|
-
drop_last: {
|
|
2547
|
+
'drop_last': {
|
|
2535
2548
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2536
2549
|
var _b = __read(_a, 2), array = _b[0], n = _b[1];
|
|
2537
2550
|
assertSeq(array, sourceCodeInfo);
|
|
@@ -2542,7 +2555,7 @@ var sequenceNormalExpression = {
|
|
|
2542
2555
|
},
|
|
2543
2556
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2544
2557
|
},
|
|
2545
|
-
drop_while: {
|
|
2558
|
+
'drop_while': {
|
|
2546
2559
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2547
2560
|
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2548
2561
|
var executeFunction = _b.executeFunction;
|
|
@@ -2558,7 +2571,7 @@ var sequenceNormalExpression = {
|
|
|
2558
2571
|
},
|
|
2559
2572
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2560
2573
|
},
|
|
2561
|
-
unshift: {
|
|
2574
|
+
'unshift': {
|
|
2562
2575
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2563
2576
|
var _b = __read(_a), seq = _b[0], values = _b.slice(1);
|
|
2564
2577
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2572,7 +2585,7 @@ var sequenceNormalExpression = {
|
|
|
2572
2585
|
},
|
|
2573
2586
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
2574
2587
|
},
|
|
2575
|
-
distinct: {
|
|
2588
|
+
'distinct': {
|
|
2576
2589
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2577
2590
|
var _b = __read(_a, 1), input = _b[0];
|
|
2578
2591
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2582,9 +2595,9 @@ var sequenceNormalExpression = {
|
|
|
2582
2595
|
},
|
|
2583
2596
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2584
2597
|
},
|
|
2585
|
-
remove: {
|
|
2598
|
+
'remove': {
|
|
2586
2599
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2587
|
-
var _c = __read(_a, 2),
|
|
2600
|
+
var _c = __read(_a, 2), input = _c[0], fn = _c[1];
|
|
2588
2601
|
var executeFunction = _b.executeFunction;
|
|
2589
2602
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2590
2603
|
assertSeq(input, sourceCodeInfo);
|
|
@@ -2597,9 +2610,9 @@ var sequenceNormalExpression = {
|
|
|
2597
2610
|
},
|
|
2598
2611
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2599
2612
|
},
|
|
2600
|
-
remove_at: {
|
|
2613
|
+
'remove_at': {
|
|
2601
2614
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2602
|
-
var _b = __read(_a, 2),
|
|
2615
|
+
var _b = __read(_a, 2), input = _b[0], index = _b[1];
|
|
2603
2616
|
assertNumber(index, sourceCodeInfo);
|
|
2604
2617
|
assertSeq(input, sourceCodeInfo);
|
|
2605
2618
|
var intIndex = Math.ceil(index);
|
|
@@ -2614,9 +2627,9 @@ var sequenceNormalExpression = {
|
|
|
2614
2627
|
},
|
|
2615
2628
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2616
2629
|
},
|
|
2617
|
-
split_at: {
|
|
2630
|
+
'split_at': {
|
|
2618
2631
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2619
|
-
var _b = __read(_a, 2),
|
|
2632
|
+
var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
|
|
2620
2633
|
assertNumber(pos, sourceCodeInfo, { finite: true });
|
|
2621
2634
|
var intPos = toNonNegativeInteger(pos);
|
|
2622
2635
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2624,9 +2637,9 @@ var sequenceNormalExpression = {
|
|
|
2624
2637
|
},
|
|
2625
2638
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2626
2639
|
},
|
|
2627
|
-
split_with: {
|
|
2640
|
+
'split_with': {
|
|
2628
2641
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2629
|
-
var _c = __read(_a, 2),
|
|
2642
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2630
2643
|
var executeFunction = _b.executeFunction;
|
|
2631
2644
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2632
2645
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2639,7 +2652,7 @@ var sequenceNormalExpression = {
|
|
|
2639
2652
|
},
|
|
2640
2653
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2641
2654
|
},
|
|
2642
|
-
frequencies: {
|
|
2655
|
+
'frequencies': {
|
|
2643
2656
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2644
2657
|
var _b = __read(_a, 1), seq = _b[0];
|
|
2645
2658
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2655,9 +2668,9 @@ var sequenceNormalExpression = {
|
|
|
2655
2668
|
},
|
|
2656
2669
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2657
2670
|
},
|
|
2658
|
-
group_by: {
|
|
2671
|
+
'group_by': {
|
|
2659
2672
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2660
|
-
var _c = __read(_a, 2),
|
|
2673
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2661
2674
|
var executeFunction = _b.executeFunction;
|
|
2662
2675
|
assertAny(fn, sourceCodeInfo);
|
|
2663
2676
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2673,34 +2686,30 @@ var sequenceNormalExpression = {
|
|
|
2673
2686
|
},
|
|
2674
2687
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2675
2688
|
},
|
|
2676
|
-
partition: {
|
|
2689
|
+
'partition': {
|
|
2677
2690
|
evaluate: function (params, sourceCodeInfo) {
|
|
2678
|
-
var
|
|
2679
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2680
|
-
var
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
: asSeq(params[3], sourceCodeInfo);
|
|
2685
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2686
|
-
var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
|
|
2691
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2692
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2693
|
+
var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2694
|
+
var pad = params.length === 4
|
|
2695
|
+
? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
|
|
2696
|
+
: undefined;
|
|
2687
2697
|
return partition(n, step, seq, pad, sourceCodeInfo);
|
|
2688
2698
|
},
|
|
2689
2699
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
|
|
2690
2700
|
},
|
|
2691
|
-
partition_all: {
|
|
2701
|
+
'partition_all': {
|
|
2692
2702
|
evaluate: function (params, sourceCodeInfo) {
|
|
2693
|
-
var
|
|
2694
|
-
var n = toNonNegativeInteger(asNumber(params[
|
|
2695
|
-
var
|
|
2696
|
-
var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
|
|
2703
|
+
var seq = asSeq(params[0], sourceCodeInfo);
|
|
2704
|
+
var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
|
|
2705
|
+
var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
|
|
2697
2706
|
return partition(n, step, seq, [], sourceCodeInfo);
|
|
2698
2707
|
},
|
|
2699
2708
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
2700
2709
|
},
|
|
2701
|
-
partition_by: {
|
|
2710
|
+
'partition_by': {
|
|
2702
2711
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
2703
|
-
var _c = __read(_a, 2),
|
|
2712
|
+
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
2704
2713
|
var executeFunction = _b.executeFunction;
|
|
2705
2714
|
assertLitsFunction(fn, sourceCodeInfo);
|
|
2706
2715
|
assertSeq(seq, sourceCodeInfo);
|
|
@@ -2717,7 +2726,88 @@ var sequenceNormalExpression = {
|
|
|
2717
2726
|
}, []);
|
|
2718
2727
|
return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
|
|
2719
2728
|
},
|
|
2720
|
-
validate: function (node) { return assertNumberOfParams(
|
|
2729
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2730
|
+
},
|
|
2731
|
+
'ends_with?': {
|
|
2732
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2733
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2734
|
+
assertSeq(str, sourceCodeInfo);
|
|
2735
|
+
if (typeof str === 'string') {
|
|
2736
|
+
assertString(search, sourceCodeInfo);
|
|
2737
|
+
return str.endsWith(search);
|
|
2738
|
+
}
|
|
2739
|
+
return str.at(-1) === search;
|
|
2740
|
+
},
|
|
2741
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2742
|
+
},
|
|
2743
|
+
'starts_with?': {
|
|
2744
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2745
|
+
var _b = __read(_a, 2), str = _b[0], search = _b[1];
|
|
2746
|
+
assertSeq(str, sourceCodeInfo);
|
|
2747
|
+
if (typeof str === 'string') {
|
|
2748
|
+
assertString(search, sourceCodeInfo);
|
|
2749
|
+
return str.startsWith(search);
|
|
2750
|
+
}
|
|
2751
|
+
return str[0] === search;
|
|
2752
|
+
},
|
|
2753
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2754
|
+
},
|
|
2755
|
+
'interleave': {
|
|
2756
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2757
|
+
var e_2, _b;
|
|
2758
|
+
var _c = __read(_a), seqs = _c.slice(0);
|
|
2759
|
+
var isStringSeq = typeof seqs[0] === 'string';
|
|
2760
|
+
var seqsArr = isStringSeq
|
|
2761
|
+
? seqs.map(function (seq) {
|
|
2762
|
+
assertString(seq, sourceCodeInfo);
|
|
2763
|
+
if (typeof seq === 'string')
|
|
2764
|
+
return seq.split('');
|
|
2765
|
+
return seq;
|
|
2766
|
+
})
|
|
2767
|
+
: seqs.map(function (seq) {
|
|
2768
|
+
assertArray(seq, sourceCodeInfo);
|
|
2769
|
+
return seq;
|
|
2770
|
+
});
|
|
2771
|
+
var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
|
|
2772
|
+
var result = [];
|
|
2773
|
+
for (var i = 0; i < maxLength; i += 1) {
|
|
2774
|
+
try {
|
|
2775
|
+
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()) {
|
|
2776
|
+
var seq = seqsArr_1_1.value;
|
|
2777
|
+
if (i < seq.length)
|
|
2778
|
+
result.push(seq[i]);
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2782
|
+
finally {
|
|
2783
|
+
try {
|
|
2784
|
+
if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
|
|
2785
|
+
}
|
|
2786
|
+
finally { if (e_2) throw e_2.error; }
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
return isStringSeq ? result.join('') : result;
|
|
2790
|
+
},
|
|
2791
|
+
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
2792
|
+
},
|
|
2793
|
+
'interpose': {
|
|
2794
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
2795
|
+
var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
|
|
2796
|
+
assertSeq(seq, sourceCodeInfo);
|
|
2797
|
+
if (typeof seq === 'string') {
|
|
2798
|
+
assertString(separator, sourceCodeInfo);
|
|
2799
|
+
return seq.split('').join(separator);
|
|
2800
|
+
}
|
|
2801
|
+
if (seq.length === 0)
|
|
2802
|
+
return [];
|
|
2803
|
+
var result = [];
|
|
2804
|
+
for (var i = 0; i < seq.length - 1; i += 1) {
|
|
2805
|
+
result.push(seq[i], separator);
|
|
2806
|
+
}
|
|
2807
|
+
result.push(seq[seq.length - 1]);
|
|
2808
|
+
return result;
|
|
2809
|
+
},
|
|
2810
|
+
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2721
2811
|
},
|
|
2722
2812
|
};
|
|
2723
2813
|
function partition(n, step, seq, pad, sourceCodeInfo) {
|
|
@@ -3880,7 +3970,7 @@ var regexpNormalExpression = {
|
|
|
3880
3970
|
},
|
|
3881
3971
|
match: {
|
|
3882
3972
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3883
|
-
var _b = __read(_a, 2),
|
|
3973
|
+
var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
|
|
3884
3974
|
assertRegularExpression(regexp, sourceCodeInfo);
|
|
3885
3975
|
if (!isString(text))
|
|
3886
3976
|
return null;
|
|
@@ -3896,15 +3986,27 @@ var regexpNormalExpression = {
|
|
|
3896
3986
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3897
3987
|
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
3898
3988
|
assertString(str, sourceCodeInfo);
|
|
3899
|
-
|
|
3989
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
3900
3990
|
assertString(value, sourceCodeInfo);
|
|
3901
|
-
var
|
|
3902
|
-
return str.replace(
|
|
3991
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
|
|
3992
|
+
return str.replace(matcher, value);
|
|
3993
|
+
},
|
|
3994
|
+
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3995
|
+
},
|
|
3996
|
+
replace_all: {
|
|
3997
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
3998
|
+
var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
|
|
3999
|
+
assertString(str, sourceCodeInfo);
|
|
4000
|
+
assertStringOrRegularExpression(regexp, sourceCodeInfo);
|
|
4001
|
+
assertString(value, sourceCodeInfo);
|
|
4002
|
+
var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
|
|
4003
|
+
return str.replaceAll(matcher, value);
|
|
3903
4004
|
},
|
|
3904
4005
|
validate: function (node) { return assertNumberOfParams(3, node); },
|
|
3905
4006
|
},
|
|
3906
4007
|
};
|
|
3907
4008
|
|
|
4009
|
+
var blankRegexp = /^\s*$/;
|
|
3908
4010
|
var stringNormalExpression = {
|
|
3909
4011
|
'subs': {
|
|
3910
4012
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -4062,6 +4164,14 @@ var stringNormalExpression = {
|
|
|
4062
4164
|
},
|
|
4063
4165
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4064
4166
|
},
|
|
4167
|
+
'split_lines': {
|
|
4168
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4169
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4170
|
+
assertString(str, sourceCodeInfo);
|
|
4171
|
+
return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
|
|
4172
|
+
},
|
|
4173
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4174
|
+
},
|
|
4065
4175
|
'pad_left': {
|
|
4066
4176
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4067
4177
|
var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
|
|
@@ -4165,6 +4275,25 @@ var stringNormalExpression = {
|
|
|
4165
4275
|
},
|
|
4166
4276
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4167
4277
|
},
|
|
4278
|
+
'blank?': {
|
|
4279
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4280
|
+
var _b = __read(_a, 1), value = _b[0];
|
|
4281
|
+
if (value === null) {
|
|
4282
|
+
return true;
|
|
4283
|
+
}
|
|
4284
|
+
assertString(value, sourceCodeInfo);
|
|
4285
|
+
return blankRegexp.test(value);
|
|
4286
|
+
},
|
|
4287
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4288
|
+
},
|
|
4289
|
+
'capitalize': {
|
|
4290
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4291
|
+
var _b = __read(_a, 1), str = _b[0];
|
|
4292
|
+
assertString(str, sourceCodeInfo);
|
|
4293
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
4294
|
+
},
|
|
4295
|
+
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4296
|
+
},
|
|
4168
4297
|
};
|
|
4169
4298
|
var doubleDollarRegexp = /\$\$/g;
|
|
4170
4299
|
function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
|
|
@@ -4510,44 +4639,6 @@ var defSpecialExpression = {
|
|
|
4510
4639
|
},
|
|
4511
4640
|
};
|
|
4512
4641
|
|
|
4513
|
-
var defsSpecialExpression = {
|
|
4514
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4515
|
-
var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4516
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4517
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4518
|
-
var node = {
|
|
4519
|
-
t: AstNodeType.SpecialExpression,
|
|
4520
|
-
n: 'defs',
|
|
4521
|
-
p: params,
|
|
4522
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4523
|
-
};
|
|
4524
|
-
return node;
|
|
4525
|
-
},
|
|
4526
|
-
validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
|
|
4527
|
-
evaluate: function (node, contextStack, _a) {
|
|
4528
|
-
var _b, _c;
|
|
4529
|
-
var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
|
|
4530
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4531
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4532
|
-
assertString(name, sourceCodeInfo);
|
|
4533
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4534
|
-
contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
|
|
4535
|
-
return null;
|
|
4536
|
-
},
|
|
4537
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4538
|
-
var _b;
|
|
4539
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4540
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4541
|
-
var subNode = node.p[1];
|
|
4542
|
-
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4543
|
-
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4544
|
-
assertString(name, sourceCodeInfo);
|
|
4545
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4546
|
-
contextStack.exportValue(name, true);
|
|
4547
|
-
return result;
|
|
4548
|
-
},
|
|
4549
|
-
};
|
|
4550
|
-
|
|
4551
4642
|
var doSpecialExpression = {
|
|
4552
4643
|
polishParse: getCommonPolishSpecialExpressionParser('do'),
|
|
4553
4644
|
validateParameterCount: function () { return undefined; },
|
|
@@ -4627,7 +4718,7 @@ var defnSpecialExpression = {
|
|
|
4627
4718
|
var _b;
|
|
4628
4719
|
var _c, _d;
|
|
4629
4720
|
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4630
|
-
var name =
|
|
4721
|
+
var name = node.f.v;
|
|
4631
4722
|
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4632
4723
|
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4633
4724
|
var litsFunction = (_b = {},
|
|
@@ -4648,53 +4739,6 @@ var defnSpecialExpression = {
|
|
|
4648
4739
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4649
4740
|
},
|
|
4650
4741
|
};
|
|
4651
|
-
var defnsSpecialExpression = {
|
|
4652
|
-
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4653
|
-
var parseToken = parsers.parseToken;
|
|
4654
|
-
var functionName = parseToken(tokenStream, parseState);
|
|
4655
|
-
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
4656
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4657
|
-
var node = {
|
|
4658
|
-
t: AstNodeType.SpecialExpression,
|
|
4659
|
-
n: 'defns',
|
|
4660
|
-
p: [],
|
|
4661
|
-
f: functionName,
|
|
4662
|
-
o: functionOverloades,
|
|
4663
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4664
|
-
};
|
|
4665
|
-
return node;
|
|
4666
|
-
},
|
|
4667
|
-
validateParameterCount: function () { return undefined; },
|
|
4668
|
-
evaluate: function (node, contextStack, _a) {
|
|
4669
|
-
var _b;
|
|
4670
|
-
var _c, _d;
|
|
4671
|
-
var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4672
|
-
var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
|
|
4673
|
-
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4674
|
-
var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
|
|
4675
|
-
var litsFunction = (_b = {},
|
|
4676
|
-
_b[FUNCTION_SYMBOL] = true,
|
|
4677
|
-
_b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
|
|
4678
|
-
_b.t = FunctionType.UserDefined,
|
|
4679
|
-
_b.n = name,
|
|
4680
|
-
_b.o = evaluatedFunctionOverloades,
|
|
4681
|
-
_b);
|
|
4682
|
-
contextStack.exportValue(name, litsFunction);
|
|
4683
|
-
return null;
|
|
4684
|
-
},
|
|
4685
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4686
|
-
var _b;
|
|
4687
|
-
var _c;
|
|
4688
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
|
|
4689
|
-
var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
|
|
4690
|
-
var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
|
|
4691
|
-
assertString(name, sourceCodeInfo);
|
|
4692
|
-
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4693
|
-
contextStack.exportValue(name, true);
|
|
4694
|
-
var newContext = (_b = {}, _b[name] = { value: true }, _b);
|
|
4695
|
-
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4696
|
-
},
|
|
4697
|
-
};
|
|
4698
4742
|
var fnSpecialExpression = {
|
|
4699
4743
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
4700
4744
|
var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
|
|
@@ -4728,14 +4772,6 @@ var fnSpecialExpression = {
|
|
|
4728
4772
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
|
|
4729
4773
|
},
|
|
4730
4774
|
};
|
|
4731
|
-
function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
|
|
4732
|
-
var _a;
|
|
4733
|
-
var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
|
|
4734
|
-
if (expressionName === 'defn')
|
|
4735
|
-
return (node.f).v;
|
|
4736
|
-
var name = evaluateAstNode(node.f, contextStack);
|
|
4737
|
-
return asString(name, sourceCodeInfo);
|
|
4738
|
-
}
|
|
4739
4775
|
function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
|
|
4740
4776
|
var e_1, _a, e_2, _b;
|
|
4741
4777
|
var evaluatedFunctionOverloades = [];
|
|
@@ -5513,8 +5549,6 @@ var specialExpressions = {
|
|
|
5513
5549
|
'switch': switchSpecialExpression,
|
|
5514
5550
|
'def': defSpecialExpression,
|
|
5515
5551
|
'defn': defnSpecialExpression,
|
|
5516
|
-
'defns': defnsSpecialExpression,
|
|
5517
|
-
'defs': defsSpecialExpression,
|
|
5518
5552
|
'do': doSpecialExpression,
|
|
5519
5553
|
'doseq': doseqSpecialExpression,
|
|
5520
5554
|
'for': forSpecialExpression,
|
|
@@ -5576,7 +5610,6 @@ var ContextStackImpl = /** @class */ (function () {
|
|
|
5576
5610
|
if (normalExpressionKeys.includes(name)) {
|
|
5577
5611
|
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5578
5612
|
}
|
|
5579
|
-
this.addValue(name, value);
|
|
5580
5613
|
this.globalContext[name] = { value: value };
|
|
5581
5614
|
};
|
|
5582
5615
|
ContextStackImpl.prototype.addValue = function (name, value) {
|
|
@@ -6240,6 +6273,33 @@ function parseString(tokenStream, parseState) {
|
|
|
6240
6273
|
token: getTokenDebugData(tkn) && tkn,
|
|
6241
6274
|
};
|
|
6242
6275
|
}
|
|
6276
|
+
function parseRegexpShorthand(tokenStream, parseState) {
|
|
6277
|
+
var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
6278
|
+
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
6279
|
+
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
6280
|
+
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
6281
|
+
var stringNode = {
|
|
6282
|
+
t: AstNodeType.String,
|
|
6283
|
+
v: regexpString,
|
|
6284
|
+
p: [],
|
|
6285
|
+
n: undefined,
|
|
6286
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6287
|
+
};
|
|
6288
|
+
var optionsNode = {
|
|
6289
|
+
t: AstNodeType.String,
|
|
6290
|
+
v: optionsString,
|
|
6291
|
+
p: [],
|
|
6292
|
+
n: undefined,
|
|
6293
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6294
|
+
};
|
|
6295
|
+
var node = {
|
|
6296
|
+
t: AstNodeType.NormalExpression,
|
|
6297
|
+
n: 'regexp',
|
|
6298
|
+
p: [stringNode, optionsNode],
|
|
6299
|
+
token: getTokenDebugData(tkn) && tkn,
|
|
6300
|
+
};
|
|
6301
|
+
return node;
|
|
6302
|
+
}
|
|
6243
6303
|
|
|
6244
6304
|
var exponentiationPrecedence = 10;
|
|
6245
6305
|
var binaryFunctionalOperatorPrecedence = 1;
|
|
@@ -6381,6 +6441,12 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6381
6441
|
this.tokenStream = tokenStream;
|
|
6382
6442
|
this.parseState = parseState;
|
|
6383
6443
|
}
|
|
6444
|
+
AlgebraicParser.prototype.peek = function () {
|
|
6445
|
+
return this.tokenStream.tokens[this.parseState.position];
|
|
6446
|
+
};
|
|
6447
|
+
AlgebraicParser.prototype.peekAhead = function (count) {
|
|
6448
|
+
return this.tokenStream.tokens[this.parseState.position + count];
|
|
6449
|
+
};
|
|
6384
6450
|
AlgebraicParser.prototype.advance = function () {
|
|
6385
6451
|
this.parseState.position += 1;
|
|
6386
6452
|
};
|
|
@@ -6402,10 +6468,6 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6402
6468
|
var left;
|
|
6403
6469
|
if (isA_SymbolToken(firstToken)) {
|
|
6404
6470
|
switch (firstToken[1]) {
|
|
6405
|
-
case 'def':
|
|
6406
|
-
return this.parseDef(firstToken);
|
|
6407
|
-
case 'defn':
|
|
6408
|
-
return this.parseDefn(firstToken);
|
|
6409
6471
|
case 'let':
|
|
6410
6472
|
return this.parseLet(firstToken);
|
|
6411
6473
|
case 'if':
|
|
@@ -6433,6 +6495,12 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6433
6495
|
break;
|
|
6434
6496
|
}
|
|
6435
6497
|
}
|
|
6498
|
+
else if (isA_ReservedSymbolToken(firstToken, 'function')) {
|
|
6499
|
+
return this.parseFunction(firstToken);
|
|
6500
|
+
}
|
|
6501
|
+
else if (isA_ReservedSymbolToken(firstToken, 'export')) {
|
|
6502
|
+
return this.parseExport(firstToken);
|
|
6503
|
+
}
|
|
6436
6504
|
left || (left = this.parseOperand());
|
|
6437
6505
|
var operator = this.peek();
|
|
6438
6506
|
while (!this.isAtExpressionEnd()) {
|
|
@@ -6564,10 +6632,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6564
6632
|
case 'String':
|
|
6565
6633
|
return parseString(this.tokenStream, this.parseState);
|
|
6566
6634
|
case 'A_Symbol': {
|
|
6635
|
+
var positionBefore = this.parseState.position;
|
|
6636
|
+
var lamdaFunction = this.parseLambdaFunction();
|
|
6637
|
+
if (lamdaFunction) {
|
|
6638
|
+
return lamdaFunction;
|
|
6639
|
+
}
|
|
6640
|
+
this.parseState.position = positionBefore;
|
|
6567
6641
|
return parseSymbol(this.tokenStream, this.parseState);
|
|
6568
6642
|
}
|
|
6569
6643
|
case 'A_ReservedSymbol':
|
|
6570
6644
|
return parseReservedSymbol(this.tokenStream, this.parseState);
|
|
6645
|
+
case 'RegexpShorthand':
|
|
6646
|
+
return parseRegexpShorthand(this.tokenStream, this.parseState);
|
|
6571
6647
|
case 'PolNotation': {
|
|
6572
6648
|
this.parseState.algebraic = false;
|
|
6573
6649
|
var astNodes = [];
|
|
@@ -6701,11 +6777,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6701
6777
|
builtin.specialExpressions[node.n].validateParameterCount(node);
|
|
6702
6778
|
return node;
|
|
6703
6779
|
}
|
|
6704
|
-
case 'defs':
|
|
6705
6780
|
case 'fn':
|
|
6706
|
-
case '
|
|
6707
|
-
case '
|
|
6708
|
-
case 'doseq':
|
|
6781
|
+
case 'def':
|
|
6782
|
+
case 'defn':
|
|
6709
6783
|
throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
|
|
6710
6784
|
default:
|
|
6711
6785
|
throw new Error("Unknown special expression: ".concat(name_2));
|
|
@@ -6724,6 +6798,11 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6724
6798
|
};
|
|
6725
6799
|
AlgebraicParser.prototype.parseLambdaFunction = function () {
|
|
6726
6800
|
var firstToken = this.peek();
|
|
6801
|
+
if (isLParenToken(firstToken)
|
|
6802
|
+
&& isA_SymbolToken(this.peekAhead(1))
|
|
6803
|
+
&& isA_OperatorToken(this.peekAhead(2), '=>')) {
|
|
6804
|
+
return null;
|
|
6805
|
+
}
|
|
6727
6806
|
try {
|
|
6728
6807
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
6729
6808
|
if (!isA_OperatorToken(this.peek(), '=>')) {
|
|
@@ -6749,6 +6828,18 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6749
6828
|
};
|
|
6750
6829
|
AlgebraicParser.prototype.parseFunctionArguments = function () {
|
|
6751
6830
|
var _a, _b, _c, _d, _e;
|
|
6831
|
+
var firstToken = this.peek();
|
|
6832
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6833
|
+
this.advance();
|
|
6834
|
+
return {
|
|
6835
|
+
functionArguments: {
|
|
6836
|
+
m: [firstToken[1]],
|
|
6837
|
+
b: [],
|
|
6838
|
+
r: undefined,
|
|
6839
|
+
},
|
|
6840
|
+
arity: 1,
|
|
6841
|
+
};
|
|
6842
|
+
}
|
|
6752
6843
|
this.advance();
|
|
6753
6844
|
var rest = false;
|
|
6754
6845
|
var letBindingObject;
|
|
@@ -6867,17 +6958,20 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6867
6958
|
};
|
|
6868
6959
|
return node;
|
|
6869
6960
|
};
|
|
6870
|
-
AlgebraicParser.prototype.parseLet = function (token) {
|
|
6961
|
+
AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
|
|
6962
|
+
if (optionalSemicolon === void 0) { optionalSemicolon = false; }
|
|
6871
6963
|
this.advance();
|
|
6872
6964
|
var letSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6873
6965
|
assertA_OperatorToken(this.peek(), '=');
|
|
6874
6966
|
this.advance();
|
|
6875
6967
|
var value = this.parseExpression();
|
|
6968
|
+
if (!optionalSemicolon) {
|
|
6969
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
6970
|
+
}
|
|
6876
6971
|
return {
|
|
6877
6972
|
t: AstNodeType.SpecialExpression,
|
|
6878
6973
|
n: 'let',
|
|
6879
6974
|
p: [],
|
|
6880
|
-
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
6881
6975
|
bs: [{
|
|
6882
6976
|
t: AstNodeType.Binding,
|
|
6883
6977
|
n: letSymbol.v,
|
|
@@ -6885,6 +6979,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
6885
6979
|
p: [],
|
|
6886
6980
|
token: getTokenDebugData(token) && token,
|
|
6887
6981
|
}],
|
|
6982
|
+
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
6888
6983
|
};
|
|
6889
6984
|
};
|
|
6890
6985
|
AlgebraicParser.prototype.parseDo = function (token) {
|
|
@@ -7052,7 +7147,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7052
7147
|
modifiers.push('&let');
|
|
7053
7148
|
letBindings = [];
|
|
7054
7149
|
while (isA_SymbolToken(token, 'let')) {
|
|
7055
|
-
var letNode = this.parseLet(token);
|
|
7150
|
+
var letNode = this.parseLet(token, true);
|
|
7056
7151
|
letBindings.push(letNode.bs[0]);
|
|
7057
7152
|
token = this.peek();
|
|
7058
7153
|
}
|
|
@@ -7239,20 +7334,7 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7239
7334
|
token: getTokenDebugData(token) && token,
|
|
7240
7335
|
};
|
|
7241
7336
|
};
|
|
7242
|
-
AlgebraicParser.prototype.
|
|
7243
|
-
this.advance();
|
|
7244
|
-
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7245
|
-
assertA_OperatorToken(this.peek(), '=');
|
|
7246
|
-
this.advance();
|
|
7247
|
-
var value = this.parseExpression();
|
|
7248
|
-
return {
|
|
7249
|
-
t: AstNodeType.SpecialExpression,
|
|
7250
|
-
n: 'def',
|
|
7251
|
-
p: [symbol, value],
|
|
7252
|
-
token: getTokenDebugData(token) && token,
|
|
7253
|
-
};
|
|
7254
|
-
};
|
|
7255
|
-
AlgebraicParser.prototype.parseDefn = function (token) {
|
|
7337
|
+
AlgebraicParser.prototype.parseFunction = function (token) {
|
|
7256
7338
|
this.advance();
|
|
7257
7339
|
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7258
7340
|
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
@@ -7265,10 +7347,9 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7265
7347
|
}
|
|
7266
7348
|
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7267
7349
|
this.advance();
|
|
7268
|
-
|
|
7350
|
+
var fnNode = {
|
|
7269
7351
|
t: AstNodeType.SpecialExpression,
|
|
7270
|
-
n: '
|
|
7271
|
-
f: symbol,
|
|
7352
|
+
n: 'fn',
|
|
7272
7353
|
p: [],
|
|
7273
7354
|
o: [{
|
|
7274
7355
|
as: functionArguments,
|
|
@@ -7277,6 +7358,19 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7277
7358
|
}],
|
|
7278
7359
|
token: getTokenDebugData(token) && token,
|
|
7279
7360
|
};
|
|
7361
|
+
return {
|
|
7362
|
+
t: AstNodeType.SpecialExpression,
|
|
7363
|
+
n: 'let',
|
|
7364
|
+
p: [],
|
|
7365
|
+
bs: [{
|
|
7366
|
+
t: AstNodeType.Binding,
|
|
7367
|
+
n: symbol.v,
|
|
7368
|
+
v: fnNode,
|
|
7369
|
+
p: [],
|
|
7370
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
7371
|
+
}],
|
|
7372
|
+
token: getTokenDebugData(token) && token,
|
|
7373
|
+
};
|
|
7280
7374
|
};
|
|
7281
7375
|
AlgebraicParser.prototype.isAtEnd = function () {
|
|
7282
7376
|
return this.parseState.position >= this.tokenStream.tokens.length;
|
|
@@ -7297,8 +7391,30 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7297
7391
|
}
|
|
7298
7392
|
return false;
|
|
7299
7393
|
};
|
|
7300
|
-
AlgebraicParser.prototype.
|
|
7301
|
-
|
|
7394
|
+
AlgebraicParser.prototype.parseExport = function (token) {
|
|
7395
|
+
var _a;
|
|
7396
|
+
this.advance();
|
|
7397
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7398
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7399
|
+
return {
|
|
7400
|
+
t: AstNodeType.SpecialExpression,
|
|
7401
|
+
n: 'def',
|
|
7402
|
+
p: [symbol, symbol],
|
|
7403
|
+
token: getTokenDebugData(token) && token,
|
|
7404
|
+
};
|
|
7405
|
+
}
|
|
7406
|
+
if (!isA_OperatorToken(this.peek(), '=')) {
|
|
7407
|
+
throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7408
|
+
}
|
|
7409
|
+
this.advance();
|
|
7410
|
+
var value = this.parseExpression();
|
|
7411
|
+
assertA_OperatorToken(this.peek(), ';');
|
|
7412
|
+
return {
|
|
7413
|
+
t: AstNodeType.SpecialExpression,
|
|
7414
|
+
n: 'def',
|
|
7415
|
+
p: [symbol, value],
|
|
7416
|
+
token: getTokenDebugData(token) && token,
|
|
7417
|
+
};
|
|
7302
7418
|
};
|
|
7303
7419
|
return AlgebraicParser;
|
|
7304
7420
|
}());
|
|
@@ -7374,33 +7490,6 @@ function parseObjectLitteral(tokenStream, parseState) {
|
|
|
7374
7490
|
assertEvenNumberOfParams(node);
|
|
7375
7491
|
return node;
|
|
7376
7492
|
}
|
|
7377
|
-
function parseRegexpShorthand(tokenStream, parseState) {
|
|
7378
|
-
var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
|
|
7379
|
-
var endStringPosition = tkn[1].lastIndexOf('"');
|
|
7380
|
-
var regexpString = tkn[1].substring(2, endStringPosition);
|
|
7381
|
-
var optionsString = tkn[1].substring(endStringPosition + 1);
|
|
7382
|
-
var stringNode = {
|
|
7383
|
-
t: AstNodeType.String,
|
|
7384
|
-
v: regexpString,
|
|
7385
|
-
p: [],
|
|
7386
|
-
n: undefined,
|
|
7387
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
7388
|
-
};
|
|
7389
|
-
var optionsNode = {
|
|
7390
|
-
t: AstNodeType.String,
|
|
7391
|
-
v: optionsString,
|
|
7392
|
-
p: [],
|
|
7393
|
-
n: undefined,
|
|
7394
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
7395
|
-
};
|
|
7396
|
-
var node = {
|
|
7397
|
-
t: AstNodeType.NormalExpression,
|
|
7398
|
-
n: 'regexp',
|
|
7399
|
-
p: [stringNode, optionsNode],
|
|
7400
|
-
token: getTokenDebugData(tkn) && tkn,
|
|
7401
|
-
};
|
|
7402
|
-
return node;
|
|
7403
|
-
}
|
|
7404
7493
|
var placeholderRegexp = /^%([1-9]\d?)?$/;
|
|
7405
7494
|
function parseFnShorthand(tokenStream, parseState) {
|
|
7406
7495
|
var _a, _b, _c, _d;
|
|
@@ -7570,7 +7659,7 @@ function parsePolishToken(tokenStream, parseState) {
|
|
|
7570
7659
|
return parseArrayLitteral(tokenStream, parseState);
|
|
7571
7660
|
case 'LBrace':
|
|
7572
7661
|
return parseObjectLitteral(tokenStream, parseState);
|
|
7573
|
-
case '
|
|
7662
|
+
case 'RegexpShorthand':
|
|
7574
7663
|
return parseRegexpShorthand(tokenStream, parseState);
|
|
7575
7664
|
case 'P_FnShorthand':
|
|
7576
7665
|
return parseFnShorthand(tokenStream, parseState);
|
|
@@ -7734,6 +7823,25 @@ var tokenizeString = function (input, position) {
|
|
|
7734
7823
|
value += '"'; // closing quote
|
|
7735
7824
|
return [length + 1, ['String', value]];
|
|
7736
7825
|
};
|
|
7826
|
+
var tokenizeRegexpShorthand = function (input, position) {
|
|
7827
|
+
if (input[position] !== '#')
|
|
7828
|
+
return NO_MATCH;
|
|
7829
|
+
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
7830
|
+
if (!token)
|
|
7831
|
+
return NO_MATCH;
|
|
7832
|
+
position += stringLength + 1;
|
|
7833
|
+
var length = stringLength + 1;
|
|
7834
|
+
var options = '';
|
|
7835
|
+
while (input[position] === 'g' || input[position] === 'i') {
|
|
7836
|
+
if (options.includes(input[position])) {
|
|
7837
|
+
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
7838
|
+
}
|
|
7839
|
+
options += input[position];
|
|
7840
|
+
length += 1;
|
|
7841
|
+
position += 1;
|
|
7842
|
+
}
|
|
7843
|
+
return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
7844
|
+
};
|
|
7737
7845
|
function tokenizeSimpleToken(type, value, input, position) {
|
|
7738
7846
|
if (value === input.slice(position, position + value.length))
|
|
7739
7847
|
return [value.length, [type]];
|
|
@@ -7751,6 +7859,7 @@ var commonTokenizers = [
|
|
|
7751
7859
|
tokenizeLBrace,
|
|
7752
7860
|
tokenizeRBrace,
|
|
7753
7861
|
tokenizeString,
|
|
7862
|
+
tokenizeRegexpShorthand,
|
|
7754
7863
|
];
|
|
7755
7864
|
|
|
7756
7865
|
var validAlgebraicReservedNamesRecord = {
|
|
@@ -7764,10 +7873,11 @@ var validAlgebraicReservedNamesRecord = {
|
|
|
7764
7873
|
case: { value: null, forbidden: false },
|
|
7765
7874
|
when: { value: null, forbidden: false },
|
|
7766
7875
|
while: { value: null, forbidden: false },
|
|
7876
|
+
function: { value: null, forbidden: false },
|
|
7877
|
+
export: { value: null, forbidden: false },
|
|
7767
7878
|
};
|
|
7768
7879
|
var forbiddenAlgebraicReservedNamesRecord = {
|
|
7769
7880
|
fn: { value: null, forbidden: true },
|
|
7770
|
-
defns: { value: null, forbidden: true },
|
|
7771
7881
|
};
|
|
7772
7882
|
var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
|
|
7773
7883
|
|
|
@@ -8152,25 +8262,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
|
|
|
8152
8262
|
return NO_MATCH;
|
|
8153
8263
|
return [1, ['P_CollectionAccessor', char]];
|
|
8154
8264
|
};
|
|
8155
|
-
var tokenizeP_RegexpShorthand = function (input, position) {
|
|
8156
|
-
if (input[position] !== '#')
|
|
8157
|
-
return NO_MATCH;
|
|
8158
|
-
var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
|
|
8159
|
-
if (!token)
|
|
8160
|
-
return NO_MATCH;
|
|
8161
|
-
position += stringLength + 1;
|
|
8162
|
-
var length = stringLength + 1;
|
|
8163
|
-
var options = '';
|
|
8164
|
-
while (input[position] === 'g' || input[position] === 'i') {
|
|
8165
|
-
if (options.includes(input[position])) {
|
|
8166
|
-
throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
|
|
8167
|
-
}
|
|
8168
|
-
options += input[position];
|
|
8169
|
-
length += 1;
|
|
8170
|
-
position += 1;
|
|
8171
|
-
}
|
|
8172
|
-
return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
|
|
8173
|
-
};
|
|
8174
8265
|
// All tokenizers, order matters!
|
|
8175
8266
|
var polishTokenizers = __spreadArray(__spreadArray([
|
|
8176
8267
|
tokenizeP_Whitespace,
|
|
@@ -8181,7 +8272,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
|
|
|
8181
8272
|
tokenizeP_ReservedSymbol,
|
|
8182
8273
|
tokenizeP_Modifier,
|
|
8183
8274
|
tokenizeP_Symbol,
|
|
8184
|
-
tokenizeP_RegexpShorthand,
|
|
8185
8275
|
tokenizeP_FnShorthand,
|
|
8186
8276
|
tokenizeP_CollectionAccessor,
|
|
8187
8277
|
], false);
|
|
@@ -9500,7 +9590,7 @@ var arrayReference = {
|
|
|
9500
9590
|
};
|
|
9501
9591
|
|
|
9502
9592
|
var sequenceReference = {
|
|
9503
|
-
nth: {
|
|
9593
|
+
'nth': {
|
|
9504
9594
|
title: 'nth',
|
|
9505
9595
|
category: 'Sequence',
|
|
9506
9596
|
linkName: 'nth',
|
|
@@ -9536,7 +9626,7 @@ var sequenceReference = {
|
|
|
9536
9626
|
'(nth nil 1 "Default value")',
|
|
9537
9627
|
],
|
|
9538
9628
|
},
|
|
9539
|
-
push: {
|
|
9629
|
+
'push': {
|
|
9540
9630
|
title: 'push',
|
|
9541
9631
|
category: 'Sequence',
|
|
9542
9632
|
linkName: 'push',
|
|
@@ -9566,7 +9656,7 @@ var sequenceReference = {
|
|
|
9566
9656
|
'(def l [1 2 3]) (push l 4) l',
|
|
9567
9657
|
],
|
|
9568
9658
|
},
|
|
9569
|
-
pop: {
|
|
9659
|
+
'pop': {
|
|
9570
9660
|
title: 'pop',
|
|
9571
9661
|
category: 'Sequence',
|
|
9572
9662
|
linkName: 'pop',
|
|
@@ -9589,7 +9679,7 @@ var sequenceReference = {
|
|
|
9589
9679
|
'(pop [])',
|
|
9590
9680
|
],
|
|
9591
9681
|
},
|
|
9592
|
-
unshift: {
|
|
9682
|
+
'unshift': {
|
|
9593
9683
|
title: 'unshift',
|
|
9594
9684
|
category: 'Sequence',
|
|
9595
9685
|
linkName: 'unshift',
|
|
@@ -9618,7 +9708,7 @@ var sequenceReference = {
|
|
|
9618
9708
|
"\n(def l [1 2 3])\n(unshift l 4)\nl",
|
|
9619
9709
|
],
|
|
9620
9710
|
},
|
|
9621
|
-
shift: {
|
|
9711
|
+
'shift': {
|
|
9622
9712
|
title: 'shift',
|
|
9623
9713
|
category: 'Sequence',
|
|
9624
9714
|
linkName: 'shift',
|
|
@@ -9642,7 +9732,7 @@ var sequenceReference = {
|
|
|
9642
9732
|
'(shift [])',
|
|
9643
9733
|
],
|
|
9644
9734
|
},
|
|
9645
|
-
slice: {
|
|
9735
|
+
'slice': {
|
|
9646
9736
|
title: 'slice',
|
|
9647
9737
|
category: 'Sequence',
|
|
9648
9738
|
linkName: 'slice',
|
|
@@ -9676,7 +9766,7 @@ var sequenceReference = {
|
|
|
9676
9766
|
'(slice [1 2 3 4 5] 2)',
|
|
9677
9767
|
],
|
|
9678
9768
|
},
|
|
9679
|
-
reductions: {
|
|
9769
|
+
'reductions': {
|
|
9680
9770
|
title: 'reductions',
|
|
9681
9771
|
category: 'Sequence',
|
|
9682
9772
|
linkName: 'reductions',
|
|
@@ -9708,7 +9798,7 @@ var sequenceReference = {
|
|
|
9708
9798
|
"\n(reductions\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
9709
9799
|
],
|
|
9710
9800
|
},
|
|
9711
|
-
reduce: {
|
|
9801
|
+
'reduce': {
|
|
9712
9802
|
title: 'reduce',
|
|
9713
9803
|
category: 'Sequence',
|
|
9714
9804
|
linkName: 'reduce',
|
|
@@ -9738,7 +9828,7 @@ var sequenceReference = {
|
|
|
9738
9828
|
"\n(reduce\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
|
|
9739
9829
|
],
|
|
9740
9830
|
},
|
|
9741
|
-
reduce_right: {
|
|
9831
|
+
'reduce_right': {
|
|
9742
9832
|
title: 'reduce_right',
|
|
9743
9833
|
category: 'Sequence',
|
|
9744
9834
|
linkName: 'reduce_right',
|
|
@@ -9766,7 +9856,7 @@ var sequenceReference = {
|
|
|
9766
9856
|
'(reduce_right str [:A :B :C] "")',
|
|
9767
9857
|
],
|
|
9768
9858
|
},
|
|
9769
|
-
map: {
|
|
9859
|
+
'map': {
|
|
9770
9860
|
title: 'map',
|
|
9771
9861
|
category: 'Sequence',
|
|
9772
9862
|
linkName: 'map',
|
|
@@ -9791,7 +9881,7 @@ var sequenceReference = {
|
|
|
9791
9881
|
'(map [1 2 3] inc)',
|
|
9792
9882
|
],
|
|
9793
9883
|
},
|
|
9794
|
-
filter: {
|
|
9884
|
+
'filter': {
|
|
9795
9885
|
title: 'filter',
|
|
9796
9886
|
category: 'Sequence',
|
|
9797
9887
|
linkName: 'filter',
|
|
@@ -9815,7 +9905,7 @@ var sequenceReference = {
|
|
|
9815
9905
|
"\n(filter\n[5 10 15 20]\n (fn [x] (> x 10)))",
|
|
9816
9906
|
],
|
|
9817
9907
|
},
|
|
9818
|
-
position: {
|
|
9908
|
+
'position': {
|
|
9819
9909
|
title: 'position',
|
|
9820
9910
|
category: 'Sequence',
|
|
9821
9911
|
linkName: 'position',
|
|
@@ -9842,7 +9932,7 @@ var sequenceReference = {
|
|
|
9842
9932
|
"\n(position\n (fn [x] (> x 100))\n nil)",
|
|
9843
9933
|
],
|
|
9844
9934
|
},
|
|
9845
|
-
index_of: {
|
|
9935
|
+
'index_of': {
|
|
9846
9936
|
title: 'index_of',
|
|
9847
9937
|
category: 'Sequence',
|
|
9848
9938
|
linkName: 'index_of',
|
|
@@ -9869,7 +9959,34 @@ var sequenceReference = {
|
|
|
9869
9959
|
'(index_of nil 1)',
|
|
9870
9960
|
],
|
|
9871
9961
|
},
|
|
9872
|
-
|
|
9962
|
+
'last_index_of': {
|
|
9963
|
+
title: 'last_index_of',
|
|
9964
|
+
category: 'Sequence',
|
|
9965
|
+
linkName: 'last_index_of',
|
|
9966
|
+
clojureDocs: null,
|
|
9967
|
+
returns: {
|
|
9968
|
+
type: ['number', 'null'],
|
|
9969
|
+
},
|
|
9970
|
+
args: {
|
|
9971
|
+
seq: {
|
|
9972
|
+
type: ['sequence', 'null'],
|
|
9973
|
+
},
|
|
9974
|
+
x: {
|
|
9975
|
+
type: 'any',
|
|
9976
|
+
},
|
|
9977
|
+
},
|
|
9978
|
+
variants: [
|
|
9979
|
+
{ argumentNames: ['seq', 'x'] },
|
|
9980
|
+
],
|
|
9981
|
+
description: 'Returns the last index of $x in $seq. If element is not present in $seq `nil` is returned.',
|
|
9982
|
+
examples: [
|
|
9983
|
+
'(last_index_of ["Albert" "Mojir" 160 [1 2]] "Mojir")',
|
|
9984
|
+
'(last_index_of [5 10 15 20] 15)',
|
|
9985
|
+
'(last_index_of [5 10 15 20] 1)',
|
|
9986
|
+
'(last_index_of nil 1)',
|
|
9987
|
+
],
|
|
9988
|
+
},
|
|
9989
|
+
'some': {
|
|
9873
9990
|
title: 'some',
|
|
9874
9991
|
category: 'Sequence',
|
|
9875
9992
|
linkName: 'some',
|
|
@@ -9896,7 +10013,7 @@ var sequenceReference = {
|
|
|
9896
10013
|
"\n(some\n nil\n (fn [x] (> x 10)))",
|
|
9897
10014
|
],
|
|
9898
10015
|
},
|
|
9899
|
-
reverse: {
|
|
10016
|
+
'reverse': {
|
|
9900
10017
|
title: 'reverse',
|
|
9901
10018
|
category: 'Sequence',
|
|
9902
10019
|
linkName: 'reverse',
|
|
@@ -9919,7 +10036,7 @@ var sequenceReference = {
|
|
|
9919
10036
|
'(reverse nil)',
|
|
9920
10037
|
],
|
|
9921
10038
|
},
|
|
9922
|
-
first: {
|
|
10039
|
+
'first': {
|
|
9923
10040
|
title: 'first',
|
|
9924
10041
|
category: 'Sequence',
|
|
9925
10042
|
linkName: 'first',
|
|
@@ -9941,7 +10058,7 @@ var sequenceReference = {
|
|
|
9941
10058
|
'(first nil)',
|
|
9942
10059
|
],
|
|
9943
10060
|
},
|
|
9944
|
-
second: {
|
|
10061
|
+
'second': {
|
|
9945
10062
|
title: 'second',
|
|
9946
10063
|
category: 'Sequence',
|
|
9947
10064
|
linkName: 'second',
|
|
@@ -9964,7 +10081,7 @@ var sequenceReference = {
|
|
|
9964
10081
|
'(second nil)',
|
|
9965
10082
|
],
|
|
9966
10083
|
},
|
|
9967
|
-
last: {
|
|
10084
|
+
'last': {
|
|
9968
10085
|
title: 'last',
|
|
9969
10086
|
category: 'Sequence',
|
|
9970
10087
|
linkName: 'last',
|
|
@@ -9988,7 +10105,7 @@ var sequenceReference = {
|
|
|
9988
10105
|
'(last nil)',
|
|
9989
10106
|
],
|
|
9990
10107
|
},
|
|
9991
|
-
rest: {
|
|
10108
|
+
'rest': {
|
|
9992
10109
|
title: 'rest',
|
|
9993
10110
|
category: 'Sequence',
|
|
9994
10111
|
linkName: 'rest',
|
|
@@ -10013,7 +10130,7 @@ var sequenceReference = {
|
|
|
10013
10130
|
'(rest "")',
|
|
10014
10131
|
],
|
|
10015
10132
|
},
|
|
10016
|
-
nthrest: {
|
|
10133
|
+
'nthrest': {
|
|
10017
10134
|
title: 'nthrest',
|
|
10018
10135
|
category: 'Sequence',
|
|
10019
10136
|
linkName: 'nthrest',
|
|
@@ -10041,7 +10158,7 @@ var sequenceReference = {
|
|
|
10041
10158
|
'(nthrest "" 0)',
|
|
10042
10159
|
],
|
|
10043
10160
|
},
|
|
10044
|
-
next: {
|
|
10161
|
+
'next': {
|
|
10045
10162
|
title: 'next',
|
|
10046
10163
|
category: 'Sequence',
|
|
10047
10164
|
linkName: 'next',
|
|
@@ -10066,7 +10183,7 @@ var sequenceReference = {
|
|
|
10066
10183
|
'(next "")',
|
|
10067
10184
|
],
|
|
10068
10185
|
},
|
|
10069
|
-
nthnext: {
|
|
10186
|
+
'nthnext': {
|
|
10070
10187
|
title: 'nthnext',
|
|
10071
10188
|
category: 'Sequence',
|
|
10072
10189
|
linkName: 'nthnext',
|
|
@@ -10094,7 +10211,7 @@ var sequenceReference = {
|
|
|
10094
10211
|
'(nthnext "" 0)',
|
|
10095
10212
|
],
|
|
10096
10213
|
},
|
|
10097
|
-
take: {
|
|
10214
|
+
'take': {
|
|
10098
10215
|
title: 'take',
|
|
10099
10216
|
category: 'Sequence',
|
|
10100
10217
|
linkName: 'take',
|
|
@@ -10120,7 +10237,7 @@ var sequenceReference = {
|
|
|
10120
10237
|
'(take 50 "Albert")',
|
|
10121
10238
|
],
|
|
10122
10239
|
},
|
|
10123
|
-
take_last: {
|
|
10240
|
+
'take_last': {
|
|
10124
10241
|
title: 'take_last',
|
|
10125
10242
|
category: 'Sequence',
|
|
10126
10243
|
linkName: 'take_last',
|
|
@@ -10144,7 +10261,7 @@ var sequenceReference = {
|
|
|
10144
10261
|
'(take_last 0 [1 2 3 4 5])',
|
|
10145
10262
|
],
|
|
10146
10263
|
},
|
|
10147
|
-
take_while: {
|
|
10264
|
+
'take_while': {
|
|
10148
10265
|
title: 'take_while',
|
|
10149
10266
|
category: 'Sequence',
|
|
10150
10267
|
linkName: 'take_while',
|
|
@@ -10168,7 +10285,7 @@ var sequenceReference = {
|
|
|
10168
10285
|
"\n(take_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10169
10286
|
],
|
|
10170
10287
|
},
|
|
10171
|
-
drop: {
|
|
10288
|
+
'drop': {
|
|
10172
10289
|
title: 'drop',
|
|
10173
10290
|
category: 'Sequence',
|
|
10174
10291
|
linkName: 'drop',
|
|
@@ -10194,7 +10311,7 @@ var sequenceReference = {
|
|
|
10194
10311
|
'(drop "Albert" 50)',
|
|
10195
10312
|
],
|
|
10196
10313
|
},
|
|
10197
|
-
drop_last: {
|
|
10314
|
+
'drop_last': {
|
|
10198
10315
|
title: 'drop_last',
|
|
10199
10316
|
category: 'Sequence',
|
|
10200
10317
|
linkName: 'drop_last',
|
|
@@ -10218,7 +10335,7 @@ var sequenceReference = {
|
|
|
10218
10335
|
'(drop_last [1 2 3 4 5] 0)',
|
|
10219
10336
|
],
|
|
10220
10337
|
},
|
|
10221
|
-
drop_while: {
|
|
10338
|
+
'drop_while': {
|
|
10222
10339
|
title: 'drop_while',
|
|
10223
10340
|
category: 'Sequence',
|
|
10224
10341
|
linkName: 'drop_while',
|
|
@@ -10242,7 +10359,7 @@ var sequenceReference = {
|
|
|
10242
10359
|
"\n(drop_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
|
|
10243
10360
|
],
|
|
10244
10361
|
},
|
|
10245
|
-
sort: {
|
|
10362
|
+
'sort': {
|
|
10246
10363
|
title: 'sort',
|
|
10247
10364
|
category: 'Sequence',
|
|
10248
10365
|
linkName: 'sort',
|
|
@@ -10269,7 +10386,7 @@ var sequenceReference = {
|
|
|
10269
10386
|
"\n(sort\n [3 1 2]\n (fn [a b] (cond (> a b) -1 (< a b) 1 true -1)))",
|
|
10270
10387
|
],
|
|
10271
10388
|
},
|
|
10272
|
-
sort_by: {
|
|
10389
|
+
'sort_by': {
|
|
10273
10390
|
title: 'sort_by',
|
|
10274
10391
|
category: 'Sequence',
|
|
10275
10392
|
linkName: 'sort_by',
|
|
@@ -10298,7 +10415,7 @@ var sequenceReference = {
|
|
|
10298
10415
|
'(sort_by "Albert" lower_case #(compare %2 %1))',
|
|
10299
10416
|
],
|
|
10300
10417
|
},
|
|
10301
|
-
distinct: {
|
|
10418
|
+
'distinct': {
|
|
10302
10419
|
title: 'distinct',
|
|
10303
10420
|
category: 'Sequence',
|
|
10304
10421
|
linkName: 'distinct',
|
|
@@ -10321,7 +10438,7 @@ var sequenceReference = {
|
|
|
10321
10438
|
'(distinct "")',
|
|
10322
10439
|
],
|
|
10323
10440
|
},
|
|
10324
|
-
remove: {
|
|
10441
|
+
'remove': {
|
|
10325
10442
|
title: 'remove',
|
|
10326
10443
|
category: 'Sequence',
|
|
10327
10444
|
linkName: 'remove',
|
|
@@ -10345,7 +10462,7 @@ var sequenceReference = {
|
|
|
10345
10462
|
'(remove "Albert Mojir" #(has? "aoueiyAOUEIY" %1))',
|
|
10346
10463
|
],
|
|
10347
10464
|
},
|
|
10348
|
-
remove_at: {
|
|
10465
|
+
'remove_at': {
|
|
10349
10466
|
title: 'remove_at',
|
|
10350
10467
|
category: 'Sequence',
|
|
10351
10468
|
linkName: 'remove_at',
|
|
@@ -10371,7 +10488,7 @@ var sequenceReference = {
|
|
|
10371
10488
|
'(remove_at "Albert Mojir" 6)',
|
|
10372
10489
|
],
|
|
10373
10490
|
},
|
|
10374
|
-
split_at: {
|
|
10491
|
+
'split_at': {
|
|
10375
10492
|
title: 'split_at',
|
|
10376
10493
|
category: 'Sequence',
|
|
10377
10494
|
linkName: 'split_at',
|
|
@@ -10396,7 +10513,7 @@ var sequenceReference = {
|
|
|
10396
10513
|
'(split_at "Albert" 2)',
|
|
10397
10514
|
],
|
|
10398
10515
|
},
|
|
10399
|
-
split_with: {
|
|
10516
|
+
'split_with': {
|
|
10400
10517
|
title: 'split_with',
|
|
10401
10518
|
category: 'Sequence',
|
|
10402
10519
|
linkName: 'split_with',
|
|
@@ -10421,7 +10538,7 @@ var sequenceReference = {
|
|
|
10421
10538
|
'(split_with "Albert" #(<= %1 :Z))',
|
|
10422
10539
|
],
|
|
10423
10540
|
},
|
|
10424
|
-
frequencies: {
|
|
10541
|
+
'frequencies': {
|
|
10425
10542
|
title: 'frequencies',
|
|
10426
10543
|
category: 'Sequence',
|
|
10427
10544
|
linkName: 'frequencies',
|
|
@@ -10442,7 +10559,7 @@ var sequenceReference = {
|
|
|
10442
10559
|
'(frequencies "Pneumonoultramicroscopicsilicovolcanoconiosis")',
|
|
10443
10560
|
],
|
|
10444
10561
|
},
|
|
10445
|
-
group_by: {
|
|
10562
|
+
'group_by': {
|
|
10446
10563
|
title: 'group_by',
|
|
10447
10564
|
category: 'Sequence',
|
|
10448
10565
|
linkName: 'group_by',
|
|
@@ -10466,7 +10583,7 @@ var sequenceReference = {
|
|
|
10466
10583
|
'(group_by "Albert Mojir" (fn [char] (if (has? "aoueiAOUEI" char) "vowel" "other")))',
|
|
10467
10584
|
],
|
|
10468
10585
|
},
|
|
10469
|
-
partition: {
|
|
10586
|
+
'partition': {
|
|
10470
10587
|
title: 'partition',
|
|
10471
10588
|
category: 'Sequence',
|
|
10472
10589
|
linkName: 'partition',
|
|
@@ -10511,7 +10628,7 @@ var sequenceReference = {
|
|
|
10511
10628
|
'(def foo [5 6 7 8]) (partition foo 2 1 foo)',
|
|
10512
10629
|
],
|
|
10513
10630
|
},
|
|
10514
|
-
partition_all: {
|
|
10631
|
+
'partition_all': {
|
|
10515
10632
|
title: 'partition_all',
|
|
10516
10633
|
category: 'Sequence',
|
|
10517
10634
|
linkName: 'partition_all',
|
|
@@ -10540,7 +10657,7 @@ var sequenceReference = {
|
|
|
10540
10657
|
'(partition_all [0 1 2 3 4 5 6 7 8 9] 2 4)',
|
|
10541
10658
|
],
|
|
10542
10659
|
},
|
|
10543
|
-
partition_by: {
|
|
10660
|
+
'partition_by': {
|
|
10544
10661
|
title: 'partition_by',
|
|
10545
10662
|
category: 'Sequence',
|
|
10546
10663
|
linkName: 'partition_by',
|
|
@@ -10565,6 +10682,114 @@ var sequenceReference = {
|
|
|
10565
10682
|
'(partition_by "Leeeeeerrroyyy" identity)',
|
|
10566
10683
|
],
|
|
10567
10684
|
},
|
|
10685
|
+
'starts_with?': {
|
|
10686
|
+
title: 'starts_with?',
|
|
10687
|
+
category: 'Sequence',
|
|
10688
|
+
linkName: 'starts_with-question',
|
|
10689
|
+
clojureDocs: null,
|
|
10690
|
+
returns: {
|
|
10691
|
+
type: 'boolean',
|
|
10692
|
+
},
|
|
10693
|
+
args: {
|
|
10694
|
+
seq: {
|
|
10695
|
+
type: 'sequence',
|
|
10696
|
+
},
|
|
10697
|
+
prefix: {
|
|
10698
|
+
type: 'sequence',
|
|
10699
|
+
},
|
|
10700
|
+
},
|
|
10701
|
+
variants: [
|
|
10702
|
+
{ argumentNames: ['seq', 'prefix'] },
|
|
10703
|
+
],
|
|
10704
|
+
description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',
|
|
10705
|
+
examples: [
|
|
10706
|
+
'(starts_with? [1 2 3 4 5] 1)',
|
|
10707
|
+
'(starts_with? [1 2 3 4 5] [1])',
|
|
10708
|
+
'(starts_with? "Albert" "Al")',
|
|
10709
|
+
'(starts_with? "Albert" "al")',
|
|
10710
|
+
],
|
|
10711
|
+
},
|
|
10712
|
+
'ends_with?': {
|
|
10713
|
+
title: 'ends_with?',
|
|
10714
|
+
category: 'Sequence',
|
|
10715
|
+
linkName: 'ends_with-question',
|
|
10716
|
+
clojureDocs: null,
|
|
10717
|
+
returns: {
|
|
10718
|
+
type: 'boolean',
|
|
10719
|
+
},
|
|
10720
|
+
args: {
|
|
10721
|
+
seq: {
|
|
10722
|
+
type: 'sequence',
|
|
10723
|
+
},
|
|
10724
|
+
suffix: {
|
|
10725
|
+
type: 'sequence',
|
|
10726
|
+
},
|
|
10727
|
+
},
|
|
10728
|
+
variants: [
|
|
10729
|
+
{ argumentNames: ['seq', 'suffix'] },
|
|
10730
|
+
],
|
|
10731
|
+
description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',
|
|
10732
|
+
examples: [
|
|
10733
|
+
'(ends_with? [1 2 3 4 5] 5)',
|
|
10734
|
+
'(ends_with? [1 2 3 4 5] [5])',
|
|
10735
|
+
'(ends_with? "Albert" "rt")',
|
|
10736
|
+
'(ends_with? "Albert" "RT")',
|
|
10737
|
+
],
|
|
10738
|
+
},
|
|
10739
|
+
'interleave': {
|
|
10740
|
+
title: 'interleave',
|
|
10741
|
+
category: 'Sequence',
|
|
10742
|
+
linkName: 'interleave',
|
|
10743
|
+
clojureDocs: null,
|
|
10744
|
+
returns: {
|
|
10745
|
+
type: 'sequence',
|
|
10746
|
+
},
|
|
10747
|
+
args: {
|
|
10748
|
+
seqs: {
|
|
10749
|
+
type: 'sequence',
|
|
10750
|
+
array: true,
|
|
10751
|
+
},
|
|
10752
|
+
},
|
|
10753
|
+
variants: [
|
|
10754
|
+
{ argumentNames: ['seqs'] },
|
|
10755
|
+
],
|
|
10756
|
+
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.',
|
|
10757
|
+
examples: [
|
|
10758
|
+
'(interleave [1 2 3] [4 5 6])',
|
|
10759
|
+
'(interleave [1 2 3] [4 5 6] [7 8 9])',
|
|
10760
|
+
'(interleave [1 2 3] [4 5 6] [7 8])',
|
|
10761
|
+
'(interleave [1 2 3] [4 5 6] [7])',
|
|
10762
|
+
'(interleave [1 2 3] [4 5 6] [])',
|
|
10763
|
+
'(interleave [1 2 3] [])',
|
|
10764
|
+
'(interleave [])',
|
|
10765
|
+
],
|
|
10766
|
+
},
|
|
10767
|
+
'interpose': {
|
|
10768
|
+
title: 'interpose',
|
|
10769
|
+
category: 'Sequence',
|
|
10770
|
+
linkName: 'interpose',
|
|
10771
|
+
clojureDocs: null,
|
|
10772
|
+
returns: {
|
|
10773
|
+
type: 'sequence',
|
|
10774
|
+
},
|
|
10775
|
+
args: {
|
|
10776
|
+
seq: {
|
|
10777
|
+
type: 'sequence',
|
|
10778
|
+
},
|
|
10779
|
+
separator: {
|
|
10780
|
+
type: 'any',
|
|
10781
|
+
},
|
|
10782
|
+
},
|
|
10783
|
+
variants: [
|
|
10784
|
+
{ argumentNames: ['seq', 'separator'] },
|
|
10785
|
+
],
|
|
10786
|
+
description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',
|
|
10787
|
+
examples: [
|
|
10788
|
+
'(interpose :a [1 2 3 4 5])',
|
|
10789
|
+
'(interpose " " ["Albert" "Mojir" "Nina"])',
|
|
10790
|
+
'(interpose "." "Albert")',
|
|
10791
|
+
],
|
|
10792
|
+
},
|
|
10568
10793
|
};
|
|
10569
10794
|
|
|
10570
10795
|
var mathReference = {
|
|
@@ -13159,12 +13384,12 @@ var regularExpressionReference = {
|
|
|
13159
13384
|
],
|
|
13160
13385
|
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.",
|
|
13161
13386
|
examples: [
|
|
13162
|
-
'(match (regexp "^\\s*(.*)$")
|
|
13163
|
-
'(match
|
|
13164
|
-
'(match
|
|
13165
|
-
'(match #"albert"i
|
|
13166
|
-
'(match #"albert"i
|
|
13167
|
-
'(match #"albert"i
|
|
13387
|
+
'(match " A string" (regexp "^\\s*(.*)$"))',
|
|
13388
|
+
'(match "My name is Albert" #"albert"i)',
|
|
13389
|
+
'(match "My name is Ben" #"albert"i)',
|
|
13390
|
+
'(match nil #"albert"i)',
|
|
13391
|
+
'(match 1 #"albert"i)',
|
|
13392
|
+
'(match {} #"albert"i)',
|
|
13168
13393
|
],
|
|
13169
13394
|
},
|
|
13170
13395
|
replace: {
|
|
@@ -13181,7 +13406,7 @@ var regularExpressionReference = {
|
|
|
13181
13406
|
type: 'string',
|
|
13182
13407
|
},
|
|
13183
13408
|
r: {
|
|
13184
|
-
type: 'regexp',
|
|
13409
|
+
type: ['regexp', 'string'],
|
|
13185
13410
|
},
|
|
13186
13411
|
x: {
|
|
13187
13412
|
type: 'string',
|
|
@@ -13190,13 +13415,49 @@ var regularExpressionReference = {
|
|
|
13190
13415
|
variants: [
|
|
13191
13416
|
{ argumentNames: ['s', 'r', 'x'] },
|
|
13192
13417
|
],
|
|
13193
|
-
description: 'Returns a new string with
|
|
13418
|
+
description: 'Returns a new string with first match of regular expression $r replaced by $x.',
|
|
13194
13419
|
examples: [
|
|
13195
|
-
'(replace "Duck"
|
|
13420
|
+
'(replace "Duck duck" "u" :i)',
|
|
13421
|
+
'(replace "Duck duck" (regexp :u) :i)',
|
|
13422
|
+
'(replace "abcABC" (regexp :a "i") "-")',
|
|
13196
13423
|
'(replace "abcABC" (regexp :a "gi") "-")',
|
|
13424
|
+
'(replace "abcABC" #"a"i "-")',
|
|
13197
13425
|
'(replace "abcABC" #"a"gi "-")',
|
|
13198
13426
|
],
|
|
13199
13427
|
},
|
|
13428
|
+
replace_all: {
|
|
13429
|
+
title: 'replace_all',
|
|
13430
|
+
category: 'Regular expression',
|
|
13431
|
+
linkName: 'replace_all',
|
|
13432
|
+
clojureDocs: null,
|
|
13433
|
+
returns: {
|
|
13434
|
+
type: 'any',
|
|
13435
|
+
array: true,
|
|
13436
|
+
},
|
|
13437
|
+
args: {
|
|
13438
|
+
s: {
|
|
13439
|
+
type: 'string',
|
|
13440
|
+
},
|
|
13441
|
+
r: {
|
|
13442
|
+
type: ['regexp', 'string'],
|
|
13443
|
+
},
|
|
13444
|
+
x: {
|
|
13445
|
+
type: 'string',
|
|
13446
|
+
},
|
|
13447
|
+
},
|
|
13448
|
+
variants: [
|
|
13449
|
+
{ argumentNames: ['s', 'r', 'x'] },
|
|
13450
|
+
],
|
|
13451
|
+
description: 'Returns a new string with all matches of regular expression $r replaced by $x.',
|
|
13452
|
+
examples: [
|
|
13453
|
+
'(replace_all "Duck duck" "u" :i)',
|
|
13454
|
+
'(replace_all "Duck duck" (regexp :u) :i)',
|
|
13455
|
+
'(replace_all "abcABC" (regexp :a "i") "-")',
|
|
13456
|
+
'(replace_all "abcABC" (regexp :a "gi") "-")',
|
|
13457
|
+
'(replace_all "abcABC" #"a"i "-")',
|
|
13458
|
+
'(replace_all "abcABC" #"a"gi "-")',
|
|
13459
|
+
],
|
|
13460
|
+
},
|
|
13200
13461
|
};
|
|
13201
13462
|
|
|
13202
13463
|
var specialExpressionsReference = {
|
|
@@ -13275,32 +13536,6 @@ var specialExpressionsReference = {
|
|
|
13275
13536
|
'(def a (object :x 10 :y true :z "A string"))',
|
|
13276
13537
|
],
|
|
13277
13538
|
},
|
|
13278
|
-
'defs': {
|
|
13279
|
-
title: 'defs',
|
|
13280
|
-
category: 'Special expression',
|
|
13281
|
-
linkName: 'defs',
|
|
13282
|
-
clojureDocs: null,
|
|
13283
|
-
returns: {
|
|
13284
|
-
type: 'any',
|
|
13285
|
-
},
|
|
13286
|
-
args: {
|
|
13287
|
-
name: {
|
|
13288
|
-
type: '*expression',
|
|
13289
|
-
},
|
|
13290
|
-
value: {
|
|
13291
|
-
type: '*expression',
|
|
13292
|
-
},
|
|
13293
|
-
},
|
|
13294
|
-
variants: [
|
|
13295
|
-
{ argumentNames: ['name', 'value'] },
|
|
13296
|
-
],
|
|
13297
|
-
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.",
|
|
13298
|
-
examples: [
|
|
13299
|
-
'(defs :a :b)',
|
|
13300
|
-
"\n(defs (str :a :1) (object :x 10 :y true :z \"A string\"))\na1",
|
|
13301
|
-
"\n(defs :a :b)\n(defs a :c)\nb",
|
|
13302
|
-
],
|
|
13303
|
-
},
|
|
13304
13539
|
'let': {
|
|
13305
13540
|
title: 'let',
|
|
13306
13541
|
category: 'Special expression',
|
|
@@ -13374,36 +13609,6 @@ var specialExpressionsReference = {
|
|
|
13374
13609
|
"\n(defn sumOfSquares [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
13375
13610
|
],
|
|
13376
13611
|
},
|
|
13377
|
-
'defns': {
|
|
13378
|
-
title: 'defns',
|
|
13379
|
-
category: 'Special expression',
|
|
13380
|
-
linkName: 'defns',
|
|
13381
|
-
clojureDocs: null,
|
|
13382
|
-
returns: {
|
|
13383
|
-
type: 'function',
|
|
13384
|
-
},
|
|
13385
|
-
args: {
|
|
13386
|
-
name: {
|
|
13387
|
-
type: '*expression',
|
|
13388
|
-
},
|
|
13389
|
-
args: {
|
|
13390
|
-
type: '*arguments',
|
|
13391
|
-
},
|
|
13392
|
-
expressions: {
|
|
13393
|
-
type: '*expression',
|
|
13394
|
-
rest: true,
|
|
13395
|
-
},
|
|
13396
|
-
},
|
|
13397
|
-
variants: [
|
|
13398
|
-
{ argumentNames: ['name', 'args', 'expressions'] },
|
|
13399
|
-
],
|
|
13400
|
-
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.',
|
|
13401
|
-
examples: [
|
|
13402
|
-
"\n(defns \"hyp\" [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\nhyp",
|
|
13403
|
-
"\n(defns\n (str :h :y :p)\n [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\n(hyp 3 4)",
|
|
13404
|
-
"\n(defns \"sumOfSquares\" [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
|
|
13405
|
-
],
|
|
13406
|
-
},
|
|
13407
13612
|
'try': {
|
|
13408
13613
|
title: 'try',
|
|
13409
13614
|
category: 'Special expression',
|
|
@@ -14072,6 +14277,30 @@ var stringReference = {
|
|
|
14072
14277
|
'(map number (split "0123456789" "" 5))',
|
|
14073
14278
|
],
|
|
14074
14279
|
},
|
|
14280
|
+
'split_lines': {
|
|
14281
|
+
title: 'split_lines',
|
|
14282
|
+
category: 'String',
|
|
14283
|
+
linkName: 'split_lines',
|
|
14284
|
+
clojureDocs: null,
|
|
14285
|
+
returns: {
|
|
14286
|
+
type: 'string',
|
|
14287
|
+
},
|
|
14288
|
+
args: {
|
|
14289
|
+
s: {
|
|
14290
|
+
type: 'string',
|
|
14291
|
+
},
|
|
14292
|
+
},
|
|
14293
|
+
variants: [
|
|
14294
|
+
{ argumentNames: ['s'] },
|
|
14295
|
+
],
|
|
14296
|
+
description: 'Divides $s into an array of substrings, each representing a line.',
|
|
14297
|
+
examples: [
|
|
14298
|
+
'(split_lines "Albert\nMojir\n")',
|
|
14299
|
+
'(split_lines "Albert\n\nMojir")',
|
|
14300
|
+
'(split_lines "Albert\nMojir\n\n")',
|
|
14301
|
+
'(split_lines "")',
|
|
14302
|
+
],
|
|
14303
|
+
},
|
|
14075
14304
|
'template': {
|
|
14076
14305
|
title: 'template',
|
|
14077
14306
|
category: 'String',
|
|
@@ -14288,6 +14517,55 @@ var stringReference = {
|
|
|
14288
14517
|
'(++)',
|
|
14289
14518
|
],
|
|
14290
14519
|
},
|
|
14520
|
+
'capitalize': {
|
|
14521
|
+
title: 'capitalize',
|
|
14522
|
+
category: 'String',
|
|
14523
|
+
linkName: 'capitalize',
|
|
14524
|
+
clojureDocs: 'clojure.string/capitalize',
|
|
14525
|
+
returns: {
|
|
14526
|
+
type: 'string',
|
|
14527
|
+
},
|
|
14528
|
+
args: {
|
|
14529
|
+
s: {
|
|
14530
|
+
type: 'string',
|
|
14531
|
+
},
|
|
14532
|
+
},
|
|
14533
|
+
variants: [
|
|
14534
|
+
{ argumentNames: ['s'] },
|
|
14535
|
+
],
|
|
14536
|
+
description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',
|
|
14537
|
+
examples: [
|
|
14538
|
+
'(capitalize "albert")',
|
|
14539
|
+
'(capitalize "ALBERT")',
|
|
14540
|
+
'(capitalize "aLBERT")',
|
|
14541
|
+
'(capitalize "")',
|
|
14542
|
+
],
|
|
14543
|
+
},
|
|
14544
|
+
'blank?': {
|
|
14545
|
+
title: 'blank?',
|
|
14546
|
+
category: 'String',
|
|
14547
|
+
linkName: 'blank-question',
|
|
14548
|
+
clojureDocs: 'clojure.string/blank_q',
|
|
14549
|
+
returns: {
|
|
14550
|
+
type: 'boolean',
|
|
14551
|
+
},
|
|
14552
|
+
args: {
|
|
14553
|
+
s: {
|
|
14554
|
+
type: ['string', 'null'],
|
|
14555
|
+
},
|
|
14556
|
+
},
|
|
14557
|
+
variants: [
|
|
14558
|
+
{ argumentNames: ['s'] },
|
|
14559
|
+
],
|
|
14560
|
+
description: 'Returns true if $s is null or only contains whitespace characters.',
|
|
14561
|
+
examples: [
|
|
14562
|
+
'(blank? "")',
|
|
14563
|
+
'(blank? null)',
|
|
14564
|
+
'(blank? "\n")',
|
|
14565
|
+
'(blank? " ")',
|
|
14566
|
+
'(blank? ".")',
|
|
14567
|
+
],
|
|
14568
|
+
},
|
|
14291
14569
|
};
|
|
14292
14570
|
|
|
14293
14571
|
var bitwiseReference = { '<<': {
|
|
@@ -14851,6 +15129,7 @@ var api = {
|
|
|
14851
15129
|
'filter',
|
|
14852
15130
|
'position',
|
|
14853
15131
|
'index_of',
|
|
15132
|
+
'last_index_of',
|
|
14854
15133
|
'some',
|
|
14855
15134
|
'reverse',
|
|
14856
15135
|
'first',
|
|
@@ -14878,6 +15157,10 @@ var api = {
|
|
|
14878
15157
|
'partition',
|
|
14879
15158
|
'partition_all',
|
|
14880
15159
|
'partition_by',
|
|
15160
|
+
'starts_with?',
|
|
15161
|
+
'ends_with?',
|
|
15162
|
+
'interleave',
|
|
15163
|
+
'interpose',
|
|
14881
15164
|
],
|
|
14882
15165
|
math: [
|
|
14883
15166
|
'+',
|
|
@@ -14998,16 +15281,15 @@ var api = {
|
|
|
14998
15281
|
'regexp',
|
|
14999
15282
|
'match',
|
|
15000
15283
|
'replace',
|
|
15284
|
+
'replace_all',
|
|
15001
15285
|
],
|
|
15002
15286
|
specialExpressions: [
|
|
15003
15287
|
'&&',
|
|
15004
15288
|
'||',
|
|
15005
15289
|
'def',
|
|
15006
|
-
'defs',
|
|
15007
15290
|
'let',
|
|
15008
15291
|
'fn',
|
|
15009
15292
|
'defn',
|
|
15010
|
-
'defns',
|
|
15011
15293
|
'try',
|
|
15012
15294
|
'throw',
|
|
15013
15295
|
'if',
|
|
@@ -15036,6 +15318,7 @@ var api = {
|
|
|
15036
15318
|
'pad_left',
|
|
15037
15319
|
'pad_right',
|
|
15038
15320
|
'split',
|
|
15321
|
+
'split_lines',
|
|
15039
15322
|
'template',
|
|
15040
15323
|
'to_char_code',
|
|
15041
15324
|
'from_char_code',
|
|
@@ -15045,6 +15328,8 @@ var api = {
|
|
|
15045
15328
|
'decode_uri_component',
|
|
15046
15329
|
'join',
|
|
15047
15330
|
'++',
|
|
15331
|
+
'capitalize',
|
|
15332
|
+
'blank?',
|
|
15048
15333
|
],
|
|
15049
15334
|
bitwise: [
|
|
15050
15335
|
'<<',
|