@mojir/lits 2.0.14 → 2.0.16
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 +1131 -1858
- package/dist/cli/reference/api.d.ts +8 -8
- package/dist/cli/src/analyze/index.d.ts +0 -2
- package/dist/cli/src/builtin/index.d.ts +6 -11
- package/dist/cli/src/builtin/specialExpressions/and.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/or.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/{when.d.ts → switch.d.ts} +2 -2
- package/dist/cli/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/cli/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
- package/dist/cli/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/cli/src/identifier.d.ts +2 -2
- package/dist/cli/src/parser/AlgebraicParser.d.ts +12 -2
- package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
- package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
- package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
- package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +1 -1
- package/dist/cli/src/tokenizer/utils.d.ts +1 -1
- package/dist/cli/src/typeGuards/index.d.ts +1 -0
- package/dist/index.esm.js +1132 -1861
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1132 -1861
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1132 -1861
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +8 -8
- package/dist/src/analyze/index.d.ts +0 -2
- package/dist/src/builtin/index.d.ts +6 -11
- package/dist/src/builtin/specialExpressions/and.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/declared.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/or.d.ts +1 -1
- package/dist/{cli/src/builtin/specialExpressions/time.d.ts → src/builtin/specialExpressions/switch.d.ts} +2 -2
- package/dist/src/builtin/specialExpressions/try.d.ts +1 -1
- package/dist/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
- package/dist/src/evaluator/ContextStack.d.ts +2 -0
- package/dist/src/identifier.d.ts +2 -2
- package/dist/src/parser/AlgebraicParser.d.ts +12 -2
- package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
- package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
- package/dist/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
- package/dist/src/tokenizer/polish/polishTokens.d.ts +1 -1
- package/dist/src/tokenizer/utils.d.ts +1 -1
- package/dist/src/typeGuards/index.d.ts +1 -0
- package/dist/testFramework.esm.js +772 -1325
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +772 -1325
- 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/calculateThrowOutcomes.d.ts +0 -3
- package/dist/cli/src/analyze/calculateOutcomes/calculateTimeOutcomes.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/if-let.d.ts +0 -7
- 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/calculateThrowOutcomes.d.ts +0 -3
- package/dist/src/analyze/calculateOutcomes/calculateTimeOutcomes.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/if-let.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/time.d.ts +0 -6
- 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/src/builtin/specialExpressions/when.d.ts +0 -6
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.0.
|
|
95
|
+
var version = "2.0.16";
|
|
96
96
|
|
|
97
97
|
var AstNodeType;
|
|
98
98
|
(function (AstNodeType) {
|
|
@@ -243,6 +243,12 @@ var UndefinedSymbolError = /** @class */ (function (_super) {
|
|
|
243
243
|
return UndefinedSymbolError;
|
|
244
244
|
}(LitsError));
|
|
245
245
|
|
|
246
|
+
function getSourceCodeInfo(anyValue, sourceCodeInfo) {
|
|
247
|
+
var _a;
|
|
248
|
+
// eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
|
|
249
|
+
return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
|
|
250
|
+
}
|
|
251
|
+
|
|
246
252
|
function isTokenDebugData(tokenDebugData) {
|
|
247
253
|
return (typeof tokenDebugData === 'object'
|
|
248
254
|
&& tokenDebugData !== null
|
|
@@ -261,8 +267,12 @@ function addTokenDebugData(token, debugData) {
|
|
|
261
267
|
}
|
|
262
268
|
token.push(debugData);
|
|
263
269
|
}
|
|
264
|
-
function throwUnexpectedToken(expected, actual) {
|
|
265
|
-
|
|
270
|
+
function throwUnexpectedToken(expected, expectedValue, actual) {
|
|
271
|
+
if (actual === undefined) {
|
|
272
|
+
throw new LitsError("Unexpected end of input, expected ".concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), undefined);
|
|
273
|
+
}
|
|
274
|
+
var actualOutput = "".concat(actual[0]).concat(actual[1] ? " '".concat(actual[1], "'") : '');
|
|
275
|
+
throw new LitsError("Unexpected token: ".concat(actualOutput, ", expected ").concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), getSourceCodeInfo(actual));
|
|
266
276
|
}
|
|
267
277
|
|
|
268
278
|
var commonSimpleTokenTypes = [
|
|
@@ -284,7 +294,7 @@ function isLParenToken(token) {
|
|
|
284
294
|
}
|
|
285
295
|
function assertLParenToken(token) {
|
|
286
296
|
if (!isLParenToken(token)) {
|
|
287
|
-
throwUnexpectedToken('LParen', token);
|
|
297
|
+
throwUnexpectedToken('LParen', undefined, token);
|
|
288
298
|
}
|
|
289
299
|
}
|
|
290
300
|
function asLParenToken(token) {
|
|
@@ -296,7 +306,7 @@ function isRParenToken(token) {
|
|
|
296
306
|
}
|
|
297
307
|
function assertRParenToken(token) {
|
|
298
308
|
if (!isRParenToken(token)) {
|
|
299
|
-
throwUnexpectedToken('RParen', token);
|
|
309
|
+
throwUnexpectedToken('RParen', undefined, token);
|
|
300
310
|
}
|
|
301
311
|
}
|
|
302
312
|
function isLBracketToken(token) {
|
|
@@ -304,7 +314,7 @@ function isLBracketToken(token) {
|
|
|
304
314
|
}
|
|
305
315
|
function assertLBracketToken(token) {
|
|
306
316
|
if (!isLBracketToken(token)) {
|
|
307
|
-
throwUnexpectedToken('LBracket', token);
|
|
317
|
+
throwUnexpectedToken('LBracket', undefined, token);
|
|
308
318
|
}
|
|
309
319
|
}
|
|
310
320
|
function asLBracketToken(token) {
|
|
@@ -316,7 +326,7 @@ function isRBracketToken(token) {
|
|
|
316
326
|
}
|
|
317
327
|
function assertRBracketToken(token) {
|
|
318
328
|
if (!isRBracketToken(token)) {
|
|
319
|
-
throwUnexpectedToken('RBracket', token);
|
|
329
|
+
throwUnexpectedToken('RBracket', undefined, token);
|
|
320
330
|
}
|
|
321
331
|
}
|
|
322
332
|
function isLBraceToken(token) {
|
|
@@ -324,7 +334,7 @@ function isLBraceToken(token) {
|
|
|
324
334
|
}
|
|
325
335
|
function assertLBraceToken(token) {
|
|
326
336
|
if (!isLBraceToken(token)) {
|
|
327
|
-
throwUnexpectedToken('LBrace', token);
|
|
337
|
+
throwUnexpectedToken('LBrace', undefined, token);
|
|
328
338
|
}
|
|
329
339
|
}
|
|
330
340
|
function asLBraceToken(token) {
|
|
@@ -336,7 +346,7 @@ function isRBraceToken(token) {
|
|
|
336
346
|
}
|
|
337
347
|
function assertRBraceToken(token) {
|
|
338
348
|
if (!isRBraceToken(token)) {
|
|
339
|
-
throwUnexpectedToken('RBrace', token);
|
|
349
|
+
throwUnexpectedToken('RBrace', undefined, token);
|
|
340
350
|
}
|
|
341
351
|
}
|
|
342
352
|
function isStringToken(token) {
|
|
@@ -344,7 +354,7 @@ function isStringToken(token) {
|
|
|
344
354
|
}
|
|
345
355
|
function assertStringToken(token) {
|
|
346
356
|
if (!isStringToken(token)) {
|
|
347
|
-
throwUnexpectedToken('String', token);
|
|
357
|
+
throwUnexpectedToken('String', undefined, token);
|
|
348
358
|
}
|
|
349
359
|
}
|
|
350
360
|
function asStringToken(token) {
|
|
@@ -362,7 +372,7 @@ function isEndNotationToken(token) {
|
|
|
362
372
|
}
|
|
363
373
|
function assertEndNotationToken(token) {
|
|
364
374
|
if (!isEndNotationToken(token)) {
|
|
365
|
-
throwUnexpectedToken('EndNotation', token);
|
|
375
|
+
throwUnexpectedToken('EndNotation', undefined, token);
|
|
366
376
|
}
|
|
367
377
|
}
|
|
368
378
|
|
|
@@ -420,24 +430,18 @@ var otherSymbolicOperators = [
|
|
|
420
430
|
var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(symbolicUnaryOperators), false), __read(symbolicBinaryOperators), false), __read(otherSymbolicOperators), false);
|
|
421
431
|
var nonFunctionOperators = [
|
|
422
432
|
'??',
|
|
423
|
-
'
|
|
433
|
+
'&&',
|
|
424
434
|
'comment',
|
|
425
435
|
'cond',
|
|
426
|
-
'
|
|
436
|
+
'defined?',
|
|
427
437
|
'if',
|
|
428
|
-
'
|
|
429
|
-
'
|
|
430
|
-
'when',
|
|
431
|
-
'when-not',
|
|
438
|
+
'unless',
|
|
439
|
+
'||',
|
|
432
440
|
'do',
|
|
433
|
-
'time!',
|
|
434
441
|
'throw',
|
|
435
442
|
'let',
|
|
436
443
|
'def',
|
|
437
444
|
'defs',
|
|
438
|
-
'if-let',
|
|
439
|
-
'when-let',
|
|
440
|
-
'when-first',
|
|
441
445
|
'fn',
|
|
442
446
|
'defn',
|
|
443
447
|
'defns',
|
|
@@ -463,23 +467,40 @@ var symbolicOperatorSet = new Set(symbolicOperators);
|
|
|
463
467
|
function isSymbolicOperator(operator) {
|
|
464
468
|
return symbolicOperatorSet.has(operator);
|
|
465
469
|
}
|
|
466
|
-
function isA_SymbolToken(token) {
|
|
467
|
-
|
|
470
|
+
function isA_SymbolToken(token, symbolName) {
|
|
471
|
+
if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_Symbol') {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
if (symbolName && token[1] !== symbolName) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
return true;
|
|
468
478
|
}
|
|
469
|
-
function assertA_SymbolToken(token) {
|
|
470
|
-
if (!isA_SymbolToken(token)) {
|
|
471
|
-
throwUnexpectedToken('A_Symbol', token);
|
|
479
|
+
function assertA_SymbolToken(token, symbolName) {
|
|
480
|
+
if (!isA_SymbolToken(token, symbolName)) {
|
|
481
|
+
throwUnexpectedToken('A_Symbol', undefined, token);
|
|
472
482
|
}
|
|
473
483
|
}
|
|
474
|
-
function asA_SymbolToken(token) {
|
|
475
|
-
assertA_SymbolToken(token);
|
|
484
|
+
function asA_SymbolToken(token, symbolName) {
|
|
485
|
+
assertA_SymbolToken(token, symbolName);
|
|
476
486
|
return token;
|
|
477
487
|
}
|
|
478
488
|
function isA_BinaryOperatorToken(token) {
|
|
479
489
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Operator' && isSymbolicBinaryOperator(token[1]);
|
|
480
490
|
}
|
|
481
|
-
function isA_ReservedSymbolToken(token) {
|
|
482
|
-
|
|
491
|
+
function isA_ReservedSymbolToken(token, symbolName) {
|
|
492
|
+
if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_ReservedSymbol') {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
if (symbolName && token[1] !== symbolName) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
function assertA_ReservedSymbolToken(token, symbolName) {
|
|
501
|
+
if (!isA_ReservedSymbolToken(token, symbolName)) {
|
|
502
|
+
throwUnexpectedToken('A_ReservedSymbol', symbolName, token);
|
|
503
|
+
}
|
|
483
504
|
}
|
|
484
505
|
function isA_CommentToken(token) {
|
|
485
506
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_SingleLineComment';
|
|
@@ -498,10 +519,9 @@ function isA_OperatorToken(token, operatorName) {
|
|
|
498
519
|
}
|
|
499
520
|
function assertA_OperatorToken(token, operatorName) {
|
|
500
521
|
if (!isA_OperatorToken(token, operatorName)) {
|
|
501
|
-
|
|
522
|
+
{
|
|
502
523
|
throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
|
|
503
524
|
}
|
|
504
|
-
throwUnexpectedToken('A_Operator', token);
|
|
505
525
|
}
|
|
506
526
|
}
|
|
507
527
|
function isA_WhitespaceToken(token) {
|
|
@@ -514,7 +534,7 @@ function isA_BasePrefixedNumberToken(token) {
|
|
|
514
534
|
return (token === null || token === void 0 ? void 0 : token[0]) === 'A_BasePrefixedNumber';
|
|
515
535
|
}
|
|
516
536
|
|
|
517
|
-
var modifierNames = ['&', '&let', '&when', '&while'];
|
|
537
|
+
var modifierNames = ['&rest', '&let', '&when', '&while'];
|
|
518
538
|
var polishOnlySimpleTokenTypes = [
|
|
519
539
|
'P_FnShorthand',
|
|
520
540
|
];
|
|
@@ -537,7 +557,7 @@ function isP_StringShorthandToken(token) {
|
|
|
537
557
|
}
|
|
538
558
|
function assertP_StringShorthandToken(token) {
|
|
539
559
|
if (!isP_StringShorthandToken(token)) {
|
|
540
|
-
throwUnexpectedToken('P_StringShorthand', token);
|
|
560
|
+
throwUnexpectedToken('P_StringShorthand', undefined, token);
|
|
541
561
|
}
|
|
542
562
|
}
|
|
543
563
|
function asP_StringShorthandToken(token) {
|
|
@@ -549,7 +569,7 @@ function isP_SymbolToken(token) {
|
|
|
549
569
|
}
|
|
550
570
|
function assertP_SymbolToken(token) {
|
|
551
571
|
if (!isP_SymbolToken(token)) {
|
|
552
|
-
throwUnexpectedToken('P_Symbol', token);
|
|
572
|
+
throwUnexpectedToken('P_Symbol', undefined, token);
|
|
553
573
|
}
|
|
554
574
|
}
|
|
555
575
|
function asP_SymbolToken(token) {
|
|
@@ -567,7 +587,7 @@ function isP_RegexpShorthandToken(token) {
|
|
|
567
587
|
}
|
|
568
588
|
function assertP_RegexpShorthandToken(token) {
|
|
569
589
|
if (!isP_RegexpShorthandToken(token)) {
|
|
570
|
-
throwUnexpectedToken('P_RegexpShorthand', token);
|
|
590
|
+
throwUnexpectedToken('P_RegexpShorthand', undefined, token);
|
|
571
591
|
}
|
|
572
592
|
}
|
|
573
593
|
function asP_RegexpShorthandToken(token) {
|
|
@@ -582,7 +602,7 @@ function isP_CollectionAccessorToken(token) {
|
|
|
582
602
|
}
|
|
583
603
|
function assertP_CollectionAccessorToken(token) {
|
|
584
604
|
if (!isP_CollectionAccessorToken(token)) {
|
|
585
|
-
throwUnexpectedToken('P_CollectionAccessor', token);
|
|
605
|
+
throwUnexpectedToken('P_CollectionAccessor', undefined, token);
|
|
586
606
|
}
|
|
587
607
|
}
|
|
588
608
|
function asP_CollectionAccessorToken(token) {
|
|
@@ -594,7 +614,7 @@ function isP_CommentToken(token) {
|
|
|
594
614
|
}
|
|
595
615
|
function assertP_CommentToken(token) {
|
|
596
616
|
if (!isP_CommentToken(token)) {
|
|
597
|
-
throwUnexpectedToken('P_Comment', token);
|
|
617
|
+
throwUnexpectedToken('P_Comment', undefined, token);
|
|
598
618
|
}
|
|
599
619
|
}
|
|
600
620
|
function asP_CommentToken(token) {
|
|
@@ -609,7 +629,7 @@ function isP_NumberToken(token) {
|
|
|
609
629
|
}
|
|
610
630
|
function assertP_NumberToken(token) {
|
|
611
631
|
if (!isP_NumberToken(token)) {
|
|
612
|
-
throwUnexpectedToken('P_Number', token);
|
|
632
|
+
throwUnexpectedToken('P_Number', undefined, token);
|
|
613
633
|
}
|
|
614
634
|
}
|
|
615
635
|
|
|
@@ -677,12 +697,6 @@ function valueToString(value) {
|
|
|
677
697
|
return JSON.stringify(value);
|
|
678
698
|
}
|
|
679
699
|
|
|
680
|
-
function getSourceCodeInfo(anyValue, sourceCodeInfo) {
|
|
681
|
-
var _a;
|
|
682
|
-
// eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
|
|
683
|
-
return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
700
|
function getAssertionError(typeName, value, sourceCodeInfo) {
|
|
687
701
|
return new LitsError("Expected ".concat(typeName, ", got ").concat(valueToString(value), "."), getSourceCodeInfo(value, sourceCodeInfo));
|
|
688
702
|
}
|
|
@@ -735,7 +749,7 @@ function isExpressionNode(value) {
|
|
|
735
749
|
}
|
|
736
750
|
|
|
737
751
|
var specialExpressionCommentRemovers = {
|
|
738
|
-
'
|
|
752
|
+
'&&': function (node, removeOptions) {
|
|
739
753
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
740
754
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
741
755
|
},
|
|
@@ -747,7 +761,11 @@ var specialExpressionCommentRemovers = {
|
|
|
747
761
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
748
762
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
749
763
|
},
|
|
750
|
-
'
|
|
764
|
+
'switch': function (node, removeOptions) {
|
|
765
|
+
removeOptions.removeCommenNodesFromArray(node.p);
|
|
766
|
+
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
767
|
+
},
|
|
768
|
+
'defined?': function (node, removeOptions) {
|
|
751
769
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
752
770
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
753
771
|
},
|
|
@@ -768,12 +786,11 @@ var specialExpressionCommentRemovers = {
|
|
|
768
786
|
'doseq': function (_node, _removeOptions) { },
|
|
769
787
|
'fn': function (_node, _removeOptions) { },
|
|
770
788
|
'for': function (_node, _removeOptions) { },
|
|
771
|
-
'if-let': function (_node, _removeOptions) { },
|
|
772
789
|
'if': function (node, removeOptions) {
|
|
773
790
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
774
791
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
775
792
|
},
|
|
776
|
-
'
|
|
793
|
+
'unless': function (node, removeOptions) {
|
|
777
794
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
778
795
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
779
796
|
},
|
|
@@ -785,7 +802,7 @@ var specialExpressionCommentRemovers = {
|
|
|
785
802
|
});
|
|
786
803
|
},
|
|
787
804
|
'loop': function (_node, _removeOptions) { },
|
|
788
|
-
'
|
|
805
|
+
'||': function (node, removeOptions) {
|
|
789
806
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
790
807
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
791
808
|
},
|
|
@@ -797,19 +814,11 @@ var specialExpressionCommentRemovers = {
|
|
|
797
814
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
798
815
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
799
816
|
},
|
|
800
|
-
'time!': function (node, removeOptions) {
|
|
801
|
-
removeOptions.removeCommenNodesFromArray(node.p);
|
|
802
|
-
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
803
|
-
},
|
|
804
817
|
'throw': function (node, removeOptions) {
|
|
805
818
|
removeOptions.removeCommenNodesFromArray(node.p);
|
|
806
819
|
node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
|
|
807
820
|
},
|
|
808
821
|
'try': function (_node, _removeOptions) { },
|
|
809
|
-
'when-first': function (_node, _removeOptions) { },
|
|
810
|
-
'when-let': function (_node, _removeOptions) { },
|
|
811
|
-
'when': function (_node, _removeOptions) { },
|
|
812
|
-
'when-not': function (_node, _removeOptions) { },
|
|
813
822
|
};
|
|
814
823
|
function removeCommentNodesFromSpecialExpression(node, removeOptions) {
|
|
815
824
|
var uncommenter = specialExpressionCommentRemovers[node.n];
|
|
@@ -851,6 +860,13 @@ function assertEvenNumberOfParams(node) {
|
|
|
851
860
|
throw new LitsError("Wrong number of arguments, expected an even number, got ".concat(valueToString(length), "."), (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
852
861
|
}
|
|
853
862
|
}
|
|
863
|
+
function assertOddNumberOfParams(node) {
|
|
864
|
+
var _a;
|
|
865
|
+
var length = withoutCommentNodes(node.p).length;
|
|
866
|
+
if (length % 2 !== 1) {
|
|
867
|
+
throw new LitsError("Wrong number of arguments, expected an odd number, got ".concat(valueToString(length), "."), (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
854
870
|
function assertNumberOfParams(count, node) {
|
|
855
871
|
var _a, _b;
|
|
856
872
|
assertCount({
|
|
@@ -988,7 +1004,7 @@ function asNumber(value, sourceCodeInfo, options) {
|
|
|
988
1004
|
}
|
|
989
1005
|
|
|
990
1006
|
var bitwiseNormalExpression = {
|
|
991
|
-
'
|
|
1007
|
+
'<<': {
|
|
992
1008
|
evaluate: function (_a, sourceCodeInfo) {
|
|
993
1009
|
var _b = __read(_a, 2), num = _b[0], count = _b[1];
|
|
994
1010
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -997,7 +1013,7 @@ var bitwiseNormalExpression = {
|
|
|
997
1013
|
},
|
|
998
1014
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
999
1015
|
},
|
|
1000
|
-
'
|
|
1016
|
+
'>>': {
|
|
1001
1017
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1002
1018
|
var _b = __read(_a, 2), num = _b[0], count = _b[1];
|
|
1003
1019
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1006,7 +1022,7 @@ var bitwiseNormalExpression = {
|
|
|
1006
1022
|
},
|
|
1007
1023
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1008
1024
|
},
|
|
1009
|
-
'
|
|
1025
|
+
'>>>': {
|
|
1010
1026
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1011
1027
|
var _b = __read(_a, 2), num = _b[0], count = _b[1];
|
|
1012
1028
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1015,7 +1031,7 @@ var bitwiseNormalExpression = {
|
|
|
1015
1031
|
},
|
|
1016
1032
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1017
1033
|
},
|
|
1018
|
-
'
|
|
1034
|
+
'~': {
|
|
1019
1035
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1020
1036
|
var _b = __read(_a, 1), num = _b[0];
|
|
1021
1037
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1023,7 +1039,7 @@ var bitwiseNormalExpression = {
|
|
|
1023
1039
|
},
|
|
1024
1040
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
1025
1041
|
},
|
|
1026
|
-
'
|
|
1042
|
+
'&': {
|
|
1027
1043
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1028
1044
|
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
1029
1045
|
assertNumber(first, sourceCodeInfo, { integer: true });
|
|
@@ -1034,7 +1050,7 @@ var bitwiseNormalExpression = {
|
|
|
1034
1050
|
},
|
|
1035
1051
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
1036
1052
|
},
|
|
1037
|
-
'
|
|
1053
|
+
'&!': {
|
|
1038
1054
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1039
1055
|
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
1040
1056
|
assertNumber(first, sourceCodeInfo, { integer: true });
|
|
@@ -1045,7 +1061,7 @@ var bitwiseNormalExpression = {
|
|
|
1045
1061
|
},
|
|
1046
1062
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
1047
1063
|
},
|
|
1048
|
-
'
|
|
1064
|
+
'|': {
|
|
1049
1065
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1050
1066
|
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
1051
1067
|
assertNumber(first, sourceCodeInfo, { integer: true });
|
|
@@ -1056,7 +1072,7 @@ var bitwiseNormalExpression = {
|
|
|
1056
1072
|
},
|
|
1057
1073
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
1058
1074
|
},
|
|
1059
|
-
'
|
|
1075
|
+
'^': {
|
|
1060
1076
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1061
1077
|
var _b = __read(_a), first = _b[0], rest = _b.slice(1);
|
|
1062
1078
|
assertNumber(first, sourceCodeInfo, { integer: true });
|
|
@@ -1067,7 +1083,7 @@ var bitwiseNormalExpression = {
|
|
|
1067
1083
|
},
|
|
1068
1084
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
1069
1085
|
},
|
|
1070
|
-
'
|
|
1086
|
+
'bit_flip': {
|
|
1071
1087
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1072
1088
|
var _b = __read(_a, 2), num = _b[0], index = _b[1];
|
|
1073
1089
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1077,7 +1093,7 @@ var bitwiseNormalExpression = {
|
|
|
1077
1093
|
},
|
|
1078
1094
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1079
1095
|
},
|
|
1080
|
-
'
|
|
1096
|
+
'bit_set': {
|
|
1081
1097
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1082
1098
|
var _b = __read(_a, 2), num = _b[0], index = _b[1];
|
|
1083
1099
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1087,7 +1103,7 @@ var bitwiseNormalExpression = {
|
|
|
1087
1103
|
},
|
|
1088
1104
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1089
1105
|
},
|
|
1090
|
-
'
|
|
1106
|
+
'bit_clear': {
|
|
1091
1107
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1092
1108
|
var _b = __read(_a, 2), num = _b[0], index = _b[1];
|
|
1093
1109
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -1097,7 +1113,7 @@ var bitwiseNormalExpression = {
|
|
|
1097
1113
|
},
|
|
1098
1114
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
1099
1115
|
},
|
|
1100
|
-
'
|
|
1116
|
+
'bit_test': {
|
|
1101
1117
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1102
1118
|
var _b = __read(_a, 2), num = _b[0], index = _b[1];
|
|
1103
1119
|
assertNumber(num, sourceCodeInfo, { integer: true });
|
|
@@ -2785,7 +2801,7 @@ var mathNormalExpression = {
|
|
|
2785
2801
|
},
|
|
2786
2802
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
2787
2803
|
},
|
|
2788
|
-
'
|
|
2804
|
+
'%': {
|
|
2789
2805
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2790
2806
|
var _b = __read(_a, 2), dividend = _b[0], divisor = _b[1];
|
|
2791
2807
|
assertNumber(dividend, sourceCodeInfo);
|
|
@@ -2811,7 +2827,7 @@ var mathNormalExpression = {
|
|
|
2811
2827
|
},
|
|
2812
2828
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
2813
2829
|
},
|
|
2814
|
-
'
|
|
2830
|
+
'**': {
|
|
2815
2831
|
evaluate: function (_a, sourceCodeInfo) {
|
|
2816
2832
|
var _b = __read(_a, 2), first = _b[0], second = _b[1];
|
|
2817
2833
|
assertNumber(first, sourceCodeInfo);
|
|
@@ -3088,8 +3104,6 @@ var mathNormalExpression = {
|
|
|
3088
3104
|
},
|
|
3089
3105
|
};
|
|
3090
3106
|
|
|
3091
|
-
var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
3092
|
-
var xyRegexp = /[xy]/g;
|
|
3093
3107
|
var miscNormalExpression = {
|
|
3094
3108
|
'!=': {
|
|
3095
3109
|
evaluate: function (params) {
|
|
@@ -3103,7 +3117,7 @@ var miscNormalExpression = {
|
|
|
3103
3117
|
},
|
|
3104
3118
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
3105
3119
|
},
|
|
3106
|
-
'
|
|
3120
|
+
'==': {
|
|
3107
3121
|
evaluate: function (_a) {
|
|
3108
3122
|
var e_1, _b;
|
|
3109
3123
|
var _c = __read(_a), first = _c[0], rest = _c.slice(1);
|
|
@@ -3228,20 +3242,14 @@ var miscNormalExpression = {
|
|
|
3228
3242
|
},
|
|
3229
3243
|
validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
3230
3244
|
},
|
|
3231
|
-
'
|
|
3245
|
+
'!': {
|
|
3232
3246
|
evaluate: function (_a) {
|
|
3233
3247
|
var _b = __read(_a, 1), first = _b[0];
|
|
3234
3248
|
return !first;
|
|
3235
3249
|
},
|
|
3236
3250
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3237
3251
|
},
|
|
3238
|
-
'
|
|
3239
|
-
evaluate: function () {
|
|
3240
|
-
return Date.now();
|
|
3241
|
-
},
|
|
3242
|
-
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
3243
|
-
},
|
|
3244
|
-
'inst-ms->iso-date-time': {
|
|
3252
|
+
'epoch>iso_date': {
|
|
3245
3253
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3246
3254
|
var _b = __read(_a, 1), ms = _b[0];
|
|
3247
3255
|
assertNumber(ms, sourceCodeInfo);
|
|
@@ -3249,7 +3257,7 @@ var miscNormalExpression = {
|
|
|
3249
3257
|
},
|
|
3250
3258
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3251
3259
|
},
|
|
3252
|
-
'
|
|
3260
|
+
'iso_date>epoch': {
|
|
3253
3261
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3254
3262
|
var _b = __read(_a, 1), dateTime = _b[0];
|
|
3255
3263
|
assertString(dateTime, sourceCodeInfo);
|
|
@@ -3282,23 +3290,7 @@ var miscNormalExpression = {
|
|
|
3282
3290
|
},
|
|
3283
3291
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
3284
3292
|
},
|
|
3285
|
-
'
|
|
3286
|
-
evaluate: function () {
|
|
3287
|
-
return uuidTemplate.replace(xyRegexp, function (character) {
|
|
3288
|
-
var randomNbr = Math.floor(Math.random() * 16);
|
|
3289
|
-
var newValue = character === 'x' ? randomNbr : (randomNbr & 0x3) | 0x8;
|
|
3290
|
-
return newValue.toString(16);
|
|
3291
|
-
});
|
|
3292
|
-
},
|
|
3293
|
-
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
3294
|
-
},
|
|
3295
|
-
'lits-version!': {
|
|
3296
|
-
evaluate: function () {
|
|
3297
|
-
return version;
|
|
3298
|
-
},
|
|
3299
|
-
validate: function (node) { return assertNumberOfParams(0, node); },
|
|
3300
|
-
},
|
|
3301
|
-
'json-parse': {
|
|
3293
|
+
'json_parse': {
|
|
3302
3294
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3303
3295
|
var _b = __read(_a, 1), first = _b[0];
|
|
3304
3296
|
assertString(first, sourceCodeInfo);
|
|
@@ -3307,7 +3299,7 @@ var miscNormalExpression = {
|
|
|
3307
3299
|
},
|
|
3308
3300
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3309
3301
|
},
|
|
3310
|
-
'
|
|
3302
|
+
'json_stringify': {
|
|
3311
3303
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3312
3304
|
var _b = __read(_a, 2), first = _b[0], second = _b[1];
|
|
3313
3305
|
assertAny(first, sourceCodeInfo);
|
|
@@ -3520,7 +3512,7 @@ var assertNormalExpression = {
|
|
|
3520
3512
|
};
|
|
3521
3513
|
|
|
3522
3514
|
var objectNormalExpression = {
|
|
3523
|
-
|
|
3515
|
+
object: {
|
|
3524
3516
|
evaluate: function (params, sourceCodeInfo) {
|
|
3525
3517
|
var result = {};
|
|
3526
3518
|
for (var i = 0; i < params.length; i += 2) {
|
|
@@ -3533,7 +3525,7 @@ var objectNormalExpression = {
|
|
|
3533
3525
|
},
|
|
3534
3526
|
validate: function (node) { return assertEvenNumberOfParams(node); },
|
|
3535
3527
|
},
|
|
3536
|
-
|
|
3528
|
+
keys: {
|
|
3537
3529
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3538
3530
|
var _b = __read(_a, 1), obj = _b[0];
|
|
3539
3531
|
assertObj(obj, sourceCodeInfo);
|
|
@@ -3541,7 +3533,7 @@ var objectNormalExpression = {
|
|
|
3541
3533
|
},
|
|
3542
3534
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3543
3535
|
},
|
|
3544
|
-
|
|
3536
|
+
vals: {
|
|
3545
3537
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3546
3538
|
var _b = __read(_a, 1), obj = _b[0];
|
|
3547
3539
|
assertObj(obj, sourceCodeInfo);
|
|
@@ -3549,7 +3541,7 @@ var objectNormalExpression = {
|
|
|
3549
3541
|
},
|
|
3550
3542
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3551
3543
|
},
|
|
3552
|
-
|
|
3544
|
+
entries: {
|
|
3553
3545
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3554
3546
|
var _b = __read(_a, 1), obj = _b[0];
|
|
3555
3547
|
assertObj(obj, sourceCodeInfo);
|
|
@@ -3557,7 +3549,7 @@ var objectNormalExpression = {
|
|
|
3557
3549
|
},
|
|
3558
3550
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3559
3551
|
},
|
|
3560
|
-
|
|
3552
|
+
find: {
|
|
3561
3553
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3562
3554
|
var _b = __read(_a, 2), obj = _b[0], key = _b[1];
|
|
3563
3555
|
assertObj(obj, sourceCodeInfo);
|
|
@@ -3568,7 +3560,7 @@ var objectNormalExpression = {
|
|
|
3568
3560
|
},
|
|
3569
3561
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
3570
3562
|
},
|
|
3571
|
-
|
|
3563
|
+
dissoc: {
|
|
3572
3564
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3573
3565
|
var _b = __read(_a, 2), obj = _b[0], key = _b[1];
|
|
3574
3566
|
assertObj(obj, sourceCodeInfo);
|
|
@@ -3579,7 +3571,7 @@ var objectNormalExpression = {
|
|
|
3579
3571
|
},
|
|
3580
3572
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
3581
3573
|
},
|
|
3582
|
-
|
|
3574
|
+
merge: {
|
|
3583
3575
|
evaluate: function (params, sourceCodeInfo) {
|
|
3584
3576
|
if (params.length === 0)
|
|
3585
3577
|
return null;
|
|
@@ -3592,7 +3584,7 @@ var objectNormalExpression = {
|
|
|
3592
3584
|
},
|
|
3593
3585
|
validate: function (node) { return assertNumberOfParams({ min: 0 }, node); },
|
|
3594
3586
|
},
|
|
3595
|
-
|
|
3587
|
+
merge_with: {
|
|
3596
3588
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
3597
3589
|
var executeFunction = _a.executeFunction;
|
|
3598
3590
|
var first = params[0];
|
|
@@ -3615,7 +3607,7 @@ var objectNormalExpression = {
|
|
|
3615
3607
|
},
|
|
3616
3608
|
validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
|
|
3617
3609
|
},
|
|
3618
|
-
|
|
3610
|
+
zipmap: {
|
|
3619
3611
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3620
3612
|
var _b = __read(_a, 2), keys = _b[0], values = _b[1];
|
|
3621
3613
|
assertStringArray(keys, sourceCodeInfo);
|
|
@@ -3630,7 +3622,7 @@ var objectNormalExpression = {
|
|
|
3630
3622
|
},
|
|
3631
3623
|
validate: function (node) { return assertNumberOfParams(2, node); },
|
|
3632
3624
|
},
|
|
3633
|
-
|
|
3625
|
+
select_keys: {
|
|
3634
3626
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3635
3627
|
var _b = __read(_a, 2), obj = _b[0], keys = _b[1];
|
|
3636
3628
|
assertStringArray(keys, sourceCodeInfo);
|
|
@@ -3896,7 +3888,7 @@ var stringNormalExpression = {
|
|
|
3896
3888
|
},
|
|
3897
3889
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
3898
3890
|
},
|
|
3899
|
-
'
|
|
3891
|
+
'string_repeat': {
|
|
3900
3892
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3901
3893
|
var _b = __read(_a, 2), str = _b[0], count = _b[1];
|
|
3902
3894
|
assertString(str, sourceCodeInfo);
|
|
@@ -3930,27 +3922,7 @@ var stringNormalExpression = {
|
|
|
3930
3922
|
},
|
|
3931
3923
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3932
3924
|
},
|
|
3933
|
-
'
|
|
3934
|
-
evaluate: function (params, sourceCodeInfo) {
|
|
3935
|
-
var _a = __read(params, 2), num = _a[0], base = _a[1];
|
|
3936
|
-
assertNumber(num, sourceCodeInfo, { finite: true });
|
|
3937
|
-
if (params.length === 1) {
|
|
3938
|
-
return "".concat(num);
|
|
3939
|
-
}
|
|
3940
|
-
else {
|
|
3941
|
-
assertNumber(base, sourceCodeInfo, { finite: true });
|
|
3942
|
-
if (base !== 2 && base !== 8 && base !== 10 && base !== 16) {
|
|
3943
|
-
throw new LitsError("Expected \"number-to-string\" base argument to be 2, 8, 10 or 16, got: ".concat(base), sourceCodeInfo);
|
|
3944
|
-
}
|
|
3945
|
-
if (base === 10)
|
|
3946
|
-
return "".concat(num);
|
|
3947
|
-
assertNumber(num, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
3948
|
-
return Number(num).toString(base);
|
|
3949
|
-
}
|
|
3950
|
-
},
|
|
3951
|
-
validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
3952
|
-
},
|
|
3953
|
-
'from-char-code': {
|
|
3925
|
+
'from_char_code': {
|
|
3954
3926
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3955
3927
|
var _b = __read(_a, 1), num = _b[0];
|
|
3956
3928
|
assertNumber(num, sourceCodeInfo, { finite: true });
|
|
@@ -3964,7 +3936,7 @@ var stringNormalExpression = {
|
|
|
3964
3936
|
},
|
|
3965
3937
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3966
3938
|
},
|
|
3967
|
-
'
|
|
3939
|
+
'to_char_code': {
|
|
3968
3940
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3969
3941
|
var _b = __read(_a, 1), str = _b[0];
|
|
3970
3942
|
assertString(str, sourceCodeInfo, { nonEmpty: true });
|
|
@@ -3972,7 +3944,7 @@ var stringNormalExpression = {
|
|
|
3972
3944
|
},
|
|
3973
3945
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3974
3946
|
},
|
|
3975
|
-
'
|
|
3947
|
+
'lower_case': {
|
|
3976
3948
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3977
3949
|
var _b = __read(_a, 1), str = _b[0];
|
|
3978
3950
|
assertString(str, sourceCodeInfo);
|
|
@@ -3980,7 +3952,7 @@ var stringNormalExpression = {
|
|
|
3980
3952
|
},
|
|
3981
3953
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3982
3954
|
},
|
|
3983
|
-
'
|
|
3955
|
+
'upper_case': {
|
|
3984
3956
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3985
3957
|
var _b = __read(_a, 1), str = _b[0];
|
|
3986
3958
|
assertString(str, sourceCodeInfo);
|
|
@@ -3996,7 +3968,7 @@ var stringNormalExpression = {
|
|
|
3996
3968
|
},
|
|
3997
3969
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
3998
3970
|
},
|
|
3999
|
-
'
|
|
3971
|
+
'trim_left': {
|
|
4000
3972
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4001
3973
|
var _b = __read(_a, 1), str = _b[0];
|
|
4002
3974
|
assertString(str, sourceCodeInfo);
|
|
@@ -4004,7 +3976,7 @@ var stringNormalExpression = {
|
|
|
4004
3976
|
},
|
|
4005
3977
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4006
3978
|
},
|
|
4007
|
-
'
|
|
3979
|
+
'trim_right': {
|
|
4008
3980
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4009
3981
|
var _b = __read(_a, 1), str = _b[0];
|
|
4010
3982
|
assertString(str, sourceCodeInfo);
|
|
@@ -4012,6 +3984,30 @@ var stringNormalExpression = {
|
|
|
4012
3984
|
},
|
|
4013
3985
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4014
3986
|
},
|
|
3987
|
+
'++': {
|
|
3988
|
+
evaluate: function (params, sourceCodeInfo) {
|
|
3989
|
+
if (params.length === 0) {
|
|
3990
|
+
return '';
|
|
3991
|
+
}
|
|
3992
|
+
var first = params[0];
|
|
3993
|
+
if (first !== null) {
|
|
3994
|
+
assertStringOrNumber(first, sourceCodeInfo);
|
|
3995
|
+
}
|
|
3996
|
+
if (params.length === 1) {
|
|
3997
|
+
return first === null ? '' : "".concat(first);
|
|
3998
|
+
}
|
|
3999
|
+
return params.slice(1).reduce(function (acc, str) {
|
|
4000
|
+
if (str !== null) {
|
|
4001
|
+
assertStringOrNumber(str, sourceCodeInfo);
|
|
4002
|
+
}
|
|
4003
|
+
if (str === null) {
|
|
4004
|
+
return acc;
|
|
4005
|
+
}
|
|
4006
|
+
return "".concat(acc).concat(str);
|
|
4007
|
+
}, first === null ? '' : "".concat(first));
|
|
4008
|
+
},
|
|
4009
|
+
validate: function () { return undefined; },
|
|
4010
|
+
},
|
|
4015
4011
|
'join': {
|
|
4016
4012
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4017
4013
|
var _b = __read(_a, 2), stringList = _b[0], delimiter = _b[1];
|
|
@@ -4036,7 +4032,7 @@ var stringNormalExpression = {
|
|
|
4036
4032
|
},
|
|
4037
4033
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4038
4034
|
},
|
|
4039
|
-
'
|
|
4035
|
+
'pad_left': {
|
|
4040
4036
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4041
4037
|
var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
|
|
4042
4038
|
assertString(str, sourceCodeInfo);
|
|
@@ -4047,7 +4043,7 @@ var stringNormalExpression = {
|
|
|
4047
4043
|
},
|
|
4048
4044
|
validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4049
4045
|
},
|
|
4050
|
-
'
|
|
4046
|
+
'pad_right': {
|
|
4051
4047
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4052
4048
|
var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
|
|
4053
4049
|
assertString(str, sourceCodeInfo);
|
|
@@ -4089,7 +4085,7 @@ var stringNormalExpression = {
|
|
|
4089
4085
|
},
|
|
4090
4086
|
validate: function (node) { return assertNumberOfParams({ min: 1, max: 10 }, node); },
|
|
4091
4087
|
},
|
|
4092
|
-
'
|
|
4088
|
+
'encode_base64': {
|
|
4093
4089
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4094
4090
|
var _b = __read(_a, 1), value = _b[0];
|
|
4095
4091
|
assertString(value, sourceCodeInfo);
|
|
@@ -4100,7 +4096,7 @@ var stringNormalExpression = {
|
|
|
4100
4096
|
},
|
|
4101
4097
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4102
4098
|
},
|
|
4103
|
-
'
|
|
4099
|
+
'decode_base64': {
|
|
4104
4100
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4105
4101
|
var _b = __read(_a, 1), value = _b[0];
|
|
4106
4102
|
assertString(value, sourceCodeInfo);
|
|
@@ -4118,7 +4114,7 @@ var stringNormalExpression = {
|
|
|
4118
4114
|
},
|
|
4119
4115
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4120
4116
|
},
|
|
4121
|
-
'
|
|
4117
|
+
'encode_uri_component': {
|
|
4122
4118
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4123
4119
|
var _b = __read(_a, 1), value = _b[0];
|
|
4124
4120
|
assertString(value, sourceCodeInfo);
|
|
@@ -4126,7 +4122,7 @@ var stringNormalExpression = {
|
|
|
4126
4122
|
},
|
|
4127
4123
|
validate: function (node) { return assertNumberOfParams(1, node); },
|
|
4128
4124
|
},
|
|
4129
|
-
'
|
|
4125
|
+
'decode_uri_component': {
|
|
4130
4126
|
evaluate: function (_a, sourceCodeInfo) {
|
|
4131
4127
|
var _b = __read(_a, 1), value = _b[0];
|
|
4132
4128
|
assertString(value, sourceCodeInfo);
|
|
@@ -4295,7 +4291,7 @@ var andSpecialExpression = {
|
|
|
4295
4291
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4296
4292
|
var node = {
|
|
4297
4293
|
t: AstNodeType.SpecialExpression,
|
|
4298
|
-
n: '
|
|
4294
|
+
n: '&&',
|
|
4299
4295
|
p: params,
|
|
4300
4296
|
token: getTokenDebugData(firstToken) && firstToken,
|
|
4301
4297
|
};
|
|
@@ -4380,8 +4376,39 @@ var condSpecialExpression = {
|
|
|
4380
4376
|
},
|
|
4381
4377
|
};
|
|
4382
4378
|
|
|
4379
|
+
var switchSpecialExpression = {
|
|
4380
|
+
polishParse: getCommonPolishSpecialExpressionParser('switch'),
|
|
4381
|
+
validateParameterCount: function (node) { return assertOddNumberOfParams(node); },
|
|
4382
|
+
evaluate: function (node, contextStack, _a) {
|
|
4383
|
+
var e_1, _b;
|
|
4384
|
+
var evaluateAstNode = _a.evaluateAstNode;
|
|
4385
|
+
var switchValue = evaluateAstNode(node.p[0], contextStack);
|
|
4386
|
+
try {
|
|
4387
|
+
for (var _c = __values(arrayToPairs(node.p.slice(1))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
4388
|
+
var _e = __read(_d.value, 2), test = _e[0], form = _e[1];
|
|
4389
|
+
var value = evaluateAstNode(test, contextStack);
|
|
4390
|
+
if (value === switchValue) {
|
|
4391
|
+
return evaluateAstNode(form, contextStack);
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4396
|
+
finally {
|
|
4397
|
+
try {
|
|
4398
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
4399
|
+
}
|
|
4400
|
+
finally { if (e_1) throw e_1.error; }
|
|
4401
|
+
}
|
|
4402
|
+
return null;
|
|
4403
|
+
},
|
|
4404
|
+
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4405
|
+
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4406
|
+
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
4407
|
+
},
|
|
4408
|
+
};
|
|
4409
|
+
|
|
4383
4410
|
var declaredSpecialExpression = {
|
|
4384
|
-
polishParse: getCommonPolishSpecialExpressionParser('
|
|
4411
|
+
polishParse: getCommonPolishSpecialExpressionParser('defined?'),
|
|
4385
4412
|
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
4386
4413
|
evaluate: function (node, contextStack) {
|
|
4387
4414
|
var lookUpResult = contextStack.lookUp(node.p[0]);
|
|
@@ -4437,9 +4464,7 @@ var defSpecialExpression = {
|
|
|
4437
4464
|
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4438
4465
|
var name = node.p[0].v;
|
|
4439
4466
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4440
|
-
contextStack.
|
|
4441
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4442
|
-
};
|
|
4467
|
+
contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
|
|
4443
4468
|
return null;
|
|
4444
4469
|
},
|
|
4445
4470
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
@@ -4450,7 +4475,7 @@ var defSpecialExpression = {
|
|
|
4450
4475
|
var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
|
|
4451
4476
|
var name = asSymbolNode(node.p[0]).v;
|
|
4452
4477
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4453
|
-
contextStack.
|
|
4478
|
+
contextStack.exportValue(name, true);
|
|
4454
4479
|
return result;
|
|
4455
4480
|
},
|
|
4456
4481
|
};
|
|
@@ -4476,9 +4501,7 @@ var defsSpecialExpression = {
|
|
|
4476
4501
|
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4477
4502
|
assertString(name, sourceCodeInfo);
|
|
4478
4503
|
assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
4479
|
-
contextStack.
|
|
4480
|
-
value: evaluateAstNode(node.p[1], contextStack),
|
|
4481
|
-
};
|
|
4504
|
+
contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
|
|
4482
4505
|
return null;
|
|
4483
4506
|
},
|
|
4484
4507
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
@@ -4490,7 +4513,7 @@ var defsSpecialExpression = {
|
|
|
4490
4513
|
var name = evaluateAstNode(node.p[0], contextStack);
|
|
4491
4514
|
assertString(name, sourceCodeInfo);
|
|
4492
4515
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4493
|
-
contextStack.
|
|
4516
|
+
contextStack.exportValue(name, true);
|
|
4494
4517
|
return result;
|
|
4495
4518
|
},
|
|
4496
4519
|
};
|
|
@@ -4521,7 +4544,7 @@ var doSpecialExpression = {
|
|
|
4521
4544
|
},
|
|
4522
4545
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4523
4546
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4524
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
4547
|
+
return findUnresolvedIdentifiers(node.p, contextStack.create({}), builtin);
|
|
4525
4548
|
},
|
|
4526
4549
|
};
|
|
4527
4550
|
|
|
@@ -4550,11 +4573,6 @@ function joinAnalyzeResults() {
|
|
|
4550
4573
|
function addAnalyzeResults(target, source) {
|
|
4551
4574
|
source.forEach(function (symbol) { return target.add(symbol); });
|
|
4552
4575
|
}
|
|
4553
|
-
function combinate(arrays) {
|
|
4554
|
-
return arrays.reduce(function (acc, curr) {
|
|
4555
|
-
return acc.flatMap(function (a) { return curr.map(function (c) { return __spreadArray(__spreadArray([], __read(a), false), [c], false); }); });
|
|
4556
|
-
}, [[]]);
|
|
4557
|
-
}
|
|
4558
4576
|
|
|
4559
4577
|
var defnSpecialExpression = {
|
|
4560
4578
|
polishParse: function (tokenStream, parseState, firstToken, parsers) {
|
|
@@ -4589,13 +4607,13 @@ var defnSpecialExpression = {
|
|
|
4589
4607
|
_b.n = name,
|
|
4590
4608
|
_b.o = evaluatedFunctionOverloades,
|
|
4591
4609
|
_b);
|
|
4592
|
-
contextStack.
|
|
4610
|
+
contextStack.exportValue(name, litsFunction);
|
|
4593
4611
|
return null;
|
|
4594
4612
|
},
|
|
4595
4613
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4596
4614
|
var _b;
|
|
4597
4615
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4598
|
-
contextStack.
|
|
4616
|
+
contextStack.exportValue(node.f.v, true);
|
|
4599
4617
|
var newContext = (_b = {}, _b[node.f.v] = { value: true }, _b);
|
|
4600
4618
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4601
4619
|
},
|
|
@@ -4631,7 +4649,7 @@ var defnsSpecialExpression = {
|
|
|
4631
4649
|
_b.n = name,
|
|
4632
4650
|
_b.o = evaluatedFunctionOverloades,
|
|
4633
4651
|
_b);
|
|
4634
|
-
contextStack.
|
|
4652
|
+
contextStack.exportValue(name, litsFunction);
|
|
4635
4653
|
return null;
|
|
4636
4654
|
},
|
|
4637
4655
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
@@ -4642,7 +4660,7 @@ var defnsSpecialExpression = {
|
|
|
4642
4660
|
var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
|
|
4643
4661
|
assertString(name, sourceCodeInfo);
|
|
4644
4662
|
assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
|
|
4645
|
-
contextStack.
|
|
4663
|
+
contextStack.exportValue(name, true);
|
|
4646
4664
|
var newContext = (_b = {}, _b[name] = { value: true }, _b);
|
|
4647
4665
|
return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
|
|
4648
4666
|
},
|
|
@@ -4852,7 +4870,7 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
|
|
|
4852
4870
|
tkn = asToken(tokenStream.tokens[parseState.position]);
|
|
4853
4871
|
if (node.t === AstNodeType.Modifier) {
|
|
4854
4872
|
switch (node.v) {
|
|
4855
|
-
case '&':
|
|
4873
|
+
case '&rest':
|
|
4856
4874
|
if (state === 'rest')
|
|
4857
4875
|
throw new LitsError('& can only appear once', (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
4858
4876
|
state = 'rest';
|
|
@@ -4915,56 +4933,8 @@ var ifSpecialExpression = {
|
|
|
4915
4933
|
},
|
|
4916
4934
|
};
|
|
4917
4935
|
|
|
4918
|
-
var
|
|
4919
|
-
polishParse:
|
|
4920
|
-
var _b, _c;
|
|
4921
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
4922
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
4923
|
-
if (bindings.length !== 1) {
|
|
4924
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
4925
|
-
}
|
|
4926
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
4927
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4928
|
-
var node = {
|
|
4929
|
-
t: AstNodeType.SpecialExpression,
|
|
4930
|
-
n: 'if-let',
|
|
4931
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
4932
|
-
p: params,
|
|
4933
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
4934
|
-
};
|
|
4935
|
-
return node;
|
|
4936
|
-
},
|
|
4937
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
|
|
4938
|
-
evaluate: function (node, contextStack, _a) {
|
|
4939
|
-
var _b;
|
|
4940
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
4941
|
-
var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
|
|
4942
|
-
var locals = {};
|
|
4943
|
-
var bindingValue = evaluateAstNode(node.b.v, contextStack);
|
|
4944
|
-
if (bindingValue) {
|
|
4945
|
-
locals[node.b.n] = { value: bindingValue };
|
|
4946
|
-
var newContextStack = contextStack.create(locals);
|
|
4947
|
-
var thenForm = asAstNode(node.p[0], sourceCodeInfo);
|
|
4948
|
-
return evaluateAstNode(thenForm, newContextStack);
|
|
4949
|
-
}
|
|
4950
|
-
if (node.p.length === 2) {
|
|
4951
|
-
var elseForm = asAstNode(node.p[1], sourceCodeInfo);
|
|
4952
|
-
return evaluateAstNode(elseForm, contextStack);
|
|
4953
|
-
}
|
|
4954
|
-
return null;
|
|
4955
|
-
},
|
|
4956
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
4957
|
-
var _b;
|
|
4958
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
4959
|
-
var newContext = (_b = {}, _b[node.b.n] = { value: true }, _b);
|
|
4960
|
-
var bindingResult = findUnresolvedIdentifiers([node.b.v], contextStack, builtin);
|
|
4961
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
4962
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
4963
|
-
},
|
|
4964
|
-
};
|
|
4965
|
-
|
|
4966
|
-
var ifNotSpecialExpression = {
|
|
4967
|
-
polishParse: getCommonPolishSpecialExpressionParser('if-not'),
|
|
4936
|
+
var unlessSpecialExpression = {
|
|
4937
|
+
polishParse: getCommonPolishSpecialExpressionParser('unless'),
|
|
4968
4938
|
validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
|
|
4969
4939
|
evaluate: function (node, contextStack, _a) {
|
|
4970
4940
|
var _b;
|
|
@@ -4989,55 +4959,39 @@ var ifNotSpecialExpression = {
|
|
|
4989
4959
|
|
|
4990
4960
|
var letSpecialExpression = {
|
|
4991
4961
|
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
4992
|
-
var parseBindings = _a.parseBindings
|
|
4962
|
+
var parseBindings = _a.parseBindings;
|
|
4993
4963
|
var bindings = parseBindings(tokenStream, parseState);
|
|
4994
|
-
|
|
4964
|
+
// const params = parseTokensUntilClosingBracket(tokenStream, parseState)
|
|
4995
4965
|
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
4996
4966
|
var node = {
|
|
4997
4967
|
t: AstNodeType.SpecialExpression,
|
|
4998
4968
|
n: 'let',
|
|
4999
|
-
p:
|
|
4969
|
+
p: [],
|
|
5000
4970
|
bs: bindings,
|
|
5001
4971
|
token: getTokenDebugData(firstToken) && firstToken,
|
|
5002
4972
|
};
|
|
5003
4973
|
return node;
|
|
5004
4974
|
},
|
|
5005
|
-
validateParameterCount: function () { return
|
|
4975
|
+
validateParameterCount: function (node) { return assertNumberOfParams(0, node); },
|
|
5006
4976
|
evaluate: function (node, contextStack, _a) {
|
|
5007
|
-
var e_1, _b
|
|
4977
|
+
var e_1, _b;
|
|
5008
4978
|
var evaluateAstNode = _a.evaluateAstNode;
|
|
5009
|
-
var locals = {};
|
|
5010
|
-
var newContextStack = contextStack.create(locals);
|
|
5011
4979
|
try {
|
|
5012
|
-
for (var
|
|
5013
|
-
var binding =
|
|
4980
|
+
for (var _c = __values(node.bs), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
4981
|
+
var binding = _d.value;
|
|
5014
4982
|
var bindingValueNode = binding.v;
|
|
5015
|
-
var bindingValue = evaluateAstNode(bindingValueNode,
|
|
5016
|
-
|
|
4983
|
+
var bindingValue = evaluateAstNode(bindingValueNode, contextStack);
|
|
4984
|
+
contextStack.addValue(binding.n, bindingValue);
|
|
5017
4985
|
}
|
|
5018
4986
|
}
|
|
5019
4987
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5020
4988
|
finally {
|
|
5021
4989
|
try {
|
|
5022
|
-
if (
|
|
4990
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5023
4991
|
}
|
|
5024
4992
|
finally { if (e_1) throw e_1.error; }
|
|
5025
4993
|
}
|
|
5026
|
-
|
|
5027
|
-
try {
|
|
5028
|
-
for (var _f = __values(node.p), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
5029
|
-
var astNode = _g.value;
|
|
5030
|
-
result = evaluateAstNode(astNode, newContextStack);
|
|
5031
|
-
}
|
|
5032
|
-
}
|
|
5033
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
5034
|
-
finally {
|
|
5035
|
-
try {
|
|
5036
|
-
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
|
|
5037
|
-
}
|
|
5038
|
-
finally { if (e_2) throw e_2.error; }
|
|
5039
|
-
}
|
|
5040
|
-
return result;
|
|
4994
|
+
return null;
|
|
5041
4995
|
},
|
|
5042
4996
|
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5043
4997
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
@@ -5047,11 +5001,10 @@ var letSpecialExpression = {
|
|
|
5047
5001
|
context[name] = { value: true };
|
|
5048
5002
|
return context;
|
|
5049
5003
|
}, {});
|
|
5050
|
-
var bindingContext = {};
|
|
5051
5004
|
var bindingResults = node.bs.map(function (bindingNode) {
|
|
5052
5005
|
var valueNode = bindingNode.v;
|
|
5053
|
-
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack
|
|
5054
|
-
|
|
5006
|
+
var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack, builtin);
|
|
5007
|
+
contextStack.addValue(bindingNode.n, { value: true });
|
|
5055
5008
|
return bindingsResult;
|
|
5056
5009
|
});
|
|
5057
5010
|
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
@@ -5174,7 +5127,7 @@ function parseLoopBinding(tokenStream, parseState, _a) {
|
|
|
5174
5127
|
loopBinding.we = parseToken(tokenStream, parseState);
|
|
5175
5128
|
loopBinding.m.push('&while');
|
|
5176
5129
|
break;
|
|
5177
|
-
case '&':
|
|
5130
|
+
case '&rest':
|
|
5178
5131
|
throw new LitsError("Illegal modifier: ".concat(modifier), (_e = getTokenDebugData(tkn)) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
|
|
5179
5132
|
default:
|
|
5180
5133
|
throw new LitsError("Illegal modifier: ".concat(modifier), (_f = getTokenDebugData(tkn)) === null || _f === void 0 ? void 0 : _f.sourceCodeInfo);
|
|
@@ -5374,7 +5327,7 @@ var doseqSpecialExpression = {
|
|
|
5374
5327
|
};
|
|
5375
5328
|
|
|
5376
5329
|
var orSpecialExpression = {
|
|
5377
|
-
polishParse: getCommonPolishSpecialExpressionParser('
|
|
5330
|
+
polishParse: getCommonPolishSpecialExpressionParser('||'),
|
|
5378
5331
|
validateParameterCount: function () { return undefined; },
|
|
5379
5332
|
evaluate: function (node, contextStack, _a) {
|
|
5380
5333
|
var e_1, _b;
|
|
@@ -5466,25 +5419,6 @@ var throwSpecialExpression = {
|
|
|
5466
5419
|
},
|
|
5467
5420
|
};
|
|
5468
5421
|
|
|
5469
|
-
var timeSpecialExpression = {
|
|
5470
|
-
polishParse: getCommonPolishSpecialExpressionParser('time!'),
|
|
5471
|
-
validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
|
|
5472
|
-
evaluate: function (node, contextStack, _a) {
|
|
5473
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5474
|
-
var param = node.p[0];
|
|
5475
|
-
var startTime = Date.now();
|
|
5476
|
-
var result = evaluateAstNode(param, contextStack);
|
|
5477
|
-
var totalTime = Date.now() - startTime;
|
|
5478
|
-
// eslint-disable-next-line no-console
|
|
5479
|
-
console.log("Elapsed time: ".concat(totalTime, " ms"));
|
|
5480
|
-
return result;
|
|
5481
|
-
},
|
|
5482
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5483
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5484
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5485
|
-
},
|
|
5486
|
-
};
|
|
5487
|
-
|
|
5488
5422
|
var trySpecialExpression = {
|
|
5489
5423
|
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5490
5424
|
var _b, _c, _d;
|
|
@@ -5521,9 +5455,10 @@ var trySpecialExpression = {
|
|
|
5521
5455
|
return evaluateAstNode(tryExpressions[0], contextStack);
|
|
5522
5456
|
}
|
|
5523
5457
|
catch (error) {
|
|
5524
|
-
var newContext =
|
|
5525
|
-
_b
|
|
5526
|
-
|
|
5458
|
+
var newContext = errorNode
|
|
5459
|
+
? (_b = {},
|
|
5460
|
+
_b[errorNode.v] = { value: asAny(error, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo) },
|
|
5461
|
+
_b) : {};
|
|
5527
5462
|
return evaluateAstNode(catchExpression, contextStack.create(newContext));
|
|
5528
5463
|
}
|
|
5529
5464
|
},
|
|
@@ -5532,288 +5467,128 @@ var trySpecialExpression = {
|
|
|
5532
5467
|
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5533
5468
|
var tryExpressions = node.p, catchExpression = node.ce, errorNode = node.e;
|
|
5534
5469
|
var tryResult = findUnresolvedIdentifiers(tryExpressions, contextStack, builtin);
|
|
5535
|
-
var newContext =
|
|
5536
|
-
_b
|
|
5537
|
-
|
|
5470
|
+
var newContext = errorNode
|
|
5471
|
+
? (_b = {},
|
|
5472
|
+
_b[errorNode.v] = { value: true },
|
|
5473
|
+
_b) : {};
|
|
5538
5474
|
var catchResult = findUnresolvedIdentifiers([catchExpression], contextStack.create(newContext), builtin);
|
|
5539
5475
|
return joinAnalyzeResults(tryResult, catchResult);
|
|
5540
5476
|
},
|
|
5541
5477
|
};
|
|
5542
5478
|
|
|
5543
|
-
var
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5479
|
+
var specialExpressions = {
|
|
5480
|
+
'&&': andSpecialExpression,
|
|
5481
|
+
'comment': commentSpecialExpression,
|
|
5482
|
+
'cond': condSpecialExpression,
|
|
5483
|
+
'switch': switchSpecialExpression,
|
|
5484
|
+
'def': defSpecialExpression,
|
|
5485
|
+
'defn': defnSpecialExpression,
|
|
5486
|
+
'defns': defnsSpecialExpression,
|
|
5487
|
+
'defs': defsSpecialExpression,
|
|
5488
|
+
'do': doSpecialExpression,
|
|
5489
|
+
'doseq': doseqSpecialExpression,
|
|
5490
|
+
'for': forSpecialExpression,
|
|
5491
|
+
'fn': fnSpecialExpression,
|
|
5492
|
+
'if': ifSpecialExpression,
|
|
5493
|
+
'unless': unlessSpecialExpression,
|
|
5494
|
+
'let': letSpecialExpression,
|
|
5495
|
+
'loop': loopSpecialExpression,
|
|
5496
|
+
'||': orSpecialExpression,
|
|
5497
|
+
'recur': recurSpecialExpression,
|
|
5498
|
+
'throw': throwSpecialExpression,
|
|
5499
|
+
'try': trySpecialExpression,
|
|
5500
|
+
'defined?': declaredSpecialExpression,
|
|
5501
|
+
'??': qqSpecialExpression,
|
|
5502
|
+
};
|
|
5503
|
+
Object.keys(specialExpressions).forEach(function (key) {
|
|
5504
|
+
/* v8 ignore next 2 */
|
|
5505
|
+
if (normalExpressions[key])
|
|
5506
|
+
throw new Error("Expression ".concat(key, " is defined as both a normal expression and a special expression"));
|
|
5507
|
+
});
|
|
5508
|
+
var builtin = {
|
|
5509
|
+
normalExpressions: normalExpressions,
|
|
5510
|
+
specialExpressions: specialExpressions,
|
|
5511
|
+
};
|
|
5512
|
+
var normalExpressionKeys = Object.keys(normalExpressions);
|
|
5513
|
+
var specialExpressionKeys = Object.keys(specialExpressions);
|
|
5514
|
+
|
|
5515
|
+
function isContextEntry(value) {
|
|
5516
|
+
return isUnknownRecord(value) && value.value !== undefined;
|
|
5517
|
+
}
|
|
5518
|
+
|
|
5519
|
+
var ContextStackImpl = /** @class */ (function () {
|
|
5520
|
+
function ContextStackImpl(_a) {
|
|
5521
|
+
var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
|
|
5522
|
+
this.globalContext = asNonUndefined(contexts[0]);
|
|
5523
|
+
this.contexts = contexts;
|
|
5524
|
+
this.values = hostValues;
|
|
5525
|
+
this.lazyValues = lazyHostValues;
|
|
5526
|
+
this.nativeJsFunctions = nativeJsFunctions;
|
|
5527
|
+
}
|
|
5528
|
+
ContextStackImpl.prototype.create = function (context, extraData) {
|
|
5529
|
+
var globalContext = this.globalContext;
|
|
5530
|
+
var contextStack = new ContextStackImpl({
|
|
5531
|
+
contexts: __spreadArray([context], __read(this.contexts), false),
|
|
5532
|
+
values: this.values,
|
|
5533
|
+
lazyValues: extraData ? __assign(__assign({}, this.lazyValues), extraData) : this.lazyValues,
|
|
5534
|
+
nativeJsFunctions: this.nativeJsFunctions,
|
|
5535
|
+
});
|
|
5536
|
+
contextStack.globalContext = globalContext;
|
|
5537
|
+
return contextStack;
|
|
5538
|
+
};
|
|
5539
|
+
ContextStackImpl.prototype.exportValue = function (name, value) {
|
|
5540
|
+
if (this.globalContext[name]) {
|
|
5541
|
+
throw new Error("Cannot redefine exported value \"".concat(name, "\""));
|
|
5542
|
+
}
|
|
5543
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5544
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5545
|
+
}
|
|
5546
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5547
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5548
|
+
}
|
|
5549
|
+
this.addValue(name, value);
|
|
5550
|
+
this.globalContext[name] = { value: value };
|
|
5551
|
+
};
|
|
5552
|
+
ContextStackImpl.prototype.addValue = function (name, value) {
|
|
5553
|
+
var currentContext = this.contexts[0];
|
|
5554
|
+
if (!currentContext) {
|
|
5555
|
+
throw new Error('No context to add value to');
|
|
5556
|
+
}
|
|
5557
|
+
if (currentContext[name]) {
|
|
5558
|
+
throw new Error("Cannot redefine value \"".concat(name, "\""));
|
|
5559
|
+
}
|
|
5560
|
+
if (specialExpressionKeys.includes(name)) {
|
|
5561
|
+
throw new Error("Cannot shadow special expression \"".concat(name, "\""));
|
|
5562
|
+
}
|
|
5563
|
+
if (normalExpressionKeys.includes(name)) {
|
|
5564
|
+
throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
|
|
5565
|
+
}
|
|
5566
|
+
currentContext[name] = { value: toAny(value) };
|
|
5567
|
+
};
|
|
5568
|
+
ContextStackImpl.prototype.clone = function () {
|
|
5569
|
+
// eslint-disable-next-line ts/no-unsafe-argument
|
|
5570
|
+
return new ContextStackImpl(JSON.parse(JSON.stringify({
|
|
5571
|
+
contexts: this.contexts,
|
|
5572
|
+
values: this.values,
|
|
5573
|
+
lazyValues: this.lazyValues,
|
|
5574
|
+
nativeJsFunctions: this.nativeJsFunctions,
|
|
5575
|
+
})));
|
|
5576
|
+
};
|
|
5577
|
+
ContextStackImpl.prototype.getValue = function (name) {
|
|
5578
|
+
var e_1, _a;
|
|
5579
|
+
var _b, _c, _d;
|
|
5555
5580
|
try {
|
|
5556
|
-
for (var
|
|
5557
|
-
var
|
|
5558
|
-
|
|
5581
|
+
for (var _e = __values(this.contexts), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5582
|
+
var context = _f.value;
|
|
5583
|
+
var contextEntry = context[name];
|
|
5584
|
+
if (contextEntry)
|
|
5585
|
+
return contextEntry.value;
|
|
5559
5586
|
}
|
|
5560
5587
|
}
|
|
5561
5588
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5562
5589
|
finally {
|
|
5563
5590
|
try {
|
|
5564
|
-
if (
|
|
5565
|
-
}
|
|
5566
|
-
finally { if (e_1) throw e_1.error; }
|
|
5567
|
-
}
|
|
5568
|
-
return result;
|
|
5569
|
-
},
|
|
5570
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5571
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5572
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5573
|
-
},
|
|
5574
|
-
};
|
|
5575
|
-
|
|
5576
|
-
var whenFirstSpecialExpression = {
|
|
5577
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5578
|
-
var _b, _c;
|
|
5579
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5580
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5581
|
-
if (bindings.length !== 1) {
|
|
5582
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5583
|
-
}
|
|
5584
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5585
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5586
|
-
var node = {
|
|
5587
|
-
t: AstNodeType.SpecialExpression,
|
|
5588
|
-
n: 'when-first',
|
|
5589
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5590
|
-
p: params,
|
|
5591
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5592
|
-
};
|
|
5593
|
-
return node;
|
|
5594
|
-
},
|
|
5595
|
-
validateParameterCount: function () { return undefined; },
|
|
5596
|
-
evaluate: function (node, contextStack, _a) {
|
|
5597
|
-
var e_1, _b;
|
|
5598
|
-
var _c;
|
|
5599
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5600
|
-
var locals = {};
|
|
5601
|
-
var binding = node.b;
|
|
5602
|
-
var evaluatedBindingForm = evaluateAstNode(binding.v, contextStack);
|
|
5603
|
-
if (!isSeq(evaluatedBindingForm)) {
|
|
5604
|
-
throw new LitsError("Expected undefined or a sequence, got ".concat(valueToString(evaluatedBindingForm)), (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5605
|
-
}
|
|
5606
|
-
if (evaluatedBindingForm.length === 0)
|
|
5607
|
-
return null;
|
|
5608
|
-
var bindingValue = toAny(evaluatedBindingForm[0]);
|
|
5609
|
-
locals[binding.n] = { value: bindingValue };
|
|
5610
|
-
var newContextStack = contextStack.create(locals);
|
|
5611
|
-
var result = null;
|
|
5612
|
-
try {
|
|
5613
|
-
for (var _d = __values(node.p), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
5614
|
-
var form = _e.value;
|
|
5615
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5616
|
-
}
|
|
5617
|
-
}
|
|
5618
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5619
|
-
finally {
|
|
5620
|
-
try {
|
|
5621
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
5622
|
-
}
|
|
5623
|
-
finally { if (e_1) throw e_1.error; }
|
|
5624
|
-
}
|
|
5625
|
-
return result;
|
|
5626
|
-
},
|
|
5627
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5628
|
-
var _b;
|
|
5629
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5630
|
-
var binding = node.b;
|
|
5631
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5632
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5633
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5634
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5635
|
-
},
|
|
5636
|
-
};
|
|
5637
|
-
|
|
5638
|
-
var whenLetSpecialExpression = {
|
|
5639
|
-
polishParse: function (tokenStream, parseState, firstToken, _a) {
|
|
5640
|
-
var _b, _c;
|
|
5641
|
-
var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
|
|
5642
|
-
var bindings = parseBindings(tokenStream, parseState);
|
|
5643
|
-
if (bindings.length !== 1) {
|
|
5644
|
-
throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
5645
|
-
}
|
|
5646
|
-
var params = parseTokensUntilClosingBracket(tokenStream, parseState);
|
|
5647
|
-
assertRParenToken(tokenStream.tokens[parseState.position++]);
|
|
5648
|
-
var node = {
|
|
5649
|
-
t: AstNodeType.SpecialExpression,
|
|
5650
|
-
n: 'when-let',
|
|
5651
|
-
b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
|
|
5652
|
-
p: params,
|
|
5653
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
5654
|
-
};
|
|
5655
|
-
return node;
|
|
5656
|
-
},
|
|
5657
|
-
validateParameterCount: function () { return undefined; },
|
|
5658
|
-
evaluate: function (node, contextStack, _a) {
|
|
5659
|
-
var e_1, _b;
|
|
5660
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5661
|
-
var binding = node.b;
|
|
5662
|
-
var locals = {};
|
|
5663
|
-
var bindingValue = evaluateAstNode(binding.v, contextStack);
|
|
5664
|
-
if (!bindingValue)
|
|
5665
|
-
return null;
|
|
5666
|
-
locals[binding.n] = { value: bindingValue };
|
|
5667
|
-
var newContextStack = contextStack.create(locals);
|
|
5668
|
-
var result = null;
|
|
5669
|
-
try {
|
|
5670
|
-
for (var _c = __values(node.p), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
5671
|
-
var form = _d.value;
|
|
5672
|
-
result = evaluateAstNode(form, newContextStack);
|
|
5673
|
-
}
|
|
5674
|
-
}
|
|
5675
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5676
|
-
finally {
|
|
5677
|
-
try {
|
|
5678
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
5679
|
-
}
|
|
5680
|
-
finally { if (e_1) throw e_1.error; }
|
|
5681
|
-
}
|
|
5682
|
-
return result;
|
|
5683
|
-
},
|
|
5684
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5685
|
-
var _b;
|
|
5686
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5687
|
-
var binding = node.b;
|
|
5688
|
-
var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
|
|
5689
|
-
var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
|
|
5690
|
-
var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
|
|
5691
|
-
return joinAnalyzeResults(bindingResult, paramsResult);
|
|
5692
|
-
},
|
|
5693
|
-
};
|
|
5694
|
-
|
|
5695
|
-
var whenNotSpecialExpression = {
|
|
5696
|
-
polishParse: getCommonPolishSpecialExpressionParser('when-not'),
|
|
5697
|
-
validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
|
|
5698
|
-
evaluate: function (node, contextStack, _a) {
|
|
5699
|
-
var e_1, _b;
|
|
5700
|
-
var _c;
|
|
5701
|
-
var evaluateAstNode = _a.evaluateAstNode;
|
|
5702
|
-
var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
|
|
5703
|
-
assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
|
|
5704
|
-
if (evaluateAstNode(whenExpression, contextStack))
|
|
5705
|
-
return null;
|
|
5706
|
-
var result = null;
|
|
5707
|
-
try {
|
|
5708
|
-
for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
|
|
5709
|
-
var form = body_1_1.value;
|
|
5710
|
-
result = evaluateAstNode(form, contextStack);
|
|
5711
|
-
}
|
|
5712
|
-
}
|
|
5713
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5714
|
-
finally {
|
|
5715
|
-
try {
|
|
5716
|
-
if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
|
|
5717
|
-
}
|
|
5718
|
-
finally { if (e_1) throw e_1.error; }
|
|
5719
|
-
}
|
|
5720
|
-
return result;
|
|
5721
|
-
},
|
|
5722
|
-
findUnresolvedIdentifiers: function (node, contextStack, _a) {
|
|
5723
|
-
var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
|
|
5724
|
-
return findUnresolvedIdentifiers(node.p, contextStack, builtin);
|
|
5725
|
-
},
|
|
5726
|
-
};
|
|
5727
|
-
|
|
5728
|
-
var specialExpressions = {
|
|
5729
|
-
'and': andSpecialExpression,
|
|
5730
|
-
'comment': commentSpecialExpression,
|
|
5731
|
-
'cond': condSpecialExpression,
|
|
5732
|
-
'def': defSpecialExpression,
|
|
5733
|
-
'defn': defnSpecialExpression,
|
|
5734
|
-
'defns': defnsSpecialExpression,
|
|
5735
|
-
'defs': defsSpecialExpression,
|
|
5736
|
-
'do': doSpecialExpression,
|
|
5737
|
-
'doseq': doseqSpecialExpression,
|
|
5738
|
-
'for': forSpecialExpression,
|
|
5739
|
-
'fn': fnSpecialExpression,
|
|
5740
|
-
'if': ifSpecialExpression,
|
|
5741
|
-
'if-let': ifLetSpecialExpression,
|
|
5742
|
-
'if-not': ifNotSpecialExpression,
|
|
5743
|
-
'let': letSpecialExpression,
|
|
5744
|
-
'loop': loopSpecialExpression,
|
|
5745
|
-
'or': orSpecialExpression,
|
|
5746
|
-
'recur': recurSpecialExpression,
|
|
5747
|
-
'throw': throwSpecialExpression,
|
|
5748
|
-
'time!': timeSpecialExpression,
|
|
5749
|
-
'try': trySpecialExpression,
|
|
5750
|
-
'when': whenSpecialExpression,
|
|
5751
|
-
'when-first': whenFirstSpecialExpression,
|
|
5752
|
-
'when-let': whenLetSpecialExpression,
|
|
5753
|
-
'when-not': whenNotSpecialExpression,
|
|
5754
|
-
'declared?': declaredSpecialExpression,
|
|
5755
|
-
'??': qqSpecialExpression,
|
|
5756
|
-
};
|
|
5757
|
-
Object.keys(specialExpressions).forEach(function (key) {
|
|
5758
|
-
/* v8 ignore next 2 */
|
|
5759
|
-
if (normalExpressions[key])
|
|
5760
|
-
throw new Error("Expression ".concat(key, " is defined as both a normal expression and a special expression"));
|
|
5761
|
-
});
|
|
5762
|
-
var builtin = {
|
|
5763
|
-
normalExpressions: normalExpressions,
|
|
5764
|
-
specialExpressions: specialExpressions,
|
|
5765
|
-
};
|
|
5766
|
-
var normalExpressionKeys = Object.keys(normalExpressions);
|
|
5767
|
-
var specialExpressionKeys = Object.keys(specialExpressions);
|
|
5768
|
-
|
|
5769
|
-
function isContextEntry(value) {
|
|
5770
|
-
return isUnknownRecord(value) && value.value !== undefined;
|
|
5771
|
-
}
|
|
5772
|
-
|
|
5773
|
-
var ContextStackImpl = /** @class */ (function () {
|
|
5774
|
-
function ContextStackImpl(_a) {
|
|
5775
|
-
var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
|
|
5776
|
-
this.contexts = contexts;
|
|
5777
|
-
this.globalContext = asNonUndefined(contexts[0]);
|
|
5778
|
-
this.values = hostValues;
|
|
5779
|
-
this.lazyValues = lazyHostValues;
|
|
5780
|
-
this.nativeJsFunctions = nativeJsFunctions;
|
|
5781
|
-
}
|
|
5782
|
-
ContextStackImpl.prototype.create = function (context, extraData) {
|
|
5783
|
-
var globalContext = this.globalContext;
|
|
5784
|
-
var contextStack = new ContextStackImpl({
|
|
5785
|
-
contexts: __spreadArray([context], __read(this.contexts), false),
|
|
5786
|
-
values: this.values,
|
|
5787
|
-
lazyValues: extraData ? __assign(__assign({}, this.lazyValues), extraData) : this.lazyValues,
|
|
5788
|
-
nativeJsFunctions: this.nativeJsFunctions,
|
|
5789
|
-
});
|
|
5790
|
-
contextStack.globalContext = globalContext;
|
|
5791
|
-
return contextStack;
|
|
5792
|
-
};
|
|
5793
|
-
ContextStackImpl.prototype.clone = function () {
|
|
5794
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
5795
|
-
return new ContextStackImpl(JSON.parse(JSON.stringify({
|
|
5796
|
-
contexts: this.contexts,
|
|
5797
|
-
values: this.values,
|
|
5798
|
-
lazyValues: this.lazyValues,
|
|
5799
|
-
nativeJsFunctions: this.nativeJsFunctions,
|
|
5800
|
-
})));
|
|
5801
|
-
};
|
|
5802
|
-
ContextStackImpl.prototype.getValue = function (name) {
|
|
5803
|
-
var e_1, _a;
|
|
5804
|
-
var _b, _c, _d;
|
|
5805
|
-
try {
|
|
5806
|
-
for (var _e = __values(this.contexts), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5807
|
-
var context = _f.value;
|
|
5808
|
-
var contextEntry = context[name];
|
|
5809
|
-
if (contextEntry)
|
|
5810
|
-
return contextEntry.value;
|
|
5811
|
-
}
|
|
5812
|
-
}
|
|
5813
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5814
|
-
finally {
|
|
5815
|
-
try {
|
|
5816
|
-
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
5591
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
5817
5592
|
}
|
|
5818
5593
|
finally { if (e_1) throw e_1.error; }
|
|
5819
5594
|
}
|
|
@@ -5919,7 +5694,7 @@ function createContextStack(params) {
|
|
|
5919
5694
|
return acc;
|
|
5920
5695
|
}, {}),
|
|
5921
5696
|
});
|
|
5922
|
-
return contextStack;
|
|
5697
|
+
return contextStack.create({});
|
|
5923
5698
|
}
|
|
5924
5699
|
|
|
5925
5700
|
var _a$2;
|
|
@@ -6231,7 +6006,14 @@ function evaluateNumberAsFunction(fn, params, sourceCodeInfo) {
|
|
|
6231
6006
|
|
|
6232
6007
|
var findUnresolvedIdentifiers = function (ast, contextStack, builtin) {
|
|
6233
6008
|
var e_1, _a;
|
|
6234
|
-
var astNodes = Array.isArray(ast)
|
|
6009
|
+
var astNodes = Array.isArray(ast)
|
|
6010
|
+
? ast
|
|
6011
|
+
: [{
|
|
6012
|
+
t: AstNodeType.SpecialExpression,
|
|
6013
|
+
n: 'do',
|
|
6014
|
+
p: ast.b,
|
|
6015
|
+
token: undefined,
|
|
6016
|
+
}];
|
|
6235
6017
|
var unresolvedIdentifiers = new Set();
|
|
6236
6018
|
try {
|
|
6237
6019
|
for (var astNodes_1 = __values(astNodes), astNodes_1_1 = astNodes_1.next(); !astNodes_1_1.done; astNodes_1_1 = astNodes_1.next()) {
|
|
@@ -6296,545 +6078,16 @@ function findUnresolvedIdentifiersInAstNode(astNode, contextStack, builtin) {
|
|
|
6296
6078
|
var unresolvedIdentifiers = specialExpression.findUnresolvedIdentifiers(astNode, contextStack, {
|
|
6297
6079
|
findUnresolvedIdentifiers: findUnresolvedIdentifiers,
|
|
6298
6080
|
builtin: builtin,
|
|
6299
|
-
evaluateAstNode: evaluateAstNode,
|
|
6300
|
-
});
|
|
6301
|
-
return unresolvedIdentifiers;
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6304
|
-
}
|
|
6305
|
-
|
|
6306
|
-
var calculateAndOutcomes = function (_a) {
|
|
6307
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6308
|
-
return combinateAstNodes(astNode.p)
|
|
6309
|
-
.map(function (p) { return ({
|
|
6310
|
-
n: 'and',
|
|
6311
|
-
t: AstNodeType.SpecialExpression,
|
|
6312
|
-
p: p,
|
|
6313
|
-
token: astNode.token,
|
|
6314
|
-
}); });
|
|
6315
|
-
};
|
|
6316
|
-
|
|
6317
|
-
var calculateCondOutcomes = function (_a) {
|
|
6318
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, isAstComputable = _a.isAstComputable;
|
|
6319
|
-
var testNodes = arrayToPairs(astNode.p).map(function (_a) {
|
|
6320
|
-
var _b = __read(_a, 1), t = _b[0];
|
|
6321
|
-
return t;
|
|
6322
|
-
});
|
|
6323
|
-
if (isAstComputable(testNodes)) {
|
|
6324
|
-
return combinate(arrayToPairs(astNode.p)
|
|
6325
|
-
// Create a list of ast nodes from the test and form of each condition
|
|
6326
|
-
.reduce(function (acc, _a) {
|
|
6327
|
-
var _b = __read(_a, 2), test = _b[0], form = _b[1];
|
|
6328
|
-
acc.push(calculatePossibleAstNodes(test), calculatePossibleAstNodes(form));
|
|
6329
|
-
return acc;
|
|
6330
|
-
}, []))
|
|
6331
|
-
// Create a new CondNode for each combination of test and form outcomes
|
|
6332
|
-
.map(function (conditionAsts) { return (__assign(__assign({}, astNode), { c: arrayToPairs(conditionAsts).map(function (_a) {
|
|
6333
|
-
var _b = __read(_a, 2), t = _b[0], f = _b[1];
|
|
6334
|
-
return ({ t: t, f: f });
|
|
6335
|
-
}) })); });
|
|
6336
|
-
}
|
|
6337
|
-
return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p).flatMap(function (_a) {
|
|
6338
|
-
var _b = __read(_a, 2); _b[0]; var form = _b[1];
|
|
6339
|
-
return calculatePossibleAstNodes(form);
|
|
6340
|
-
})), false), [
|
|
6341
|
-
nilNode,
|
|
6342
|
-
], false);
|
|
6343
|
-
};
|
|
6344
|
-
|
|
6345
|
-
var trueNode = { t: AstNodeType.ReservedSymbol, v: 'true', token: undefined, p: [], n: undefined };
|
|
6346
|
-
var falseNode = { t: AstNodeType.ReservedSymbol, v: 'false', token: undefined, p: [], n: undefined };
|
|
6347
|
-
var calculateDeclaredOutcomes = function (_a) {
|
|
6348
|
-
var astNode = _a.astNode, isAstComputable = _a.isAstComputable;
|
|
6349
|
-
if (isAstComputable(astNode.p))
|
|
6350
|
-
return [trueNode];
|
|
6351
|
-
return [trueNode, falseNode];
|
|
6352
|
-
};
|
|
6353
|
-
|
|
6354
|
-
var calculateDefOutcomes = function (_a) {
|
|
6355
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6356
|
-
var nameNode = asSymbolNode(astNode.p[0]);
|
|
6357
|
-
var valueNode = astNode.p[1];
|
|
6358
|
-
addGlobalIdentifier(nameNode.v);
|
|
6359
|
-
return calculatePossibleAstNodes(valueNode)
|
|
6360
|
-
.map(function (node) { return (__assign(__assign({}, astNode), { p: [nameNode, node] })); });
|
|
6361
|
-
};
|
|
6362
|
-
|
|
6363
|
-
var calculateDefsOutcomes = function (_a) {
|
|
6364
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6365
|
-
return combinateAstNodes(astNode.p)
|
|
6366
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6367
|
-
};
|
|
6368
|
-
|
|
6369
|
-
var calculateDoOutcomes = function (_a) {
|
|
6370
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6371
|
-
return combinateAstNodes(astNode.p).map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6372
|
-
};
|
|
6373
|
-
|
|
6374
|
-
function calculateFunctionOverloadOutcomes(combinateAstNodes, functionOverloads) {
|
|
6375
|
-
return combinate(functionOverloads
|
|
6376
|
-
// For each overload, calculate the possible outcomes for each parameter
|
|
6377
|
-
.map(function (functionOverload) {
|
|
6378
|
-
var _a;
|
|
6379
|
-
return combinateAstNodes(functionOverload.b, [
|
|
6380
|
-
functionOverload.as.m,
|
|
6381
|
-
functionOverload.as.b.map(function (bindingNode) { return bindingNode.n; }),
|
|
6382
|
-
(_a = functionOverload.as.r) !== null && _a !== void 0 ? _a : [],
|
|
6383
|
-
].flat())
|
|
6384
|
-
// For each combination of parameter outcomes, create a new overload
|
|
6385
|
-
.map(function (body) { return (__assign(__assign({}, functionOverload), { b: body })); });
|
|
6386
|
-
}));
|
|
6387
|
-
}
|
|
6388
|
-
var calculateDefnOutcomes = function (_a) {
|
|
6389
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
|
|
6390
|
-
addGlobalIdentifier(astNode.f.v);
|
|
6391
|
-
// astNode.o is an array of overloads
|
|
6392
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6393
|
-
};
|
|
6394
|
-
var calculateDefnsOutcomes = function (_a) {
|
|
6395
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes;
|
|
6396
|
-
// astNode.o is an array of overloads
|
|
6397
|
-
return calculatePossibleAstNodes(astNode.f).flatMap(function (functionName) {
|
|
6398
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { f: functionName, o: functionOverloads })); });
|
|
6399
|
-
});
|
|
6400
|
-
};
|
|
6401
|
-
var calculateFnOutcomes = function (_a) {
|
|
6402
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6403
|
-
// astNode.o is an array of overloads
|
|
6404
|
-
return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
|
|
6405
|
-
};
|
|
6406
|
-
|
|
6407
|
-
var calculateIfLetOutcomes = function (_a) {
|
|
6408
|
-
var _b;
|
|
6409
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6410
|
-
var bindingNode = astNode.b;
|
|
6411
|
-
var thenBranch = astNode.p[0];
|
|
6412
|
-
var elseBranch = (_b = astNode.p[1]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6413
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6414
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6415
|
-
}
|
|
6416
|
-
var newIdentifier = bindingNode.n;
|
|
6417
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6418
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6419
|
-
.flatMap(function (b) { return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6420
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); }); });
|
|
6421
|
-
};
|
|
6422
|
-
|
|
6423
|
-
var calculateIfNotOutcomes = function (_a) {
|
|
6424
|
-
var _b;
|
|
6425
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6426
|
-
var condition = astNode.p[0];
|
|
6427
|
-
var thenBranch = astNode.p[1];
|
|
6428
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6429
|
-
if (isAstComputable(condition)) {
|
|
6430
|
-
return combinateAstNodes(astNode.p)
|
|
6431
|
-
.map(function (p) { return ({
|
|
6432
|
-
n: 'if-not',
|
|
6433
|
-
t: astNode.t,
|
|
6434
|
-
p: p,
|
|
6435
|
-
token: astNode.token,
|
|
6436
|
-
}); });
|
|
6437
|
-
}
|
|
6438
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6439
|
-
};
|
|
6440
|
-
|
|
6441
|
-
var calculateIfOutcomes = function (_a) {
|
|
6442
|
-
var _b;
|
|
6443
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6444
|
-
var condition = astNode.p[0];
|
|
6445
|
-
var thenBranch = astNode.p[1];
|
|
6446
|
-
var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
|
|
6447
|
-
if (isAstComputable(condition)) {
|
|
6448
|
-
return combinateAstNodes(astNode.p)
|
|
6449
|
-
.map(function (p) { return ({
|
|
6450
|
-
n: 'if',
|
|
6451
|
-
t: astNode.t,
|
|
6452
|
-
p: p,
|
|
6453
|
-
token: astNode.token,
|
|
6454
|
-
}); });
|
|
6455
|
-
}
|
|
6456
|
-
return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
|
|
6457
|
-
};
|
|
6458
|
-
|
|
6459
|
-
var calculateLetOutcomes = function (_a) {
|
|
6460
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6461
|
-
try {
|
|
6462
|
-
// check bindings, if any binding value cannot be calculated, convert the whole let to a do-expression
|
|
6463
|
-
if (!isAstComputable(astNode.bs.map(function (b) { return calculatePossibleAstNodes(b.v); })))
|
|
6464
|
-
throw new Error('Could not calculate binding value');
|
|
6465
|
-
}
|
|
6466
|
-
catch (_b) {
|
|
6467
|
-
var doNodes = combinateAstNodes(astNode.p)
|
|
6468
|
-
.map(function (p) {
|
|
6469
|
-
return {
|
|
6470
|
-
n: 'do',
|
|
6471
|
-
t: AstNodeType.SpecialExpression,
|
|
6472
|
-
p: p,
|
|
6473
|
-
token: astNode.token,
|
|
6474
|
-
};
|
|
6475
|
-
});
|
|
6476
|
-
return doNodes;
|
|
6477
|
-
}
|
|
6478
|
-
var newIdentifiers = astNode.bs.map(function (bindingNode) { return bindingNode.n; });
|
|
6479
|
-
var letNodes = combinate(astNode.bs.map(function (bindingNode) {
|
|
6480
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6481
|
-
.map(function (bindingValues) { return (__assign(__assign({}, bindingNode), { v: bindingValues })); });
|
|
6482
|
-
}))
|
|
6483
|
-
.flatMap(function (bindingNodes) { return combinate(astNode.p.map(function (p) { return calculatePossibleAstNodes(p, newIdentifiers); }))
|
|
6484
|
-
.map(function (p) {
|
|
6485
|
-
return {
|
|
6486
|
-
n: 'let',
|
|
6487
|
-
bs: bindingNodes,
|
|
6488
|
-
t: AstNodeType.SpecialExpression,
|
|
6489
|
-
p: p,
|
|
6490
|
-
token: astNode.token,
|
|
6491
|
-
};
|
|
6492
|
-
}); });
|
|
6493
|
-
return letNodes;
|
|
6494
|
-
};
|
|
6495
|
-
|
|
6496
|
-
var calculateForOutcomes = function (_a) {
|
|
6497
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6498
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6499
|
-
throw new Error('Could not calculate for loop, not deterministic');
|
|
6500
|
-
return [astNode];
|
|
6501
|
-
};
|
|
6502
|
-
var calculateDoSeqOutcomes = function (_a) {
|
|
6503
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6504
|
-
if (!isDeterministic(calculatePossibleAstNodes, astNode))
|
|
6505
|
-
throw new Error('Could not calculate doSeq node, not deterministic');
|
|
6506
|
-
return [astNode];
|
|
6507
|
-
};
|
|
6508
|
-
function isDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6509
|
-
var e_1, _a;
|
|
6510
|
-
try {
|
|
6511
|
-
for (var _b = __values(astNode.l), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6512
|
-
var _d = _c.value, b = _d.b, l = _d.l, wn = _d.wn, we = _d.we;
|
|
6513
|
-
if (l && l.some(function (_a) {
|
|
6514
|
-
var v = _a.v;
|
|
6515
|
-
return !astIsDeterministic(calculatePossibleAstNodes, v);
|
|
6516
|
-
}))
|
|
6517
|
-
return false;
|
|
6518
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, b.v))
|
|
6519
|
-
return false;
|
|
6520
|
-
if (wn && !astIsDeterministic(calculatePossibleAstNodes, wn))
|
|
6521
|
-
return false;
|
|
6522
|
-
if (we && !astIsDeterministic(calculatePossibleAstNodes, we))
|
|
6523
|
-
return false;
|
|
6524
|
-
}
|
|
6525
|
-
}
|
|
6526
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6527
|
-
finally {
|
|
6528
|
-
try {
|
|
6529
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6530
|
-
}
|
|
6531
|
-
finally { if (e_1) throw e_1.error; }
|
|
6532
|
-
}
|
|
6533
|
-
if (!astIsDeterministic(calculatePossibleAstNodes, astNode.p[0]))
|
|
6534
|
-
return false;
|
|
6535
|
-
return true;
|
|
6536
|
-
}
|
|
6537
|
-
function astIsDeterministic(calculatePossibleAstNodes, astNode) {
|
|
6538
|
-
return calculatePossibleAstNodes(astNode).length === 1;
|
|
6539
|
-
}
|
|
6540
|
-
|
|
6541
|
-
var calculateOrOutcomes = function (_a) {
|
|
6542
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6543
|
-
return combinateAstNodes(astNode.p)
|
|
6544
|
-
.map(function (p) { return ({
|
|
6545
|
-
n: 'or',
|
|
6546
|
-
t: AstNodeType.SpecialExpression,
|
|
6547
|
-
p: p,
|
|
6548
|
-
token: astNode.token,
|
|
6549
|
-
}); });
|
|
6550
|
-
};
|
|
6551
|
-
|
|
6552
|
-
var calculateQqOutcomes = function (_a) {
|
|
6553
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6554
|
-
if (!isAstComputable(astNode.p[0]))
|
|
6555
|
-
throw new Error('First argument of ?? not computable');
|
|
6556
|
-
return combinateAstNodes(astNode.p)
|
|
6557
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6558
|
-
};
|
|
6559
|
-
|
|
6560
|
-
var calculateThrowOutcomes = function (_a) {
|
|
6561
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6562
|
-
return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
|
|
6563
|
-
};
|
|
6564
|
-
|
|
6565
|
-
var calculateTimeOutcomes = function (_a) {
|
|
6566
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6567
|
-
return calculatePossibleAstNodes(astNode.p[0])
|
|
6568
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { n: 'do', p: [p] })); });
|
|
6569
|
-
};
|
|
6570
|
-
|
|
6571
|
-
var calculateTryOutcomes = function (_a) {
|
|
6572
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
|
|
6573
|
-
var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
|
|
6574
|
-
if (node.n === 'throw') {
|
|
6575
|
-
acc.throws.push(node.p[0]);
|
|
6576
|
-
}
|
|
6577
|
-
else {
|
|
6578
|
-
acc.vals.push(node);
|
|
6579
|
-
}
|
|
6580
|
-
return acc;
|
|
6581
|
-
}, { vals: [], throws: [] }), vals = _b.vals, throws = _b.throws;
|
|
6582
|
-
var catches = throws.flatMap(function (throwNode) {
|
|
6583
|
-
var letNode = {
|
|
6584
|
-
t: AstNodeType.SpecialExpression,
|
|
6585
|
-
n: 'let',
|
|
6586
|
-
bs: [{
|
|
6587
|
-
t: AstNodeType.Binding,
|
|
6588
|
-
n: astNode.e.v,
|
|
6589
|
-
v: throwNode,
|
|
6590
|
-
token: undefined,
|
|
6591
|
-
p: [],
|
|
6592
|
-
}],
|
|
6593
|
-
p: [astNode.ce],
|
|
6594
|
-
token: undefined,
|
|
6595
|
-
};
|
|
6596
|
-
return calculatePossibleAstNodes(letNode);
|
|
6597
|
-
});
|
|
6598
|
-
return __spreadArray(__spreadArray([], __read(vals), false), __read(catches), false);
|
|
6599
|
-
};
|
|
6600
|
-
|
|
6601
|
-
var calculateWhenFirstOutcomes = function (_a) {
|
|
6602
|
-
var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6603
|
-
var bindingNode = astNode.b;
|
|
6604
|
-
if (!isAstComputable(bindingNode.v))
|
|
6605
|
-
throw new Error('Could not calculate binding value');
|
|
6606
|
-
var newIdentifier = bindingNode.n;
|
|
6607
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6608
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6609
|
-
.flatMap(function (b) {
|
|
6610
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6611
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6612
|
-
});
|
|
6613
|
-
};
|
|
6614
|
-
|
|
6615
|
-
var calculateWhenLetOutcomes = function (_a) {
|
|
6616
|
-
var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
|
|
6617
|
-
var bindingNode = astNode.b;
|
|
6618
|
-
if (!isAstComputable(bindingNode.v)) {
|
|
6619
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(astNode.p)
|
|
6620
|
-
.map(function (p) { return ({
|
|
6621
|
-
n: 'do',
|
|
6622
|
-
t: astNode.t,
|
|
6623
|
-
p: p,
|
|
6624
|
-
token: astNode.token,
|
|
6625
|
-
}); })), false), [
|
|
6626
|
-
nilNode,
|
|
6627
|
-
], false);
|
|
6628
|
-
}
|
|
6629
|
-
var newIdentifier = bindingNode.n;
|
|
6630
|
-
return calculatePossibleAstNodes(bindingNode.v)
|
|
6631
|
-
.map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
|
|
6632
|
-
.flatMap(function (b) {
|
|
6633
|
-
return combinateAstNodes(astNode.p, [newIdentifier])
|
|
6634
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
|
|
6635
|
-
});
|
|
6636
|
-
};
|
|
6637
|
-
|
|
6638
|
-
var calculateWhenNotOutcomes = function (_a) {
|
|
6639
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6640
|
-
var condition = astNode.p[0];
|
|
6641
|
-
if (isAstComputable(condition)) {
|
|
6642
|
-
return combinateAstNodes(astNode.p)
|
|
6643
|
-
.map(function (p) { return ({
|
|
6644
|
-
n: 'when-not',
|
|
6645
|
-
t: astNode.t,
|
|
6646
|
-
p: p,
|
|
6647
|
-
token: astNode.token,
|
|
6648
|
-
}); });
|
|
6649
|
-
}
|
|
6650
|
-
var body = astNode.p.slice(1);
|
|
6651
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6652
|
-
.map(function (p) { return ({
|
|
6653
|
-
n: 'do',
|
|
6654
|
-
t: astNode.t,
|
|
6655
|
-
p: p,
|
|
6656
|
-
token: astNode.token,
|
|
6657
|
-
}); })), false), [
|
|
6658
|
-
nilNode,
|
|
6659
|
-
], false);
|
|
6660
|
-
};
|
|
6661
|
-
|
|
6662
|
-
var calculateWhenOutcomes = function (_a) {
|
|
6663
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
|
|
6664
|
-
var condition = astNode.p[0];
|
|
6665
|
-
if (isAstComputable(condition)) {
|
|
6666
|
-
return combinateAstNodes(astNode.p)
|
|
6667
|
-
.map(function (p) { return ({
|
|
6668
|
-
n: 'when',
|
|
6669
|
-
t: astNode.t,
|
|
6670
|
-
p: p,
|
|
6671
|
-
token: astNode.token,
|
|
6672
|
-
}); });
|
|
6673
|
-
}
|
|
6674
|
-
var body = astNode.p.slice(1);
|
|
6675
|
-
return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
|
|
6676
|
-
.map(function (p) { return ({
|
|
6677
|
-
n: 'do',
|
|
6678
|
-
t: astNode.t,
|
|
6679
|
-
p: p,
|
|
6680
|
-
token: astNode.token,
|
|
6681
|
-
}); })), false), [
|
|
6682
|
-
nilNode,
|
|
6683
|
-
], false);
|
|
6684
|
-
};
|
|
6685
|
-
|
|
6686
|
-
var calculateRecurOutcomes = function (_a) {
|
|
6687
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6688
|
-
return combinateAstNodes(astNode.p)
|
|
6689
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6690
|
-
};
|
|
6691
|
-
|
|
6692
|
-
var calculateCommentOutcomes = function (_a) {
|
|
6693
|
-
var nilNode = _a.nilNode;
|
|
6694
|
-
return [nilNode];
|
|
6695
|
-
};
|
|
6696
|
-
|
|
6697
|
-
var calculateLoopOutcomes = function (_a) {
|
|
6698
|
-
var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
|
|
6699
|
-
return combinateAstNodes(astNode.p, astNode.bs.map(function (bindingNode) { return bindingNode.n; }))
|
|
6700
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6701
|
-
};
|
|
6702
|
-
|
|
6703
|
-
var specialExpressionCalculator = {
|
|
6704
|
-
'and': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6705
|
-
'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6706
|
-
'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6707
|
-
'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6708
|
-
'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6709
|
-
'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6710
|
-
'defns': function (astNode, helperOptions) { return calculateDefnsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6711
|
-
'defs': function (astNode, helperOptions) { return calculateDefsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6712
|
-
'do': function (astNode, helperOptions) { return calculateDoOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6713
|
-
'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6714
|
-
'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6715
|
-
'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6716
|
-
'if-let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6717
|
-
'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6718
|
-
'if-not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6719
|
-
'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6720
|
-
'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6721
|
-
'or': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6722
|
-
'??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6723
|
-
'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6724
|
-
'time!': function (astNode, helperOptions) { return calculateTimeOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6725
|
-
'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6726
|
-
'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6727
|
-
'when-first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6728
|
-
'when-let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6729
|
-
'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6730
|
-
'when-not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
|
|
6731
|
-
};
|
|
6732
|
-
|
|
6733
|
-
function isIdempotent(normalExpressionName) {
|
|
6734
|
-
return !normalExpressionName.endsWith('!')
|
|
6735
|
-
|| normalExpressionName === 'write!';
|
|
6736
|
-
}
|
|
6737
|
-
function calculateOutcomes(contextStack, astNodes) {
|
|
6738
|
-
// First, we try to calculate outcomes for the whole astNodes array.
|
|
6739
|
-
// If that fails, we try to calculate outcomes for the array without the first element.
|
|
6740
|
-
// If that fails, we try to calculate outcomes for the array without the first two elements.
|
|
6741
|
-
// And so on.
|
|
6742
|
-
// This makes it possible to calculate outcomes for e.g.
|
|
6743
|
-
// (write! x) x
|
|
6744
|
-
// Problems occur for e.g.
|
|
6745
|
-
// (def x 1) (write! x) x
|
|
6746
|
-
// This should output [1], but since (write! x) fails to calculate outcomes, we get null.
|
|
6747
|
-
// Ok, but not optimal
|
|
6748
|
-
// The contract is that when an array is returned, it must be correct.
|
|
6749
|
-
// But returning null (indicating that the calculation failed) is always a way out.
|
|
6750
|
-
for (var i = 0; i < astNodes.length; i++) {
|
|
6751
|
-
var usingAstNode = astNodes.slice(i);
|
|
6752
|
-
var outcomes = calculateOutcomesInner(contextStack, usingAstNode);
|
|
6753
|
-
if (outcomes !== null)
|
|
6754
|
-
return outcomes;
|
|
6755
|
-
}
|
|
6756
|
-
return null;
|
|
6757
|
-
}
|
|
6758
|
-
function calculateOutcomesInner(contextStack, astNodes) {
|
|
6759
|
-
var e_1, _a;
|
|
6760
|
-
var possibleAsts = calculatePossibleAsts(contextStack.clone(), astNodes);
|
|
6761
|
-
if (possibleAsts === null)
|
|
6762
|
-
return null;
|
|
6763
|
-
var outcomes = [];
|
|
6764
|
-
try {
|
|
6765
|
-
for (var possibleAsts_1 = __values(possibleAsts), possibleAsts_1_1 = possibleAsts_1.next(); !possibleAsts_1_1.done; possibleAsts_1_1 = possibleAsts_1.next()) {
|
|
6766
|
-
var possibleAst = possibleAsts_1_1.value;
|
|
6767
|
-
var unresolvedIdentifiers = findUnresolvedIdentifiers(possibleAst, contextStack.clone(), builtin);
|
|
6768
|
-
if (unresolvedIdentifiers.size !== 0)
|
|
6769
|
-
return null;
|
|
6770
|
-
var ast = {
|
|
6771
|
-
b: possibleAst,
|
|
6772
|
-
hasDebugData: true,
|
|
6773
|
-
};
|
|
6774
|
-
try {
|
|
6775
|
-
outcomes.push(evaluate(ast, contextStack.clone()));
|
|
6776
|
-
}
|
|
6777
|
-
catch (e) {
|
|
6778
|
-
outcomes.push(e);
|
|
6779
|
-
}
|
|
6780
|
-
}
|
|
6781
|
-
}
|
|
6782
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6783
|
-
finally {
|
|
6784
|
-
try {
|
|
6785
|
-
if (possibleAsts_1_1 && !possibleAsts_1_1.done && (_a = possibleAsts_1.return)) _a.call(possibleAsts_1);
|
|
6081
|
+
evaluateAstNode: evaluateAstNode,
|
|
6082
|
+
});
|
|
6083
|
+
return unresolvedIdentifiers;
|
|
6786
6084
|
}
|
|
6787
|
-
finally { if (e_1) throw e_1.error; }
|
|
6788
|
-
}
|
|
6789
|
-
return outcomes;
|
|
6790
|
-
}
|
|
6791
|
-
function calculatePossibleAsts(contextStack, astNodes) {
|
|
6792
|
-
var possibleAsts;
|
|
6793
|
-
try {
|
|
6794
|
-
possibleAsts = combinate(astNodes.map(function (astNode) { return calculatePossibleAstNodes(contextStack, astNode); }));
|
|
6795
|
-
}
|
|
6796
|
-
catch (e) {
|
|
6797
|
-
return null;
|
|
6798
|
-
}
|
|
6799
|
-
return possibleAsts;
|
|
6800
|
-
}
|
|
6801
|
-
var nilNode = { t: AstNodeType.ReservedSymbol, v: 'nil', token: undefined, p: [], n: undefined };
|
|
6802
|
-
function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
|
|
6803
|
-
var newContext = newIndentifiers
|
|
6804
|
-
? newIndentifiers.reduce(function (acc, identity) {
|
|
6805
|
-
acc[identity] = { value: null };
|
|
6806
|
-
return acc;
|
|
6807
|
-
}, {})
|
|
6808
|
-
: undefined;
|
|
6809
|
-
var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
|
|
6810
|
-
if (astNode.t === AstNodeType.NormalExpression) {
|
|
6811
|
-
if (astNode.n && !isIdempotent(astNode.n))
|
|
6812
|
-
throw new Error("NormalExpressionNode with name ".concat(astNode.n, " is not idempotent. Cannot calculate possible ASTs."));
|
|
6813
|
-
return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
|
|
6814
|
-
.map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
|
|
6815
|
-
}
|
|
6816
|
-
else if (astNode.t === AstNodeType.SpecialExpression) {
|
|
6817
|
-
var helperOptions = {
|
|
6818
|
-
nilNode: nilNode,
|
|
6819
|
-
calculatePossibleAstNodes: function (node, identifiers) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); },
|
|
6820
|
-
combinateAstNodes: function (nodes, identifiers) {
|
|
6821
|
-
return combinate(nodes.map(function (node) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); }));
|
|
6822
|
-
},
|
|
6823
|
-
isAstComputable: function (node) {
|
|
6824
|
-
return calculateOutcomesInner(newContextStack, Array.isArray(node) ? node.flat() : [node]) !== null;
|
|
6825
|
-
},
|
|
6826
|
-
addGlobalIdentifier: function (name) { return newContextStack.globalContext[name] = { value: null }; },
|
|
6827
|
-
};
|
|
6828
|
-
// eslint-disable-next-line ts/no-unsafe-argument
|
|
6829
|
-
return specialExpressionCalculator[astNode.n](astNode, helperOptions);
|
|
6830
6085
|
}
|
|
6831
|
-
return [astNode];
|
|
6832
6086
|
}
|
|
6833
6087
|
|
|
6834
6088
|
function analyze(ast, params) {
|
|
6835
6089
|
return {
|
|
6836
6090
|
unresolvedIdentifiers: findUnresolvedIdentifiers(ast, createContextStack(params), builtin),
|
|
6837
|
-
outcomes: calculateOutcomes(createContextStack(params), ast.b),
|
|
6838
6091
|
};
|
|
6839
6092
|
}
|
|
6840
6093
|
|
|
@@ -7036,13 +6289,10 @@ function fromUnaryAlgebraicToAstNode(operator, operand) {
|
|
|
7036
6289
|
var operatorName = operator[1];
|
|
7037
6290
|
switch (operatorName) {
|
|
7038
6291
|
case '+':
|
|
7039
|
-
return createNamedNormalExpressionNode('+', [operand], token);
|
|
7040
6292
|
case '-':
|
|
7041
|
-
return createNamedNormalExpressionNode('-', [operand], token);
|
|
7042
6293
|
case '!':
|
|
7043
|
-
return createNamedNormalExpressionNode('not', [operand], token);
|
|
7044
6294
|
case '~':
|
|
7045
|
-
return createNamedNormalExpressionNode(
|
|
6295
|
+
return createNamedNormalExpressionNode(operatorName, [operand], token);
|
|
7046
6296
|
/* v8 ignore next 2 */
|
|
7047
6297
|
default:
|
|
7048
6298
|
throw new Error("Unknown operator: ".concat(operatorName));
|
|
@@ -7055,64 +6305,31 @@ function fromBinaryOperatorToAstNode(operator, left, right, token) {
|
|
|
7055
6305
|
case '.':
|
|
7056
6306
|
return createAccessorNode(left, fromSymbolToStringNode(asSymbolNode(right, (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo)), token);
|
|
7057
6307
|
case '**': // exponentiation
|
|
7058
|
-
return createNamedNormalExpressionNode('pow', [left, right], token);
|
|
7059
6308
|
case '*':
|
|
7060
|
-
return createNamedNormalExpressionNode('*', [left, right], token);
|
|
7061
6309
|
case '/':
|
|
7062
|
-
return createNamedNormalExpressionNode('/', [left, right], token);
|
|
7063
6310
|
case '%':
|
|
7064
|
-
return createNamedNormalExpressionNode('rem', [left, right], token);
|
|
7065
6311
|
case '+':
|
|
7066
|
-
return createNamedNormalExpressionNode('+', [left, right], token);
|
|
7067
6312
|
case '-':
|
|
7068
|
-
return createNamedNormalExpressionNode('-', [left, right], token);
|
|
7069
6313
|
case '<<':
|
|
7070
|
-
return createNamedNormalExpressionNode('bit-shift-left', [left, right], token);
|
|
7071
6314
|
case '>>':
|
|
7072
|
-
return createNamedNormalExpressionNode('bit-shift-right', [left, right], token);
|
|
7073
6315
|
case '>>>':
|
|
7074
|
-
|
|
7075
|
-
case '++': {
|
|
7076
|
-
var leftString = createNamedNormalExpressionNode('str', [left], token);
|
|
7077
|
-
var rightString = createNamedNormalExpressionNode('str', [right], token);
|
|
7078
|
-
return createNamedNormalExpressionNode('str', [leftString, rightString], token);
|
|
7079
|
-
}
|
|
6316
|
+
case '++':
|
|
7080
6317
|
case '<':
|
|
7081
|
-
return createNamedNormalExpressionNode('<', [left, right], token);
|
|
7082
6318
|
case '<=':
|
|
7083
|
-
return createNamedNormalExpressionNode('<=', [left, right], token);
|
|
7084
6319
|
case '>':
|
|
7085
|
-
return createNamedNormalExpressionNode('>', [left, right], token);
|
|
7086
6320
|
case '>=':
|
|
7087
|
-
return createNamedNormalExpressionNode('>=', [left, right], token);
|
|
7088
6321
|
case '==':
|
|
7089
|
-
return createNamedNormalExpressionNode('=', [left, right], token);
|
|
7090
6322
|
case '!=':
|
|
7091
|
-
return createNamedNormalExpressionNode('!=', [left, right], token);
|
|
7092
6323
|
case '&':
|
|
7093
|
-
return createNamedNormalExpressionNode('bit-and', [left, right], token);
|
|
7094
6324
|
case '^':
|
|
7095
|
-
return createNamedNormalExpressionNode('bit-xor', [left, right], token);
|
|
7096
6325
|
case '|':
|
|
7097
|
-
return createNamedNormalExpressionNode(
|
|
6326
|
+
return createNamedNormalExpressionNode(operatorName, [left, right], token);
|
|
7098
6327
|
case '&&':
|
|
7099
|
-
return {
|
|
7100
|
-
t: AstNodeType.SpecialExpression,
|
|
7101
|
-
n: 'and',
|
|
7102
|
-
p: [left, right],
|
|
7103
|
-
token: getTokenDebugData(token) && token,
|
|
7104
|
-
};
|
|
7105
6328
|
case '||':
|
|
7106
|
-
return {
|
|
7107
|
-
t: AstNodeType.SpecialExpression,
|
|
7108
|
-
n: 'or',
|
|
7109
|
-
p: [left, right],
|
|
7110
|
-
token: getTokenDebugData(token) && token,
|
|
7111
|
-
};
|
|
7112
6329
|
case '??':
|
|
7113
6330
|
return {
|
|
7114
6331
|
t: AstNodeType.SpecialExpression,
|
|
7115
|
-
n:
|
|
6332
|
+
n: operatorName,
|
|
7116
6333
|
p: [left, right],
|
|
7117
6334
|
token: getTokenDebugData(token) && token,
|
|
7118
6335
|
};
|
|
@@ -7152,19 +6369,43 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7152
6369
|
var _a;
|
|
7153
6370
|
if (precedence === void 0) { precedence = 0; }
|
|
7154
6371
|
var firstToken = this.peek();
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
6372
|
+
var left;
|
|
6373
|
+
if (isA_SymbolToken(firstToken)) {
|
|
6374
|
+
switch (firstToken[1]) {
|
|
6375
|
+
case 'def':
|
|
6376
|
+
return this.parseDef(firstToken);
|
|
6377
|
+
case 'defn':
|
|
6378
|
+
return this.parseDefn(firstToken);
|
|
6379
|
+
case 'let':
|
|
6380
|
+
return this.parseLet(firstToken);
|
|
6381
|
+
case 'if':
|
|
6382
|
+
case 'unless':
|
|
6383
|
+
left = this.parseIfOrUnless(firstToken);
|
|
6384
|
+
break;
|
|
6385
|
+
case 'cond':
|
|
6386
|
+
left = this.parseCond(firstToken);
|
|
6387
|
+
break;
|
|
6388
|
+
case 'switch':
|
|
6389
|
+
left = this.parseSwitch(firstToken);
|
|
6390
|
+
break;
|
|
6391
|
+
case 'for':
|
|
6392
|
+
case 'doseq':
|
|
6393
|
+
left = this.parseForOrDoseq(firstToken);
|
|
6394
|
+
break;
|
|
6395
|
+
case 'do':
|
|
6396
|
+
left = this.parseDo(firstToken);
|
|
6397
|
+
break;
|
|
6398
|
+
case 'loop':
|
|
6399
|
+
left = this.parseLoop(firstToken);
|
|
6400
|
+
break;
|
|
6401
|
+
case 'try':
|
|
6402
|
+
left = this.parseTry(firstToken);
|
|
6403
|
+
break;
|
|
6404
|
+
}
|
|
7160
6405
|
}
|
|
7161
|
-
|
|
6406
|
+
left || (left = this.parseOperand());
|
|
7162
6407
|
var operator = this.peek();
|
|
7163
|
-
while (!this.
|
|
7164
|
-
&& !isA_OperatorToken(operator, ',')
|
|
7165
|
-
&& !isA_OperatorToken(operator, ';')
|
|
7166
|
-
&& !isRBracketToken(operator)
|
|
7167
|
-
&& !isRParenToken(operator)) {
|
|
6408
|
+
while (!this.isAtExpressionEnd()) {
|
|
7168
6409
|
if (isA_BinaryOperatorToken(operator)) {
|
|
7169
6410
|
var name_1 = operator[1];
|
|
7170
6411
|
var newPrecedece = getPrecedence(name_1);
|
|
@@ -7395,9 +6636,6 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7395
6636
|
var _a, _b;
|
|
7396
6637
|
var isNamedFunction = symbol.t === AstNodeType.Symbol;
|
|
7397
6638
|
this.advance();
|
|
7398
|
-
if (isNamedFunction && symbol.v === 'for') {
|
|
7399
|
-
return this.parseFor(symbol);
|
|
7400
|
-
}
|
|
7401
6639
|
var params = [];
|
|
7402
6640
|
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
7403
6641
|
params.push(this.parseExpression());
|
|
@@ -7418,17 +6656,11 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7418
6656
|
var name_2 = symbol.v;
|
|
7419
6657
|
switch (name_2) {
|
|
7420
6658
|
case '??':
|
|
7421
|
-
case '
|
|
6659
|
+
case '&&':
|
|
7422
6660
|
case 'comment':
|
|
7423
|
-
case '
|
|
7424
|
-
case '
|
|
7425
|
-
case '
|
|
7426
|
-
case 'if-not':
|
|
7427
|
-
case 'or':
|
|
7428
|
-
case 'when':
|
|
7429
|
-
case 'when-not':
|
|
7430
|
-
case 'do':
|
|
7431
|
-
case 'time!':
|
|
6661
|
+
case 'defined?':
|
|
6662
|
+
case '||':
|
|
6663
|
+
case 'recur':
|
|
7432
6664
|
case 'throw': {
|
|
7433
6665
|
var node = {
|
|
7434
6666
|
t: AstNodeType.SpecialExpression,
|
|
@@ -7439,17 +6671,10 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7439
6671
|
builtin.specialExpressions[node.n].validateParameterCount(node);
|
|
7440
6672
|
return node;
|
|
7441
6673
|
}
|
|
7442
|
-
case 'let':
|
|
7443
|
-
return this.parseLet(symbol, params);
|
|
7444
6674
|
case 'defs':
|
|
7445
|
-
case 'if-let':
|
|
7446
|
-
case 'when-let':
|
|
7447
|
-
case 'when-first':
|
|
7448
6675
|
case 'fn':
|
|
7449
6676
|
case 'defns':
|
|
7450
6677
|
case 'try':
|
|
7451
|
-
case 'recur':
|
|
7452
|
-
case 'loop':
|
|
7453
6678
|
case 'doseq':
|
|
7454
6679
|
throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
|
|
7455
6680
|
default:
|
|
@@ -7612,67 +6837,174 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7612
6837
|
};
|
|
7613
6838
|
return node;
|
|
7614
6839
|
};
|
|
7615
|
-
AlgebraicParser.prototype.parseLet = function (
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
var
|
|
7621
|
-
if (letObject.t !== AstNodeType.NormalExpression || letObject.n !== 'object') {
|
|
7622
|
-
throw new LitsError('let expects an object as first argument', (_b = getTokenDebugData(letObject.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
|
|
7623
|
-
}
|
|
7624
|
-
var letBindings = arrayToPairs(letObject.p);
|
|
7625
|
-
var expression = params[1];
|
|
6840
|
+
AlgebraicParser.prototype.parseLet = function (token) {
|
|
6841
|
+
this.advance();
|
|
6842
|
+
var letSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6843
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
6844
|
+
this.advance();
|
|
6845
|
+
var value = this.parseExpression();
|
|
7626
6846
|
return {
|
|
7627
6847
|
t: AstNodeType.SpecialExpression,
|
|
7628
6848
|
n: 'let',
|
|
7629
|
-
p: [
|
|
6849
|
+
p: [],
|
|
7630
6850
|
token: getTokenDebugData(letSymbol.token) && letSymbol.token,
|
|
7631
|
-
bs:
|
|
7632
|
-
var key = pair[0];
|
|
7633
|
-
var value = pair[1];
|
|
7634
|
-
return {
|
|
6851
|
+
bs: [{
|
|
7635
6852
|
t: AstNodeType.Binding,
|
|
7636
|
-
n:
|
|
6853
|
+
n: letSymbol.v,
|
|
7637
6854
|
v: value,
|
|
7638
6855
|
p: [],
|
|
7639
|
-
token: getTokenDebugData(
|
|
7640
|
-
}
|
|
7641
|
-
|
|
6856
|
+
token: getTokenDebugData(token) && token,
|
|
6857
|
+
}],
|
|
6858
|
+
};
|
|
6859
|
+
};
|
|
6860
|
+
AlgebraicParser.prototype.parseDo = function (token) {
|
|
6861
|
+
this.advance();
|
|
6862
|
+
var expressions = [];
|
|
6863
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
6864
|
+
expressions.push(this.parseExpression());
|
|
6865
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6866
|
+
this.advance();
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6870
|
+
this.advance();
|
|
6871
|
+
return {
|
|
6872
|
+
t: AstNodeType.SpecialExpression,
|
|
6873
|
+
n: 'do',
|
|
6874
|
+
p: expressions,
|
|
6875
|
+
token: getTokenDebugData(token) && token,
|
|
6876
|
+
};
|
|
6877
|
+
};
|
|
6878
|
+
AlgebraicParser.prototype.parseLoop = function (token) {
|
|
6879
|
+
var _a;
|
|
6880
|
+
this.advance();
|
|
6881
|
+
assertLParenToken(this.peek());
|
|
6882
|
+
this.advance();
|
|
6883
|
+
var bindingNodes = [];
|
|
6884
|
+
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
6885
|
+
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6886
|
+
assertA_OperatorToken(this.peek(), '=');
|
|
6887
|
+
this.advance();
|
|
6888
|
+
var value = this.parseExpression();
|
|
6889
|
+
bindingNodes.push({
|
|
6890
|
+
t: AstNodeType.Binding,
|
|
6891
|
+
n: symbol.v,
|
|
6892
|
+
v: value,
|
|
6893
|
+
p: [],
|
|
6894
|
+
token: getTokenDebugData(symbol.token) && symbol.token,
|
|
6895
|
+
});
|
|
6896
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
6897
|
+
this.advance();
|
|
6898
|
+
}
|
|
6899
|
+
}
|
|
6900
|
+
if (bindingNodes.length === 0) {
|
|
6901
|
+
throw new LitsError('Expected binding', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
6902
|
+
}
|
|
6903
|
+
assertRParenToken(this.peek());
|
|
6904
|
+
this.advance();
|
|
6905
|
+
var params = [];
|
|
6906
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
6907
|
+
params.push(this.parseExpression());
|
|
6908
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6909
|
+
this.advance();
|
|
6910
|
+
}
|
|
6911
|
+
}
|
|
6912
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6913
|
+
this.advance();
|
|
6914
|
+
return {
|
|
6915
|
+
t: AstNodeType.SpecialExpression,
|
|
6916
|
+
n: 'loop',
|
|
6917
|
+
p: params,
|
|
6918
|
+
bs: bindingNodes,
|
|
6919
|
+
token: getTokenDebugData(token) && token,
|
|
6920
|
+
};
|
|
6921
|
+
};
|
|
6922
|
+
AlgebraicParser.prototype.parseTry = function (token) {
|
|
6923
|
+
this.advance();
|
|
6924
|
+
var tryExpressions = [];
|
|
6925
|
+
while (!this.isAtEnd() && !isA_SymbolToken(this.peek(), 'catch')) {
|
|
6926
|
+
tryExpressions.push(this.parseExpression());
|
|
6927
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6928
|
+
this.advance();
|
|
6929
|
+
}
|
|
6930
|
+
}
|
|
6931
|
+
var tryExpression = tryExpressions.length === 1
|
|
6932
|
+
? tryExpressions[0]
|
|
6933
|
+
: {
|
|
6934
|
+
t: AstNodeType.SpecialExpression,
|
|
6935
|
+
n: 'do',
|
|
6936
|
+
p: tryExpressions,
|
|
6937
|
+
token: getTokenDebugData(token) && token,
|
|
6938
|
+
};
|
|
6939
|
+
assertA_SymbolToken(this.peek(), 'catch');
|
|
6940
|
+
this.advance();
|
|
6941
|
+
var errorSymbol;
|
|
6942
|
+
if (isLParenToken(this.peek())) {
|
|
6943
|
+
this.advance();
|
|
6944
|
+
errorSymbol = parseSymbol(this.tokenStream, this.parseState);
|
|
6945
|
+
assertRParenToken(this.peek());
|
|
6946
|
+
this.advance();
|
|
6947
|
+
}
|
|
6948
|
+
var catchExpressions = [];
|
|
6949
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
6950
|
+
catchExpressions.push(this.parseExpression());
|
|
6951
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
6952
|
+
this.advance();
|
|
6953
|
+
}
|
|
6954
|
+
}
|
|
6955
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6956
|
+
this.advance();
|
|
6957
|
+
var catchExpression = catchExpressions.length === 1
|
|
6958
|
+
? catchExpressions[0]
|
|
6959
|
+
: {
|
|
6960
|
+
t: AstNodeType.SpecialExpression,
|
|
6961
|
+
n: 'do',
|
|
6962
|
+
p: catchExpressions,
|
|
6963
|
+
token: getTokenDebugData(token) && token,
|
|
6964
|
+
};
|
|
6965
|
+
return {
|
|
6966
|
+
t: AstNodeType.SpecialExpression,
|
|
6967
|
+
n: 'try',
|
|
6968
|
+
p: [tryExpression],
|
|
6969
|
+
ce: catchExpression,
|
|
6970
|
+
e: errorSymbol,
|
|
6971
|
+
token: getTokenDebugData(token) && token,
|
|
7642
6972
|
};
|
|
7643
6973
|
};
|
|
7644
|
-
AlgebraicParser.prototype.
|
|
6974
|
+
AlgebraicParser.prototype.parseForOrDoseq = function (token) {
|
|
6975
|
+
var isDoseq = token[1] === 'doseq';
|
|
6976
|
+
this.advance();
|
|
6977
|
+
assertLParenToken(this.peek());
|
|
6978
|
+
this.advance();
|
|
7645
6979
|
var forLoopBindings = [
|
|
7646
6980
|
this.parseForLoopBinding(),
|
|
7647
6981
|
];
|
|
7648
|
-
|
|
7649
|
-
while (isA_SymbolToken(nextToken) && nextToken[1] === 'of') {
|
|
6982
|
+
while (!this.isAtEnd() && !isRParenToken(this.peek())) {
|
|
7650
6983
|
forLoopBindings.push(this.parseForLoopBinding());
|
|
7651
|
-
|
|
6984
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
6985
|
+
this.advance();
|
|
6986
|
+
}
|
|
7652
6987
|
}
|
|
7653
|
-
var expression = this.parseExpression();
|
|
7654
6988
|
assertRParenToken(this.peek());
|
|
7655
6989
|
this.advance();
|
|
6990
|
+
var expression = this.parseExpression();
|
|
6991
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
6992
|
+
this.advance();
|
|
7656
6993
|
return {
|
|
7657
6994
|
t: AstNodeType.SpecialExpression,
|
|
7658
|
-
n: 'for',
|
|
6995
|
+
n: isDoseq ? 'doseq' : 'for',
|
|
7659
6996
|
p: [expression],
|
|
7660
|
-
token: getTokenDebugData(
|
|
6997
|
+
token: getTokenDebugData(token) && token,
|
|
7661
6998
|
l: forLoopBindings,
|
|
7662
6999
|
};
|
|
7663
7000
|
};
|
|
7664
|
-
// export interface LoopBindingNode {
|
|
7665
|
-
// b: BindingNode // Binding
|
|
7666
|
-
// m: Array<'&let' | '&when' | '&while'> // Modifiers
|
|
7667
|
-
// l?: BindingNode[] // Let-Bindings
|
|
7668
|
-
// wn?: AstNode // When Node
|
|
7669
|
-
// we?: AstNode // While Node
|
|
7670
|
-
// }
|
|
7671
7001
|
AlgebraicParser.prototype.parseForLoopBinding = function () {
|
|
7672
7002
|
var _a;
|
|
7673
7003
|
var bindingNode = this.parseBinding();
|
|
7674
|
-
if (isA_OperatorToken(this.peek(), ',')) {
|
|
7675
|
-
this.
|
|
7004
|
+
if (isRParenToken(this.peek()) || isA_OperatorToken(this.peek(), ',')) {
|
|
7005
|
+
if (isA_OperatorToken(this.peek(), ',')) {
|
|
7006
|
+
this.advance();
|
|
7007
|
+
}
|
|
7676
7008
|
return {
|
|
7677
7009
|
b: bindingNode,
|
|
7678
7010
|
m: [],
|
|
@@ -7680,33 +7012,26 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7680
7012
|
}
|
|
7681
7013
|
var modifiers = [];
|
|
7682
7014
|
var token = this.peek();
|
|
7683
|
-
if (!isA_SymbolToken(token)
|
|
7015
|
+
if (!isA_SymbolToken(token, 'let')
|
|
7016
|
+
&& !isA_ReservedSymbolToken(token, 'when')
|
|
7017
|
+
&& !isA_ReservedSymbolToken(token, 'while')) {
|
|
7684
7018
|
throw new LitsError('Expected symbol let, when or while', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7685
7019
|
}
|
|
7686
7020
|
var letBindings;
|
|
7687
7021
|
if (token[1] === 'let') {
|
|
7688
7022
|
modifiers.push('&let');
|
|
7689
7023
|
letBindings = [];
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
return {
|
|
7696
|
-
t: AstNodeType.Binding,
|
|
7697
|
-
n: key.v,
|
|
7698
|
-
v: value,
|
|
7699
|
-
p: [],
|
|
7700
|
-
token: getTokenDebugData(key.token) && key.token,
|
|
7701
|
-
};
|
|
7702
|
-
});
|
|
7024
|
+
while (isA_SymbolToken(token, 'let')) {
|
|
7025
|
+
var letNode = this.parseLet(token);
|
|
7026
|
+
letBindings.push(letNode.bs[0]);
|
|
7027
|
+
token = this.peek();
|
|
7028
|
+
}
|
|
7703
7029
|
}
|
|
7704
7030
|
token = this.peek();
|
|
7705
7031
|
var whenNode;
|
|
7706
7032
|
var whileNode;
|
|
7707
|
-
while (
|
|
7708
|
-
|
|
7709
|
-
|| (token[1] === 'while' && !modifiers.includes('&while')))) {
|
|
7033
|
+
while (isA_ReservedSymbolToken(token, 'when')
|
|
7034
|
+
|| isA_ReservedSymbolToken(token, 'while')) {
|
|
7710
7035
|
this.advance();
|
|
7711
7036
|
if (token[1] === 'when') {
|
|
7712
7037
|
modifiers.push('&when');
|
|
@@ -7716,37 +7041,173 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7716
7041
|
modifiers.push('&while');
|
|
7717
7042
|
whileNode = this.parseExpression();
|
|
7718
7043
|
}
|
|
7719
|
-
token = this.peek();
|
|
7044
|
+
token = this.peek();
|
|
7045
|
+
}
|
|
7046
|
+
if (isA_OperatorToken(token, ',')) {
|
|
7047
|
+
this.advance();
|
|
7048
|
+
}
|
|
7049
|
+
return {
|
|
7050
|
+
b: bindingNode,
|
|
7051
|
+
m: modifiers,
|
|
7052
|
+
l: letBindings,
|
|
7053
|
+
wn: whenNode,
|
|
7054
|
+
we: whileNode,
|
|
7055
|
+
};
|
|
7056
|
+
};
|
|
7057
|
+
AlgebraicParser.prototype.parseBinding = function () {
|
|
7058
|
+
var _a;
|
|
7059
|
+
var firstToken = asA_SymbolToken(this.peek());
|
|
7060
|
+
var name = firstToken[1];
|
|
7061
|
+
this.advance();
|
|
7062
|
+
var ofSymbol = asA_SymbolToken(this.peek());
|
|
7063
|
+
if (ofSymbol[1] !== 'of') {
|
|
7064
|
+
throw new LitsError('Expected "of"', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7065
|
+
}
|
|
7066
|
+
this.advance();
|
|
7067
|
+
var value = this.parseExpression();
|
|
7068
|
+
var node = {
|
|
7069
|
+
t: AstNodeType.Binding,
|
|
7070
|
+
n: name,
|
|
7071
|
+
v: value,
|
|
7072
|
+
p: [],
|
|
7073
|
+
token: getTokenDebugData(firstToken) && firstToken,
|
|
7074
|
+
};
|
|
7075
|
+
return node;
|
|
7076
|
+
};
|
|
7077
|
+
AlgebraicParser.prototype.parseIfOrUnless = function (token) {
|
|
7078
|
+
var isUnless = token[1] === 'unless';
|
|
7079
|
+
this.advance();
|
|
7080
|
+
var condition = this.parseExpression();
|
|
7081
|
+
assertA_ReservedSymbolToken(this.peek(), 'then');
|
|
7082
|
+
this.advance();
|
|
7083
|
+
var thenExpressions = [];
|
|
7084
|
+
while (!this.isAtEnd()
|
|
7085
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'else')
|
|
7086
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7087
|
+
thenExpressions.push(this.parseExpression());
|
|
7088
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7089
|
+
this.advance();
|
|
7090
|
+
}
|
|
7091
|
+
}
|
|
7092
|
+
var thenExpression = thenExpressions.length === 1
|
|
7093
|
+
? thenExpressions[0]
|
|
7094
|
+
: {
|
|
7095
|
+
t: AstNodeType.SpecialExpression,
|
|
7096
|
+
n: 'do',
|
|
7097
|
+
p: thenExpressions,
|
|
7098
|
+
token: getTokenDebugData(token) && token,
|
|
7099
|
+
};
|
|
7100
|
+
var elseExpression;
|
|
7101
|
+
if (isA_ReservedSymbolToken(this.peek(), 'else')) {
|
|
7102
|
+
this.advance();
|
|
7103
|
+
var elseExpressions = [];
|
|
7104
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7105
|
+
elseExpressions.push(this.parseExpression());
|
|
7106
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7107
|
+
this.advance();
|
|
7108
|
+
}
|
|
7109
|
+
}
|
|
7110
|
+
elseExpression = elseExpressions.length === 1
|
|
7111
|
+
? elseExpressions[0]
|
|
7112
|
+
: {
|
|
7113
|
+
t: AstNodeType.SpecialExpression,
|
|
7114
|
+
n: 'do',
|
|
7115
|
+
p: elseExpressions,
|
|
7116
|
+
token: getTokenDebugData(token) && token,
|
|
7117
|
+
};
|
|
7118
|
+
}
|
|
7119
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7120
|
+
this.advance();
|
|
7121
|
+
var params = [condition, thenExpression];
|
|
7122
|
+
if (elseExpression) {
|
|
7123
|
+
params.push(elseExpression);
|
|
7124
|
+
}
|
|
7125
|
+
return {
|
|
7126
|
+
t: AstNodeType.SpecialExpression,
|
|
7127
|
+
n: isUnless ? 'unless' : 'if',
|
|
7128
|
+
p: params,
|
|
7129
|
+
token: getTokenDebugData(token) && token,
|
|
7130
|
+
};
|
|
7131
|
+
};
|
|
7132
|
+
AlgebraicParser.prototype.parseCond = function (token) {
|
|
7133
|
+
this.advance();
|
|
7134
|
+
var params = [];
|
|
7135
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7136
|
+
assertA_ReservedSymbolToken(this.peek(), 'case');
|
|
7137
|
+
this.advance();
|
|
7138
|
+
params.push(this.parseExpression());
|
|
7139
|
+
assertA_ReservedSymbolToken(this.peek(), 'then');
|
|
7140
|
+
this.advance();
|
|
7141
|
+
var expressions = [];
|
|
7142
|
+
while (!this.isAtEnd()
|
|
7143
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'case')
|
|
7144
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7145
|
+
expressions.push(this.parseExpression());
|
|
7146
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7147
|
+
this.advance();
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
7150
|
+
params.push(expressions.length === 1
|
|
7151
|
+
? expressions[0]
|
|
7152
|
+
: {
|
|
7153
|
+
t: AstNodeType.SpecialExpression,
|
|
7154
|
+
n: 'do',
|
|
7155
|
+
p: expressions,
|
|
7156
|
+
token: getTokenDebugData(token) && token,
|
|
7157
|
+
});
|
|
7158
|
+
if (isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7159
|
+
break;
|
|
7160
|
+
}
|
|
7161
|
+
assertA_ReservedSymbolToken(this.peek(), 'case');
|
|
7162
|
+
}
|
|
7163
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7164
|
+
this.advance();
|
|
7165
|
+
return {
|
|
7166
|
+
t: AstNodeType.SpecialExpression,
|
|
7167
|
+
n: 'cond',
|
|
7168
|
+
p: params,
|
|
7169
|
+
token: getTokenDebugData(token) && token,
|
|
7170
|
+
};
|
|
7171
|
+
};
|
|
7172
|
+
AlgebraicParser.prototype.parseSwitch = function (token) {
|
|
7173
|
+
this.advance();
|
|
7174
|
+
var params = [this.parseExpression()];
|
|
7175
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7176
|
+
assertA_ReservedSymbolToken(this.peek(), 'case');
|
|
7177
|
+
this.advance();
|
|
7178
|
+
params.push(this.parseExpression());
|
|
7179
|
+
assertA_ReservedSymbolToken(this.peek(), 'then');
|
|
7180
|
+
this.advance();
|
|
7181
|
+
var expressions = [];
|
|
7182
|
+
while (!this.isAtEnd()
|
|
7183
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'case')
|
|
7184
|
+
&& !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7185
|
+
expressions.push(this.parseExpression());
|
|
7186
|
+
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7187
|
+
this.advance();
|
|
7188
|
+
}
|
|
7189
|
+
}
|
|
7190
|
+
params.push(expressions.length === 1
|
|
7191
|
+
? expressions[0]
|
|
7192
|
+
: {
|
|
7193
|
+
t: AstNodeType.SpecialExpression,
|
|
7194
|
+
n: 'do',
|
|
7195
|
+
p: expressions,
|
|
7196
|
+
token: getTokenDebugData(token) && token,
|
|
7197
|
+
});
|
|
7198
|
+
if (isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7199
|
+
break;
|
|
7200
|
+
}
|
|
7201
|
+
assertA_ReservedSymbolToken(this.peek(), 'case');
|
|
7720
7202
|
}
|
|
7721
|
-
|
|
7203
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7722
7204
|
this.advance();
|
|
7723
7205
|
return {
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
we: whileNode,
|
|
7729
|
-
};
|
|
7730
|
-
};
|
|
7731
|
-
AlgebraicParser.prototype.parseBinding = function () {
|
|
7732
|
-
var _a;
|
|
7733
|
-
var firstToken = asA_SymbolToken(this.peek());
|
|
7734
|
-
var name = firstToken[1];
|
|
7735
|
-
this.advance();
|
|
7736
|
-
var ofSymbol = asA_SymbolToken(this.peek());
|
|
7737
|
-
if (ofSymbol[1] !== 'of') {
|
|
7738
|
-
throw new LitsError('Expected "of"', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7739
|
-
}
|
|
7740
|
-
this.advance();
|
|
7741
|
-
var value = this.parseExpression();
|
|
7742
|
-
var node = {
|
|
7743
|
-
t: AstNodeType.Binding,
|
|
7744
|
-
n: name,
|
|
7745
|
-
v: value,
|
|
7746
|
-
p: [],
|
|
7747
|
-
token: getTokenDebugData(firstToken) && firstToken,
|
|
7206
|
+
t: AstNodeType.SpecialExpression,
|
|
7207
|
+
n: 'switch',
|
|
7208
|
+
p: params,
|
|
7209
|
+
token: getTokenDebugData(token) && token,
|
|
7748
7210
|
};
|
|
7749
|
-
return node;
|
|
7750
7211
|
};
|
|
7751
7212
|
AlgebraicParser.prototype.parseDef = function (token) {
|
|
7752
7213
|
this.advance();
|
|
@@ -7762,22 +7223,17 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7762
7223
|
};
|
|
7763
7224
|
};
|
|
7764
7225
|
AlgebraicParser.prototype.parseDefn = function (token) {
|
|
7765
|
-
var _a;
|
|
7766
7226
|
this.advance();
|
|
7767
7227
|
var symbol = parseSymbol(this.tokenStream, this.parseState);
|
|
7768
|
-
var
|
|
7769
|
-
assertLBraceToken(this.peek());
|
|
7770
|
-
this.advance();
|
|
7228
|
+
var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
|
|
7771
7229
|
var body = [];
|
|
7772
|
-
while (!this.isAtEnd() && !
|
|
7230
|
+
while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
|
|
7773
7231
|
body.push(this.parseExpression());
|
|
7774
7232
|
if (isA_OperatorToken(this.peek(), ';')) {
|
|
7775
7233
|
this.advance();
|
|
7776
7234
|
}
|
|
7777
7235
|
}
|
|
7778
|
-
|
|
7779
|
-
throw new LitsError('Expected closing brace', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
|
|
7780
|
-
}
|
|
7236
|
+
assertA_ReservedSymbolToken(this.peek(), 'end');
|
|
7781
7237
|
this.advance();
|
|
7782
7238
|
return {
|
|
7783
7239
|
t: AstNodeType.SpecialExpression,
|
|
@@ -7795,12 +7251,25 @@ var AlgebraicParser = /** @class */ (function () {
|
|
|
7795
7251
|
AlgebraicParser.prototype.isAtEnd = function () {
|
|
7796
7252
|
return this.parseState.position >= this.tokenStream.tokens.length;
|
|
7797
7253
|
};
|
|
7254
|
+
AlgebraicParser.prototype.isAtExpressionEnd = function () {
|
|
7255
|
+
if (this.isAtEnd()) {
|
|
7256
|
+
return true;
|
|
7257
|
+
}
|
|
7258
|
+
var token = this.peek();
|
|
7259
|
+
if (isA_OperatorToken(token)) {
|
|
7260
|
+
return [';', ','].includes(token[1]);
|
|
7261
|
+
}
|
|
7262
|
+
if (isA_SymbolToken(token)) {
|
|
7263
|
+
return ['catch'].includes(token[1]);
|
|
7264
|
+
}
|
|
7265
|
+
if (isA_ReservedSymbolToken(token)) {
|
|
7266
|
+
return ['else', 'when', 'while', 'then', 'end', 'case'].includes(token[1]);
|
|
7267
|
+
}
|
|
7268
|
+
return false;
|
|
7269
|
+
};
|
|
7798
7270
|
AlgebraicParser.prototype.peek = function () {
|
|
7799
7271
|
return this.tokenStream.tokens[this.parseState.position];
|
|
7800
7272
|
};
|
|
7801
|
-
AlgebraicParser.prototype.peekAhead = function () {
|
|
7802
|
-
return this.tokenStream.tokens[this.parseState.position + 1];
|
|
7803
|
-
};
|
|
7804
7273
|
return AlgebraicParser;
|
|
7805
7274
|
}());
|
|
7806
7275
|
|
|
@@ -8173,8 +7642,8 @@ function parseToken(tokenStream, parseState) {
|
|
|
8173
7642
|
return parsePolishToken(tokenStream, parseState);
|
|
8174
7643
|
}
|
|
8175
7644
|
|
|
8176
|
-
var polishIdentifierCharacterClass = '[\\w
|
|
8177
|
-
var polishIdentifierFirstCharacterClass = '[a-zA-Z_
|
|
7645
|
+
var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:&\|~-]';
|
|
7646
|
+
var polishIdentifierFirstCharacterClass = '[a-zA-Z_@%^?=!$<>+*/&\|~-]';
|
|
8178
7647
|
var algebraicIdentifierCharacterClass = '[\\w$:!?]';
|
|
8179
7648
|
var algebraicIdentifierFirstCharacterClass = '[a-zA-Z_$]';
|
|
8180
7649
|
|
|
@@ -8254,22 +7723,23 @@ var commonTokenizers = [
|
|
|
8254
7723
|
tokenizeString,
|
|
8255
7724
|
];
|
|
8256
7725
|
|
|
8257
|
-
var
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
'recur': { value: null, forbidden: true },
|
|
8269
|
-
'loop': { value: null, forbidden: true },
|
|
8270
|
-
'time!': { value: null, forbidden: true },
|
|
8271
|
-
'doseq': { value: null, forbidden: true },
|
|
7726
|
+
var validAlgebraicReservedNamesRecord = {
|
|
7727
|
+
true: { value: true, forbidden: false },
|
|
7728
|
+
false: { value: false, forbidden: false },
|
|
7729
|
+
nil: { value: null, forbidden: false },
|
|
7730
|
+
null: { value: null, forbidden: false },
|
|
7731
|
+
then: { value: null, forbidden: false },
|
|
7732
|
+
else: { value: null, forbidden: false },
|
|
7733
|
+
end: { value: null, forbidden: false },
|
|
7734
|
+
case: { value: null, forbidden: false },
|
|
7735
|
+
when: { value: null, forbidden: false },
|
|
7736
|
+
while: { value: null, forbidden: false },
|
|
8272
7737
|
};
|
|
7738
|
+
var forbiddenAlgebraicReservedNamesRecord = {
|
|
7739
|
+
fn: { value: null, forbidden: true },
|
|
7740
|
+
defns: { value: null, forbidden: true },
|
|
7741
|
+
};
|
|
7742
|
+
var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
|
|
8273
7743
|
|
|
8274
7744
|
var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
|
|
8275
7745
|
var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
|
|
@@ -8341,45 +7811,19 @@ var tokenizeA_BasePrefixedNumber = function (input, position) {
|
|
|
8341
7811
|
}
|
|
8342
7812
|
return [length, ['A_BasePrefixedNumber', input.substring(position, i)]];
|
|
8343
7813
|
};
|
|
8344
|
-
var tokenizeA_ReservedSymbolToken = function (input, position) {
|
|
8345
|
-
var e_1, _a;
|
|
8346
|
-
try {
|
|
8347
|
-
for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8348
|
-
var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
|
|
8349
|
-
var length_1 = reservedName.length;
|
|
8350
|
-
var nextChar = input[position + length_1];
|
|
8351
|
-
if (nextChar && identifierRegExp.test(nextChar))
|
|
8352
|
-
continue;
|
|
8353
|
-
var name_1 = input.substring(position, position + length_1);
|
|
8354
|
-
if (name_1 === reservedName) {
|
|
8355
|
-
if (forbidden)
|
|
8356
|
-
throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
|
|
8357
|
-
return [length_1, ['A_ReservedSymbol', reservedName]];
|
|
8358
|
-
}
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8362
|
-
finally {
|
|
8363
|
-
try {
|
|
8364
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8365
|
-
}
|
|
8366
|
-
finally { if (e_1) throw e_1.error; }
|
|
8367
|
-
}
|
|
8368
|
-
return NO_MATCH;
|
|
8369
|
-
};
|
|
8370
7814
|
var tokenizeA_Symbol = function (input, position) {
|
|
8371
7815
|
var value = input[position];
|
|
8372
7816
|
if (!value) {
|
|
8373
7817
|
return NO_MATCH;
|
|
8374
7818
|
}
|
|
8375
7819
|
if (value === '\'') {
|
|
8376
|
-
var
|
|
8377
|
-
var char = input[position +
|
|
7820
|
+
var length_1 = 1;
|
|
7821
|
+
var char = input[position + length_1];
|
|
8378
7822
|
var escaping = false;
|
|
8379
7823
|
while (char !== '\'' || escaping) {
|
|
8380
7824
|
if (char === undefined)
|
|
8381
7825
|
throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
|
|
8382
|
-
|
|
7826
|
+
length_1 += 1;
|
|
8383
7827
|
if (escaping) {
|
|
8384
7828
|
escaping = false;
|
|
8385
7829
|
value += char;
|
|
@@ -8390,10 +7834,10 @@ var tokenizeA_Symbol = function (input, position) {
|
|
|
8390
7834
|
}
|
|
8391
7835
|
value += char;
|
|
8392
7836
|
}
|
|
8393
|
-
char = input[position +
|
|
7837
|
+
char = input[position + length_1];
|
|
8394
7838
|
}
|
|
8395
7839
|
value += '\''; // closing quote
|
|
8396
|
-
return [
|
|
7840
|
+
return [length_1 + 1, ['A_Symbol', value]];
|
|
8397
7841
|
}
|
|
8398
7842
|
if (identifierFirstCharacterRegExp.test(value)) {
|
|
8399
7843
|
var initialPosition = position;
|
|
@@ -8408,6 +7852,22 @@ var tokenizeA_Symbol = function (input, position) {
|
|
|
8408
7852
|
}
|
|
8409
7853
|
return NO_MATCH;
|
|
8410
7854
|
};
|
|
7855
|
+
var tokenizeA_ReservedSymbolToken = function (input, position) {
|
|
7856
|
+
var symbolMeta = tokenizeA_Symbol(input, position);
|
|
7857
|
+
if (symbolMeta[0] === 0 || !symbolMeta[1]) {
|
|
7858
|
+
return NO_MATCH;
|
|
7859
|
+
}
|
|
7860
|
+
var symbolName = symbolMeta[1][1];
|
|
7861
|
+
symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
|
|
7862
|
+
var info = algebraicReservedNamesRecord[symbolName];
|
|
7863
|
+
if (!info) {
|
|
7864
|
+
return NO_MATCH;
|
|
7865
|
+
}
|
|
7866
|
+
if (info.forbidden) {
|
|
7867
|
+
throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
|
|
7868
|
+
}
|
|
7869
|
+
return [symbolMeta[0], ['A_ReservedSymbol', symbolName]];
|
|
7870
|
+
};
|
|
8411
7871
|
var tokenizeA_Operator = function (input, position) {
|
|
8412
7872
|
var _a;
|
|
8413
7873
|
var threeChars = input.slice(position, position + 3);
|
|
@@ -8426,30 +7886,30 @@ var tokenizeA_Operator = function (input, position) {
|
|
|
8426
7886
|
};
|
|
8427
7887
|
var tokenizeA_MultiLineComment = function (input, position) {
|
|
8428
7888
|
if (input[position] === '/' && input[position + 1] === '*') {
|
|
8429
|
-
var
|
|
7889
|
+
var length_2 = 2;
|
|
8430
7890
|
var value = '/*';
|
|
8431
|
-
while (input[position +
|
|
8432
|
-
value += input[position +
|
|
8433
|
-
|
|
7891
|
+
while (input[position + length_2] !== '*' && input[position + length_2 + 1] !== '/' && position + length_2 + 1 < input.length) {
|
|
7892
|
+
value += input[position + length_2];
|
|
7893
|
+
length_2 += 1;
|
|
8434
7894
|
}
|
|
8435
|
-
if (position +
|
|
7895
|
+
if (position + length_2 + 1 >= input.length) {
|
|
8436
7896
|
throw new LitsError('Comment not closed', undefined);
|
|
8437
7897
|
}
|
|
8438
7898
|
value += '*/';
|
|
8439
|
-
|
|
8440
|
-
return [
|
|
7899
|
+
length_2 += 2;
|
|
7900
|
+
return [length_2, ['A_MultiLineComment', value]];
|
|
8441
7901
|
}
|
|
8442
7902
|
return NO_MATCH;
|
|
8443
7903
|
};
|
|
8444
7904
|
var tokenizeA_SingleLineComment = function (input, position) {
|
|
8445
7905
|
if (input[position] === '/' && input[position + 1] === '/') {
|
|
8446
|
-
var
|
|
7906
|
+
var length_3 = 2;
|
|
8447
7907
|
var value = '//';
|
|
8448
|
-
while (input[position +
|
|
8449
|
-
value += input[position +
|
|
8450
|
-
|
|
7908
|
+
while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
|
|
7909
|
+
value += input[position + length_3];
|
|
7910
|
+
length_3 += 1;
|
|
8451
7911
|
}
|
|
8452
|
-
return [
|
|
7912
|
+
return [length_3, ['A_SingleLineComment', value]];
|
|
8453
7913
|
}
|
|
8454
7914
|
return NO_MATCH;
|
|
8455
7915
|
};
|
|
@@ -8609,31 +8069,20 @@ var tokenizeP_FnShorthand = function (input, position) {
|
|
|
8609
8069
|
return [1, ['P_FnShorthand']];
|
|
8610
8070
|
};
|
|
8611
8071
|
var tokenizeP_ReservedSymbol = function (input, position) {
|
|
8612
|
-
var
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
|
|
8616
|
-
var length_3 = reservedName.length;
|
|
8617
|
-
var nextChar = input[position + length_3];
|
|
8618
|
-
if (nextChar && P_symbolRegExp.test(nextChar)) {
|
|
8619
|
-
continue;
|
|
8620
|
-
}
|
|
8621
|
-
var symbol = input.substring(position, position + length_3);
|
|
8622
|
-
if (symbol === reservedName) {
|
|
8623
|
-
if (forbidden)
|
|
8624
|
-
throw new LitsError("".concat(symbol, " is forbidden!"), undefined);
|
|
8625
|
-
return [length_3, ['P_ReservedSymbol', reservedName]];
|
|
8626
|
-
}
|
|
8627
|
-
}
|
|
8072
|
+
var symbolMeta = tokenizeP_Symbol(input, position);
|
|
8073
|
+
if (symbolMeta[0] === 0 || !symbolMeta[1]) {
|
|
8074
|
+
return NO_MATCH;
|
|
8628
8075
|
}
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
finally { if (e_1) throw e_1.error; }
|
|
8076
|
+
var symbolName = symbolMeta[1][1];
|
|
8077
|
+
symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
|
|
8078
|
+
var info = polishReservedNamesRecord[symbolName];
|
|
8079
|
+
if (!info) {
|
|
8080
|
+
return NO_MATCH;
|
|
8635
8081
|
}
|
|
8636
|
-
|
|
8082
|
+
if (info.forbidden) {
|
|
8083
|
+
throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
|
|
8084
|
+
}
|
|
8085
|
+
return [symbolMeta[0], ['P_ReservedSymbol', symbolName]];
|
|
8637
8086
|
};
|
|
8638
8087
|
var tokenizeP_StringShorthand = function (input, position) {
|
|
8639
8088
|
if (input[position] !== ':')
|
|
@@ -8646,24 +8095,24 @@ var tokenizeP_StringShorthand = function (input, position) {
|
|
|
8646
8095
|
return [symbolDescription[0] + 1, ['P_StringShorthand', ":".concat(symbolToken[1])]];
|
|
8647
8096
|
};
|
|
8648
8097
|
var tokenizeP_Modifier = function (input, position) {
|
|
8649
|
-
var
|
|
8098
|
+
var e_1, _a;
|
|
8650
8099
|
try {
|
|
8651
8100
|
for (var modifierNames_1 = __values(modifierNames), modifierNames_1_1 = modifierNames_1.next(); !modifierNames_1_1.done; modifierNames_1_1 = modifierNames_1.next()) {
|
|
8652
8101
|
var modifierName = modifierNames_1_1.value;
|
|
8653
|
-
var
|
|
8654
|
-
var charAfterModifier = input[position +
|
|
8655
|
-
if (input.substring(position, position +
|
|
8102
|
+
var length_3 = modifierName.length;
|
|
8103
|
+
var charAfterModifier = input[position + length_3];
|
|
8104
|
+
if (input.substring(position, position + length_3) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
|
|
8656
8105
|
var value = modifierName;
|
|
8657
|
-
return [
|
|
8106
|
+
return [length_3, ['P_Modifier', value]];
|
|
8658
8107
|
}
|
|
8659
8108
|
}
|
|
8660
8109
|
}
|
|
8661
|
-
catch (
|
|
8110
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
8662
8111
|
finally {
|
|
8663
8112
|
try {
|
|
8664
8113
|
if (modifierNames_1_1 && !modifierNames_1_1.done && (_a = modifierNames_1.return)) _a.call(modifierNames_1);
|
|
8665
8114
|
}
|
|
8666
|
-
finally { if (
|
|
8115
|
+
finally { if (e_1) throw e_1.error; }
|
|
8667
8116
|
}
|
|
8668
8117
|
return NO_MATCH;
|
|
8669
8118
|
};
|
|
@@ -8700,8 +8149,8 @@ var polishTokenizers = __spreadArray(__spreadArray([
|
|
|
8700
8149
|
tokenizeP_StringShorthand,
|
|
8701
8150
|
tokenizeP_Number,
|
|
8702
8151
|
tokenizeP_ReservedSymbol,
|
|
8703
|
-
tokenizeP_Symbol,
|
|
8704
8152
|
tokenizeP_Modifier,
|
|
8153
|
+
tokenizeP_Symbol,
|
|
8705
8154
|
tokenizeP_RegexpShorthand,
|
|
8706
8155
|
tokenizeP_FnShorthand,
|
|
8707
8156
|
tokenizeP_CollectionAccessor,
|
|
@@ -9109,7 +8558,7 @@ var collectionReference = {
|
|
|
9109
8558
|
},
|
|
9110
8559
|
args: {
|
|
9111
8560
|
coll: {
|
|
9112
|
-
type: ['collection', 'string', '
|
|
8561
|
+
type: ['collection', 'string', 'null'],
|
|
9113
8562
|
},
|
|
9114
8563
|
},
|
|
9115
8564
|
variants: [
|
|
@@ -9198,7 +8647,7 @@ var collectionReference = {
|
|
|
9198
8647
|
},
|
|
9199
8648
|
args: {
|
|
9200
8649
|
coll: {
|
|
9201
|
-
type: ['collection', '
|
|
8650
|
+
type: ['collection', 'null'],
|
|
9202
8651
|
},
|
|
9203
8652
|
key: {
|
|
9204
8653
|
type: ['string', 'number'],
|
|
@@ -9226,7 +8675,7 @@ var collectionReference = {
|
|
|
9226
8675
|
},
|
|
9227
8676
|
args: {
|
|
9228
8677
|
coll: {
|
|
9229
|
-
type: ['collection', '
|
|
8678
|
+
type: ['collection', 'null'],
|
|
9230
8679
|
},
|
|
9231
8680
|
value: {
|
|
9232
8681
|
type: ['any'],
|
|
@@ -9429,7 +8878,7 @@ var collectionReference = {
|
|
|
9429
8878
|
},
|
|
9430
8879
|
args: {
|
|
9431
8880
|
coll: {
|
|
9432
|
-
type: ['collection', '
|
|
8881
|
+
type: ['collection', 'null'],
|
|
9433
8882
|
},
|
|
9434
8883
|
},
|
|
9435
8884
|
variants: [
|
|
@@ -9987,7 +9436,7 @@ var arrayReference = {
|
|
|
9987
9436
|
description: 'Takes a nested array $x and flattens it.',
|
|
9988
9437
|
examples: [
|
|
9989
9438
|
'(flatten [1 2 [3 4] 5])',
|
|
9990
|
-
"\n(let [foo :bar]\n
|
|
9439
|
+
"\n(let [foo :bar])\n(flatten\n [1\n \" 2 A \"\n [foo [4 [:ABC]]] 6])",
|
|
9991
9440
|
'(flatten 12)',
|
|
9992
9441
|
],
|
|
9993
9442
|
},
|
|
@@ -10030,7 +9479,7 @@ var sequenceReference = {
|
|
|
10030
9479
|
},
|
|
10031
9480
|
args: {
|
|
10032
9481
|
'seq': {
|
|
10033
|
-
type: ['sequence', '
|
|
9482
|
+
type: ['sequence', 'null'],
|
|
10034
9483
|
},
|
|
10035
9484
|
'n': {
|
|
10036
9485
|
type: 'integer',
|
|
@@ -10092,7 +9541,7 @@ var sequenceReference = {
|
|
|
10092
9541
|
category: 'Sequence',
|
|
10093
9542
|
linkName: 'pop',
|
|
10094
9543
|
returns: {
|
|
10095
|
-
type: ['sequence', '
|
|
9544
|
+
type: ['sequence', 'null'],
|
|
10096
9545
|
array: true,
|
|
10097
9546
|
},
|
|
10098
9547
|
args: {
|
|
@@ -10145,7 +9594,7 @@ var sequenceReference = {
|
|
|
10145
9594
|
linkName: 'shift',
|
|
10146
9595
|
clojureDocs: null,
|
|
10147
9596
|
returns: {
|
|
10148
|
-
type: ['sequence', '
|
|
9597
|
+
type: ['sequence', 'null'],
|
|
10149
9598
|
array: true,
|
|
10150
9599
|
},
|
|
10151
9600
|
args: {
|
|
@@ -10342,11 +9791,11 @@ var sequenceReference = {
|
|
|
10342
9791
|
linkName: 'position',
|
|
10343
9792
|
clojureDocs: null,
|
|
10344
9793
|
returns: {
|
|
10345
|
-
type: ['number', '
|
|
9794
|
+
type: ['number', 'null'],
|
|
10346
9795
|
},
|
|
10347
9796
|
args: {
|
|
10348
9797
|
seq: {
|
|
10349
|
-
type: ['sequence', '
|
|
9798
|
+
type: ['sequence', 'null'],
|
|
10350
9799
|
},
|
|
10351
9800
|
fn: {
|
|
10352
9801
|
type: 'function',
|
|
@@ -10369,11 +9818,11 @@ var sequenceReference = {
|
|
|
10369
9818
|
linkName: 'index_of',
|
|
10370
9819
|
clojureDocs: null,
|
|
10371
9820
|
returns: {
|
|
10372
|
-
type: ['number', '
|
|
9821
|
+
type: ['number', 'null'],
|
|
10373
9822
|
},
|
|
10374
9823
|
args: {
|
|
10375
9824
|
seq: {
|
|
10376
|
-
type: ['sequence', '
|
|
9825
|
+
type: ['sequence', 'null'],
|
|
10377
9826
|
},
|
|
10378
9827
|
x: {
|
|
10379
9828
|
type: 'any',
|
|
@@ -10399,7 +9848,7 @@ var sequenceReference = {
|
|
|
10399
9848
|
},
|
|
10400
9849
|
args: {
|
|
10401
9850
|
seq: {
|
|
10402
|
-
type: ['sequence', '
|
|
9851
|
+
type: ['sequence', 'null'],
|
|
10403
9852
|
},
|
|
10404
9853
|
fn: {
|
|
10405
9854
|
type: 'function',
|
|
@@ -10422,11 +9871,11 @@ var sequenceReference = {
|
|
|
10422
9871
|
category: 'Sequence',
|
|
10423
9872
|
linkName: 'reverse',
|
|
10424
9873
|
returns: {
|
|
10425
|
-
type: ['sequence', '
|
|
9874
|
+
type: ['sequence', 'null'],
|
|
10426
9875
|
},
|
|
10427
9876
|
args: {
|
|
10428
9877
|
seq: {
|
|
10429
|
-
type: ['sequence', '
|
|
9878
|
+
type: ['sequence', 'null'],
|
|
10430
9879
|
},
|
|
10431
9880
|
},
|
|
10432
9881
|
variants: [
|
|
@@ -10449,7 +9898,7 @@ var sequenceReference = {
|
|
|
10449
9898
|
},
|
|
10450
9899
|
args: {
|
|
10451
9900
|
seq: {
|
|
10452
|
-
type: ['sequence', '
|
|
9901
|
+
type: ['sequence', 'null'],
|
|
10453
9902
|
},
|
|
10454
9903
|
},
|
|
10455
9904
|
variants: [
|
|
@@ -10471,7 +9920,7 @@ var sequenceReference = {
|
|
|
10471
9920
|
},
|
|
10472
9921
|
args: {
|
|
10473
9922
|
seq: {
|
|
10474
|
-
type: ['sequence', '
|
|
9923
|
+
type: ['sequence', 'null'],
|
|
10475
9924
|
},
|
|
10476
9925
|
},
|
|
10477
9926
|
variants: [
|
|
@@ -10494,7 +9943,7 @@ var sequenceReference = {
|
|
|
10494
9943
|
},
|
|
10495
9944
|
args: {
|
|
10496
9945
|
seq: {
|
|
10497
|
-
type: ['sequence', '
|
|
9946
|
+
type: ['sequence', 'null'],
|
|
10498
9947
|
},
|
|
10499
9948
|
},
|
|
10500
9949
|
variants: [
|
|
@@ -10514,7 +9963,7 @@ var sequenceReference = {
|
|
|
10514
9963
|
category: 'Sequence',
|
|
10515
9964
|
linkName: 'rest',
|
|
10516
9965
|
returns: {
|
|
10517
|
-
type: ['sequence', '
|
|
9966
|
+
type: ['sequence', 'null'],
|
|
10518
9967
|
},
|
|
10519
9968
|
args: {
|
|
10520
9969
|
seq: {
|
|
@@ -10567,7 +10016,7 @@ var sequenceReference = {
|
|
|
10567
10016
|
category: 'Sequence',
|
|
10568
10017
|
linkName: 'next',
|
|
10569
10018
|
returns: {
|
|
10570
|
-
type: ['sequence', '
|
|
10019
|
+
type: ['sequence', 'null'],
|
|
10571
10020
|
},
|
|
10572
10021
|
args: {
|
|
10573
10022
|
seq: {
|
|
@@ -10592,7 +10041,7 @@ var sequenceReference = {
|
|
|
10592
10041
|
category: 'Sequence',
|
|
10593
10042
|
linkName: 'nthnext',
|
|
10594
10043
|
returns: {
|
|
10595
|
-
type: ['sequence', '
|
|
10044
|
+
type: ['sequence', 'null'],
|
|
10596
10045
|
array: true,
|
|
10597
10046
|
},
|
|
10598
10047
|
args: {
|
|
@@ -10816,7 +10265,7 @@ var sequenceReference = {
|
|
|
10816
10265
|
description: 'Returns a sorted sequence of the items in $seq, where the sort order is determined by comparing `(keyfn item)`. If no $comp is supplied, uses builtin `compare`.',
|
|
10817
10266
|
examples: [
|
|
10818
10267
|
'(sort_by ["Albert" "Mojir" "Nina"] count)',
|
|
10819
|
-
'(sort_by "Albert"
|
|
10268
|
+
'(sort_by "Albert" lower_case #(compare %2 %1))',
|
|
10820
10269
|
],
|
|
10821
10270
|
},
|
|
10822
10271
|
distinct: {
|
|
@@ -11081,7 +10530,7 @@ var sequenceReference = {
|
|
|
11081
10530
|
],
|
|
11082
10531
|
description: 'Applies $fn to each value in $seq, splitting it each time $fn returns a new value. Returns an array of sequences.',
|
|
11083
10532
|
examples: [
|
|
11084
|
-
'(partition_by [1 2 3 4 5] #(
|
|
10533
|
+
'(partition_by [1 2 3 4 5] #(== 3 %1))',
|
|
11085
10534
|
'(partition_by [1 1 1 2 2 3 3] odd?)',
|
|
11086
10535
|
'(partition_by "Leeeeeerrroyyy" identity)',
|
|
11087
10536
|
],
|
|
@@ -11187,10 +10636,11 @@ var mathReference = {
|
|
|
11187
10636
|
description: 'Modulus of `dividend` and `divisor`. Truncates toward negative infinity.',
|
|
11188
10637
|
examples: ['(mod 5 3)', '(mod 5.2 3.1)', '(mod -5 3)', '(mod 5 -3)', '(mod -5 -3)'],
|
|
11189
10638
|
},
|
|
11190
|
-
'
|
|
11191
|
-
title: '
|
|
10639
|
+
'%': {
|
|
10640
|
+
title: '%',
|
|
11192
10641
|
category: 'Math',
|
|
11193
|
-
linkName: '
|
|
10642
|
+
linkName: '-percent',
|
|
10643
|
+
clojureDocs: 'rem',
|
|
11194
10644
|
returns: {
|
|
11195
10645
|
type: 'number',
|
|
11196
10646
|
},
|
|
@@ -11206,7 +10656,7 @@ var mathReference = {
|
|
|
11206
10656
|
{ argumentNames: ['a', 'b'] },
|
|
11207
10657
|
],
|
|
11208
10658
|
description: 'Remainder of dividing `dividend` and `divisor`.',
|
|
11209
|
-
examples: ['(
|
|
10659
|
+
examples: ['(% 5 3)', '(% 5.2 3.1)', '(% -5 3)', '(% 5 -3)', '(% -5 -3)'],
|
|
11210
10660
|
},
|
|
11211
10661
|
'quot': {
|
|
11212
10662
|
title: 'quot',
|
|
@@ -11303,10 +10753,10 @@ var mathReference = {
|
|
|
11303
10753
|
description: 'Computes cube root of $x.',
|
|
11304
10754
|
examples: ['(cbrt 0)', '(cbrt 27)', '(cbrt 2)', '(cbrt 1)'],
|
|
11305
10755
|
},
|
|
11306
|
-
'
|
|
11307
|
-
title: '
|
|
10756
|
+
'**': {
|
|
10757
|
+
title: '**',
|
|
11308
10758
|
category: 'Math',
|
|
11309
|
-
linkName: '
|
|
10759
|
+
linkName: '-star-star',
|
|
11310
10760
|
clojureDocs: null,
|
|
11311
10761
|
returns: {
|
|
11312
10762
|
type: 'number',
|
|
@@ -11323,7 +10773,7 @@ var mathReference = {
|
|
|
11323
10773
|
{ argumentNames: ['a', 'b'] },
|
|
11324
10774
|
],
|
|
11325
10775
|
description: 'Computes returns $a raised to the power of $b.',
|
|
11326
|
-
examples: ['(
|
|
10776
|
+
examples: ['(** 2 3)', '(** 2 0)', '(** 2 -3)', '(** -2 3)', '(** -2 -3)'],
|
|
11327
10777
|
},
|
|
11328
10778
|
'exp': {
|
|
11329
10779
|
title: 'exp',
|
|
@@ -11693,7 +11143,7 @@ var mathReference = {
|
|
|
11693
11143
|
{ argumentNames: ['x'] },
|
|
11694
11144
|
],
|
|
11695
11145
|
description: 'Returns the base `2` logarithm of a number.',
|
|
11696
|
-
examples: ['(log2 0.01)', '(log2 (
|
|
11146
|
+
examples: ['(log2 0.01)', '(log2 (** 2 12))', '(log2 2.5)'],
|
|
11697
11147
|
},
|
|
11698
11148
|
'log10': {
|
|
11699
11149
|
title: 'log10',
|
|
@@ -11712,7 +11162,7 @@ var mathReference = {
|
|
|
11712
11162
|
{ argumentNames: ['x'] },
|
|
11713
11163
|
],
|
|
11714
11164
|
description: 'Returns the `10` logarithm of a number.',
|
|
11715
|
-
examples: ['(log10 0.01)', '(log10 (
|
|
11165
|
+
examples: ['(log10 0.01)', '(log10 (** 10 12))', '(log10 2.5)'],
|
|
11716
11166
|
},
|
|
11717
11167
|
'sin': {
|
|
11718
11168
|
title: 'sin',
|
|
@@ -11966,13 +11416,14 @@ var miscReference = {
|
|
|
11966
11416
|
{ argumentNames: ['x'] },
|
|
11967
11417
|
{ argumentNames: ['x', 'ys'] },
|
|
11968
11418
|
],
|
|
11969
|
-
description: 'Result is `true` if no two `values` are equal to each other, otherwise result is `false`. Note that only two argument version result is negation of `=` function, that is `(!= a b)` is same as `(
|
|
11419
|
+
description: 'Result is `true` if no two `values` are equal to each other, otherwise result is `false`. Note that only two argument version result is negation of `=` function, that is `(!= a b)` is same as `(! (== a b))`.',
|
|
11970
11420
|
examples: ['(!= 3)', '(!= 3 2)', '(!= :3 3)', '(!= 3 3 2)', '(!= :3 :2 :1 :0)', '(!= 0 -0)'],
|
|
11971
11421
|
},
|
|
11972
|
-
'
|
|
11973
|
-
title: '
|
|
11422
|
+
'==': {
|
|
11423
|
+
title: '==',
|
|
11974
11424
|
category: 'Misc',
|
|
11975
|
-
linkName: '-equal',
|
|
11425
|
+
linkName: '-equal-equal',
|
|
11426
|
+
clojureDocs: '=',
|
|
11976
11427
|
returns: {
|
|
11977
11428
|
type: 'boolean',
|
|
11978
11429
|
},
|
|
@@ -11990,7 +11441,7 @@ var miscReference = {
|
|
|
11990
11441
|
{ argumentNames: ['x', 'ys'] },
|
|
11991
11442
|
],
|
|
11992
11443
|
description: 'Compares `values` according to \'equal\' predicate. Result is `true` if every specified value is equal to each other, otherwise result is `false`.',
|
|
11993
|
-
examples: ['(
|
|
11444
|
+
examples: ['(== 1 1)', '(== 1.01 1)', '(== :1 1)', '(== :2 :2 :2 :2)', '(== 2 2 1 2)'],
|
|
11994
11445
|
},
|
|
11995
11446
|
'<': {
|
|
11996
11447
|
title: '<',
|
|
@@ -12084,10 +11535,11 @@ var miscReference = {
|
|
|
12084
11535
|
description: 'Returns `true` if the number $x and $ys are in non increasing order, `false` otherwise.',
|
|
12085
11536
|
examples: ['(>= 1 0)', '(>= 1.01 1)', '(>= 1 1)', '(>= 4 3 2 1)', '(>= 3 2 2 1)'],
|
|
12086
11537
|
},
|
|
12087
|
-
'
|
|
12088
|
-
title: '
|
|
11538
|
+
'!': {
|
|
11539
|
+
title: '!',
|
|
12089
11540
|
category: 'Misc',
|
|
12090
|
-
linkName: '
|
|
11541
|
+
linkName: '-exclamation',
|
|
11542
|
+
clojureDocs: 'not',
|
|
12091
11543
|
returns: {
|
|
12092
11544
|
type: 'boolean',
|
|
12093
11545
|
},
|
|
@@ -12100,7 +11552,7 @@ var miscReference = {
|
|
|
12100
11552
|
{ argumentNames: ['x'] },
|
|
12101
11553
|
],
|
|
12102
11554
|
description: 'Computes logical negation. Note that any other $x than `false`, `0`, `nil` and `\'\'` is truthy.',
|
|
12103
|
-
examples: ['(
|
|
11555
|
+
examples: ['(! 3)', '(! true)', '(! "A string")', '(! 0)', '(! false)', '(! nil)', '(! "")'],
|
|
12104
11556
|
},
|
|
12105
11557
|
'write!': {
|
|
12106
11558
|
title: 'write!',
|
|
@@ -12129,25 +11581,10 @@ var miscReference = {
|
|
|
12129
11581
|
'(write! nil true false)',
|
|
12130
11582
|
],
|
|
12131
11583
|
},
|
|
12132
|
-
'
|
|
12133
|
-
title: '
|
|
12134
|
-
category: 'Misc',
|
|
12135
|
-
linkName: 'inst-ms-exclamation',
|
|
12136
|
-
clojureDocs: 'inst-ms',
|
|
12137
|
-
returns: {
|
|
12138
|
-
type: 'number',
|
|
12139
|
-
},
|
|
12140
|
-
args: {},
|
|
12141
|
-
variants: [
|
|
12142
|
-
{ argumentNames: [] },
|
|
12143
|
-
],
|
|
12144
|
-
description: 'Returns milliseconds elapsed since the UNIX epoch.',
|
|
12145
|
-
examples: ['(inst-ms!)'],
|
|
12146
|
-
},
|
|
12147
|
-
'iso-date-time->inst-ms': {
|
|
12148
|
-
title: 'iso-date-time->inst-ms',
|
|
11584
|
+
'iso_date>epoch': {
|
|
11585
|
+
title: 'iso_date>epoch',
|
|
12149
11586
|
category: 'Misc',
|
|
12150
|
-
linkName: '
|
|
11587
|
+
linkName: 'iso_date-gtepoch',
|
|
12151
11588
|
returns: {
|
|
12152
11589
|
type: 'number',
|
|
12153
11590
|
},
|
|
@@ -12161,14 +11598,14 @@ var miscReference = {
|
|
|
12161
11598
|
],
|
|
12162
11599
|
description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',
|
|
12163
11600
|
examples: [
|
|
12164
|
-
'(
|
|
12165
|
-
'(
|
|
11601
|
+
'(iso_date>epoch "2022-04-12T09:37:10.899Z")',
|
|
11602
|
+
'(iso_date>epoch "1980-01-01")',
|
|
12166
11603
|
],
|
|
12167
11604
|
},
|
|
12168
|
-
'
|
|
12169
|
-
title: '
|
|
11605
|
+
'epoch>iso_date': {
|
|
11606
|
+
title: 'epoch>iso_date',
|
|
12170
11607
|
category: 'Misc',
|
|
12171
|
-
linkName: '
|
|
11608
|
+
linkName: 'epoch-gtiso_date',
|
|
12172
11609
|
returns: {
|
|
12173
11610
|
type: 'string',
|
|
12174
11611
|
},
|
|
@@ -12182,8 +11619,8 @@ var miscReference = {
|
|
|
12182
11619
|
],
|
|
12183
11620
|
description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',
|
|
12184
11621
|
examples: [
|
|
12185
|
-
'(
|
|
12186
|
-
'(
|
|
11622
|
+
'(epoch>iso_date 1649756230899)',
|
|
11623
|
+
'(epoch>iso_date 0)',
|
|
12187
11624
|
],
|
|
12188
11625
|
},
|
|
12189
11626
|
'boolean': {
|
|
@@ -12239,34 +11676,6 @@ var miscReference = {
|
|
|
12239
11676
|
'(compare + -)',
|
|
12240
11677
|
],
|
|
12241
11678
|
},
|
|
12242
|
-
'lits-version!': {
|
|
12243
|
-
title: 'lits-version!',
|
|
12244
|
-
category: 'Misc',
|
|
12245
|
-
linkName: 'lits-version-exclamation',
|
|
12246
|
-
returns: {
|
|
12247
|
-
type: 'string',
|
|
12248
|
-
},
|
|
12249
|
-
args: {},
|
|
12250
|
-
variants: [
|
|
12251
|
-
{ argumentNames: [] },
|
|
12252
|
-
],
|
|
12253
|
-
description: 'Returns the lits version.',
|
|
12254
|
-
examples: ['(lits-version!)'],
|
|
12255
|
-
},
|
|
12256
|
-
'uuid!': {
|
|
12257
|
-
title: 'uuid!',
|
|
12258
|
-
category: 'Misc',
|
|
12259
|
-
linkName: 'uuid-exclamation',
|
|
12260
|
-
returns: {
|
|
12261
|
-
type: 'string',
|
|
12262
|
-
},
|
|
12263
|
-
args: {},
|
|
12264
|
-
variants: [
|
|
12265
|
-
{ argumentNames: [] },
|
|
12266
|
-
],
|
|
12267
|
-
description: 'Returns random UUID string.',
|
|
12268
|
-
examples: ['(uuid!)'],
|
|
12269
|
-
},
|
|
12270
11679
|
'equal?': {
|
|
12271
11680
|
title: 'equal?',
|
|
12272
11681
|
category: 'Misc',
|
|
@@ -12292,14 +11701,14 @@ var miscReference = {
|
|
|
12292
11701
|
'(equal? [1 true nil] [1 true nil])',
|
|
12293
11702
|
'(equal? {:a 10 :b [1 2 {:b 20}]} {:b [1 2 {:b 20}] :a 10})',
|
|
12294
11703
|
'(equal? {:a 10 :b [1 2 {:b 20}]} {:b [1 2 {:b 21}] :a 10})',
|
|
12295
|
-
'(
|
|
11704
|
+
'(== 0.3 (+ 0.1 0.2))',
|
|
12296
11705
|
'(equal? 0.3 (+ 0.1 0.2))',
|
|
12297
11706
|
],
|
|
12298
11707
|
},
|
|
12299
|
-
'
|
|
12300
|
-
title: '
|
|
11708
|
+
'json_parse': {
|
|
11709
|
+
title: 'json_parse',
|
|
12301
11710
|
category: 'Misc',
|
|
12302
|
-
linkName: '
|
|
11711
|
+
linkName: 'json_parse',
|
|
12303
11712
|
clojureDocs: null,
|
|
12304
11713
|
returns: {
|
|
12305
11714
|
type: 'any',
|
|
@@ -12314,13 +11723,13 @@ var miscReference = {
|
|
|
12314
11723
|
],
|
|
12315
11724
|
description: 'Returns `JSON.parse(`$x`)`.',
|
|
12316
11725
|
examples: [
|
|
12317
|
-
'(
|
|
11726
|
+
'(json_parse "[1, 2, 3]")',
|
|
12318
11727
|
],
|
|
12319
11728
|
},
|
|
12320
|
-
'
|
|
12321
|
-
title: '
|
|
11729
|
+
'json_stringify': {
|
|
11730
|
+
title: 'json_stringify',
|
|
12322
11731
|
category: 'Misc',
|
|
12323
|
-
linkName: '
|
|
11732
|
+
linkName: 'json_stringify',
|
|
12324
11733
|
clojureDocs: null,
|
|
12325
11734
|
returns: {
|
|
12326
11735
|
type: 'string',
|
|
@@ -12340,8 +11749,8 @@ var miscReference = {
|
|
|
12340
11749
|
],
|
|
12341
11750
|
description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',
|
|
12342
11751
|
examples: [
|
|
12343
|
-
'(
|
|
12344
|
-
'(
|
|
11752
|
+
'(json_stringify [1, 2, 3])',
|
|
11753
|
+
'(json_stringify {:a {:b 10}} 2)',
|
|
12345
11754
|
],
|
|
12346
11755
|
},
|
|
12347
11756
|
};
|
|
@@ -12373,7 +11782,7 @@ var assertReference = { 'assert': {
|
|
|
12373
11782
|
linkName: 'assert-equal',
|
|
12374
11783
|
clojureDocs: null,
|
|
12375
11784
|
returns: {
|
|
12376
|
-
type: '
|
|
11785
|
+
type: 'null',
|
|
12377
11786
|
},
|
|
12378
11787
|
args: {
|
|
12379
11788
|
a: {
|
|
@@ -12402,7 +11811,7 @@ var assertReference = { 'assert': {
|
|
|
12402
11811
|
linkName: 'assert-exclamation-equal',
|
|
12403
11812
|
clojureDocs: null,
|
|
12404
11813
|
returns: {
|
|
12405
|
-
type: '
|
|
11814
|
+
type: 'null',
|
|
12406
11815
|
},
|
|
12407
11816
|
args: {
|
|
12408
11817
|
a: {
|
|
@@ -12431,7 +11840,7 @@ var assertReference = { 'assert': {
|
|
|
12431
11840
|
linkName: 'assert_equal',
|
|
12432
11841
|
clojureDocs: null,
|
|
12433
11842
|
returns: {
|
|
12434
|
-
type: '
|
|
11843
|
+
type: 'null',
|
|
12435
11844
|
},
|
|
12436
11845
|
args: {
|
|
12437
11846
|
a: {
|
|
@@ -12460,7 +11869,7 @@ var assertReference = { 'assert': {
|
|
|
12460
11869
|
linkName: 'assert_not_equal',
|
|
12461
11870
|
clojureDocs: null,
|
|
12462
11871
|
returns: {
|
|
12463
|
-
type: '
|
|
11872
|
+
type: 'null',
|
|
12464
11873
|
},
|
|
12465
11874
|
args: {
|
|
12466
11875
|
a: {
|
|
@@ -12489,7 +11898,7 @@ var assertReference = { 'assert': {
|
|
|
12489
11898
|
linkName: 'assert_gt',
|
|
12490
11899
|
clojureDocs: null,
|
|
12491
11900
|
returns: {
|
|
12492
|
-
type: '
|
|
11901
|
+
type: 'null',
|
|
12493
11902
|
},
|
|
12494
11903
|
args: {
|
|
12495
11904
|
a: {
|
|
@@ -12518,7 +11927,7 @@ var assertReference = { 'assert': {
|
|
|
12518
11927
|
linkName: 'assert_lt',
|
|
12519
11928
|
clojureDocs: null,
|
|
12520
11929
|
returns: {
|
|
12521
|
-
type: '
|
|
11930
|
+
type: 'null',
|
|
12522
11931
|
},
|
|
12523
11932
|
args: {
|
|
12524
11933
|
a: {
|
|
@@ -12547,7 +11956,7 @@ var assertReference = { 'assert': {
|
|
|
12547
11956
|
linkName: 'assert_gte',
|
|
12548
11957
|
clojureDocs: null,
|
|
12549
11958
|
returns: {
|
|
12550
|
-
type: '
|
|
11959
|
+
type: 'null',
|
|
12551
11960
|
},
|
|
12552
11961
|
args: {
|
|
12553
11962
|
a: {
|
|
@@ -12576,7 +11985,7 @@ var assertReference = { 'assert': {
|
|
|
12576
11985
|
linkName: 'assert_lte',
|
|
12577
11986
|
clojureDocs: null,
|
|
12578
11987
|
returns: {
|
|
12579
|
-
type: '
|
|
11988
|
+
type: 'null',
|
|
12580
11989
|
},
|
|
12581
11990
|
args: {
|
|
12582
11991
|
a: {
|
|
@@ -12605,7 +12014,7 @@ var assertReference = { 'assert': {
|
|
|
12605
12014
|
linkName: 'assert_true',
|
|
12606
12015
|
clojureDocs: null,
|
|
12607
12016
|
returns: {
|
|
12608
|
-
type: '
|
|
12017
|
+
type: 'null',
|
|
12609
12018
|
},
|
|
12610
12019
|
args: {
|
|
12611
12020
|
value: {
|
|
@@ -12631,7 +12040,7 @@ var assertReference = { 'assert': {
|
|
|
12631
12040
|
linkName: 'assert_false',
|
|
12632
12041
|
clojureDocs: null,
|
|
12633
12042
|
returns: {
|
|
12634
|
-
type: '
|
|
12043
|
+
type: 'null',
|
|
12635
12044
|
},
|
|
12636
12045
|
args: {
|
|
12637
12046
|
value: {
|
|
@@ -12657,7 +12066,7 @@ var assertReference = { 'assert': {
|
|
|
12657
12066
|
linkName: 'assert_truthy',
|
|
12658
12067
|
clojureDocs: null,
|
|
12659
12068
|
returns: {
|
|
12660
|
-
type: '
|
|
12069
|
+
type: 'null',
|
|
12661
12070
|
},
|
|
12662
12071
|
args: {
|
|
12663
12072
|
value: {
|
|
@@ -12690,7 +12099,7 @@ var assertReference = { 'assert': {
|
|
|
12690
12099
|
linkName: 'assert_falsy',
|
|
12691
12100
|
clojureDocs: null,
|
|
12692
12101
|
returns: {
|
|
12693
|
-
type: '
|
|
12102
|
+
type: 'null',
|
|
12694
12103
|
},
|
|
12695
12104
|
args: {
|
|
12696
12105
|
value: {
|
|
@@ -12722,7 +12131,7 @@ var assertReference = { 'assert': {
|
|
|
12722
12131
|
linkName: 'assert_null',
|
|
12723
12132
|
clojureDocs: null,
|
|
12724
12133
|
returns: {
|
|
12725
|
-
type: '
|
|
12134
|
+
type: 'null',
|
|
12726
12135
|
},
|
|
12727
12136
|
args: {
|
|
12728
12137
|
value: {
|
|
@@ -12754,7 +12163,7 @@ var assertReference = { 'assert': {
|
|
|
12754
12163
|
linkName: 'assert_throws',
|
|
12755
12164
|
clojureDocs: null,
|
|
12756
12165
|
returns: {
|
|
12757
|
-
type: '
|
|
12166
|
+
type: 'null',
|
|
12758
12167
|
},
|
|
12759
12168
|
args: {
|
|
12760
12169
|
fn: {
|
|
@@ -12776,7 +12185,7 @@ var assertReference = { 'assert': {
|
|
|
12776
12185
|
linkName: 'assert_throws_error',
|
|
12777
12186
|
clojureDocs: null,
|
|
12778
12187
|
returns: {
|
|
12779
|
-
type: '
|
|
12188
|
+
type: 'null',
|
|
12780
12189
|
},
|
|
12781
12190
|
args: {
|
|
12782
12191
|
'fn': {
|
|
@@ -12805,7 +12214,7 @@ var assertReference = { 'assert': {
|
|
|
12805
12214
|
linkName: 'assert_not_throws',
|
|
12806
12215
|
clojureDocs: null,
|
|
12807
12216
|
returns: {
|
|
12808
|
-
type: '
|
|
12217
|
+
type: 'null',
|
|
12809
12218
|
},
|
|
12810
12219
|
args: {
|
|
12811
12220
|
fn: {
|
|
@@ -12824,7 +12233,7 @@ var assertReference = { 'assert': {
|
|
|
12824
12233
|
} };
|
|
12825
12234
|
|
|
12826
12235
|
var objectReference = {
|
|
12827
|
-
|
|
12236
|
+
dissoc: {
|
|
12828
12237
|
title: 'dissoc',
|
|
12829
12238
|
category: 'Object',
|
|
12830
12239
|
linkName: 'dissoc',
|
|
@@ -12849,7 +12258,7 @@ var objectReference = {
|
|
|
12849
12258
|
"\n(def o { :a 5 }) (dissoc o :a)\no",
|
|
12850
12259
|
],
|
|
12851
12260
|
},
|
|
12852
|
-
|
|
12261
|
+
object: {
|
|
12853
12262
|
title: 'object',
|
|
12854
12263
|
category: 'Object',
|
|
12855
12264
|
linkName: 'object',
|
|
@@ -12875,7 +12284,7 @@ var objectReference = {
|
|
|
12875
12284
|
'{:a 1 :b 2}',
|
|
12876
12285
|
],
|
|
12877
12286
|
},
|
|
12878
|
-
|
|
12287
|
+
keys: {
|
|
12879
12288
|
title: 'keys',
|
|
12880
12289
|
category: 'Object',
|
|
12881
12290
|
linkName: 'keys',
|
|
@@ -12897,7 +12306,7 @@ var objectReference = {
|
|
|
12897
12306
|
'(keys (object :x 10 :y true :z "A string"))',
|
|
12898
12307
|
],
|
|
12899
12308
|
},
|
|
12900
|
-
|
|
12309
|
+
vals: {
|
|
12901
12310
|
title: 'vals',
|
|
12902
12311
|
category: 'Object',
|
|
12903
12312
|
linkName: 'vals',
|
|
@@ -12919,7 +12328,7 @@ var objectReference = {
|
|
|
12919
12328
|
'(vals (object :x 10 :y true :z "A string"))',
|
|
12920
12329
|
],
|
|
12921
12330
|
},
|
|
12922
|
-
|
|
12331
|
+
entries: {
|
|
12923
12332
|
title: 'entries',
|
|
12924
12333
|
category: 'Object',
|
|
12925
12334
|
linkName: 'entries',
|
|
@@ -12941,12 +12350,12 @@ var objectReference = {
|
|
|
12941
12350
|
'(entries (object :x 10 :y true :z "A string"))',
|
|
12942
12351
|
],
|
|
12943
12352
|
},
|
|
12944
|
-
|
|
12353
|
+
find: {
|
|
12945
12354
|
title: 'find',
|
|
12946
12355
|
category: 'Object',
|
|
12947
12356
|
linkName: 'find',
|
|
12948
12357
|
returns: {
|
|
12949
|
-
type: ['array', '
|
|
12358
|
+
type: ['array', 'null'],
|
|
12950
12359
|
},
|
|
12951
12360
|
args: {
|
|
12952
12361
|
obj: {
|
|
@@ -12965,7 +12374,7 @@ var objectReference = {
|
|
|
12965
12374
|
'(find (object :a 1 :b 2) :c)',
|
|
12966
12375
|
],
|
|
12967
12376
|
},
|
|
12968
|
-
|
|
12377
|
+
merge: {
|
|
12969
12378
|
title: 'merge',
|
|
12970
12379
|
category: 'Object',
|
|
12971
12380
|
linkName: 'merge',
|
|
@@ -12987,10 +12396,10 @@ var objectReference = {
|
|
|
12987
12396
|
'(merge (object :x 10) (object :x 15 :y 20))',
|
|
12988
12397
|
],
|
|
12989
12398
|
},
|
|
12990
|
-
|
|
12991
|
-
title: '
|
|
12399
|
+
merge_with: {
|
|
12400
|
+
title: 'merge_with',
|
|
12992
12401
|
category: 'Object',
|
|
12993
|
-
linkName: '
|
|
12402
|
+
linkName: 'merge_with',
|
|
12994
12403
|
returns: {
|
|
12995
12404
|
type: 'object',
|
|
12996
12405
|
},
|
|
@@ -13008,12 +12417,12 @@ var objectReference = {
|
|
|
13008
12417
|
],
|
|
13009
12418
|
description: "\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fn is used to calculate the new value.\n\nIf no arguments are provided `nil` is returned.",
|
|
13010
12419
|
examples: [
|
|
13011
|
-
'(
|
|
13012
|
-
'(
|
|
13013
|
-
'(
|
|
12420
|
+
'(merge_with (object :x 10) (object :y 20) +)',
|
|
12421
|
+
'(merge_with (object :x 10) (object :x 15 :y 20) +)',
|
|
12422
|
+
'(merge_with (object :x 10) (object :x 20) (object :x 30) (object :x 40) -)',
|
|
13014
12423
|
],
|
|
13015
12424
|
},
|
|
13016
|
-
|
|
12425
|
+
zipmap: {
|
|
13017
12426
|
title: 'zipmap',
|
|
13018
12427
|
category: 'Object',
|
|
13019
12428
|
linkName: 'zipmap',
|
|
@@ -13040,10 +12449,10 @@ var objectReference = {
|
|
|
13040
12449
|
'(zipmap [] [10 nil [1 2 3]])',
|
|
13041
12450
|
],
|
|
13042
12451
|
},
|
|
13043
|
-
|
|
13044
|
-
title: '
|
|
12452
|
+
select_keys: {
|
|
12453
|
+
title: 'select_keys',
|
|
13045
12454
|
category: 'Object',
|
|
13046
|
-
linkName: '
|
|
12455
|
+
linkName: 'select_keys',
|
|
13047
12456
|
returns: {
|
|
13048
12457
|
type: 'object',
|
|
13049
12458
|
},
|
|
@@ -13061,8 +12470,8 @@ var objectReference = {
|
|
|
13061
12470
|
],
|
|
13062
12471
|
description: 'Returns an object containing only those entries in $obj whose key is in $keys.',
|
|
13063
12472
|
examples: [
|
|
13064
|
-
'(
|
|
13065
|
-
'(
|
|
12473
|
+
'(select_keys {:a 1 :b 2 :c 3} [:a :b])',
|
|
12474
|
+
'(select_keys {:a 1} [:a :b])',
|
|
13066
12475
|
],
|
|
13067
12476
|
},
|
|
13068
12477
|
};
|
|
@@ -13511,7 +12920,7 @@ var predicateReference = {
|
|
|
13511
12920
|
variants: [
|
|
13512
12921
|
{ argumentNames: ['x'] },
|
|
13513
12922
|
],
|
|
13514
|
-
description: 'Returns `true` if $x is NaN (
|
|
12923
|
+
description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
|
|
13515
12924
|
examples: [
|
|
13516
12925
|
'(nan? 1.0)',
|
|
13517
12926
|
'(nan? (/ 1 0))',
|
|
@@ -13622,7 +13031,7 @@ var predicateReference = {
|
|
|
13622
13031
|
},
|
|
13623
13032
|
args: {
|
|
13624
13033
|
x: {
|
|
13625
|
-
type: ['collection', 'string', '
|
|
13034
|
+
type: ['collection', 'string', 'null'],
|
|
13626
13035
|
},
|
|
13627
13036
|
},
|
|
13628
13037
|
variants: [
|
|
@@ -13649,7 +13058,7 @@ var predicateReference = {
|
|
|
13649
13058
|
},
|
|
13650
13059
|
args: {
|
|
13651
13060
|
x: {
|
|
13652
|
-
type: ['collection', 'string', '
|
|
13061
|
+
type: ['collection', 'string', 'null'],
|
|
13653
13062
|
},
|
|
13654
13063
|
},
|
|
13655
13064
|
variants: [
|
|
@@ -13761,10 +13170,10 @@ var regularExpressionReference = {
|
|
|
13761
13170
|
};
|
|
13762
13171
|
|
|
13763
13172
|
var specialExpressionsReference = {
|
|
13764
|
-
'
|
|
13765
|
-
title: '
|
|
13173
|
+
'&&': {
|
|
13174
|
+
title: '&&',
|
|
13766
13175
|
category: 'Special expression',
|
|
13767
|
-
linkName: 'and',
|
|
13176
|
+
linkName: '-and-and',
|
|
13768
13177
|
returns: {
|
|
13769
13178
|
type: 'boolean',
|
|
13770
13179
|
},
|
|
@@ -13777,19 +13186,20 @@ var specialExpressionsReference = {
|
|
|
13777
13186
|
variants: [
|
|
13778
13187
|
{ argumentNames: ['expressions'] },
|
|
13779
13188
|
],
|
|
13780
|
-
description: "\nComputes logical `and
|
|
13189
|
+
description: "\nComputes logical `and`. Evaluation of $expressions starts from left.\nAs soon as a `expression` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.",
|
|
13781
13190
|
examples: [
|
|
13782
|
-
'(
|
|
13783
|
-
'(
|
|
13784
|
-
'(
|
|
13785
|
-
'(
|
|
13786
|
-
'(
|
|
13191
|
+
'(&& 1 1)',
|
|
13192
|
+
'(&& (> 3 2) "string")',
|
|
13193
|
+
'(&& (< 3 2) "string")',
|
|
13194
|
+
'(&& true true true true)',
|
|
13195
|
+
'(&& true true 0 true)',
|
|
13787
13196
|
],
|
|
13788
13197
|
},
|
|
13789
|
-
'
|
|
13790
|
-
title: '
|
|
13198
|
+
'||': {
|
|
13199
|
+
title: '||',
|
|
13791
13200
|
category: 'Special expression',
|
|
13792
|
-
linkName: 'or',
|
|
13201
|
+
linkName: '-or-or',
|
|
13202
|
+
clojureDocs: 'or',
|
|
13793
13203
|
returns: {
|
|
13794
13204
|
type: 'boolean',
|
|
13795
13205
|
},
|
|
@@ -13802,13 +13212,13 @@ var specialExpressionsReference = {
|
|
|
13802
13212
|
variants: [
|
|
13803
13213
|
{ argumentNames: ['expressions'] },
|
|
13804
13214
|
],
|
|
13805
|
-
description: "\nComputes logical `or
|
|
13215
|
+
description: "\nComputes logical `or`. Evaluation of $expressions evaluation starts from left.\nAs soon as a `expression` evaluates to a truthy value, the result is returned.\n\nIf all expressions evaluate to falsy values, the value of the last expression is returned.",
|
|
13806
13216
|
examples: [
|
|
13807
|
-
'(
|
|
13808
|
-
'(
|
|
13809
|
-
'(
|
|
13810
|
-
'(
|
|
13811
|
-
'(
|
|
13217
|
+
'(|| 1 1)',
|
|
13218
|
+
'(|| (> 3 2) "string")',
|
|
13219
|
+
'(|| (< 3 2) "string")',
|
|
13220
|
+
'(|| true true true true)',
|
|
13221
|
+
'(|| 1 2 3 4)',
|
|
13812
13222
|
],
|
|
13813
13223
|
},
|
|
13814
13224
|
'def': {
|
|
@@ -13873,97 +13283,12 @@ var specialExpressionsReference = {
|
|
|
13873
13283
|
type: '*binding',
|
|
13874
13284
|
rest: true,
|
|
13875
13285
|
},
|
|
13876
|
-
expressions: {
|
|
13877
|
-
type: '*expression',
|
|
13878
|
-
rest: true,
|
|
13879
|
-
},
|
|
13880
|
-
},
|
|
13881
|
-
variants: [
|
|
13882
|
-
{ argumentNames: ['bindings', 'expressions'] },
|
|
13883
|
-
],
|
|
13884
|
-
description: "\nBinds local variables. The variables lives only within $expressions.\nIt returns evaluation of the last expression in $expressions.",
|
|
13885
|
-
examples: ["\n (let [a (+ 1 2 3 4) \n b (* 1 2 3 4)]\n (write! a b))"],
|
|
13886
|
-
},
|
|
13887
|
-
'if-let': {
|
|
13888
|
-
title: 'if-let',
|
|
13889
|
-
category: 'Special expression',
|
|
13890
|
-
linkName: 'if-let',
|
|
13891
|
-
returns: {
|
|
13892
|
-
type: 'any',
|
|
13893
|
-
},
|
|
13894
|
-
args: {
|
|
13895
|
-
'binding': {
|
|
13896
|
-
type: '*binding',
|
|
13897
|
-
},
|
|
13898
|
-
'then-expr': {
|
|
13899
|
-
type: '*expression',
|
|
13900
|
-
},
|
|
13901
|
-
'else-expr': {
|
|
13902
|
-
type: '*expression',
|
|
13903
|
-
},
|
|
13904
|
-
},
|
|
13905
|
-
variants: [
|
|
13906
|
-
{ argumentNames: ['binding', 'then-expr'] },
|
|
13907
|
-
{ argumentNames: ['binding', 'then-expr', 'else-expr'] },
|
|
13908
|
-
],
|
|
13909
|
-
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).",
|
|
13910
|
-
examples: [
|
|
13911
|
-
"\n(if-let [a (> (count \"Albert\") 4)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
13912
|
-
"\n(if-let [a (> (count \"Albert\") 10)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
|
|
13913
|
-
],
|
|
13914
|
-
},
|
|
13915
|
-
'when-let': {
|
|
13916
|
-
title: 'when-let',
|
|
13917
|
-
category: 'Special expression',
|
|
13918
|
-
linkName: 'when-let',
|
|
13919
|
-
returns: {
|
|
13920
|
-
type: 'any',
|
|
13921
|
-
},
|
|
13922
|
-
args: {
|
|
13923
|
-
binding: {
|
|
13924
|
-
type: '*binding',
|
|
13925
|
-
},
|
|
13926
|
-
expressions: {
|
|
13927
|
-
type: '*expression',
|
|
13928
|
-
rest: true,
|
|
13929
|
-
},
|
|
13930
|
-
},
|
|
13931
|
-
variants: [
|
|
13932
|
-
{ argumentNames: ['binding', 'expressions'] },
|
|
13933
|
-
],
|
|
13934
|
-
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.",
|
|
13935
|
-
examples: [
|
|
13936
|
-
"\n(when-let [a (> (count \"Albert\") 4)]\n (write! a))",
|
|
13937
|
-
],
|
|
13938
|
-
},
|
|
13939
|
-
'when-first': {
|
|
13940
|
-
title: 'when-first',
|
|
13941
|
-
category: 'Special expression',
|
|
13942
|
-
linkName: 'when-first',
|
|
13943
|
-
returns: {
|
|
13944
|
-
type: 'any',
|
|
13945
|
-
},
|
|
13946
|
-
args: {
|
|
13947
|
-
binding: {
|
|
13948
|
-
type: '*binding',
|
|
13949
|
-
rest: true,
|
|
13950
|
-
},
|
|
13951
|
-
expressions: {
|
|
13952
|
-
type: '*expression',
|
|
13953
|
-
rest: true,
|
|
13954
|
-
},
|
|
13955
13286
|
},
|
|
13956
13287
|
variants: [
|
|
13957
|
-
{ argumentNames: ['
|
|
13958
|
-
],
|
|
13959
|
-
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.',
|
|
13960
|
-
examples: [
|
|
13961
|
-
"\n(when-first [x [1 2 3]]\n (write! x)\n x)",
|
|
13962
|
-
"\n(when-first [x \"Albert\"]\n (write! x)\n x)",
|
|
13963
|
-
"\n(when-first [x [0]]\n (write! x)\n x)",
|
|
13964
|
-
"\n(when-first [x [nil]]\n (write! x)\n x)",
|
|
13965
|
-
"\n(when-first [x []]\n (write! x)\n x)",
|
|
13288
|
+
{ argumentNames: ['bindings'] },
|
|
13966
13289
|
],
|
|
13290
|
+
description: "\nBinds local variables.",
|
|
13291
|
+
examples: ["\n(let [a (+ 1 2 3 4) \n b (* 1 2 3 4)])\n(write! a b)"],
|
|
13967
13292
|
},
|
|
13968
13293
|
'fn': {
|
|
13969
13294
|
title: 'fn',
|
|
@@ -14127,10 +13452,11 @@ var specialExpressionsReference = {
|
|
|
14127
13452
|
'(if false (write! "TRUE"))',
|
|
14128
13453
|
],
|
|
14129
13454
|
},
|
|
14130
|
-
'
|
|
14131
|
-
title: '
|
|
13455
|
+
'unless': {
|
|
13456
|
+
title: 'unless',
|
|
14132
13457
|
category: 'Special expression',
|
|
14133
|
-
linkName: '
|
|
13458
|
+
linkName: 'unless',
|
|
13459
|
+
clojureDocs: 'if-not',
|
|
14134
13460
|
returns: {
|
|
14135
13461
|
type: 'any',
|
|
14136
13462
|
},
|
|
@@ -14151,10 +13477,10 @@ var specialExpressionsReference = {
|
|
|
14151
13477
|
],
|
|
14152
13478
|
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.',
|
|
14153
13479
|
examples: [
|
|
14154
|
-
'(
|
|
14155
|
-
'(
|
|
14156
|
-
'(
|
|
14157
|
-
'(
|
|
13480
|
+
'(unless true (write! "TRUE") (write! "FALSE"))',
|
|
13481
|
+
'(unless false (write! "TRUE") (write! "FALSE"))',
|
|
13482
|
+
'(unless true (write! "TRUE"))',
|
|
13483
|
+
'(unless false (write! "TRUE"))',
|
|
14158
13484
|
],
|
|
14159
13485
|
},
|
|
14160
13486
|
'cond': {
|
|
@@ -14179,58 +13505,29 @@ var specialExpressionsReference = {
|
|
|
14179
13505
|
"\n(cond\n false (write! \"FALSE\")\n nil (write! \"nil\"))",
|
|
14180
13506
|
],
|
|
14181
13507
|
},
|
|
14182
|
-
'
|
|
14183
|
-
title: '
|
|
14184
|
-
category: 'Special expression',
|
|
14185
|
-
linkName: 'when',
|
|
14186
|
-
returns: {
|
|
14187
|
-
type: 'any',
|
|
14188
|
-
},
|
|
14189
|
-
args: {
|
|
14190
|
-
test: {
|
|
14191
|
-
type: '*expression',
|
|
14192
|
-
},
|
|
14193
|
-
expressions: {
|
|
14194
|
-
type: '*expression',
|
|
14195
|
-
rest: true,
|
|
14196
|
-
},
|
|
14197
|
-
},
|
|
14198
|
-
variants: [
|
|
14199
|
-
{ argumentNames: ['test', 'expressions'] },
|
|
14200
|
-
],
|
|
14201
|
-
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.",
|
|
14202
|
-
examples: [
|
|
14203
|
-
"(when true\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14204
|
-
"(when false\n (write! \"Hi\")\n (write! \"There\"))",
|
|
14205
|
-
'(when true)',
|
|
14206
|
-
'(when false)',
|
|
14207
|
-
],
|
|
14208
|
-
},
|
|
14209
|
-
'when-not': {
|
|
14210
|
-
title: 'when-not',
|
|
13508
|
+
'switch': {
|
|
13509
|
+
title: 'switch',
|
|
14211
13510
|
category: 'Special expression',
|
|
14212
|
-
linkName: '
|
|
13511
|
+
linkName: 'switch',
|
|
14213
13512
|
returns: {
|
|
14214
13513
|
type: 'any',
|
|
14215
13514
|
},
|
|
14216
13515
|
args: {
|
|
14217
|
-
|
|
14218
|
-
type: '
|
|
13516
|
+
value: {
|
|
13517
|
+
type: 'any',
|
|
14219
13518
|
},
|
|
14220
|
-
|
|
14221
|
-
type: '*
|
|
14222
|
-
rest: true,
|
|
13519
|
+
conds: {
|
|
13520
|
+
type: '*conditions',
|
|
14223
13521
|
},
|
|
14224
13522
|
},
|
|
14225
13523
|
variants: [
|
|
14226
|
-
{ argumentNames: ['
|
|
13524
|
+
{ argumentNames: ['value', 'conds'] },
|
|
14227
13525
|
],
|
|
14228
|
-
description:
|
|
13526
|
+
description: 'Used for branching. $conds are tested sequentially from the top against $value. If no branch is tested truthy, `nil` is returned.',
|
|
14229
13527
|
examples: [
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
'(when-not false)',
|
|
13528
|
+
"\n(switch 1\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
|
|
13529
|
+
"\n(switch 2\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
|
|
13530
|
+
"\n(switch 3\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
|
|
14234
13531
|
],
|
|
14235
13532
|
},
|
|
14236
13533
|
'comment': {
|
|
@@ -14238,7 +13535,7 @@ var specialExpressionsReference = {
|
|
|
14238
13535
|
category: 'Special expression',
|
|
14239
13536
|
linkName: 'comment',
|
|
14240
13537
|
returns: {
|
|
14241
|
-
type: '
|
|
13538
|
+
type: 'null',
|
|
14242
13539
|
},
|
|
14243
13540
|
args: {
|
|
14244
13541
|
expressions: {
|
|
@@ -14279,7 +13576,7 @@ var specialExpressionsReference = {
|
|
|
14279
13576
|
category: 'Special expression',
|
|
14280
13577
|
linkName: 'recur',
|
|
14281
13578
|
returns: {
|
|
14282
|
-
type: '
|
|
13579
|
+
type: 'null',
|
|
14283
13580
|
},
|
|
14284
13581
|
args: {
|
|
14285
13582
|
expressions: {
|
|
@@ -14292,9 +13589,9 @@ var specialExpressionsReference = {
|
|
|
14292
13589
|
],
|
|
14293
13590
|
description: 'Recursevly calls enclosing function or loop with its evaluated $expressions.',
|
|
14294
13591
|
examples: [
|
|
14295
|
-
"\n(defn foo [n]\n (write! n)\n (
|
|
14296
|
-
"\n(\n (fn [n]\n (write! n)\n (
|
|
14297
|
-
"\n(\n loop [n 3]\n (write! n)\n (
|
|
13592
|
+
"\n(defn foo [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n(foo 3)",
|
|
13593
|
+
"\n(\n (fn [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n 3)",
|
|
13594
|
+
"\n(\n loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
14298
13595
|
],
|
|
14299
13596
|
},
|
|
14300
13597
|
'loop': {
|
|
@@ -14319,35 +13616,16 @@ var specialExpressionsReference = {
|
|
|
14319
13616
|
],
|
|
14320
13617
|
description: 'Executes $expressions with initial $bindings. The $bindings will be replaced with the recur parameters for subsequent recursions.',
|
|
14321
13618
|
examples: [
|
|
14322
|
-
"\n(loop [n 3]\n (write! n)\n (
|
|
14323
|
-
"\n(loop [n 3]\n (write! n)\n (if\n (
|
|
14324
|
-
],
|
|
14325
|
-
},
|
|
14326
|
-
'time!': {
|
|
14327
|
-
title: 'time!',
|
|
14328
|
-
category: 'Special expression',
|
|
14329
|
-
linkName: 'time-exclamation',
|
|
14330
|
-
clojureDocs: 'time',
|
|
14331
|
-
returns: {
|
|
14332
|
-
type: 'any',
|
|
14333
|
-
},
|
|
14334
|
-
args: {
|
|
14335
|
-
expression: {
|
|
14336
|
-
type: '*expression',
|
|
14337
|
-
},
|
|
14338
|
-
},
|
|
14339
|
-
variants: [
|
|
14340
|
-
{ argumentNames: ['expression'] },
|
|
13619
|
+
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
|
|
13620
|
+
"\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))\n n))",
|
|
14341
13621
|
],
|
|
14342
|
-
description: 'Prints the time it took to evaluate $expression. Returns $expression evaluated.',
|
|
14343
|
-
examples: ["\n(defn fib [x]\n (if\n (<= x 2)\n 1\n (+ \n (fib (dec x))\n (fib (- x 2)))))\n(time! (fib 20))"],
|
|
14344
13622
|
},
|
|
14345
13623
|
'doseq': {
|
|
14346
13624
|
title: 'doseq',
|
|
14347
13625
|
category: 'Special expression',
|
|
14348
13626
|
linkName: 'doseq',
|
|
14349
13627
|
returns: {
|
|
14350
|
-
type: '
|
|
13628
|
+
type: 'null',
|
|
14351
13629
|
},
|
|
14352
13630
|
args: {
|
|
14353
13631
|
bindings: {
|
|
@@ -14397,10 +13675,10 @@ var specialExpressionsReference = {
|
|
|
14397
13675
|
"\n(for\n [x [1 2 3] y [1 2 3] z [1 2 3]\n &while (<= x y)]\n \n [x y z])",
|
|
14398
13676
|
],
|
|
14399
13677
|
},
|
|
14400
|
-
'
|
|
14401
|
-
title: '
|
|
13678
|
+
'defined?': {
|
|
13679
|
+
title: 'defined?',
|
|
14402
13680
|
category: 'Special expression',
|
|
14403
|
-
linkName: '
|
|
13681
|
+
linkName: 'defined-question',
|
|
14404
13682
|
returns: {
|
|
14405
13683
|
type: 'boolean',
|
|
14406
13684
|
},
|
|
@@ -14414,11 +13692,11 @@ var specialExpressionsReference = {
|
|
|
14414
13692
|
],
|
|
14415
13693
|
description: 'Returns `true` if $n is a declared variable or a builtin function, otherwise `false`.',
|
|
14416
13694
|
examples: [
|
|
14417
|
-
'(
|
|
14418
|
-
"\n(def foo :foo)\n(
|
|
14419
|
-
'(
|
|
14420
|
-
"\n(def foo nil)\n(
|
|
14421
|
-
'(
|
|
13695
|
+
'(defined? foo)',
|
|
13696
|
+
"\n(def foo :foo)\n(defined? foo)",
|
|
13697
|
+
'(defined? +)',
|
|
13698
|
+
"\n(def foo nil)\n(defined? foo)",
|
|
13699
|
+
'(defined? if)',
|
|
14422
13700
|
],
|
|
14423
13701
|
},
|
|
14424
13702
|
'??': {
|
|
@@ -14487,10 +13765,10 @@ var stringReference = {
|
|
|
14487
13765
|
'(subs "A string" 100)',
|
|
14488
13766
|
],
|
|
14489
13767
|
},
|
|
14490
|
-
'
|
|
14491
|
-
title: '
|
|
13768
|
+
'string_repeat': {
|
|
13769
|
+
title: 'string_repeat',
|
|
14492
13770
|
category: 'String',
|
|
14493
|
-
linkName: '
|
|
13771
|
+
linkName: 'string_repeat',
|
|
14494
13772
|
clojureDocs: null,
|
|
14495
13773
|
returns: {
|
|
14496
13774
|
type: 'number',
|
|
@@ -14508,8 +13786,8 @@ var stringReference = {
|
|
|
14508
13786
|
],
|
|
14509
13787
|
description: 'Repeates $s $n times.',
|
|
14510
13788
|
examples: [
|
|
14511
|
-
'(
|
|
14512
|
-
'(
|
|
13789
|
+
'(string_repeat "*" 10)',
|
|
13790
|
+
'(string_repeat "***" 0)',
|
|
14513
13791
|
],
|
|
14514
13792
|
},
|
|
14515
13793
|
'str': {
|
|
@@ -14559,41 +13837,10 @@ var stringReference = {
|
|
|
14559
13837
|
'(number "-1.01")',
|
|
14560
13838
|
],
|
|
14561
13839
|
},
|
|
14562
|
-
'
|
|
14563
|
-
title: '
|
|
13840
|
+
'lower_case': {
|
|
13841
|
+
title: 'lower_case',
|
|
14564
13842
|
category: 'String',
|
|
14565
|
-
linkName: '
|
|
14566
|
-
clojureDocs: null,
|
|
14567
|
-
returns: {
|
|
14568
|
-
type: 'string',
|
|
14569
|
-
},
|
|
14570
|
-
args: {
|
|
14571
|
-
n: {
|
|
14572
|
-
type: 'number',
|
|
14573
|
-
},
|
|
14574
|
-
base: {
|
|
14575
|
-
type: 'number',
|
|
14576
|
-
description: '2, 8, 10 or 16',
|
|
14577
|
-
},
|
|
14578
|
-
},
|
|
14579
|
-
variants: [
|
|
14580
|
-
{ argumentNames: ['n'] },
|
|
14581
|
-
{ argumentNames: ['n', 'base'] },
|
|
14582
|
-
],
|
|
14583
|
-
description: 'Converts $n to a string. If $base is not equal to `10`, $n must be a non negative integer.',
|
|
14584
|
-
examples: [
|
|
14585
|
-
'(number-to-string 10)',
|
|
14586
|
-
'(number-to-string -1.01)',
|
|
14587
|
-
'(number-to-string -.01)',
|
|
14588
|
-
'(number-to-string 15 2)',
|
|
14589
|
-
'(number-to-string 15 8)',
|
|
14590
|
-
'(number-to-string 15 16)',
|
|
14591
|
-
],
|
|
14592
|
-
},
|
|
14593
|
-
'lower-case': {
|
|
14594
|
-
title: 'lower-case',
|
|
14595
|
-
category: 'String',
|
|
14596
|
-
linkName: 'lower-case',
|
|
13843
|
+
linkName: 'lower_case',
|
|
14597
13844
|
returns: {
|
|
14598
13845
|
type: 'string',
|
|
14599
13846
|
},
|
|
@@ -14607,14 +13854,14 @@ var stringReference = {
|
|
|
14607
13854
|
],
|
|
14608
13855
|
description: 'Returns $s converted to lower case.',
|
|
14609
13856
|
examples: [
|
|
14610
|
-
'(
|
|
14611
|
-
'(
|
|
13857
|
+
'(lower_case "Albert")',
|
|
13858
|
+
'(lower_case "")',
|
|
14612
13859
|
],
|
|
14613
13860
|
},
|
|
14614
|
-
'
|
|
14615
|
-
title: '
|
|
13861
|
+
'upper_case': {
|
|
13862
|
+
title: 'upper_case',
|
|
14616
13863
|
category: 'String',
|
|
14617
|
-
linkName: '
|
|
13864
|
+
linkName: 'upper_case',
|
|
14618
13865
|
clojureDocs: null,
|
|
14619
13866
|
returns: {
|
|
14620
13867
|
type: 'string',
|
|
@@ -14629,8 +13876,8 @@ var stringReference = {
|
|
|
14629
13876
|
],
|
|
14630
13877
|
description: 'Returns $s converted to upper case.',
|
|
14631
13878
|
examples: [
|
|
14632
|
-
'(
|
|
14633
|
-
'(
|
|
13879
|
+
'(upper_case "Albert")',
|
|
13880
|
+
'(upper_case "")',
|
|
14634
13881
|
],
|
|
14635
13882
|
},
|
|
14636
13883
|
'trim': {
|
|
@@ -14656,10 +13903,10 @@ var stringReference = {
|
|
|
14656
13903
|
'(trim "")',
|
|
14657
13904
|
],
|
|
14658
13905
|
},
|
|
14659
|
-
'
|
|
14660
|
-
title: '
|
|
13906
|
+
'trim_left': {
|
|
13907
|
+
title: 'trim_left',
|
|
14661
13908
|
category: 'String',
|
|
14662
|
-
linkName: '
|
|
13909
|
+
linkName: 'trim_left',
|
|
14663
13910
|
clojureDocs: null,
|
|
14664
13911
|
returns: {
|
|
14665
13912
|
type: 'string',
|
|
@@ -14674,15 +13921,15 @@ var stringReference = {
|
|
|
14674
13921
|
],
|
|
14675
13922
|
description: 'Returns a new string with leading whitespaces removed.',
|
|
14676
13923
|
examples: [
|
|
14677
|
-
'(
|
|
14678
|
-
'(
|
|
14679
|
-
'(
|
|
13924
|
+
'(trim_left " Albert ")',
|
|
13925
|
+
'(trim_left " ")',
|
|
13926
|
+
'(trim_left "")',
|
|
14680
13927
|
],
|
|
14681
13928
|
},
|
|
14682
|
-
'
|
|
14683
|
-
title: '
|
|
13929
|
+
'trim_right': {
|
|
13930
|
+
title: 'trim_right',
|
|
14684
13931
|
category: 'String',
|
|
14685
|
-
linkName: '
|
|
13932
|
+
linkName: 'trim_right',
|
|
14686
13933
|
clojureDocs: null,
|
|
14687
13934
|
returns: {
|
|
14688
13935
|
type: 'string',
|
|
@@ -14697,15 +13944,15 @@ var stringReference = {
|
|
|
14697
13944
|
],
|
|
14698
13945
|
description: 'Returns a new string with trailing whitespaces removed.',
|
|
14699
13946
|
examples: [
|
|
14700
|
-
'(
|
|
14701
|
-
'(
|
|
14702
|
-
'(
|
|
13947
|
+
'(trim_right " Albert ")',
|
|
13948
|
+
'(trim_right " ")',
|
|
13949
|
+
'(trim_right "")',
|
|
14703
13950
|
],
|
|
14704
13951
|
},
|
|
14705
|
-
'
|
|
14706
|
-
title: '
|
|
13952
|
+
'pad_left': {
|
|
13953
|
+
title: 'pad_left',
|
|
14707
13954
|
category: 'String',
|
|
14708
|
-
linkName: '
|
|
13955
|
+
linkName: 'pad_left',
|
|
14709
13956
|
clojureDocs: null,
|
|
14710
13957
|
returns: {
|
|
14711
13958
|
type: 'string',
|
|
@@ -14727,16 +13974,16 @@ var stringReference = {
|
|
|
14727
13974
|
],
|
|
14728
13975
|
description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.',
|
|
14729
13976
|
examples: [
|
|
14730
|
-
'(
|
|
14731
|
-
'(
|
|
14732
|
-
'(
|
|
14733
|
-
'(
|
|
13977
|
+
'(pad_left "Albert" 20)',
|
|
13978
|
+
'(pad_left "Albert" 20 "-*-")',
|
|
13979
|
+
'(pad_left "Albert" 5)',
|
|
13980
|
+
'(pad_left "Albert" -1)',
|
|
14734
13981
|
],
|
|
14735
13982
|
},
|
|
14736
|
-
'
|
|
14737
|
-
title: '
|
|
13983
|
+
'pad_right': {
|
|
13984
|
+
title: 'pad_right',
|
|
14738
13985
|
category: 'String',
|
|
14739
|
-
linkName: '
|
|
13986
|
+
linkName: 'pad_right',
|
|
14740
13987
|
clojureDocs: null,
|
|
14741
13988
|
returns: {
|
|
14742
13989
|
type: 'string',
|
|
@@ -14758,10 +14005,10 @@ var stringReference = {
|
|
|
14758
14005
|
],
|
|
14759
14006
|
description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.',
|
|
14760
14007
|
examples: [
|
|
14761
|
-
'(
|
|
14762
|
-
'(
|
|
14763
|
-
'(
|
|
14764
|
-
'(
|
|
14008
|
+
'(pad_right "Albert" 20)',
|
|
14009
|
+
'(pad_right "Albert" 20 "-*-")',
|
|
14010
|
+
'(pad_right "Albert" 5)',
|
|
14011
|
+
'(pad_right "Albert" -1)',
|
|
14765
14012
|
],
|
|
14766
14013
|
},
|
|
14767
14014
|
'split': {
|
|
@@ -14832,10 +14079,10 @@ var stringReference = {
|
|
|
14832
14079
|
'(template "No book||||One book||||Two books||||Three books||||$1 books" 4)',
|
|
14833
14080
|
],
|
|
14834
14081
|
},
|
|
14835
|
-
'
|
|
14836
|
-
title: '
|
|
14082
|
+
'to_char_code': {
|
|
14083
|
+
title: 'to_char_code',
|
|
14837
14084
|
category: 'String',
|
|
14838
|
-
linkName: '
|
|
14085
|
+
linkName: 'to_char_code',
|
|
14839
14086
|
clojureDocs: null,
|
|
14840
14087
|
returns: {
|
|
14841
14088
|
type: 'number',
|
|
@@ -14850,14 +14097,14 @@ var stringReference = {
|
|
|
14850
14097
|
],
|
|
14851
14098
|
description: 'Return code point for first character in $c.',
|
|
14852
14099
|
examples: [
|
|
14853
|
-
'(
|
|
14854
|
-
'(
|
|
14100
|
+
'(to_char_code :A)',
|
|
14101
|
+
'(to_char_code "Albert")',
|
|
14855
14102
|
],
|
|
14856
14103
|
},
|
|
14857
|
-
'
|
|
14858
|
-
title: '
|
|
14104
|
+
'from_char_code': {
|
|
14105
|
+
title: 'from_char_code',
|
|
14859
14106
|
category: 'String',
|
|
14860
|
-
linkName: '
|
|
14107
|
+
linkName: 'from_char_code',
|
|
14861
14108
|
clojureDocs: null,
|
|
14862
14109
|
returns: {
|
|
14863
14110
|
type: 'string',
|
|
@@ -14872,14 +14119,14 @@ var stringReference = {
|
|
|
14872
14119
|
],
|
|
14873
14120
|
description: 'Return character for code point $code.',
|
|
14874
14121
|
examples: [
|
|
14875
|
-
'(
|
|
14876
|
-
'(
|
|
14122
|
+
'(from_char_code 65)',
|
|
14123
|
+
'(from_char_code 0)',
|
|
14877
14124
|
],
|
|
14878
14125
|
},
|
|
14879
|
-
'
|
|
14880
|
-
title: '
|
|
14126
|
+
'encode_base64': {
|
|
14127
|
+
title: 'encode_base64',
|
|
14881
14128
|
category: 'String',
|
|
14882
|
-
linkName: '
|
|
14129
|
+
linkName: 'encode_base64',
|
|
14883
14130
|
clojureDocs: null,
|
|
14884
14131
|
returns: {
|
|
14885
14132
|
type: 'string',
|
|
@@ -14894,13 +14141,13 @@ var stringReference = {
|
|
|
14894
14141
|
],
|
|
14895
14142
|
description: 'Returns a Base64 encoded string from $s.',
|
|
14896
14143
|
examples: [
|
|
14897
|
-
'(
|
|
14144
|
+
'(encode_base64 "Albert")',
|
|
14898
14145
|
],
|
|
14899
14146
|
},
|
|
14900
|
-
'
|
|
14901
|
-
title: '
|
|
14147
|
+
'decode_base64': {
|
|
14148
|
+
title: 'decode_base64',
|
|
14902
14149
|
category: 'String',
|
|
14903
|
-
linkName: '
|
|
14150
|
+
linkName: 'decode_base64',
|
|
14904
14151
|
clojureDocs: null,
|
|
14905
14152
|
returns: {
|
|
14906
14153
|
type: 'string',
|
|
@@ -14915,13 +14162,13 @@ var stringReference = {
|
|
|
14915
14162
|
],
|
|
14916
14163
|
description: 'Returns a Base64 decoded string from $base64string.',
|
|
14917
14164
|
examples: [
|
|
14918
|
-
'(
|
|
14165
|
+
'(decode_base64 "QWxiZXJ0IPCfkLs=")',
|
|
14919
14166
|
],
|
|
14920
14167
|
},
|
|
14921
|
-
'
|
|
14922
|
-
title: '
|
|
14168
|
+
'encode_uri_component': {
|
|
14169
|
+
title: 'encode_uri_component',
|
|
14923
14170
|
category: 'String',
|
|
14924
|
-
linkName: '
|
|
14171
|
+
linkName: 'encode_uri_component',
|
|
14925
14172
|
clojureDocs: null,
|
|
14926
14173
|
returns: {
|
|
14927
14174
|
type: 'string',
|
|
@@ -14936,13 +14183,13 @@ var stringReference = {
|
|
|
14936
14183
|
],
|
|
14937
14184
|
description: 'Returns an escaped `URI` string.',
|
|
14938
14185
|
examples: [
|
|
14939
|
-
'(
|
|
14186
|
+
'(encode_uri_component "Hi everyone!?")',
|
|
14940
14187
|
],
|
|
14941
14188
|
},
|
|
14942
|
-
'
|
|
14943
|
-
title: '
|
|
14189
|
+
'decode_uri_component': {
|
|
14190
|
+
title: 'decode_uri_component',
|
|
14944
14191
|
category: 'String',
|
|
14945
|
-
linkName: '
|
|
14192
|
+
linkName: 'decode_uri_component',
|
|
14946
14193
|
clojureDocs: null,
|
|
14947
14194
|
returns: {
|
|
14948
14195
|
type: 'string',
|
|
@@ -14957,7 +14204,7 @@ var stringReference = {
|
|
|
14957
14204
|
],
|
|
14958
14205
|
description: 'Returns an un-escaped `URI` string.',
|
|
14959
14206
|
examples: [
|
|
14960
|
-
'(
|
|
14207
|
+
'(decode_uri_component "Hi%20everyone!%3F%20%F0%9F%91%8D")',
|
|
14961
14208
|
],
|
|
14962
14209
|
},
|
|
14963
14210
|
'join': {
|
|
@@ -14982,15 +14229,42 @@ var stringReference = {
|
|
|
14982
14229
|
description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',
|
|
14983
14230
|
examples: [
|
|
14984
14231
|
'(join ["Albert" "Mojir"] " ")',
|
|
14985
|
-
'(join (map
|
|
14232
|
+
'(join (map [0 1 2 3 4 5 6 7 8 9] str) ", ")',
|
|
14233
|
+
],
|
|
14234
|
+
},
|
|
14235
|
+
'++': {
|
|
14236
|
+
title: '++',
|
|
14237
|
+
category: 'String',
|
|
14238
|
+
linkName: '-plus-plus',
|
|
14239
|
+
clojureDocs: null,
|
|
14240
|
+
returns: {
|
|
14241
|
+
type: 'string',
|
|
14242
|
+
},
|
|
14243
|
+
args: {
|
|
14244
|
+
strings: {
|
|
14245
|
+
type: ['string', 'number', 'null'],
|
|
14246
|
+
rest: true,
|
|
14247
|
+
},
|
|
14248
|
+
},
|
|
14249
|
+
variants: [{
|
|
14250
|
+
argumentNames: ['strings'],
|
|
14251
|
+
}],
|
|
14252
|
+
description: 'Concatenats $strings into one string.',
|
|
14253
|
+
examples: [
|
|
14254
|
+
'(++ "Albert" " " "Mojir")',
|
|
14255
|
+
'(++ "Albert" "Mojir")',
|
|
14256
|
+
'(++ "Albert" null "Mojir")',
|
|
14257
|
+
'(++ "Albert")',
|
|
14258
|
+
'(++)',
|
|
14986
14259
|
],
|
|
14987
14260
|
},
|
|
14988
14261
|
};
|
|
14989
14262
|
|
|
14990
|
-
var bitwiseReference = { '
|
|
14991
|
-
title: '
|
|
14263
|
+
var bitwiseReference = { '<<': {
|
|
14264
|
+
title: '<<',
|
|
14992
14265
|
category: 'Bitwise',
|
|
14993
|
-
linkName: '
|
|
14266
|
+
linkName: '-lt-lt',
|
|
14267
|
+
clojureDocs: 'bit-shift-left',
|
|
14994
14268
|
returns: {
|
|
14995
14269
|
type: 'integer',
|
|
14996
14270
|
},
|
|
@@ -15006,11 +14280,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15006
14280
|
{ argumentNames: ['x', 'n'] },
|
|
15007
14281
|
],
|
|
15008
14282
|
description: 'Shifts $x arithmetically left by $n bit positions.',
|
|
15009
|
-
examples: ['(
|
|
15010
|
-
}, '
|
|
15011
|
-
title: '
|
|
14283
|
+
examples: ['(<< 1 10)', '(<< -4 2)'],
|
|
14284
|
+
}, '>>': {
|
|
14285
|
+
title: '>>',
|
|
15012
14286
|
category: 'Bitwise',
|
|
15013
|
-
linkName: '
|
|
14287
|
+
linkName: '-gt-gt',
|
|
14288
|
+
clojureDocs: 'bit-shift-right',
|
|
15014
14289
|
returns: {
|
|
15015
14290
|
type: 'integer',
|
|
15016
14291
|
},
|
|
@@ -15026,11 +14301,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15026
14301
|
{ argumentNames: ['x', 'n'] },
|
|
15027
14302
|
],
|
|
15028
14303
|
description: 'Shifts $x arithmetically right by $n bit positions.',
|
|
15029
|
-
examples: ['(
|
|
15030
|
-
}, '
|
|
15031
|
-
title: '
|
|
14304
|
+
examples: ['(>> 2048 10)', '(>> 4 10)'],
|
|
14305
|
+
}, '>>>': {
|
|
14306
|
+
title: '>>>',
|
|
15032
14307
|
category: 'Bitwise',
|
|
15033
|
-
linkName: '
|
|
14308
|
+
linkName: '-gt-gt-gt',
|
|
14309
|
+
clojureDocs: 'unsigned-bit-shift-right',
|
|
15034
14310
|
returns: {
|
|
15035
14311
|
type: 'integer',
|
|
15036
14312
|
},
|
|
@@ -15046,11 +14322,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15046
14322
|
{ argumentNames: ['x', 'n'] },
|
|
15047
14323
|
],
|
|
15048
14324
|
description: 'Shifts $x arithmetically right by $n bit positions without sign extension.',
|
|
15049
|
-
examples: ['(
|
|
15050
|
-
}, '
|
|
15051
|
-
title: '
|
|
14325
|
+
examples: ['(>>> 2048 10)', '(>>> 4 10)', '(>>> -1 10)'],
|
|
14326
|
+
}, '~': {
|
|
14327
|
+
title: '~',
|
|
15052
14328
|
category: 'Bitwise',
|
|
15053
|
-
linkName: '
|
|
14329
|
+
linkName: '-tilde',
|
|
14330
|
+
clojureDocs: 'bit-not',
|
|
15054
14331
|
returns: {
|
|
15055
14332
|
type: 'integer',
|
|
15056
14333
|
},
|
|
@@ -15063,11 +14340,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15063
14340
|
{ argumentNames: ['x'] },
|
|
15064
14341
|
],
|
|
15065
14342
|
description: 'Returns bitwise `not` of $x.',
|
|
15066
|
-
examples: ['(
|
|
15067
|
-
}, '
|
|
15068
|
-
title: '
|
|
14343
|
+
examples: ['(~ 0)', '(~ 255)'],
|
|
14344
|
+
}, '&': {
|
|
14345
|
+
title: '&',
|
|
15069
14346
|
category: 'Bitwise',
|
|
15070
|
-
linkName: '
|
|
14347
|
+
linkName: '-and',
|
|
14348
|
+
clojureDocs: 'bit-and',
|
|
15071
14349
|
returns: {
|
|
15072
14350
|
type: 'integer',
|
|
15073
14351
|
},
|
|
@@ -15089,13 +14367,14 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15089
14367
|
],
|
|
15090
14368
|
description: 'Returns bitwise `and` of all arguments.',
|
|
15091
14369
|
examples: [
|
|
15092
|
-
'(
|
|
15093
|
-
'(
|
|
14370
|
+
'(& 0b0011 0b0110)',
|
|
14371
|
+
'(& 0b0011 0b0110 0b1001)',
|
|
15094
14372
|
],
|
|
15095
|
-
}, '
|
|
15096
|
-
title: '
|
|
14373
|
+
}, '&!': {
|
|
14374
|
+
title: '&!',
|
|
15097
14375
|
category: 'Bitwise',
|
|
15098
|
-
linkName: '
|
|
14376
|
+
linkName: '-and-exclamation',
|
|
14377
|
+
clojureDocs: 'bit-and-not',
|
|
15099
14378
|
returns: {
|
|
15100
14379
|
type: 'integer',
|
|
15101
14380
|
},
|
|
@@ -15116,11 +14395,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15116
14395
|
{ argumentNames: ['x', 'y', 'rest'] },
|
|
15117
14396
|
],
|
|
15118
14397
|
description: 'Returns bitwise `and` with complement.',
|
|
15119
|
-
examples: ['(
|
|
15120
|
-
}, '
|
|
15121
|
-
title: '
|
|
14398
|
+
examples: ['(&! 0b0011 0b0110)', '(&! 0b0011 0b0110 0b1001)'],
|
|
14399
|
+
}, '|': {
|
|
14400
|
+
title: '|',
|
|
15122
14401
|
category: 'Bitwise',
|
|
15123
|
-
linkName: '
|
|
14402
|
+
linkName: '-or',
|
|
14403
|
+
clojureDocs: 'bit-or',
|
|
15124
14404
|
returns: {
|
|
15125
14405
|
type: 'integer',
|
|
15126
14406
|
},
|
|
@@ -15141,11 +14421,12 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15141
14421
|
{ argumentNames: ['x', 'y', 'rest'] },
|
|
15142
14422
|
],
|
|
15143
14423
|
description: 'Returns bitwise `or` of all arguments.',
|
|
15144
|
-
examples: ['(
|
|
15145
|
-
}, '
|
|
15146
|
-
title: '
|
|
14424
|
+
examples: ['(| 0b0011 0b0110)', '(| 0b1000 0b0100 0b0010)'],
|
|
14425
|
+
}, '^': {
|
|
14426
|
+
title: '^',
|
|
15147
14427
|
category: 'Bitwise',
|
|
15148
|
-
linkName: '
|
|
14428
|
+
linkName: '-caret',
|
|
14429
|
+
clojureDocs: 'bit-xor',
|
|
15149
14430
|
returns: {
|
|
15150
14431
|
type: 'integer',
|
|
15151
14432
|
},
|
|
@@ -15166,11 +14447,11 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15166
14447
|
{ argumentNames: ['x', 'y', 'rest'] },
|
|
15167
14448
|
],
|
|
15168
14449
|
description: 'Returns bitwise `xor` of all arguments.',
|
|
15169
|
-
examples: ['(
|
|
15170
|
-
}, '
|
|
15171
|
-
title: '
|
|
14450
|
+
examples: ['(^ 0b0011 0b0110)', '(^ 0b11110000 0b00111100 0b10101010)'],
|
|
14451
|
+
}, 'bit_flip': {
|
|
14452
|
+
title: 'bit_flip',
|
|
15172
14453
|
category: 'Bitwise',
|
|
15173
|
-
linkName: '
|
|
14454
|
+
linkName: 'bit_flip',
|
|
15174
14455
|
returns: {
|
|
15175
14456
|
type: 'integer',
|
|
15176
14457
|
},
|
|
@@ -15186,11 +14467,11 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15186
14467
|
{ argumentNames: ['x', 'n'] },
|
|
15187
14468
|
],
|
|
15188
14469
|
description: 'Flips bit number $n.',
|
|
15189
|
-
examples: ['(
|
|
15190
|
-
}, '
|
|
15191
|
-
title: '
|
|
14470
|
+
examples: ['(bit_flip 0b0011 1)', '(bit_flip 0b1100 1)'],
|
|
14471
|
+
}, 'bit_clear': {
|
|
14472
|
+
title: 'bit_clear',
|
|
15192
14473
|
category: 'Bitwise',
|
|
15193
|
-
linkName: '
|
|
14474
|
+
linkName: 'bit_clear',
|
|
15194
14475
|
returns: {
|
|
15195
14476
|
type: 'integer',
|
|
15196
14477
|
},
|
|
@@ -15206,11 +14487,11 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15206
14487
|
{ argumentNames: ['x', 'n'] },
|
|
15207
14488
|
],
|
|
15208
14489
|
description: 'Clears bit number $n.',
|
|
15209
|
-
examples: ['(
|
|
15210
|
-
}, '
|
|
15211
|
-
title: '
|
|
14490
|
+
examples: ['(bit_clear 0b0011 1)', '(bit_clear 0b1100 1)'],
|
|
14491
|
+
}, 'bit_set': {
|
|
14492
|
+
title: 'bit_set',
|
|
15212
14493
|
category: 'Bitwise',
|
|
15213
|
-
linkName: '
|
|
14494
|
+
linkName: 'bit_set',
|
|
15214
14495
|
returns: {
|
|
15215
14496
|
type: 'integer',
|
|
15216
14497
|
},
|
|
@@ -15226,11 +14507,11 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15226
14507
|
{ argumentNames: ['x', 'n'] },
|
|
15227
14508
|
],
|
|
15228
14509
|
description: 'Sets bit number $n.',
|
|
15229
|
-
examples: ['(
|
|
15230
|
-
}, '
|
|
15231
|
-
title: '
|
|
14510
|
+
examples: ['(bit_set 0b0011 1)', '(bit_set 0b1100 1)'],
|
|
14511
|
+
}, 'bit_test': {
|
|
14512
|
+
title: 'bit_test',
|
|
15232
14513
|
category: 'Bitwise',
|
|
15233
|
-
linkName: '
|
|
14514
|
+
linkName: 'bit_test',
|
|
15234
14515
|
returns: {
|
|
15235
14516
|
type: 'boolean',
|
|
15236
14517
|
},
|
|
@@ -15246,7 +14527,7 @@ var bitwiseReference = { 'bit-shift-left': {
|
|
|
15246
14527
|
{ argumentNames: ['x', 'n'] },
|
|
15247
14528
|
],
|
|
15248
14529
|
description: 'Checks if bit number $n is set.',
|
|
15249
|
-
examples: ['(
|
|
14530
|
+
examples: ['(bit_test 0b0011 1)', '(bit_test 0b1100 1)'],
|
|
15250
14531
|
} };
|
|
15251
14532
|
|
|
15252
14533
|
var shorthand = {
|
|
@@ -15562,13 +14843,13 @@ var api = {
|
|
|
15562
14843
|
'*',
|
|
15563
14844
|
'/',
|
|
15564
14845
|
'mod',
|
|
15565
|
-
'
|
|
14846
|
+
'%',
|
|
15566
14847
|
'quot',
|
|
15567
14848
|
'inc',
|
|
15568
14849
|
'dec',
|
|
15569
14850
|
'sqrt',
|
|
15570
14851
|
'cbrt',
|
|
15571
|
-
'
|
|
14852
|
+
'**',
|
|
15572
14853
|
'exp',
|
|
15573
14854
|
'round',
|
|
15574
14855
|
'trunc',
|
|
@@ -15618,23 +14899,20 @@ var api = {
|
|
|
15618
14899
|
],
|
|
15619
14900
|
misc: [
|
|
15620
14901
|
'!=',
|
|
15621
|
-
'
|
|
14902
|
+
'==',
|
|
15622
14903
|
'<',
|
|
15623
14904
|
'>',
|
|
15624
14905
|
'<=',
|
|
15625
14906
|
'>=',
|
|
15626
|
-
'
|
|
14907
|
+
'!',
|
|
15627
14908
|
'write!',
|
|
15628
|
-
'
|
|
15629
|
-
'
|
|
15630
|
-
'inst-ms->iso-date-time',
|
|
14909
|
+
'iso_date>epoch',
|
|
14910
|
+
'epoch>iso_date',
|
|
15631
14911
|
'boolean',
|
|
15632
14912
|
'compare',
|
|
15633
|
-
'lits-version!',
|
|
15634
|
-
'uuid!',
|
|
15635
14913
|
'equal?',
|
|
15636
|
-
'
|
|
15637
|
-
'
|
|
14914
|
+
'json_parse',
|
|
14915
|
+
'json_stringify',
|
|
15638
14916
|
],
|
|
15639
14917
|
object: [
|
|
15640
14918
|
'dissoc',
|
|
@@ -15644,9 +14922,9 @@ var api = {
|
|
|
15644
14922
|
'entries',
|
|
15645
14923
|
'find',
|
|
15646
14924
|
'merge',
|
|
15647
|
-
'
|
|
14925
|
+
'merge_with',
|
|
15648
14926
|
'zipmap',
|
|
15649
|
-
'
|
|
14927
|
+
'select_keys',
|
|
15650
14928
|
],
|
|
15651
14929
|
predicate: [
|
|
15652
14930
|
'boolean?',
|
|
@@ -15680,70 +14958,65 @@ var api = {
|
|
|
15680
14958
|
'replace',
|
|
15681
14959
|
],
|
|
15682
14960
|
specialExpressions: [
|
|
15683
|
-
'
|
|
15684
|
-
'
|
|
14961
|
+
'&&',
|
|
14962
|
+
'||',
|
|
15685
14963
|
'def',
|
|
15686
14964
|
'defs',
|
|
15687
14965
|
'let',
|
|
15688
|
-
'if-let',
|
|
15689
|
-
'when-let',
|
|
15690
|
-
'when-first',
|
|
15691
14966
|
'fn',
|
|
15692
14967
|
'defn',
|
|
15693
14968
|
'defns',
|
|
15694
14969
|
'try',
|
|
15695
14970
|
'throw',
|
|
15696
14971
|
'if',
|
|
15697
|
-
'
|
|
14972
|
+
'unless',
|
|
15698
14973
|
'cond',
|
|
15699
|
-
'
|
|
15700
|
-
'when-not',
|
|
14974
|
+
'switch',
|
|
15701
14975
|
'comment',
|
|
15702
14976
|
'do',
|
|
15703
14977
|
'recur',
|
|
15704
14978
|
'loop',
|
|
15705
|
-
'time!',
|
|
15706
14979
|
'doseq',
|
|
15707
14980
|
'for',
|
|
15708
|
-
'
|
|
14981
|
+
'defined?',
|
|
15709
14982
|
'??',
|
|
15710
14983
|
],
|
|
15711
14984
|
string: [
|
|
15712
14985
|
'subs',
|
|
15713
|
-
'
|
|
14986
|
+
'string_repeat',
|
|
15714
14987
|
'str',
|
|
15715
14988
|
'number',
|
|
15716
|
-
'
|
|
15717
|
-
'
|
|
15718
|
-
'upper-case',
|
|
14989
|
+
'lower_case',
|
|
14990
|
+
'upper_case',
|
|
15719
14991
|
'trim',
|
|
15720
|
-
'
|
|
15721
|
-
'
|
|
15722
|
-
'
|
|
15723
|
-
'
|
|
14992
|
+
'trim_left',
|
|
14993
|
+
'trim_right',
|
|
14994
|
+
'pad_left',
|
|
14995
|
+
'pad_right',
|
|
15724
14996
|
'split',
|
|
15725
14997
|
'template',
|
|
15726
|
-
'
|
|
15727
|
-
'
|
|
15728
|
-
'
|
|
15729
|
-
'
|
|
15730
|
-
'
|
|
15731
|
-
'
|
|
14998
|
+
'to_char_code',
|
|
14999
|
+
'from_char_code',
|
|
15000
|
+
'encode_base64',
|
|
15001
|
+
'decode_base64',
|
|
15002
|
+
'encode_uri_component',
|
|
15003
|
+
'decode_uri_component',
|
|
15732
15004
|
'join',
|
|
15005
|
+
'++',
|
|
15733
15006
|
],
|
|
15734
15007
|
bitwise: [
|
|
15735
|
-
'
|
|
15736
|
-
'
|
|
15737
|
-
'
|
|
15738
|
-
'
|
|
15739
|
-
'
|
|
15740
|
-
'
|
|
15741
|
-
'
|
|
15742
|
-
'
|
|
15743
|
-
'
|
|
15744
|
-
'
|
|
15745
|
-
'
|
|
15746
|
-
'
|
|
15008
|
+
'<<',
|
|
15009
|
+
'>>',
|
|
15010
|
+
'>>>',
|
|
15011
|
+
'~',
|
|
15012
|
+
'&',
|
|
15013
|
+
'&!',
|
|
15014
|
+
'|',
|
|
15015
|
+
'^',
|
|
15016
|
+
'bit_flip',
|
|
15017
|
+
'bit_clear',
|
|
15018
|
+
'bit_set',
|
|
15019
|
+
'bit_test',
|
|
15747
15020
|
],
|
|
15748
15021
|
assert: [
|
|
15749
15022
|
'assert',
|