@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.
Files changed (112) hide show
  1. package/dist/cli/cli.js +1131 -1858
  2. package/dist/cli/reference/api.d.ts +8 -8
  3. package/dist/cli/src/analyze/index.d.ts +0 -2
  4. package/dist/cli/src/builtin/index.d.ts +6 -11
  5. package/dist/cli/src/builtin/specialExpressions/and.d.ts +1 -1
  6. package/dist/cli/src/builtin/specialExpressions/declared.d.ts +1 -1
  7. package/dist/cli/src/builtin/specialExpressions/or.d.ts +1 -1
  8. package/dist/cli/src/builtin/specialExpressions/{when.d.ts → switch.d.ts} +2 -2
  9. package/dist/cli/src/builtin/specialExpressions/try.d.ts +1 -1
  10. package/dist/cli/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
  11. package/dist/cli/src/evaluator/ContextStack.d.ts +2 -0
  12. package/dist/cli/src/identifier.d.ts +2 -2
  13. package/dist/cli/src/parser/AlgebraicParser.d.ts +12 -2
  14. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
  15. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  16. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
  17. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
  18. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +1 -1
  19. package/dist/cli/src/tokenizer/utils.d.ts +1 -1
  20. package/dist/cli/src/typeGuards/index.d.ts +1 -0
  21. package/dist/index.esm.js +1132 -1861
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/index.js +1132 -1861
  24. package/dist/index.js.map +1 -1
  25. package/dist/lits.iife.js +1132 -1861
  26. package/dist/lits.iife.js.map +1 -1
  27. package/dist/reference/api.d.ts +8 -8
  28. package/dist/src/analyze/index.d.ts +0 -2
  29. package/dist/src/builtin/index.d.ts +6 -11
  30. package/dist/src/builtin/specialExpressions/and.d.ts +1 -1
  31. package/dist/src/builtin/specialExpressions/declared.d.ts +1 -1
  32. package/dist/src/builtin/specialExpressions/or.d.ts +1 -1
  33. package/dist/{cli/src/builtin/specialExpressions/time.d.ts → src/builtin/specialExpressions/switch.d.ts} +2 -2
  34. package/dist/src/builtin/specialExpressions/try.d.ts +1 -1
  35. package/dist/src/builtin/specialExpressions/{if-not.d.ts → unless.d.ts} +2 -2
  36. package/dist/src/evaluator/ContextStack.d.ts +2 -0
  37. package/dist/src/identifier.d.ts +2 -2
  38. package/dist/src/parser/AlgebraicParser.d.ts +12 -2
  39. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +94 -7
  40. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  41. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +8 -7
  42. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
  43. package/dist/src/tokenizer/polish/polishTokens.d.ts +1 -1
  44. package/dist/src/tokenizer/utils.d.ts +1 -1
  45. package/dist/src/typeGuards/index.d.ts +1 -0
  46. package/dist/testFramework.esm.js +772 -1325
  47. package/dist/testFramework.esm.js.map +1 -1
  48. package/dist/testFramework.js +772 -1325
  49. package/dist/testFramework.js.map +1 -1
  50. package/package.json +1 -1
  51. package/dist/cli/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
  52. package/dist/cli/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
  53. package/dist/cli/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
  54. package/dist/cli/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
  55. package/dist/cli/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
  56. package/dist/cli/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
  57. package/dist/cli/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
  58. package/dist/cli/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
  59. package/dist/cli/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
  60. package/dist/cli/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
  61. package/dist/cli/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
  62. package/dist/cli/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
  63. package/dist/cli/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
  64. package/dist/cli/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
  65. package/dist/cli/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
  66. package/dist/cli/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
  67. package/dist/cli/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
  68. package/dist/cli/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
  69. package/dist/cli/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
  70. package/dist/cli/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
  71. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
  72. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
  73. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
  74. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
  75. package/dist/cli/src/analyze/calculateOutcomes/index.d.ts +0 -18
  76. package/dist/cli/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
  77. package/dist/cli/src/builtin/specialExpressions/if-let.d.ts +0 -7
  78. package/dist/cli/src/builtin/specialExpressions/when-first.d.ts +0 -7
  79. package/dist/cli/src/builtin/specialExpressions/when-let.d.ts +0 -7
  80. package/dist/cli/src/builtin/specialExpressions/when-not.d.ts +0 -6
  81. package/dist/src/analyze/calculateOutcomes/calculateAndOutcomes.d.ts +0 -3
  82. package/dist/src/analyze/calculateOutcomes/calculateCommentOutcomes.d.ts +0 -3
  83. package/dist/src/analyze/calculateOutcomes/calculateCondOutcomes.d.ts +0 -3
  84. package/dist/src/analyze/calculateOutcomes/calculateDeclaredOutcomes.d.ts +0 -3
  85. package/dist/src/analyze/calculateOutcomes/calculateDefOutcomes.d.ts +0 -3
  86. package/dist/src/analyze/calculateOutcomes/calculateDefsOutcomes.d.ts +0 -3
  87. package/dist/src/analyze/calculateOutcomes/calculateDoOutcomes.d.ts +0 -3
  88. package/dist/src/analyze/calculateOutcomes/calculateFunctionOutcomes.d.ts +0 -5
  89. package/dist/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +0 -3
  90. package/dist/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +0 -3
  91. package/dist/src/analyze/calculateOutcomes/calculateIfOutcomes.d.ts +0 -3
  92. package/dist/src/analyze/calculateOutcomes/calculateLetOutcomes.d.ts +0 -3
  93. package/dist/src/analyze/calculateOutcomes/calculateLoopOutcomes.d.ts +0 -3
  94. package/dist/src/analyze/calculateOutcomes/calculateLoopsOutcomes.d.ts +0 -4
  95. package/dist/src/analyze/calculateOutcomes/calculateOrOutcomes.d.ts +0 -3
  96. package/dist/src/analyze/calculateOutcomes/calculateQqOutcomes.d.ts +0 -3
  97. package/dist/src/analyze/calculateOutcomes/calculateRecurOutcomes.d.ts +0 -3
  98. package/dist/src/analyze/calculateOutcomes/calculateThrowOutcomes.d.ts +0 -3
  99. package/dist/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
  100. package/dist/src/analyze/calculateOutcomes/calculateTryOutcomes.d.ts +0 -3
  101. package/dist/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +0 -3
  102. package/dist/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +0 -3
  103. package/dist/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +0 -3
  104. package/dist/src/analyze/calculateOutcomes/calculateWhenOutcomes.d.ts +0 -3
  105. package/dist/src/analyze/calculateOutcomes/index.d.ts +0 -18
  106. package/dist/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +0 -55
  107. package/dist/src/builtin/specialExpressions/if-let.d.ts +0 -7
  108. package/dist/src/builtin/specialExpressions/time.d.ts +0 -6
  109. package/dist/src/builtin/specialExpressions/when-first.d.ts +0 -7
  110. package/dist/src/builtin/specialExpressions/when-let.d.ts +0 -7
  111. package/dist/src/builtin/specialExpressions/when-not.d.ts +0 -6
  112. package/dist/src/builtin/specialExpressions/when.d.ts +0 -6
package/dist/index.esm.js CHANGED
@@ -236,6 +236,12 @@ function isLitsError(error) {
236
236
  return error instanceof LitsError;
237
237
  }
238
238
 
239
+ function getSourceCodeInfo(anyValue, sourceCodeInfo) {
240
+ var _a;
241
+ // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
242
+ return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
243
+ }
244
+
239
245
  function isTokenDebugData(tokenDebugData) {
240
246
  return (typeof tokenDebugData === 'object'
241
247
  && tokenDebugData !== null
@@ -254,8 +260,12 @@ function addTokenDebugData(token, debugData) {
254
260
  }
255
261
  token.push(debugData);
256
262
  }
257
- function throwUnexpectedToken(expected, actual) {
258
- throw new LitsError("Unexpected token: ".concat(actual, ", expected ").concat(expected), undefined);
263
+ function throwUnexpectedToken(expected, expectedValue, actual) {
264
+ if (actual === undefined) {
265
+ throw new LitsError("Unexpected end of input, expected ".concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), undefined);
266
+ }
267
+ var actualOutput = "".concat(actual[0]).concat(actual[1] ? " '".concat(actual[1], "'") : '');
268
+ throw new LitsError("Unexpected token: ".concat(actualOutput, ", expected ").concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), getSourceCodeInfo(actual));
259
269
  }
260
270
 
261
271
  var commonSimpleTokenTypes = [
@@ -277,7 +287,7 @@ function isLParenToken(token) {
277
287
  }
278
288
  function assertLParenToken(token) {
279
289
  if (!isLParenToken(token)) {
280
- throwUnexpectedToken('LParen', token);
290
+ throwUnexpectedToken('LParen', undefined, token);
281
291
  }
282
292
  }
283
293
  function asLParenToken(token) {
@@ -289,7 +299,7 @@ function isRParenToken(token) {
289
299
  }
290
300
  function assertRParenToken(token) {
291
301
  if (!isRParenToken(token)) {
292
- throwUnexpectedToken('RParen', token);
302
+ throwUnexpectedToken('RParen', undefined, token);
293
303
  }
294
304
  }
295
305
  function isLBracketToken(token) {
@@ -297,7 +307,7 @@ function isLBracketToken(token) {
297
307
  }
298
308
  function assertLBracketToken(token) {
299
309
  if (!isLBracketToken(token)) {
300
- throwUnexpectedToken('LBracket', token);
310
+ throwUnexpectedToken('LBracket', undefined, token);
301
311
  }
302
312
  }
303
313
  function asLBracketToken(token) {
@@ -309,7 +319,7 @@ function isRBracketToken(token) {
309
319
  }
310
320
  function assertRBracketToken(token) {
311
321
  if (!isRBracketToken(token)) {
312
- throwUnexpectedToken('RBracket', token);
322
+ throwUnexpectedToken('RBracket', undefined, token);
313
323
  }
314
324
  }
315
325
  function isLBraceToken(token) {
@@ -317,7 +327,7 @@ function isLBraceToken(token) {
317
327
  }
318
328
  function assertLBraceToken(token) {
319
329
  if (!isLBraceToken(token)) {
320
- throwUnexpectedToken('LBrace', token);
330
+ throwUnexpectedToken('LBrace', undefined, token);
321
331
  }
322
332
  }
323
333
  function asLBraceToken(token) {
@@ -329,7 +339,7 @@ function isRBraceToken(token) {
329
339
  }
330
340
  function assertRBraceToken(token) {
331
341
  if (!isRBraceToken(token)) {
332
- throwUnexpectedToken('RBrace', token);
342
+ throwUnexpectedToken('RBrace', undefined, token);
333
343
  }
334
344
  }
335
345
  function isStringToken(token) {
@@ -337,7 +347,7 @@ function isStringToken(token) {
337
347
  }
338
348
  function assertStringToken(token) {
339
349
  if (!isStringToken(token)) {
340
- throwUnexpectedToken('String', token);
350
+ throwUnexpectedToken('String', undefined, token);
341
351
  }
342
352
  }
343
353
  function asStringToken(token) {
@@ -355,7 +365,7 @@ function isEndNotationToken(token) {
355
365
  }
356
366
  function assertEndNotationToken(token) {
357
367
  if (!isEndNotationToken(token)) {
358
- throwUnexpectedToken('EndNotation', token);
368
+ throwUnexpectedToken('EndNotation', undefined, token);
359
369
  }
360
370
  }
361
371
 
@@ -413,24 +423,18 @@ var otherSymbolicOperators = [
413
423
  var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(symbolicUnaryOperators), false), __read(symbolicBinaryOperators), false), __read(otherSymbolicOperators), false);
414
424
  var nonFunctionOperators = [
415
425
  '??',
416
- 'and',
426
+ '&&',
417
427
  'comment',
418
428
  'cond',
419
- 'declared?',
429
+ 'defined?',
420
430
  'if',
421
- 'if-not',
422
- 'or',
423
- 'when',
424
- 'when-not',
431
+ 'unless',
432
+ '||',
425
433
  'do',
426
- 'time!',
427
434
  'throw',
428
435
  'let',
429
436
  'def',
430
437
  'defs',
431
- 'if-let',
432
- 'when-let',
433
- 'when-first',
434
438
  'fn',
435
439
  'defn',
436
440
  'defns',
@@ -456,23 +460,40 @@ var symbolicOperatorSet = new Set(symbolicOperators);
456
460
  function isSymbolicOperator(operator) {
457
461
  return symbolicOperatorSet.has(operator);
458
462
  }
459
- function isA_SymbolToken(token) {
460
- return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Symbol';
463
+ function isA_SymbolToken(token, symbolName) {
464
+ if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_Symbol') {
465
+ return false;
466
+ }
467
+ if (symbolName && token[1] !== symbolName) {
468
+ return false;
469
+ }
470
+ return true;
461
471
  }
462
- function assertA_SymbolToken(token) {
463
- if (!isA_SymbolToken(token)) {
464
- throwUnexpectedToken('A_Symbol', token);
472
+ function assertA_SymbolToken(token, symbolName) {
473
+ if (!isA_SymbolToken(token, symbolName)) {
474
+ throwUnexpectedToken('A_Symbol', undefined, token);
465
475
  }
466
476
  }
467
- function asA_SymbolToken(token) {
468
- assertA_SymbolToken(token);
477
+ function asA_SymbolToken(token, symbolName) {
478
+ assertA_SymbolToken(token, symbolName);
469
479
  return token;
470
480
  }
471
481
  function isA_BinaryOperatorToken(token) {
472
482
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Operator' && isSymbolicBinaryOperator(token[1]);
473
483
  }
474
- function isA_ReservedSymbolToken(token) {
475
- return (token === null || token === void 0 ? void 0 : token[0]) === 'A_ReservedSymbol';
484
+ function isA_ReservedSymbolToken(token, symbolName) {
485
+ if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_ReservedSymbol') {
486
+ return false;
487
+ }
488
+ if (symbolName && token[1] !== symbolName) {
489
+ return false;
490
+ }
491
+ return true;
492
+ }
493
+ function assertA_ReservedSymbolToken(token, symbolName) {
494
+ if (!isA_ReservedSymbolToken(token, symbolName)) {
495
+ throwUnexpectedToken('A_ReservedSymbol', symbolName, token);
496
+ }
476
497
  }
477
498
  function isA_CommentToken(token) {
478
499
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_SingleLineComment';
@@ -491,10 +512,9 @@ function isA_OperatorToken(token, operatorName) {
491
512
  }
492
513
  function assertA_OperatorToken(token, operatorName) {
493
514
  if (!isA_OperatorToken(token, operatorName)) {
494
- if (operatorName) {
515
+ {
495
516
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
496
517
  }
497
- throwUnexpectedToken('A_Operator', token);
498
518
  }
499
519
  }
500
520
  function isA_WhitespaceToken(token) {
@@ -507,7 +527,7 @@ function isA_BasePrefixedNumberToken(token) {
507
527
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_BasePrefixedNumber';
508
528
  }
509
529
 
510
- var modifierNames = ['&', '&let', '&when', '&while'];
530
+ var modifierNames = ['&rest', '&let', '&when', '&while'];
511
531
  var polishOnlySimpleTokenTypes = [
512
532
  'P_FnShorthand',
513
533
  ];
@@ -530,7 +550,7 @@ function isP_StringShorthandToken(token) {
530
550
  }
531
551
  function assertP_StringShorthandToken(token) {
532
552
  if (!isP_StringShorthandToken(token)) {
533
- throwUnexpectedToken('P_StringShorthand', token);
553
+ throwUnexpectedToken('P_StringShorthand', undefined, token);
534
554
  }
535
555
  }
536
556
  function asP_StringShorthandToken(token) {
@@ -542,7 +562,7 @@ function isP_SymbolToken(token) {
542
562
  }
543
563
  function assertP_SymbolToken(token) {
544
564
  if (!isP_SymbolToken(token)) {
545
- throwUnexpectedToken('P_Symbol', token);
565
+ throwUnexpectedToken('P_Symbol', undefined, token);
546
566
  }
547
567
  }
548
568
  function asP_SymbolToken(token) {
@@ -560,7 +580,7 @@ function isP_RegexpShorthandToken(token) {
560
580
  }
561
581
  function assertP_RegexpShorthandToken(token) {
562
582
  if (!isP_RegexpShorthandToken(token)) {
563
- throwUnexpectedToken('P_RegexpShorthand', token);
583
+ throwUnexpectedToken('P_RegexpShorthand', undefined, token);
564
584
  }
565
585
  }
566
586
  function asP_RegexpShorthandToken(token) {
@@ -575,7 +595,7 @@ function isP_CollectionAccessorToken(token) {
575
595
  }
576
596
  function assertP_CollectionAccessorToken(token) {
577
597
  if (!isP_CollectionAccessorToken(token)) {
578
- throwUnexpectedToken('P_CollectionAccessor', token);
598
+ throwUnexpectedToken('P_CollectionAccessor', undefined, token);
579
599
  }
580
600
  }
581
601
  function asP_CollectionAccessorToken(token) {
@@ -587,7 +607,7 @@ function isP_CommentToken(token) {
587
607
  }
588
608
  function assertP_CommentToken(token) {
589
609
  if (!isP_CommentToken(token)) {
590
- throwUnexpectedToken('P_Comment', token);
610
+ throwUnexpectedToken('P_Comment', undefined, token);
591
611
  }
592
612
  }
593
613
  function asP_CommentToken(token) {
@@ -602,7 +622,7 @@ function isP_NumberToken(token) {
602
622
  }
603
623
  function assertP_NumberToken(token) {
604
624
  if (!isP_NumberToken(token)) {
605
- throwUnexpectedToken('P_Number', token);
625
+ throwUnexpectedToken('P_Number', undefined, token);
606
626
  }
607
627
  }
608
628
 
@@ -670,12 +690,6 @@ function valueToString(value) {
670
690
  return JSON.stringify(value);
671
691
  }
672
692
 
673
- function getSourceCodeInfo(anyValue, sourceCodeInfo) {
674
- var _a;
675
- // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
676
- return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
677
- }
678
-
679
693
  function getAssertionError(typeName, value, sourceCodeInfo) {
680
694
  return new LitsError("Expected ".concat(typeName, ", got ").concat(valueToString(value), "."), getSourceCodeInfo(value, sourceCodeInfo));
681
695
  }
@@ -728,7 +742,7 @@ function isExpressionNode(value) {
728
742
  }
729
743
 
730
744
  var specialExpressionCommentRemovers = {
731
- 'and': function (node, removeOptions) {
745
+ '&&': function (node, removeOptions) {
732
746
  removeOptions.removeCommenNodesFromArray(node.p);
733
747
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
734
748
  },
@@ -740,7 +754,11 @@ var specialExpressionCommentRemovers = {
740
754
  removeOptions.removeCommenNodesFromArray(node.p);
741
755
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
742
756
  },
743
- 'declared?': function (node, removeOptions) {
757
+ 'switch': function (node, removeOptions) {
758
+ removeOptions.removeCommenNodesFromArray(node.p);
759
+ node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
760
+ },
761
+ 'defined?': function (node, removeOptions) {
744
762
  removeOptions.removeCommenNodesFromArray(node.p);
745
763
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
746
764
  },
@@ -761,12 +779,11 @@ var specialExpressionCommentRemovers = {
761
779
  'doseq': function (_node, _removeOptions) { },
762
780
  'fn': function (_node, _removeOptions) { },
763
781
  'for': function (_node, _removeOptions) { },
764
- 'if-let': function (_node, _removeOptions) { },
765
782
  'if': function (node, removeOptions) {
766
783
  removeOptions.removeCommenNodesFromArray(node.p);
767
784
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
768
785
  },
769
- 'if-not': function (node, removeOptions) {
786
+ 'unless': function (node, removeOptions) {
770
787
  removeOptions.removeCommenNodesFromArray(node.p);
771
788
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
772
789
  },
@@ -778,7 +795,7 @@ var specialExpressionCommentRemovers = {
778
795
  });
779
796
  },
780
797
  'loop': function (_node, _removeOptions) { },
781
- 'or': function (node, removeOptions) {
798
+ '||': function (node, removeOptions) {
782
799
  removeOptions.removeCommenNodesFromArray(node.p);
783
800
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
784
801
  },
@@ -790,19 +807,11 @@ var specialExpressionCommentRemovers = {
790
807
  removeOptions.removeCommenNodesFromArray(node.p);
791
808
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
792
809
  },
793
- 'time!': function (node, removeOptions) {
794
- removeOptions.removeCommenNodesFromArray(node.p);
795
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
796
- },
797
810
  'throw': function (node, removeOptions) {
798
811
  removeOptions.removeCommenNodesFromArray(node.p);
799
812
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
800
813
  },
801
814
  'try': function (_node, _removeOptions) { },
802
- 'when-first': function (_node, _removeOptions) { },
803
- 'when-let': function (_node, _removeOptions) { },
804
- 'when': function (_node, _removeOptions) { },
805
- 'when-not': function (_node, _removeOptions) { },
806
815
  };
807
816
  function removeCommentNodesFromSpecialExpression(node, removeOptions) {
808
817
  var uncommenter = specialExpressionCommentRemovers[node.n];
@@ -844,6 +853,13 @@ function assertEvenNumberOfParams(node) {
844
853
  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);
845
854
  }
846
855
  }
856
+ function assertOddNumberOfParams(node) {
857
+ var _a;
858
+ var length = withoutCommentNodes(node.p).length;
859
+ if (length % 2 !== 1) {
860
+ 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);
861
+ }
862
+ }
847
863
  function assertNumberOfParams(count, node) {
848
864
  var _a, _b;
849
865
  assertCount({
@@ -1007,7 +1023,7 @@ function asNumber(value, sourceCodeInfo, options) {
1007
1023
  }
1008
1024
 
1009
1025
  var bitwiseNormalExpression = {
1010
- 'bit-shift-left': {
1026
+ '<<': {
1011
1027
  evaluate: function (_a, sourceCodeInfo) {
1012
1028
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
1013
1029
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1016,7 +1032,7 @@ var bitwiseNormalExpression = {
1016
1032
  },
1017
1033
  validate: function (node) { return assertNumberOfParams(2, node); },
1018
1034
  },
1019
- 'bit-shift-right': {
1035
+ '>>': {
1020
1036
  evaluate: function (_a, sourceCodeInfo) {
1021
1037
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
1022
1038
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1025,7 +1041,7 @@ var bitwiseNormalExpression = {
1025
1041
  },
1026
1042
  validate: function (node) { return assertNumberOfParams(2, node); },
1027
1043
  },
1028
- 'unsigned-bit-shift-right': {
1044
+ '>>>': {
1029
1045
  evaluate: function (_a, sourceCodeInfo) {
1030
1046
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
1031
1047
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1034,7 +1050,7 @@ var bitwiseNormalExpression = {
1034
1050
  },
1035
1051
  validate: function (node) { return assertNumberOfParams(2, node); },
1036
1052
  },
1037
- 'bit-not': {
1053
+ '~': {
1038
1054
  evaluate: function (_a, sourceCodeInfo) {
1039
1055
  var _b = __read(_a, 1), num = _b[0];
1040
1056
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1042,7 +1058,7 @@ var bitwiseNormalExpression = {
1042
1058
  },
1043
1059
  validate: function (node) { return assertNumberOfParams(1, node); },
1044
1060
  },
1045
- 'bit-and': {
1061
+ '&': {
1046
1062
  evaluate: function (_a, sourceCodeInfo) {
1047
1063
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1048
1064
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1053,7 +1069,7 @@ var bitwiseNormalExpression = {
1053
1069
  },
1054
1070
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1055
1071
  },
1056
- 'bit-and-not': {
1072
+ '&!': {
1057
1073
  evaluate: function (_a, sourceCodeInfo) {
1058
1074
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1059
1075
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1064,7 +1080,7 @@ var bitwiseNormalExpression = {
1064
1080
  },
1065
1081
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1066
1082
  },
1067
- 'bit-or': {
1083
+ '|': {
1068
1084
  evaluate: function (_a, sourceCodeInfo) {
1069
1085
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1070
1086
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1075,7 +1091,7 @@ var bitwiseNormalExpression = {
1075
1091
  },
1076
1092
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1077
1093
  },
1078
- 'bit-xor': {
1094
+ '^': {
1079
1095
  evaluate: function (_a, sourceCodeInfo) {
1080
1096
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1081
1097
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1086,7 +1102,7 @@ var bitwiseNormalExpression = {
1086
1102
  },
1087
1103
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1088
1104
  },
1089
- 'bit-flip': {
1105
+ 'bit_flip': {
1090
1106
  evaluate: function (_a, sourceCodeInfo) {
1091
1107
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1092
1108
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1096,7 +1112,7 @@ var bitwiseNormalExpression = {
1096
1112
  },
1097
1113
  validate: function (node) { return assertNumberOfParams(2, node); },
1098
1114
  },
1099
- 'bit-set': {
1115
+ 'bit_set': {
1100
1116
  evaluate: function (_a, sourceCodeInfo) {
1101
1117
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1102
1118
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1106,7 +1122,7 @@ var bitwiseNormalExpression = {
1106
1122
  },
1107
1123
  validate: function (node) { return assertNumberOfParams(2, node); },
1108
1124
  },
1109
- 'bit-clear': {
1125
+ 'bit_clear': {
1110
1126
  evaluate: function (_a, sourceCodeInfo) {
1111
1127
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1112
1128
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1116,7 +1132,7 @@ var bitwiseNormalExpression = {
1116
1132
  },
1117
1133
  validate: function (node) { return assertNumberOfParams(2, node); },
1118
1134
  },
1119
- 'bit-test': {
1135
+ 'bit_test': {
1120
1136
  evaluate: function (_a, sourceCodeInfo) {
1121
1137
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1122
1138
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -2815,7 +2831,7 @@ var mathNormalExpression = {
2815
2831
  },
2816
2832
  validate: function (node) { return assertNumberOfParams(2, node); },
2817
2833
  },
2818
- 'rem': {
2834
+ '%': {
2819
2835
  evaluate: function (_a, sourceCodeInfo) {
2820
2836
  var _b = __read(_a, 2), dividend = _b[0], divisor = _b[1];
2821
2837
  assertNumber(dividend, sourceCodeInfo);
@@ -2841,7 +2857,7 @@ var mathNormalExpression = {
2841
2857
  },
2842
2858
  validate: function (node) { return assertNumberOfParams(1, node); },
2843
2859
  },
2844
- 'pow': {
2860
+ '**': {
2845
2861
  evaluate: function (_a, sourceCodeInfo) {
2846
2862
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
2847
2863
  assertNumber(first, sourceCodeInfo);
@@ -3118,10 +3134,6 @@ var mathNormalExpression = {
3118
3134
  },
3119
3135
  };
3120
3136
 
3121
- var version = "2.0.14";
3122
-
3123
- var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
3124
- var xyRegexp = /[xy]/g;
3125
3137
  var miscNormalExpression = {
3126
3138
  '!=': {
3127
3139
  evaluate: function (params) {
@@ -3135,7 +3147,7 @@ var miscNormalExpression = {
3135
3147
  },
3136
3148
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3137
3149
  },
3138
- '=': {
3150
+ '==': {
3139
3151
  evaluate: function (_a) {
3140
3152
  var e_1, _b;
3141
3153
  var _c = __read(_a), first = _c[0], rest = _c.slice(1);
@@ -3260,20 +3272,14 @@ var miscNormalExpression = {
3260
3272
  },
3261
3273
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3262
3274
  },
3263
- 'not': {
3275
+ '!': {
3264
3276
  evaluate: function (_a) {
3265
3277
  var _b = __read(_a, 1), first = _b[0];
3266
3278
  return !first;
3267
3279
  },
3268
3280
  validate: function (node) { return assertNumberOfParams(1, node); },
3269
3281
  },
3270
- 'inst-ms!': {
3271
- evaluate: function () {
3272
- return Date.now();
3273
- },
3274
- validate: function (node) { return assertNumberOfParams(0, node); },
3275
- },
3276
- 'inst-ms->iso-date-time': {
3282
+ 'epoch>iso_date': {
3277
3283
  evaluate: function (_a, sourceCodeInfo) {
3278
3284
  var _b = __read(_a, 1), ms = _b[0];
3279
3285
  assertNumber(ms, sourceCodeInfo);
@@ -3281,7 +3287,7 @@ var miscNormalExpression = {
3281
3287
  },
3282
3288
  validate: function (node) { return assertNumberOfParams(1, node); },
3283
3289
  },
3284
- 'iso-date-time->inst-ms': {
3290
+ 'iso_date>epoch': {
3285
3291
  evaluate: function (_a, sourceCodeInfo) {
3286
3292
  var _b = __read(_a, 1), dateTime = _b[0];
3287
3293
  assertString(dateTime, sourceCodeInfo);
@@ -3314,23 +3320,7 @@ var miscNormalExpression = {
3314
3320
  },
3315
3321
  validate: function (node) { return assertNumberOfParams(2, node); },
3316
3322
  },
3317
- 'uuid!': {
3318
- evaluate: function () {
3319
- return uuidTemplate.replace(xyRegexp, function (character) {
3320
- var randomNbr = Math.floor(Math.random() * 16);
3321
- var newValue = character === 'x' ? randomNbr : (randomNbr & 0x3) | 0x8;
3322
- return newValue.toString(16);
3323
- });
3324
- },
3325
- validate: function (node) { return assertNumberOfParams(0, node); },
3326
- },
3327
- 'lits-version!': {
3328
- evaluate: function () {
3329
- return version;
3330
- },
3331
- validate: function (node) { return assertNumberOfParams(0, node); },
3332
- },
3333
- 'json-parse': {
3323
+ 'json_parse': {
3334
3324
  evaluate: function (_a, sourceCodeInfo) {
3335
3325
  var _b = __read(_a, 1), first = _b[0];
3336
3326
  assertString(first, sourceCodeInfo);
@@ -3339,7 +3329,7 @@ var miscNormalExpression = {
3339
3329
  },
3340
3330
  validate: function (node) { return assertNumberOfParams(1, node); },
3341
3331
  },
3342
- 'json-stringify': {
3332
+ 'json_stringify': {
3343
3333
  evaluate: function (_a, sourceCodeInfo) {
3344
3334
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
3345
3335
  assertAny(first, sourceCodeInfo);
@@ -3552,7 +3542,7 @@ var assertNormalExpression = {
3552
3542
  };
3553
3543
 
3554
3544
  var objectNormalExpression = {
3555
- 'object': {
3545
+ object: {
3556
3546
  evaluate: function (params, sourceCodeInfo) {
3557
3547
  var result = {};
3558
3548
  for (var i = 0; i < params.length; i += 2) {
@@ -3565,7 +3555,7 @@ var objectNormalExpression = {
3565
3555
  },
3566
3556
  validate: function (node) { return assertEvenNumberOfParams(node); },
3567
3557
  },
3568
- 'keys': {
3558
+ keys: {
3569
3559
  evaluate: function (_a, sourceCodeInfo) {
3570
3560
  var _b = __read(_a, 1), obj = _b[0];
3571
3561
  assertObj(obj, sourceCodeInfo);
@@ -3573,7 +3563,7 @@ var objectNormalExpression = {
3573
3563
  },
3574
3564
  validate: function (node) { return assertNumberOfParams(1, node); },
3575
3565
  },
3576
- 'vals': {
3566
+ vals: {
3577
3567
  evaluate: function (_a, sourceCodeInfo) {
3578
3568
  var _b = __read(_a, 1), obj = _b[0];
3579
3569
  assertObj(obj, sourceCodeInfo);
@@ -3581,7 +3571,7 @@ var objectNormalExpression = {
3581
3571
  },
3582
3572
  validate: function (node) { return assertNumberOfParams(1, node); },
3583
3573
  },
3584
- 'entries': {
3574
+ entries: {
3585
3575
  evaluate: function (_a, sourceCodeInfo) {
3586
3576
  var _b = __read(_a, 1), obj = _b[0];
3587
3577
  assertObj(obj, sourceCodeInfo);
@@ -3589,7 +3579,7 @@ var objectNormalExpression = {
3589
3579
  },
3590
3580
  validate: function (node) { return assertNumberOfParams(1, node); },
3591
3581
  },
3592
- 'find': {
3582
+ find: {
3593
3583
  evaluate: function (_a, sourceCodeInfo) {
3594
3584
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3595
3585
  assertObj(obj, sourceCodeInfo);
@@ -3600,7 +3590,7 @@ var objectNormalExpression = {
3600
3590
  },
3601
3591
  validate: function (node) { return assertNumberOfParams(2, node); },
3602
3592
  },
3603
- 'dissoc': {
3593
+ dissoc: {
3604
3594
  evaluate: function (_a, sourceCodeInfo) {
3605
3595
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3606
3596
  assertObj(obj, sourceCodeInfo);
@@ -3611,7 +3601,7 @@ var objectNormalExpression = {
3611
3601
  },
3612
3602
  validate: function (node) { return assertNumberOfParams(2, node); },
3613
3603
  },
3614
- 'merge': {
3604
+ merge: {
3615
3605
  evaluate: function (params, sourceCodeInfo) {
3616
3606
  if (params.length === 0)
3617
3607
  return null;
@@ -3624,7 +3614,7 @@ var objectNormalExpression = {
3624
3614
  },
3625
3615
  validate: function (node) { return assertNumberOfParams({ min: 0 }, node); },
3626
3616
  },
3627
- 'merge-with': {
3617
+ merge_with: {
3628
3618
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
3629
3619
  var executeFunction = _a.executeFunction;
3630
3620
  var first = params[0];
@@ -3647,7 +3637,7 @@ var objectNormalExpression = {
3647
3637
  },
3648
3638
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
3649
3639
  },
3650
- 'zipmap': {
3640
+ zipmap: {
3651
3641
  evaluate: function (_a, sourceCodeInfo) {
3652
3642
  var _b = __read(_a, 2), keys = _b[0], values = _b[1];
3653
3643
  assertStringArray(keys, sourceCodeInfo);
@@ -3662,7 +3652,7 @@ var objectNormalExpression = {
3662
3652
  },
3663
3653
  validate: function (node) { return assertNumberOfParams(2, node); },
3664
3654
  },
3665
- 'select-keys': {
3655
+ select_keys: {
3666
3656
  evaluate: function (_a, sourceCodeInfo) {
3667
3657
  var _b = __read(_a, 2), obj = _b[0], keys = _b[1];
3668
3658
  assertStringArray(keys, sourceCodeInfo);
@@ -3928,7 +3918,7 @@ var stringNormalExpression = {
3928
3918
  },
3929
3919
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
3930
3920
  },
3931
- 'string-repeat': {
3921
+ 'string_repeat': {
3932
3922
  evaluate: function (_a, sourceCodeInfo) {
3933
3923
  var _b = __read(_a, 2), str = _b[0], count = _b[1];
3934
3924
  assertString(str, sourceCodeInfo);
@@ -3962,27 +3952,7 @@ var stringNormalExpression = {
3962
3952
  },
3963
3953
  validate: function (node) { return assertNumberOfParams(1, node); },
3964
3954
  },
3965
- 'number-to-string': {
3966
- evaluate: function (params, sourceCodeInfo) {
3967
- var _a = __read(params, 2), num = _a[0], base = _a[1];
3968
- assertNumber(num, sourceCodeInfo, { finite: true });
3969
- if (params.length === 1) {
3970
- return "".concat(num);
3971
- }
3972
- else {
3973
- assertNumber(base, sourceCodeInfo, { finite: true });
3974
- if (base !== 2 && base !== 8 && base !== 10 && base !== 16) {
3975
- throw new LitsError("Expected \"number-to-string\" base argument to be 2, 8, 10 or 16, got: ".concat(base), sourceCodeInfo);
3976
- }
3977
- if (base === 10)
3978
- return "".concat(num);
3979
- assertNumber(num, sourceCodeInfo, { integer: true, nonNegative: true });
3980
- return Number(num).toString(base);
3981
- }
3982
- },
3983
- validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
3984
- },
3985
- 'from-char-code': {
3955
+ 'from_char_code': {
3986
3956
  evaluate: function (_a, sourceCodeInfo) {
3987
3957
  var _b = __read(_a, 1), num = _b[0];
3988
3958
  assertNumber(num, sourceCodeInfo, { finite: true });
@@ -3996,7 +3966,7 @@ var stringNormalExpression = {
3996
3966
  },
3997
3967
  validate: function (node) { return assertNumberOfParams(1, node); },
3998
3968
  },
3999
- 'to-char-code': {
3969
+ 'to_char_code': {
4000
3970
  evaluate: function (_a, sourceCodeInfo) {
4001
3971
  var _b = __read(_a, 1), str = _b[0];
4002
3972
  assertString(str, sourceCodeInfo, { nonEmpty: true });
@@ -4004,7 +3974,7 @@ var stringNormalExpression = {
4004
3974
  },
4005
3975
  validate: function (node) { return assertNumberOfParams(1, node); },
4006
3976
  },
4007
- 'lower-case': {
3977
+ 'lower_case': {
4008
3978
  evaluate: function (_a, sourceCodeInfo) {
4009
3979
  var _b = __read(_a, 1), str = _b[0];
4010
3980
  assertString(str, sourceCodeInfo);
@@ -4012,7 +3982,7 @@ var stringNormalExpression = {
4012
3982
  },
4013
3983
  validate: function (node) { return assertNumberOfParams(1, node); },
4014
3984
  },
4015
- 'upper-case': {
3985
+ 'upper_case': {
4016
3986
  evaluate: function (_a, sourceCodeInfo) {
4017
3987
  var _b = __read(_a, 1), str = _b[0];
4018
3988
  assertString(str, sourceCodeInfo);
@@ -4028,7 +3998,7 @@ var stringNormalExpression = {
4028
3998
  },
4029
3999
  validate: function (node) { return assertNumberOfParams(1, node); },
4030
4000
  },
4031
- 'trim-left': {
4001
+ 'trim_left': {
4032
4002
  evaluate: function (_a, sourceCodeInfo) {
4033
4003
  var _b = __read(_a, 1), str = _b[0];
4034
4004
  assertString(str, sourceCodeInfo);
@@ -4036,7 +4006,7 @@ var stringNormalExpression = {
4036
4006
  },
4037
4007
  validate: function (node) { return assertNumberOfParams(1, node); },
4038
4008
  },
4039
- 'trim-right': {
4009
+ 'trim_right': {
4040
4010
  evaluate: function (_a, sourceCodeInfo) {
4041
4011
  var _b = __read(_a, 1), str = _b[0];
4042
4012
  assertString(str, sourceCodeInfo);
@@ -4044,6 +4014,30 @@ var stringNormalExpression = {
4044
4014
  },
4045
4015
  validate: function (node) { return assertNumberOfParams(1, node); },
4046
4016
  },
4017
+ '++': {
4018
+ evaluate: function (params, sourceCodeInfo) {
4019
+ if (params.length === 0) {
4020
+ return '';
4021
+ }
4022
+ var first = params[0];
4023
+ if (first !== null) {
4024
+ assertStringOrNumber(first, sourceCodeInfo);
4025
+ }
4026
+ if (params.length === 1) {
4027
+ return first === null ? '' : "".concat(first);
4028
+ }
4029
+ return params.slice(1).reduce(function (acc, str) {
4030
+ if (str !== null) {
4031
+ assertStringOrNumber(str, sourceCodeInfo);
4032
+ }
4033
+ if (str === null) {
4034
+ return acc;
4035
+ }
4036
+ return "".concat(acc).concat(str);
4037
+ }, first === null ? '' : "".concat(first));
4038
+ },
4039
+ validate: function () { return undefined; },
4040
+ },
4047
4041
  'join': {
4048
4042
  evaluate: function (_a, sourceCodeInfo) {
4049
4043
  var _b = __read(_a, 2), stringList = _b[0], delimiter = _b[1];
@@ -4068,7 +4062,7 @@ var stringNormalExpression = {
4068
4062
  },
4069
4063
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4070
4064
  },
4071
- 'pad-left': {
4065
+ 'pad_left': {
4072
4066
  evaluate: function (_a, sourceCodeInfo) {
4073
4067
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4074
4068
  assertString(str, sourceCodeInfo);
@@ -4079,7 +4073,7 @@ var stringNormalExpression = {
4079
4073
  },
4080
4074
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4081
4075
  },
4082
- 'pad-right': {
4076
+ 'pad_right': {
4083
4077
  evaluate: function (_a, sourceCodeInfo) {
4084
4078
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4085
4079
  assertString(str, sourceCodeInfo);
@@ -4121,7 +4115,7 @@ var stringNormalExpression = {
4121
4115
  },
4122
4116
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 10 }, node); },
4123
4117
  },
4124
- 'encode-base64': {
4118
+ 'encode_base64': {
4125
4119
  evaluate: function (_a, sourceCodeInfo) {
4126
4120
  var _b = __read(_a, 1), value = _b[0];
4127
4121
  assertString(value, sourceCodeInfo);
@@ -4132,7 +4126,7 @@ var stringNormalExpression = {
4132
4126
  },
4133
4127
  validate: function (node) { return assertNumberOfParams(1, node); },
4134
4128
  },
4135
- 'decode-base64': {
4129
+ 'decode_base64': {
4136
4130
  evaluate: function (_a, sourceCodeInfo) {
4137
4131
  var _b = __read(_a, 1), value = _b[0];
4138
4132
  assertString(value, sourceCodeInfo);
@@ -4150,7 +4144,7 @@ var stringNormalExpression = {
4150
4144
  },
4151
4145
  validate: function (node) { return assertNumberOfParams(1, node); },
4152
4146
  },
4153
- 'encode-uri-component': {
4147
+ 'encode_uri_component': {
4154
4148
  evaluate: function (_a, sourceCodeInfo) {
4155
4149
  var _b = __read(_a, 1), value = _b[0];
4156
4150
  assertString(value, sourceCodeInfo);
@@ -4158,7 +4152,7 @@ var stringNormalExpression = {
4158
4152
  },
4159
4153
  validate: function (node) { return assertNumberOfParams(1, node); },
4160
4154
  },
4161
- 'decode-uri-component': {
4155
+ 'decode_uri_component': {
4162
4156
  evaluate: function (_a, sourceCodeInfo) {
4163
4157
  var _b = __read(_a, 1), value = _b[0];
4164
4158
  assertString(value, sourceCodeInfo);
@@ -4327,7 +4321,7 @@ var andSpecialExpression = {
4327
4321
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4328
4322
  var node = {
4329
4323
  t: AstNodeType.SpecialExpression,
4330
- n: 'and',
4324
+ n: '&&',
4331
4325
  p: params,
4332
4326
  token: getTokenDebugData(firstToken) && firstToken,
4333
4327
  };
@@ -4412,8 +4406,39 @@ var condSpecialExpression = {
4412
4406
  },
4413
4407
  };
4414
4408
 
4409
+ var switchSpecialExpression = {
4410
+ polishParse: getCommonPolishSpecialExpressionParser('switch'),
4411
+ validateParameterCount: function (node) { return assertOddNumberOfParams(node); },
4412
+ evaluate: function (node, contextStack, _a) {
4413
+ var e_1, _b;
4414
+ var evaluateAstNode = _a.evaluateAstNode;
4415
+ var switchValue = evaluateAstNode(node.p[0], contextStack);
4416
+ try {
4417
+ for (var _c = __values(arrayToPairs(node.p.slice(1))), _d = _c.next(); !_d.done; _d = _c.next()) {
4418
+ var _e = __read(_d.value, 2), test = _e[0], form = _e[1];
4419
+ var value = evaluateAstNode(test, contextStack);
4420
+ if (value === switchValue) {
4421
+ return evaluateAstNode(form, contextStack);
4422
+ }
4423
+ }
4424
+ }
4425
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4426
+ finally {
4427
+ try {
4428
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
4429
+ }
4430
+ finally { if (e_1) throw e_1.error; }
4431
+ }
4432
+ return null;
4433
+ },
4434
+ findUnresolvedIdentifiers: function (node, contextStack, _a) {
4435
+ var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4436
+ return findUnresolvedIdentifiers(node.p, contextStack, builtin);
4437
+ },
4438
+ };
4439
+
4415
4440
  var declaredSpecialExpression = {
4416
- polishParse: getCommonPolishSpecialExpressionParser('declared?'),
4441
+ polishParse: getCommonPolishSpecialExpressionParser('defined?'),
4417
4442
  validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
4418
4443
  evaluate: function (node, contextStack) {
4419
4444
  var lookUpResult = contextStack.lookUp(node.p[0]);
@@ -4469,9 +4494,7 @@ var defSpecialExpression = {
4469
4494
  var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4470
4495
  var name = node.p[0].v;
4471
4496
  assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4472
- contextStack.globalContext[name] = {
4473
- value: evaluateAstNode(node.p[1], contextStack),
4474
- };
4497
+ contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
4475
4498
  return null;
4476
4499
  },
4477
4500
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
@@ -4482,7 +4505,7 @@ var defSpecialExpression = {
4482
4505
  var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
4483
4506
  var name = asSymbolNode(node.p[0]).v;
4484
4507
  assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4485
- contextStack.globalContext[name] = { value: true };
4508
+ contextStack.exportValue(name, true);
4486
4509
  return result;
4487
4510
  },
4488
4511
  };
@@ -4508,9 +4531,7 @@ var defsSpecialExpression = {
4508
4531
  var name = evaluateAstNode(node.p[0], contextStack);
4509
4532
  assertString(name, sourceCodeInfo);
4510
4533
  assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4511
- contextStack.globalContext[name] = {
4512
- value: evaluateAstNode(node.p[1], contextStack),
4513
- };
4534
+ contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
4514
4535
  return null;
4515
4536
  },
4516
4537
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
@@ -4522,7 +4543,7 @@ var defsSpecialExpression = {
4522
4543
  var name = evaluateAstNode(node.p[0], contextStack);
4523
4544
  assertString(name, sourceCodeInfo);
4524
4545
  assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4525
- contextStack.globalContext[name] = { value: true };
4546
+ contextStack.exportValue(name, true);
4526
4547
  return result;
4527
4548
  },
4528
4549
  };
@@ -4553,7 +4574,7 @@ var doSpecialExpression = {
4553
4574
  },
4554
4575
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
4555
4576
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4556
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
4577
+ return findUnresolvedIdentifiers(node.p, contextStack.create({}), builtin);
4557
4578
  },
4558
4579
  };
4559
4580
 
@@ -4582,11 +4603,6 @@ function joinAnalyzeResults() {
4582
4603
  function addAnalyzeResults(target, source) {
4583
4604
  source.forEach(function (symbol) { return target.add(symbol); });
4584
4605
  }
4585
- function combinate(arrays) {
4586
- return arrays.reduce(function (acc, curr) {
4587
- return acc.flatMap(function (a) { return curr.map(function (c) { return __spreadArray(__spreadArray([], __read(a), false), [c], false); }); });
4588
- }, [[]]);
4589
- }
4590
4606
 
4591
4607
  var defnSpecialExpression = {
4592
4608
  polishParse: function (tokenStream, parseState, firstToken, parsers) {
@@ -4621,13 +4637,13 @@ var defnSpecialExpression = {
4621
4637
  _b.n = name,
4622
4638
  _b.o = evaluatedFunctionOverloades,
4623
4639
  _b);
4624
- contextStack.globalContext[name] = { value: litsFunction };
4640
+ contextStack.exportValue(name, litsFunction);
4625
4641
  return null;
4626
4642
  },
4627
4643
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
4628
4644
  var _b;
4629
4645
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4630
- contextStack.globalContext[node.f.v] = { value: true };
4646
+ contextStack.exportValue(node.f.v, true);
4631
4647
  var newContext = (_b = {}, _b[node.f.v] = { value: true }, _b);
4632
4648
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4633
4649
  },
@@ -4663,7 +4679,7 @@ var defnsSpecialExpression = {
4663
4679
  _b.n = name,
4664
4680
  _b.o = evaluatedFunctionOverloades,
4665
4681
  _b);
4666
- contextStack.globalContext[name] = { value: litsFunction };
4682
+ contextStack.exportValue(name, litsFunction);
4667
4683
  return null;
4668
4684
  },
4669
4685
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
@@ -4674,7 +4690,7 @@ var defnsSpecialExpression = {
4674
4690
  var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
4675
4691
  assertString(name, sourceCodeInfo);
4676
4692
  assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4677
- contextStack.globalContext[name] = { value: true };
4693
+ contextStack.exportValue(name, true);
4678
4694
  var newContext = (_b = {}, _b[name] = { value: true }, _b);
4679
4695
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4680
4696
  },
@@ -4884,7 +4900,7 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
4884
4900
  tkn = asToken(tokenStream.tokens[parseState.position]);
4885
4901
  if (node.t === AstNodeType.Modifier) {
4886
4902
  switch (node.v) {
4887
- case '&':
4903
+ case '&rest':
4888
4904
  if (state === 'rest')
4889
4905
  throw new LitsError('& can only appear once', (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
4890
4906
  state = 'rest';
@@ -4947,56 +4963,8 @@ var ifSpecialExpression = {
4947
4963
  },
4948
4964
  };
4949
4965
 
4950
- var ifLetSpecialExpression = {
4951
- polishParse: function (tokenStream, parseState, firstToken, _a) {
4952
- var _b, _c;
4953
- var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4954
- var bindings = parseBindings(tokenStream, parseState);
4955
- if (bindings.length !== 1) {
4956
- throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
4957
- }
4958
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4959
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4960
- var node = {
4961
- t: AstNodeType.SpecialExpression,
4962
- n: 'if-let',
4963
- b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
4964
- p: params,
4965
- token: getTokenDebugData(firstToken) && firstToken,
4966
- };
4967
- return node;
4968
- },
4969
- validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
4970
- evaluate: function (node, contextStack, _a) {
4971
- var _b;
4972
- var evaluateAstNode = _a.evaluateAstNode;
4973
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4974
- var locals = {};
4975
- var bindingValue = evaluateAstNode(node.b.v, contextStack);
4976
- if (bindingValue) {
4977
- locals[node.b.n] = { value: bindingValue };
4978
- var newContextStack = contextStack.create(locals);
4979
- var thenForm = asAstNode(node.p[0], sourceCodeInfo);
4980
- return evaluateAstNode(thenForm, newContextStack);
4981
- }
4982
- if (node.p.length === 2) {
4983
- var elseForm = asAstNode(node.p[1], sourceCodeInfo);
4984
- return evaluateAstNode(elseForm, contextStack);
4985
- }
4986
- return null;
4987
- },
4988
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4989
- var _b;
4990
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4991
- var newContext = (_b = {}, _b[node.b.n] = { value: true }, _b);
4992
- var bindingResult = findUnresolvedIdentifiers([node.b.v], contextStack, builtin);
4993
- var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
4994
- return joinAnalyzeResults(bindingResult, paramsResult);
4995
- },
4996
- };
4997
-
4998
- var ifNotSpecialExpression = {
4999
- polishParse: getCommonPolishSpecialExpressionParser('if-not'),
4966
+ var unlessSpecialExpression = {
4967
+ polishParse: getCommonPolishSpecialExpressionParser('unless'),
5000
4968
  validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
5001
4969
  evaluate: function (node, contextStack, _a) {
5002
4970
  var _b;
@@ -5021,55 +4989,39 @@ var ifNotSpecialExpression = {
5021
4989
 
5022
4990
  var letSpecialExpression = {
5023
4991
  polishParse: function (tokenStream, parseState, firstToken, _a) {
5024
- var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4992
+ var parseBindings = _a.parseBindings;
5025
4993
  var bindings = parseBindings(tokenStream, parseState);
5026
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4994
+ // const params = parseTokensUntilClosingBracket(tokenStream, parseState)
5027
4995
  assertRParenToken(tokenStream.tokens[parseState.position++]);
5028
4996
  var node = {
5029
4997
  t: AstNodeType.SpecialExpression,
5030
4998
  n: 'let',
5031
- p: params,
4999
+ p: [],
5032
5000
  bs: bindings,
5033
5001
  token: getTokenDebugData(firstToken) && firstToken,
5034
5002
  };
5035
5003
  return node;
5036
5004
  },
5037
- validateParameterCount: function () { return undefined; },
5005
+ validateParameterCount: function (node) { return assertNumberOfParams(0, node); },
5038
5006
  evaluate: function (node, contextStack, _a) {
5039
- var e_1, _b, e_2, _c;
5007
+ var e_1, _b;
5040
5008
  var evaluateAstNode = _a.evaluateAstNode;
5041
- var locals = {};
5042
- var newContextStack = contextStack.create(locals);
5043
5009
  try {
5044
- for (var _d = __values(node.bs), _e = _d.next(); !_e.done; _e = _d.next()) {
5045
- var binding = _e.value;
5010
+ for (var _c = __values(node.bs), _d = _c.next(); !_d.done; _d = _c.next()) {
5011
+ var binding = _d.value;
5046
5012
  var bindingValueNode = binding.v;
5047
- var bindingValue = evaluateAstNode(bindingValueNode, newContextStack);
5048
- locals[binding.n] = { value: bindingValue };
5013
+ var bindingValue = evaluateAstNode(bindingValueNode, contextStack);
5014
+ contextStack.addValue(binding.n, bindingValue);
5049
5015
  }
5050
5016
  }
5051
5017
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5052
5018
  finally {
5053
5019
  try {
5054
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
5020
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
5055
5021
  }
5056
5022
  finally { if (e_1) throw e_1.error; }
5057
5023
  }
5058
- var result = null;
5059
- try {
5060
- for (var _f = __values(node.p), _g = _f.next(); !_g.done; _g = _f.next()) {
5061
- var astNode = _g.value;
5062
- result = evaluateAstNode(astNode, newContextStack);
5063
- }
5064
- }
5065
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
5066
- finally {
5067
- try {
5068
- if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
5069
- }
5070
- finally { if (e_2) throw e_2.error; }
5071
- }
5072
- return result;
5024
+ return null;
5073
5025
  },
5074
5026
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
5075
5027
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
@@ -5079,11 +5031,10 @@ var letSpecialExpression = {
5079
5031
  context[name] = { value: true };
5080
5032
  return context;
5081
5033
  }, {});
5082
- var bindingContext = {};
5083
5034
  var bindingResults = node.bs.map(function (bindingNode) {
5084
5035
  var valueNode = bindingNode.v;
5085
- var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack.create(bindingContext), builtin);
5086
- bindingContext[bindingNode.n] = { value: true };
5036
+ var bindingsResult = findUnresolvedIdentifiers([valueNode], contextStack, builtin);
5037
+ contextStack.addValue(bindingNode.n, { value: true });
5087
5038
  return bindingsResult;
5088
5039
  });
5089
5040
  var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
@@ -5206,7 +5157,7 @@ function parseLoopBinding(tokenStream, parseState, _a) {
5206
5157
  loopBinding.we = parseToken(tokenStream, parseState);
5207
5158
  loopBinding.m.push('&while');
5208
5159
  break;
5209
- case '&':
5160
+ case '&rest':
5210
5161
  throw new LitsError("Illegal modifier: ".concat(modifier), (_e = getTokenDebugData(tkn)) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
5211
5162
  default:
5212
5163
  throw new LitsError("Illegal modifier: ".concat(modifier), (_f = getTokenDebugData(tkn)) === null || _f === void 0 ? void 0 : _f.sourceCodeInfo);
@@ -5406,7 +5357,7 @@ var doseqSpecialExpression = {
5406
5357
  };
5407
5358
 
5408
5359
  var orSpecialExpression = {
5409
- polishParse: getCommonPolishSpecialExpressionParser('or'),
5360
+ polishParse: getCommonPolishSpecialExpressionParser('||'),
5410
5361
  validateParameterCount: function () { return undefined; },
5411
5362
  evaluate: function (node, contextStack, _a) {
5412
5363
  var e_1, _b;
@@ -5498,25 +5449,6 @@ var throwSpecialExpression = {
5498
5449
  },
5499
5450
  };
5500
5451
 
5501
- var timeSpecialExpression = {
5502
- polishParse: getCommonPolishSpecialExpressionParser('time!'),
5503
- validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5504
- evaluate: function (node, contextStack, _a) {
5505
- var evaluateAstNode = _a.evaluateAstNode;
5506
- var param = node.p[0];
5507
- var startTime = Date.now();
5508
- var result = evaluateAstNode(param, contextStack);
5509
- var totalTime = Date.now() - startTime;
5510
- // eslint-disable-next-line no-console
5511
- console.log("Elapsed time: ".concat(totalTime, " ms"));
5512
- return result;
5513
- },
5514
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5515
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5516
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
5517
- },
5518
- };
5519
-
5520
5452
  var trySpecialExpression = {
5521
5453
  polishParse: function (tokenStream, parseState, firstToken, _a) {
5522
5454
  var _b, _c, _d;
@@ -5553,9 +5485,10 @@ var trySpecialExpression = {
5553
5485
  return evaluateAstNode(tryExpressions[0], contextStack);
5554
5486
  }
5555
5487
  catch (error) {
5556
- var newContext = (_b = {},
5557
- _b[errorNode.v] = { value: asAny(error, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo) },
5558
- _b);
5488
+ var newContext = errorNode
5489
+ ? (_b = {},
5490
+ _b[errorNode.v] = { value: asAny(error, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo) },
5491
+ _b) : {};
5559
5492
  return evaluateAstNode(catchExpression, contextStack.create(newContext));
5560
5493
  }
5561
5494
  },
@@ -5564,288 +5497,128 @@ var trySpecialExpression = {
5564
5497
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5565
5498
  var tryExpressions = node.p, catchExpression = node.ce, errorNode = node.e;
5566
5499
  var tryResult = findUnresolvedIdentifiers(tryExpressions, contextStack, builtin);
5567
- var newContext = (_b = {},
5568
- _b[errorNode.v] = { value: true },
5569
- _b);
5500
+ var newContext = errorNode
5501
+ ? (_b = {},
5502
+ _b[errorNode.v] = { value: true },
5503
+ _b) : {};
5570
5504
  var catchResult = findUnresolvedIdentifiers([catchExpression], contextStack.create(newContext), builtin);
5571
5505
  return joinAnalyzeResults(tryResult, catchResult);
5572
5506
  },
5573
5507
  };
5574
5508
 
5575
- var whenSpecialExpression = {
5576
- polishParse: getCommonPolishSpecialExpressionParser('when'),
5577
- validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5578
- evaluate: function (node, contextStack, _a) {
5579
- var e_1, _b;
5580
- var _c;
5581
- var evaluateAstNode = _a.evaluateAstNode;
5582
- var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
5583
- assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
5584
- if (!evaluateAstNode(whenExpression, contextStack))
5585
- return null;
5586
- var result = null;
5509
+ var specialExpressions = {
5510
+ '&&': andSpecialExpression,
5511
+ 'comment': commentSpecialExpression,
5512
+ 'cond': condSpecialExpression,
5513
+ 'switch': switchSpecialExpression,
5514
+ 'def': defSpecialExpression,
5515
+ 'defn': defnSpecialExpression,
5516
+ 'defns': defnsSpecialExpression,
5517
+ 'defs': defsSpecialExpression,
5518
+ 'do': doSpecialExpression,
5519
+ 'doseq': doseqSpecialExpression,
5520
+ 'for': forSpecialExpression,
5521
+ 'fn': fnSpecialExpression,
5522
+ 'if': ifSpecialExpression,
5523
+ 'unless': unlessSpecialExpression,
5524
+ 'let': letSpecialExpression,
5525
+ 'loop': loopSpecialExpression,
5526
+ '||': orSpecialExpression,
5527
+ 'recur': recurSpecialExpression,
5528
+ 'throw': throwSpecialExpression,
5529
+ 'try': trySpecialExpression,
5530
+ 'defined?': declaredSpecialExpression,
5531
+ '??': qqSpecialExpression,
5532
+ };
5533
+ Object.keys(specialExpressions).forEach(function (key) {
5534
+ /* v8 ignore next 2 */
5535
+ if (normalExpressions[key])
5536
+ throw new Error("Expression ".concat(key, " is defined as both a normal expression and a special expression"));
5537
+ });
5538
+ var builtin = {
5539
+ normalExpressions: normalExpressions,
5540
+ specialExpressions: specialExpressions,
5541
+ };
5542
+ var normalExpressionKeys = Object.keys(normalExpressions);
5543
+ var specialExpressionKeys = Object.keys(specialExpressions);
5544
+
5545
+ function isContextEntry(value) {
5546
+ return isUnknownRecord(value) && value.value !== undefined;
5547
+ }
5548
+
5549
+ var ContextStackImpl = /** @class */ (function () {
5550
+ function ContextStackImpl(_a) {
5551
+ var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
5552
+ this.globalContext = asNonUndefined(contexts[0]);
5553
+ this.contexts = contexts;
5554
+ this.values = hostValues;
5555
+ this.lazyValues = lazyHostValues;
5556
+ this.nativeJsFunctions = nativeJsFunctions;
5557
+ }
5558
+ ContextStackImpl.prototype.create = function (context, extraData) {
5559
+ var globalContext = this.globalContext;
5560
+ var contextStack = new ContextStackImpl({
5561
+ contexts: __spreadArray([context], __read(this.contexts), false),
5562
+ values: this.values,
5563
+ lazyValues: extraData ? __assign(__assign({}, this.lazyValues), extraData) : this.lazyValues,
5564
+ nativeJsFunctions: this.nativeJsFunctions,
5565
+ });
5566
+ contextStack.globalContext = globalContext;
5567
+ return contextStack;
5568
+ };
5569
+ ContextStackImpl.prototype.exportValue = function (name, value) {
5570
+ if (this.globalContext[name]) {
5571
+ throw new Error("Cannot redefine exported value \"".concat(name, "\""));
5572
+ }
5573
+ if (specialExpressionKeys.includes(name)) {
5574
+ throw new Error("Cannot shadow special expression \"".concat(name, "\""));
5575
+ }
5576
+ if (normalExpressionKeys.includes(name)) {
5577
+ throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
5578
+ }
5579
+ this.addValue(name, value);
5580
+ this.globalContext[name] = { value: value };
5581
+ };
5582
+ ContextStackImpl.prototype.addValue = function (name, value) {
5583
+ var currentContext = this.contexts[0];
5584
+ if (!currentContext) {
5585
+ throw new Error('No context to add value to');
5586
+ }
5587
+ if (currentContext[name]) {
5588
+ throw new Error("Cannot redefine value \"".concat(name, "\""));
5589
+ }
5590
+ if (specialExpressionKeys.includes(name)) {
5591
+ throw new Error("Cannot shadow special expression \"".concat(name, "\""));
5592
+ }
5593
+ if (normalExpressionKeys.includes(name)) {
5594
+ throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
5595
+ }
5596
+ currentContext[name] = { value: toAny(value) };
5597
+ };
5598
+ ContextStackImpl.prototype.clone = function () {
5599
+ // eslint-disable-next-line ts/no-unsafe-argument
5600
+ return new ContextStackImpl(JSON.parse(JSON.stringify({
5601
+ contexts: this.contexts,
5602
+ values: this.values,
5603
+ lazyValues: this.lazyValues,
5604
+ nativeJsFunctions: this.nativeJsFunctions,
5605
+ })));
5606
+ };
5607
+ ContextStackImpl.prototype.getValue = function (name) {
5608
+ var e_1, _a;
5609
+ var _b, _c, _d;
5587
5610
  try {
5588
- for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
5589
- var form = body_1_1.value;
5590
- result = evaluateAstNode(form, contextStack);
5611
+ for (var _e = __values(this.contexts), _f = _e.next(); !_f.done; _f = _e.next()) {
5612
+ var context = _f.value;
5613
+ var contextEntry = context[name];
5614
+ if (contextEntry)
5615
+ return contextEntry.value;
5591
5616
  }
5592
5617
  }
5593
5618
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5594
5619
  finally {
5595
5620
  try {
5596
- if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
5597
- }
5598
- finally { if (e_1) throw e_1.error; }
5599
- }
5600
- return result;
5601
- },
5602
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5603
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5604
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
5605
- },
5606
- };
5607
-
5608
- var whenFirstSpecialExpression = {
5609
- polishParse: function (tokenStream, parseState, firstToken, _a) {
5610
- var _b, _c;
5611
- var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5612
- var bindings = parseBindings(tokenStream, parseState);
5613
- if (bindings.length !== 1) {
5614
- throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
5615
- }
5616
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5617
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5618
- var node = {
5619
- t: AstNodeType.SpecialExpression,
5620
- n: 'when-first',
5621
- b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5622
- p: params,
5623
- token: getTokenDebugData(firstToken) && firstToken,
5624
- };
5625
- return node;
5626
- },
5627
- validateParameterCount: function () { return undefined; },
5628
- evaluate: function (node, contextStack, _a) {
5629
- var e_1, _b;
5630
- var _c;
5631
- var evaluateAstNode = _a.evaluateAstNode;
5632
- var locals = {};
5633
- var binding = node.b;
5634
- var evaluatedBindingForm = evaluateAstNode(binding.v, contextStack);
5635
- if (!isSeq(evaluatedBindingForm)) {
5636
- throw new LitsError("Expected undefined or a sequence, got ".concat(valueToString(evaluatedBindingForm)), (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
5637
- }
5638
- if (evaluatedBindingForm.length === 0)
5639
- return null;
5640
- var bindingValue = toAny(evaluatedBindingForm[0]);
5641
- locals[binding.n] = { value: bindingValue };
5642
- var newContextStack = contextStack.create(locals);
5643
- var result = null;
5644
- try {
5645
- for (var _d = __values(node.p), _e = _d.next(); !_e.done; _e = _d.next()) {
5646
- var form = _e.value;
5647
- result = evaluateAstNode(form, newContextStack);
5648
- }
5649
- }
5650
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5651
- finally {
5652
- try {
5653
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
5654
- }
5655
- finally { if (e_1) throw e_1.error; }
5656
- }
5657
- return result;
5658
- },
5659
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5660
- var _b;
5661
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5662
- var binding = node.b;
5663
- var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
5664
- var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
5665
- var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
5666
- return joinAnalyzeResults(bindingResult, paramsResult);
5667
- },
5668
- };
5669
-
5670
- var whenLetSpecialExpression = {
5671
- polishParse: function (tokenStream, parseState, firstToken, _a) {
5672
- var _b, _c;
5673
- var parseBindings = _a.parseBindings, parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5674
- var bindings = parseBindings(tokenStream, parseState);
5675
- if (bindings.length !== 1) {
5676
- throw new LitsError("Expected exactly one binding, got ".concat(valueToString(bindings.length)), (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
5677
- }
5678
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5679
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5680
- var node = {
5681
- t: AstNodeType.SpecialExpression,
5682
- n: 'when-let',
5683
- b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5684
- p: params,
5685
- token: getTokenDebugData(firstToken) && firstToken,
5686
- };
5687
- return node;
5688
- },
5689
- validateParameterCount: function () { return undefined; },
5690
- evaluate: function (node, contextStack, _a) {
5691
- var e_1, _b;
5692
- var evaluateAstNode = _a.evaluateAstNode;
5693
- var binding = node.b;
5694
- var locals = {};
5695
- var bindingValue = evaluateAstNode(binding.v, contextStack);
5696
- if (!bindingValue)
5697
- return null;
5698
- locals[binding.n] = { value: bindingValue };
5699
- var newContextStack = contextStack.create(locals);
5700
- var result = null;
5701
- try {
5702
- for (var _c = __values(node.p), _d = _c.next(); !_d.done; _d = _c.next()) {
5703
- var form = _d.value;
5704
- result = evaluateAstNode(form, newContextStack);
5705
- }
5706
- }
5707
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5708
- finally {
5709
- try {
5710
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
5711
- }
5712
- finally { if (e_1) throw e_1.error; }
5713
- }
5714
- return result;
5715
- },
5716
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5717
- var _b;
5718
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5719
- var binding = node.b;
5720
- var newContext = (_b = {}, _b[binding.n] = { value: true }, _b);
5721
- var bindingResult = findUnresolvedIdentifiers([binding.v], contextStack, builtin);
5722
- var paramsResult = findUnresolvedIdentifiers(node.p, contextStack.create(newContext), builtin);
5723
- return joinAnalyzeResults(bindingResult, paramsResult);
5724
- },
5725
- };
5726
-
5727
- var whenNotSpecialExpression = {
5728
- polishParse: getCommonPolishSpecialExpressionParser('when-not'),
5729
- validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5730
- evaluate: function (node, contextStack, _a) {
5731
- var e_1, _b;
5732
- var _c;
5733
- var evaluateAstNode = _a.evaluateAstNode;
5734
- var _d = __read(node.p), whenExpression = _d[0], body = _d.slice(1);
5735
- assertAstNode(whenExpression, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
5736
- if (evaluateAstNode(whenExpression, contextStack))
5737
- return null;
5738
- var result = null;
5739
- try {
5740
- for (var body_1 = __values(body), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
5741
- var form = body_1_1.value;
5742
- result = evaluateAstNode(form, contextStack);
5743
- }
5744
- }
5745
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5746
- finally {
5747
- try {
5748
- if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
5749
- }
5750
- finally { if (e_1) throw e_1.error; }
5751
- }
5752
- return result;
5753
- },
5754
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5755
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5756
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
5757
- },
5758
- };
5759
-
5760
- var specialExpressions = {
5761
- 'and': andSpecialExpression,
5762
- 'comment': commentSpecialExpression,
5763
- 'cond': condSpecialExpression,
5764
- 'def': defSpecialExpression,
5765
- 'defn': defnSpecialExpression,
5766
- 'defns': defnsSpecialExpression,
5767
- 'defs': defsSpecialExpression,
5768
- 'do': doSpecialExpression,
5769
- 'doseq': doseqSpecialExpression,
5770
- 'for': forSpecialExpression,
5771
- 'fn': fnSpecialExpression,
5772
- 'if': ifSpecialExpression,
5773
- 'if-let': ifLetSpecialExpression,
5774
- 'if-not': ifNotSpecialExpression,
5775
- 'let': letSpecialExpression,
5776
- 'loop': loopSpecialExpression,
5777
- 'or': orSpecialExpression,
5778
- 'recur': recurSpecialExpression,
5779
- 'throw': throwSpecialExpression,
5780
- 'time!': timeSpecialExpression,
5781
- 'try': trySpecialExpression,
5782
- 'when': whenSpecialExpression,
5783
- 'when-first': whenFirstSpecialExpression,
5784
- 'when-let': whenLetSpecialExpression,
5785
- 'when-not': whenNotSpecialExpression,
5786
- 'declared?': declaredSpecialExpression,
5787
- '??': qqSpecialExpression,
5788
- };
5789
- Object.keys(specialExpressions).forEach(function (key) {
5790
- /* v8 ignore next 2 */
5791
- if (normalExpressions[key])
5792
- throw new Error("Expression ".concat(key, " is defined as both a normal expression and a special expression"));
5793
- });
5794
- var builtin = {
5795
- normalExpressions: normalExpressions,
5796
- specialExpressions: specialExpressions,
5797
- };
5798
- var normalExpressionKeys = Object.keys(normalExpressions);
5799
- var specialExpressionKeys = Object.keys(specialExpressions);
5800
-
5801
- function isContextEntry(value) {
5802
- return isUnknownRecord(value) && value.value !== undefined;
5803
- }
5804
-
5805
- var ContextStackImpl = /** @class */ (function () {
5806
- function ContextStackImpl(_a) {
5807
- var contexts = _a.contexts, hostValues = _a.values, lazyHostValues = _a.lazyValues, nativeJsFunctions = _a.nativeJsFunctions;
5808
- this.contexts = contexts;
5809
- this.globalContext = asNonUndefined(contexts[0]);
5810
- this.values = hostValues;
5811
- this.lazyValues = lazyHostValues;
5812
- this.nativeJsFunctions = nativeJsFunctions;
5813
- }
5814
- ContextStackImpl.prototype.create = function (context, extraData) {
5815
- var globalContext = this.globalContext;
5816
- var contextStack = new ContextStackImpl({
5817
- contexts: __spreadArray([context], __read(this.contexts), false),
5818
- values: this.values,
5819
- lazyValues: extraData ? __assign(__assign({}, this.lazyValues), extraData) : this.lazyValues,
5820
- nativeJsFunctions: this.nativeJsFunctions,
5821
- });
5822
- contextStack.globalContext = globalContext;
5823
- return contextStack;
5824
- };
5825
- ContextStackImpl.prototype.clone = function () {
5826
- // eslint-disable-next-line ts/no-unsafe-argument
5827
- return new ContextStackImpl(JSON.parse(JSON.stringify({
5828
- contexts: this.contexts,
5829
- values: this.values,
5830
- lazyValues: this.lazyValues,
5831
- nativeJsFunctions: this.nativeJsFunctions,
5832
- })));
5833
- };
5834
- ContextStackImpl.prototype.getValue = function (name) {
5835
- var e_1, _a;
5836
- var _b, _c, _d;
5837
- try {
5838
- for (var _e = __values(this.contexts), _f = _e.next(); !_f.done; _f = _e.next()) {
5839
- var context = _f.value;
5840
- var contextEntry = context[name];
5841
- if (contextEntry)
5842
- return contextEntry.value;
5843
- }
5844
- }
5845
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5846
- finally {
5847
- try {
5848
- if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
5621
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
5849
5622
  }
5850
5623
  finally { if (e_1) throw e_1.error; }
5851
5624
  }
@@ -5951,7 +5724,7 @@ function createContextStack(params) {
5951
5724
  return acc;
5952
5725
  }, {}),
5953
5726
  });
5954
- return contextStack;
5727
+ return contextStack.create({});
5955
5728
  }
5956
5729
 
5957
5730
  var _a$1;
@@ -6263,7 +6036,14 @@ function evaluateNumberAsFunction(fn, params, sourceCodeInfo) {
6263
6036
 
6264
6037
  var findUnresolvedIdentifiers = function (ast, contextStack, builtin) {
6265
6038
  var e_1, _a;
6266
- var astNodes = Array.isArray(ast) ? ast : ast.b;
6039
+ var astNodes = Array.isArray(ast)
6040
+ ? ast
6041
+ : [{
6042
+ t: AstNodeType.SpecialExpression,
6043
+ n: 'do',
6044
+ p: ast.b,
6045
+ token: undefined,
6046
+ }];
6267
6047
  var unresolvedIdentifiers = new Set();
6268
6048
  try {
6269
6049
  for (var astNodes_1 = __values(astNodes), astNodes_1_1 = astNodes_1.next(); !astNodes_1_1.done; astNodes_1_1 = astNodes_1.next()) {
@@ -6327,546 +6107,17 @@ function findUnresolvedIdentifiersInAstNode(astNode, contextStack, builtin) {
6327
6107
  // eslint-disable-next-line ts/no-unsafe-argument
6328
6108
  var unresolvedIdentifiers = specialExpression.findUnresolvedIdentifiers(astNode, contextStack, {
6329
6109
  findUnresolvedIdentifiers: findUnresolvedIdentifiers,
6330
- builtin: builtin,
6331
- evaluateAstNode: evaluateAstNode,
6332
- });
6333
- return unresolvedIdentifiers;
6334
- }
6335
- }
6336
- }
6337
-
6338
- var calculateAndOutcomes = function (_a) {
6339
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6340
- return combinateAstNodes(astNode.p)
6341
- .map(function (p) { return ({
6342
- n: 'and',
6343
- t: AstNodeType.SpecialExpression,
6344
- p: p,
6345
- token: astNode.token,
6346
- }); });
6347
- };
6348
-
6349
- var calculateCondOutcomes = function (_a) {
6350
- var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, isAstComputable = _a.isAstComputable;
6351
- var testNodes = arrayToPairs(astNode.p).map(function (_a) {
6352
- var _b = __read(_a, 1), t = _b[0];
6353
- return t;
6354
- });
6355
- if (isAstComputable(testNodes)) {
6356
- return combinate(arrayToPairs(astNode.p)
6357
- // Create a list of ast nodes from the test and form of each condition
6358
- .reduce(function (acc, _a) {
6359
- var _b = __read(_a, 2), test = _b[0], form = _b[1];
6360
- acc.push(calculatePossibleAstNodes(test), calculatePossibleAstNodes(form));
6361
- return acc;
6362
- }, []))
6363
- // Create a new CondNode for each combination of test and form outcomes
6364
- .map(function (conditionAsts) { return (__assign(__assign({}, astNode), { c: arrayToPairs(conditionAsts).map(function (_a) {
6365
- var _b = __read(_a, 2), t = _b[0], f = _b[1];
6366
- return ({ t: t, f: f });
6367
- }) })); });
6368
- }
6369
- return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p).flatMap(function (_a) {
6370
- var _b = __read(_a, 2); _b[0]; var form = _b[1];
6371
- return calculatePossibleAstNodes(form);
6372
- })), false), [
6373
- nilNode,
6374
- ], false);
6375
- };
6376
-
6377
- var trueNode = { t: AstNodeType.ReservedSymbol, v: 'true', token: undefined, p: [], n: undefined };
6378
- var falseNode = { t: AstNodeType.ReservedSymbol, v: 'false', token: undefined, p: [], n: undefined };
6379
- var calculateDeclaredOutcomes = function (_a) {
6380
- var astNode = _a.astNode, isAstComputable = _a.isAstComputable;
6381
- if (isAstComputable(astNode.p))
6382
- return [trueNode];
6383
- return [trueNode, falseNode];
6384
- };
6385
-
6386
- var calculateDefOutcomes = function (_a) {
6387
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
6388
- var nameNode = asSymbolNode(astNode.p[0]);
6389
- var valueNode = astNode.p[1];
6390
- addGlobalIdentifier(nameNode.v);
6391
- return calculatePossibleAstNodes(valueNode)
6392
- .map(function (node) { return (__assign(__assign({}, astNode), { p: [nameNode, node] })); });
6393
- };
6394
-
6395
- var calculateDefsOutcomes = function (_a) {
6396
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6397
- return combinateAstNodes(astNode.p)
6398
- .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6399
- };
6400
-
6401
- var calculateDoOutcomes = function (_a) {
6402
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6403
- return combinateAstNodes(astNode.p).map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6404
- };
6405
-
6406
- function calculateFunctionOverloadOutcomes(combinateAstNodes, functionOverloads) {
6407
- return combinate(functionOverloads
6408
- // For each overload, calculate the possible outcomes for each parameter
6409
- .map(function (functionOverload) {
6410
- var _a;
6411
- return combinateAstNodes(functionOverload.b, [
6412
- functionOverload.as.m,
6413
- functionOverload.as.b.map(function (bindingNode) { return bindingNode.n; }),
6414
- (_a = functionOverload.as.r) !== null && _a !== void 0 ? _a : [],
6415
- ].flat())
6416
- // For each combination of parameter outcomes, create a new overload
6417
- .map(function (body) { return (__assign(__assign({}, functionOverload), { b: body })); });
6418
- }));
6419
- }
6420
- var calculateDefnOutcomes = function (_a) {
6421
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, addGlobalIdentifier = _a.addGlobalIdentifier;
6422
- addGlobalIdentifier(astNode.f.v);
6423
- // astNode.o is an array of overloads
6424
- return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
6425
- };
6426
- var calculateDefnsOutcomes = function (_a) {
6427
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes;
6428
- // astNode.o is an array of overloads
6429
- return calculatePossibleAstNodes(astNode.f).flatMap(function (functionName) {
6430
- return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { f: functionName, o: functionOverloads })); });
6431
- });
6432
- };
6433
- var calculateFnOutcomes = function (_a) {
6434
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6435
- // astNode.o is an array of overloads
6436
- return calculateFunctionOverloadOutcomes(combinateAstNodes, astNode.o).map(function (functionOverloads) { return (__assign(__assign({}, astNode), { o: functionOverloads })); });
6437
- };
6438
-
6439
- var calculateIfLetOutcomes = function (_a) {
6440
- var _b;
6441
- var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6442
- var bindingNode = astNode.b;
6443
- var thenBranch = astNode.p[0];
6444
- var elseBranch = (_b = astNode.p[1]) !== null && _b !== void 0 ? _b : nilNode;
6445
- if (!isAstComputable(bindingNode.v)) {
6446
- return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
6447
- }
6448
- var newIdentifier = bindingNode.n;
6449
- return calculatePossibleAstNodes(bindingNode.v)
6450
- .map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
6451
- .flatMap(function (b) { return combinateAstNodes(astNode.p, [newIdentifier])
6452
- .map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); }); });
6453
- };
6454
-
6455
- var calculateIfNotOutcomes = function (_a) {
6456
- var _b;
6457
- var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6458
- var condition = astNode.p[0];
6459
- var thenBranch = astNode.p[1];
6460
- var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
6461
- if (isAstComputable(condition)) {
6462
- return combinateAstNodes(astNode.p)
6463
- .map(function (p) { return ({
6464
- n: 'if-not',
6465
- t: astNode.t,
6466
- p: p,
6467
- token: astNode.token,
6468
- }); });
6469
- }
6470
- return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
6471
- };
6472
-
6473
- var calculateIfOutcomes = function (_a) {
6474
- var _b;
6475
- var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6476
- var condition = astNode.p[0];
6477
- var thenBranch = astNode.p[1];
6478
- var elseBranch = (_b = astNode.p[2]) !== null && _b !== void 0 ? _b : nilNode;
6479
- if (isAstComputable(condition)) {
6480
- return combinateAstNodes(astNode.p)
6481
- .map(function (p) { return ({
6482
- n: 'if',
6483
- t: astNode.t,
6484
- p: p,
6485
- token: astNode.token,
6486
- }); });
6487
- }
6488
- return __spreadArray(__spreadArray([], __read(calculatePossibleAstNodes(thenBranch)), false), __read(calculatePossibleAstNodes(elseBranch)), false);
6489
- };
6490
-
6491
- var calculateLetOutcomes = function (_a) {
6492
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6493
- try {
6494
- // check bindings, if any binding value cannot be calculated, convert the whole let to a do-expression
6495
- if (!isAstComputable(astNode.bs.map(function (b) { return calculatePossibleAstNodes(b.v); })))
6496
- throw new Error('Could not calculate binding value');
6497
- }
6498
- catch (_b) {
6499
- var doNodes = combinateAstNodes(astNode.p)
6500
- .map(function (p) {
6501
- return {
6502
- n: 'do',
6503
- t: AstNodeType.SpecialExpression,
6504
- p: p,
6505
- token: astNode.token,
6506
- };
6507
- });
6508
- return doNodes;
6509
- }
6510
- var newIdentifiers = astNode.bs.map(function (bindingNode) { return bindingNode.n; });
6511
- var letNodes = combinate(astNode.bs.map(function (bindingNode) {
6512
- return calculatePossibleAstNodes(bindingNode.v)
6513
- .map(function (bindingValues) { return (__assign(__assign({}, bindingNode), { v: bindingValues })); });
6514
- }))
6515
- .flatMap(function (bindingNodes) { return combinate(astNode.p.map(function (p) { return calculatePossibleAstNodes(p, newIdentifiers); }))
6516
- .map(function (p) {
6517
- return {
6518
- n: 'let',
6519
- bs: bindingNodes,
6520
- t: AstNodeType.SpecialExpression,
6521
- p: p,
6522
- token: astNode.token,
6523
- };
6524
- }); });
6525
- return letNodes;
6526
- };
6527
-
6528
- var calculateForOutcomes = function (_a) {
6529
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6530
- if (!isDeterministic(calculatePossibleAstNodes, astNode))
6531
- throw new Error('Could not calculate for loop, not deterministic');
6532
- return [astNode];
6533
- };
6534
- var calculateDoSeqOutcomes = function (_a) {
6535
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6536
- if (!isDeterministic(calculatePossibleAstNodes, astNode))
6537
- throw new Error('Could not calculate doSeq node, not deterministic');
6538
- return [astNode];
6539
- };
6540
- function isDeterministic(calculatePossibleAstNodes, astNode) {
6541
- var e_1, _a;
6542
- try {
6543
- for (var _b = __values(astNode.l), _c = _b.next(); !_c.done; _c = _b.next()) {
6544
- var _d = _c.value, b = _d.b, l = _d.l, wn = _d.wn, we = _d.we;
6545
- if (l && l.some(function (_a) {
6546
- var v = _a.v;
6547
- return !astIsDeterministic(calculatePossibleAstNodes, v);
6548
- }))
6549
- return false;
6550
- if (!astIsDeterministic(calculatePossibleAstNodes, b.v))
6551
- return false;
6552
- if (wn && !astIsDeterministic(calculatePossibleAstNodes, wn))
6553
- return false;
6554
- if (we && !astIsDeterministic(calculatePossibleAstNodes, we))
6555
- return false;
6556
- }
6557
- }
6558
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6559
- finally {
6560
- try {
6561
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
6562
- }
6563
- finally { if (e_1) throw e_1.error; }
6564
- }
6565
- if (!astIsDeterministic(calculatePossibleAstNodes, astNode.p[0]))
6566
- return false;
6567
- return true;
6568
- }
6569
- function astIsDeterministic(calculatePossibleAstNodes, astNode) {
6570
- return calculatePossibleAstNodes(astNode).length === 1;
6571
- }
6572
-
6573
- var calculateOrOutcomes = function (_a) {
6574
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6575
- return combinateAstNodes(astNode.p)
6576
- .map(function (p) { return ({
6577
- n: 'or',
6578
- t: AstNodeType.SpecialExpression,
6579
- p: p,
6580
- token: astNode.token,
6581
- }); });
6582
- };
6583
-
6584
- var calculateQqOutcomes = function (_a) {
6585
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6586
- if (!isAstComputable(astNode.p[0]))
6587
- throw new Error('First argument of ?? not computable');
6588
- return combinateAstNodes(astNode.p)
6589
- .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6590
- };
6591
-
6592
- var calculateThrowOutcomes = function (_a) {
6593
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6594
- return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
6595
- };
6596
-
6597
- var calculateTimeOutcomes = function (_a) {
6598
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6599
- return calculatePossibleAstNodes(astNode.p[0])
6600
- .map(function (p) { return (__assign(__assign({}, astNode), { n: 'do', p: [p] })); });
6601
- };
6602
-
6603
- var calculateTryOutcomes = function (_a) {
6604
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6605
- var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
6606
- if (node.n === 'throw') {
6607
- acc.throws.push(node.p[0]);
6608
- }
6609
- else {
6610
- acc.vals.push(node);
6611
- }
6612
- return acc;
6613
- }, { vals: [], throws: [] }), vals = _b.vals, throws = _b.throws;
6614
- var catches = throws.flatMap(function (throwNode) {
6615
- var letNode = {
6616
- t: AstNodeType.SpecialExpression,
6617
- n: 'let',
6618
- bs: [{
6619
- t: AstNodeType.Binding,
6620
- n: astNode.e.v,
6621
- v: throwNode,
6622
- token: undefined,
6623
- p: [],
6624
- }],
6625
- p: [astNode.ce],
6626
- token: undefined,
6627
- };
6628
- return calculatePossibleAstNodes(letNode);
6629
- });
6630
- return __spreadArray(__spreadArray([], __read(vals), false), __read(catches), false);
6631
- };
6632
-
6633
- var calculateWhenFirstOutcomes = function (_a) {
6634
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6635
- var bindingNode = astNode.b;
6636
- if (!isAstComputable(bindingNode.v))
6637
- throw new Error('Could not calculate binding value');
6638
- var newIdentifier = bindingNode.n;
6639
- return calculatePossibleAstNodes(bindingNode.v)
6640
- .map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
6641
- .flatMap(function (b) {
6642
- return combinateAstNodes(astNode.p, [newIdentifier])
6643
- .map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
6644
- });
6645
- };
6646
-
6647
- var calculateWhenLetOutcomes = function (_a) {
6648
- var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes, combinateAstNodes = _a.combinateAstNodes, isAstComputable = _a.isAstComputable;
6649
- var bindingNode = astNode.b;
6650
- if (!isAstComputable(bindingNode.v)) {
6651
- return __spreadArray(__spreadArray([], __read(combinateAstNodes(astNode.p)
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
- var newIdentifier = bindingNode.n;
6662
- return calculatePossibleAstNodes(bindingNode.v)
6663
- .map(function (bindingValue) { return (__assign(__assign({}, bindingNode), { v: bindingValue })); })
6664
- .flatMap(function (b) {
6665
- return combinateAstNodes(astNode.p, [newIdentifier])
6666
- .map(function (p) { return (__assign(__assign({}, astNode), { b: b, p: p })); });
6667
- });
6668
- };
6669
-
6670
- var calculateWhenNotOutcomes = function (_a) {
6671
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
6672
- var condition = astNode.p[0];
6673
- if (isAstComputable(condition)) {
6674
- return combinateAstNodes(astNode.p)
6675
- .map(function (p) { return ({
6676
- n: 'when-not',
6677
- t: astNode.t,
6678
- p: p,
6679
- token: astNode.token,
6680
- }); });
6681
- }
6682
- var body = astNode.p.slice(1);
6683
- return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
6684
- .map(function (p) { return ({
6685
- n: 'do',
6686
- t: astNode.t,
6687
- p: p,
6688
- token: astNode.token,
6689
- }); })), false), [
6690
- nilNode,
6691
- ], false);
6692
- };
6693
-
6694
- var calculateWhenOutcomes = function (_a) {
6695
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes, nilNode = _a.nilNode, isAstComputable = _a.isAstComputable;
6696
- var condition = astNode.p[0];
6697
- if (isAstComputable(condition)) {
6698
- return combinateAstNodes(astNode.p)
6699
- .map(function (p) { return ({
6700
- n: 'when',
6701
- t: astNode.t,
6702
- p: p,
6703
- token: astNode.token,
6704
- }); });
6705
- }
6706
- var body = astNode.p.slice(1);
6707
- return __spreadArray(__spreadArray([], __read(combinateAstNodes(body)
6708
- .map(function (p) { return ({
6709
- n: 'do',
6710
- t: astNode.t,
6711
- p: p,
6712
- token: astNode.token,
6713
- }); })), false), [
6714
- nilNode,
6715
- ], false);
6716
- };
6717
-
6718
- var calculateRecurOutcomes = function (_a) {
6719
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6720
- return combinateAstNodes(astNode.p)
6721
- .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6722
- };
6723
-
6724
- var calculateCommentOutcomes = function (_a) {
6725
- var nilNode = _a.nilNode;
6726
- return [nilNode];
6727
- };
6728
-
6729
- var calculateLoopOutcomes = function (_a) {
6730
- var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6731
- return combinateAstNodes(astNode.p, astNode.bs.map(function (bindingNode) { return bindingNode.n; }))
6732
- .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6733
- };
6734
-
6735
- var specialExpressionCalculator = {
6736
- 'and': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6737
- 'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6738
- 'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6739
- 'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6740
- 'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6741
- 'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6742
- 'defns': function (astNode, helperOptions) { return calculateDefnsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6743
- 'defs': function (astNode, helperOptions) { return calculateDefsOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6744
- 'do': function (astNode, helperOptions) { return calculateDoOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6745
- 'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6746
- 'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6747
- 'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6748
- 'if-let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6749
- 'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6750
- 'if-not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6751
- 'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6752
- 'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6753
- 'or': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6754
- '??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6755
- 'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6756
- 'time!': function (astNode, helperOptions) { return calculateTimeOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6757
- 'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6758
- 'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6759
- 'when-first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6760
- 'when-let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6761
- 'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6762
- 'when-not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6763
- };
6764
-
6765
- function isIdempotent(normalExpressionName) {
6766
- return !normalExpressionName.endsWith('!')
6767
- || normalExpressionName === 'write!';
6768
- }
6769
- function calculateOutcomes(contextStack, astNodes) {
6770
- // First, we try to calculate outcomes for the whole astNodes array.
6771
- // If that fails, we try to calculate outcomes for the array without the first element.
6772
- // If that fails, we try to calculate outcomes for the array without the first two elements.
6773
- // And so on.
6774
- // This makes it possible to calculate outcomes for e.g.
6775
- // (write! x) x
6776
- // Problems occur for e.g.
6777
- // (def x 1) (write! x) x
6778
- // This should output [1], but since (write! x) fails to calculate outcomes, we get null.
6779
- // Ok, but not optimal
6780
- // The contract is that when an array is returned, it must be correct.
6781
- // But returning null (indicating that the calculation failed) is always a way out.
6782
- for (var i = 0; i < astNodes.length; i++) {
6783
- var usingAstNode = astNodes.slice(i);
6784
- var outcomes = calculateOutcomesInner(contextStack, usingAstNode);
6785
- if (outcomes !== null)
6786
- return outcomes;
6787
- }
6788
- return null;
6789
- }
6790
- function calculateOutcomesInner(contextStack, astNodes) {
6791
- var e_1, _a;
6792
- var possibleAsts = calculatePossibleAsts(contextStack.clone(), astNodes);
6793
- if (possibleAsts === null)
6794
- return null;
6795
- var outcomes = [];
6796
- try {
6797
- for (var possibleAsts_1 = __values(possibleAsts), possibleAsts_1_1 = possibleAsts_1.next(); !possibleAsts_1_1.done; possibleAsts_1_1 = possibleAsts_1.next()) {
6798
- var possibleAst = possibleAsts_1_1.value;
6799
- var unresolvedIdentifiers = findUnresolvedIdentifiers(possibleAst, contextStack.clone(), builtin);
6800
- if (unresolvedIdentifiers.size !== 0)
6801
- return null;
6802
- var ast = {
6803
- b: possibleAst,
6804
- hasDebugData: true,
6805
- };
6806
- try {
6807
- outcomes.push(evaluate(ast, contextStack.clone()));
6808
- }
6809
- catch (e) {
6810
- outcomes.push(e);
6811
- }
6812
- }
6813
- }
6814
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6815
- finally {
6816
- try {
6817
- if (possibleAsts_1_1 && !possibleAsts_1_1.done && (_a = possibleAsts_1.return)) _a.call(possibleAsts_1);
6110
+ builtin: builtin,
6111
+ evaluateAstNode: evaluateAstNode,
6112
+ });
6113
+ return unresolvedIdentifiers;
6818
6114
  }
6819
- finally { if (e_1) throw e_1.error; }
6820
- }
6821
- return outcomes;
6822
- }
6823
- function calculatePossibleAsts(contextStack, astNodes) {
6824
- var possibleAsts;
6825
- try {
6826
- possibleAsts = combinate(astNodes.map(function (astNode) { return calculatePossibleAstNodes(contextStack, astNode); }));
6827
- }
6828
- catch (e) {
6829
- return null;
6830
- }
6831
- return possibleAsts;
6832
- }
6833
- var nilNode = { t: AstNodeType.ReservedSymbol, v: 'nil', token: undefined, p: [], n: undefined };
6834
- function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
6835
- var newContext = newIndentifiers
6836
- ? newIndentifiers.reduce(function (acc, identity) {
6837
- acc[identity] = { value: null };
6838
- return acc;
6839
- }, {})
6840
- : undefined;
6841
- var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
6842
- if (astNode.t === AstNodeType.NormalExpression) {
6843
- if (astNode.n && !isIdempotent(astNode.n))
6844
- throw new Error("NormalExpressionNode with name ".concat(astNode.n, " is not idempotent. Cannot calculate possible ASTs."));
6845
- return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
6846
- .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6847
- }
6848
- else if (astNode.t === AstNodeType.SpecialExpression) {
6849
- var helperOptions = {
6850
- nilNode: nilNode,
6851
- calculatePossibleAstNodes: function (node, identifiers) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); },
6852
- combinateAstNodes: function (nodes, identifiers) {
6853
- return combinate(nodes.map(function (node) { return calculatePossibleAstNodes(newContextStack.clone(), node, identifiers); }));
6854
- },
6855
- isAstComputable: function (node) {
6856
- return calculateOutcomesInner(newContextStack, Array.isArray(node) ? node.flat() : [node]) !== null;
6857
- },
6858
- addGlobalIdentifier: function (name) { return newContextStack.globalContext[name] = { value: null }; },
6859
- };
6860
- // eslint-disable-next-line ts/no-unsafe-argument
6861
- return specialExpressionCalculator[astNode.n](astNode, helperOptions);
6862
6115
  }
6863
- return [astNode];
6864
6116
  }
6865
6117
 
6866
6118
  function analyze(ast, params) {
6867
6119
  return {
6868
6120
  unresolvedIdentifiers: findUnresolvedIdentifiers(ast, createContextStack(params), builtin),
6869
- outcomes: calculateOutcomes(createContextStack(params), ast.b),
6870
6121
  };
6871
6122
  }
6872
6123
 
@@ -7068,13 +6319,10 @@ function fromUnaryAlgebraicToAstNode(operator, operand) {
7068
6319
  var operatorName = operator[1];
7069
6320
  switch (operatorName) {
7070
6321
  case '+':
7071
- return createNamedNormalExpressionNode('+', [operand], token);
7072
6322
  case '-':
7073
- return createNamedNormalExpressionNode('-', [operand], token);
7074
6323
  case '!':
7075
- return createNamedNormalExpressionNode('not', [operand], token);
7076
6324
  case '~':
7077
- return createNamedNormalExpressionNode('bit-not', [operand], token);
6325
+ return createNamedNormalExpressionNode(operatorName, [operand], token);
7078
6326
  /* v8 ignore next 2 */
7079
6327
  default:
7080
6328
  throw new Error("Unknown operator: ".concat(operatorName));
@@ -7087,64 +6335,31 @@ function fromBinaryOperatorToAstNode(operator, left, right, token) {
7087
6335
  case '.':
7088
6336
  return createAccessorNode(left, fromSymbolToStringNode(asSymbolNode(right, (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo)), token);
7089
6337
  case '**': // exponentiation
7090
- return createNamedNormalExpressionNode('pow', [left, right], token);
7091
6338
  case '*':
7092
- return createNamedNormalExpressionNode('*', [left, right], token);
7093
6339
  case '/':
7094
- return createNamedNormalExpressionNode('/', [left, right], token);
7095
6340
  case '%':
7096
- return createNamedNormalExpressionNode('rem', [left, right], token);
7097
6341
  case '+':
7098
- return createNamedNormalExpressionNode('+', [left, right], token);
7099
6342
  case '-':
7100
- return createNamedNormalExpressionNode('-', [left, right], token);
7101
6343
  case '<<':
7102
- return createNamedNormalExpressionNode('bit-shift-left', [left, right], token);
7103
6344
  case '>>':
7104
- return createNamedNormalExpressionNode('bit-shift-right', [left, right], token);
7105
6345
  case '>>>':
7106
- return createNamedNormalExpressionNode('unsigned-bit-shift-right', [left, right], token);
7107
- case '++': {
7108
- var leftString = createNamedNormalExpressionNode('str', [left], token);
7109
- var rightString = createNamedNormalExpressionNode('str', [right], token);
7110
- return createNamedNormalExpressionNode('str', [leftString, rightString], token);
7111
- }
6346
+ case '++':
7112
6347
  case '<':
7113
- return createNamedNormalExpressionNode('<', [left, right], token);
7114
6348
  case '<=':
7115
- return createNamedNormalExpressionNode('<=', [left, right], token);
7116
6349
  case '>':
7117
- return createNamedNormalExpressionNode('>', [left, right], token);
7118
6350
  case '>=':
7119
- return createNamedNormalExpressionNode('>=', [left, right], token);
7120
6351
  case '==':
7121
- return createNamedNormalExpressionNode('=', [left, right], token);
7122
6352
  case '!=':
7123
- return createNamedNormalExpressionNode('!=', [left, right], token);
7124
6353
  case '&':
7125
- return createNamedNormalExpressionNode('bit-and', [left, right], token);
7126
6354
  case '^':
7127
- return createNamedNormalExpressionNode('bit-xor', [left, right], token);
7128
6355
  case '|':
7129
- return createNamedNormalExpressionNode('bit-or', [left, right], token);
6356
+ return createNamedNormalExpressionNode(operatorName, [left, right], token);
7130
6357
  case '&&':
7131
- return {
7132
- t: AstNodeType.SpecialExpression,
7133
- n: 'and',
7134
- p: [left, right],
7135
- token: getTokenDebugData(token) && token,
7136
- };
7137
6358
  case '||':
7138
- return {
7139
- t: AstNodeType.SpecialExpression,
7140
- n: 'or',
7141
- p: [left, right],
7142
- token: getTokenDebugData(token) && token,
7143
- };
7144
6359
  case '??':
7145
6360
  return {
7146
6361
  t: AstNodeType.SpecialExpression,
7147
- n: '??',
6362
+ n: operatorName,
7148
6363
  p: [left, right],
7149
6364
  token: getTokenDebugData(token) && token,
7150
6365
  };
@@ -7184,19 +6399,43 @@ var AlgebraicParser = /** @class */ (function () {
7184
6399
  var _a;
7185
6400
  if (precedence === void 0) { precedence = 0; }
7186
6401
  var firstToken = this.peek();
7187
- if (isA_SymbolToken(firstToken) && firstToken[1] === 'def') {
7188
- return this.parseDef(firstToken);
7189
- }
7190
- if (isA_SymbolToken(firstToken) && firstToken[1] === 'defn') {
7191
- return this.parseDefn(firstToken);
6402
+ var left;
6403
+ if (isA_SymbolToken(firstToken)) {
6404
+ switch (firstToken[1]) {
6405
+ case 'def':
6406
+ return this.parseDef(firstToken);
6407
+ case 'defn':
6408
+ return this.parseDefn(firstToken);
6409
+ case 'let':
6410
+ return this.parseLet(firstToken);
6411
+ case 'if':
6412
+ case 'unless':
6413
+ left = this.parseIfOrUnless(firstToken);
6414
+ break;
6415
+ case 'cond':
6416
+ left = this.parseCond(firstToken);
6417
+ break;
6418
+ case 'switch':
6419
+ left = this.parseSwitch(firstToken);
6420
+ break;
6421
+ case 'for':
6422
+ case 'doseq':
6423
+ left = this.parseForOrDoseq(firstToken);
6424
+ break;
6425
+ case 'do':
6426
+ left = this.parseDo(firstToken);
6427
+ break;
6428
+ case 'loop':
6429
+ left = this.parseLoop(firstToken);
6430
+ break;
6431
+ case 'try':
6432
+ left = this.parseTry(firstToken);
6433
+ break;
6434
+ }
7192
6435
  }
7193
- var left = this.parseOperand();
6436
+ left || (left = this.parseOperand());
7194
6437
  var operator = this.peek();
7195
- while (!this.isAtEnd()
7196
- && !isA_OperatorToken(operator, ',')
7197
- && !isA_OperatorToken(operator, ';')
7198
- && !isRBracketToken(operator)
7199
- && !isRParenToken(operator)) {
6438
+ while (!this.isAtExpressionEnd()) {
7200
6439
  if (isA_BinaryOperatorToken(operator)) {
7201
6440
  var name_1 = operator[1];
7202
6441
  var newPrecedece = getPrecedence(name_1);
@@ -7427,9 +6666,6 @@ var AlgebraicParser = /** @class */ (function () {
7427
6666
  var _a, _b;
7428
6667
  var isNamedFunction = symbol.t === AstNodeType.Symbol;
7429
6668
  this.advance();
7430
- if (isNamedFunction && symbol.v === 'for') {
7431
- return this.parseFor(symbol);
7432
- }
7433
6669
  var params = [];
7434
6670
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7435
6671
  params.push(this.parseExpression());
@@ -7450,17 +6686,11 @@ var AlgebraicParser = /** @class */ (function () {
7450
6686
  var name_2 = symbol.v;
7451
6687
  switch (name_2) {
7452
6688
  case '??':
7453
- case 'and':
6689
+ case '&&':
7454
6690
  case 'comment':
7455
- case 'cond':
7456
- case 'declared?':
7457
- case 'if':
7458
- case 'if-not':
7459
- case 'or':
7460
- case 'when':
7461
- case 'when-not':
7462
- case 'do':
7463
- case 'time!':
6691
+ case 'defined?':
6692
+ case '||':
6693
+ case 'recur':
7464
6694
  case 'throw': {
7465
6695
  var node = {
7466
6696
  t: AstNodeType.SpecialExpression,
@@ -7471,17 +6701,10 @@ var AlgebraicParser = /** @class */ (function () {
7471
6701
  builtin.specialExpressions[node.n].validateParameterCount(node);
7472
6702
  return node;
7473
6703
  }
7474
- case 'let':
7475
- return this.parseLet(symbol, params);
7476
6704
  case 'defs':
7477
- case 'if-let':
7478
- case 'when-let':
7479
- case 'when-first':
7480
6705
  case 'fn':
7481
6706
  case 'defns':
7482
6707
  case 'try':
7483
- case 'recur':
7484
- case 'loop':
7485
6708
  case 'doseq':
7486
6709
  throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
7487
6710
  default:
@@ -7644,67 +6867,174 @@ var AlgebraicParser = /** @class */ (function () {
7644
6867
  };
7645
6868
  return node;
7646
6869
  };
7647
- AlgebraicParser.prototype.parseLet = function (letSymbol, params) {
7648
- var _a, _b;
7649
- if (params.length !== 2) {
7650
- throw new LitsError('let expects two arguments', (_a = getTokenDebugData(letSymbol.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7651
- }
7652
- var letObject = params[0];
7653
- if (letObject.t !== AstNodeType.NormalExpression || letObject.n !== 'object') {
7654
- throw new LitsError('let expects an object as first argument', (_b = getTokenDebugData(letObject.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
7655
- }
7656
- var letBindings = arrayToPairs(letObject.p);
7657
- var expression = params[1];
6870
+ AlgebraicParser.prototype.parseLet = function (token) {
6871
+ this.advance();
6872
+ var letSymbol = parseSymbol(this.tokenStream, this.parseState);
6873
+ assertA_OperatorToken(this.peek(), '=');
6874
+ this.advance();
6875
+ var value = this.parseExpression();
7658
6876
  return {
7659
6877
  t: AstNodeType.SpecialExpression,
7660
6878
  n: 'let',
7661
- p: [expression],
6879
+ p: [],
7662
6880
  token: getTokenDebugData(letSymbol.token) && letSymbol.token,
7663
- bs: letBindings.map(function (pair) {
7664
- var key = pair[0];
7665
- var value = pair[1];
7666
- return {
6881
+ bs: [{
7667
6882
  t: AstNodeType.Binding,
7668
- n: key.v,
6883
+ n: letSymbol.v,
7669
6884
  v: value,
7670
6885
  p: [],
7671
- token: getTokenDebugData(key.token) && key.token,
7672
- };
7673
- }),
6886
+ token: getTokenDebugData(token) && token,
6887
+ }],
6888
+ };
6889
+ };
6890
+ AlgebraicParser.prototype.parseDo = function (token) {
6891
+ this.advance();
6892
+ var expressions = [];
6893
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
6894
+ expressions.push(this.parseExpression());
6895
+ if (isA_OperatorToken(this.peek(), ';')) {
6896
+ this.advance();
6897
+ }
6898
+ }
6899
+ assertA_ReservedSymbolToken(this.peek(), 'end');
6900
+ this.advance();
6901
+ return {
6902
+ t: AstNodeType.SpecialExpression,
6903
+ n: 'do',
6904
+ p: expressions,
6905
+ token: getTokenDebugData(token) && token,
6906
+ };
6907
+ };
6908
+ AlgebraicParser.prototype.parseLoop = function (token) {
6909
+ var _a;
6910
+ this.advance();
6911
+ assertLParenToken(this.peek());
6912
+ this.advance();
6913
+ var bindingNodes = [];
6914
+ while (!this.isAtEnd() && !isRParenToken(this.peek())) {
6915
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
6916
+ assertA_OperatorToken(this.peek(), '=');
6917
+ this.advance();
6918
+ var value = this.parseExpression();
6919
+ bindingNodes.push({
6920
+ t: AstNodeType.Binding,
6921
+ n: symbol.v,
6922
+ v: value,
6923
+ p: [],
6924
+ token: getTokenDebugData(symbol.token) && symbol.token,
6925
+ });
6926
+ if (isA_OperatorToken(this.peek(), ',')) {
6927
+ this.advance();
6928
+ }
6929
+ }
6930
+ if (bindingNodes.length === 0) {
6931
+ throw new LitsError('Expected binding', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
6932
+ }
6933
+ assertRParenToken(this.peek());
6934
+ this.advance();
6935
+ var params = [];
6936
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
6937
+ params.push(this.parseExpression());
6938
+ if (isA_OperatorToken(this.peek(), ';')) {
6939
+ this.advance();
6940
+ }
6941
+ }
6942
+ assertA_ReservedSymbolToken(this.peek(), 'end');
6943
+ this.advance();
6944
+ return {
6945
+ t: AstNodeType.SpecialExpression,
6946
+ n: 'loop',
6947
+ p: params,
6948
+ bs: bindingNodes,
6949
+ token: getTokenDebugData(token) && token,
6950
+ };
6951
+ };
6952
+ AlgebraicParser.prototype.parseTry = function (token) {
6953
+ this.advance();
6954
+ var tryExpressions = [];
6955
+ while (!this.isAtEnd() && !isA_SymbolToken(this.peek(), 'catch')) {
6956
+ tryExpressions.push(this.parseExpression());
6957
+ if (isA_OperatorToken(this.peek(), ';')) {
6958
+ this.advance();
6959
+ }
6960
+ }
6961
+ var tryExpression = tryExpressions.length === 1
6962
+ ? tryExpressions[0]
6963
+ : {
6964
+ t: AstNodeType.SpecialExpression,
6965
+ n: 'do',
6966
+ p: tryExpressions,
6967
+ token: getTokenDebugData(token) && token,
6968
+ };
6969
+ assertA_SymbolToken(this.peek(), 'catch');
6970
+ this.advance();
6971
+ var errorSymbol;
6972
+ if (isLParenToken(this.peek())) {
6973
+ this.advance();
6974
+ errorSymbol = parseSymbol(this.tokenStream, this.parseState);
6975
+ assertRParenToken(this.peek());
6976
+ this.advance();
6977
+ }
6978
+ var catchExpressions = [];
6979
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
6980
+ catchExpressions.push(this.parseExpression());
6981
+ if (isA_OperatorToken(this.peek(), ';')) {
6982
+ this.advance();
6983
+ }
6984
+ }
6985
+ assertA_ReservedSymbolToken(this.peek(), 'end');
6986
+ this.advance();
6987
+ var catchExpression = catchExpressions.length === 1
6988
+ ? catchExpressions[0]
6989
+ : {
6990
+ t: AstNodeType.SpecialExpression,
6991
+ n: 'do',
6992
+ p: catchExpressions,
6993
+ token: getTokenDebugData(token) && token,
6994
+ };
6995
+ return {
6996
+ t: AstNodeType.SpecialExpression,
6997
+ n: 'try',
6998
+ p: [tryExpression],
6999
+ ce: catchExpression,
7000
+ e: errorSymbol,
7001
+ token: getTokenDebugData(token) && token,
7674
7002
  };
7675
7003
  };
7676
- AlgebraicParser.prototype.parseFor = function (forSymbol) {
7004
+ AlgebraicParser.prototype.parseForOrDoseq = function (token) {
7005
+ var isDoseq = token[1] === 'doseq';
7006
+ this.advance();
7007
+ assertLParenToken(this.peek());
7008
+ this.advance();
7677
7009
  var forLoopBindings = [
7678
7010
  this.parseForLoopBinding(),
7679
7011
  ];
7680
- var nextToken = this.peekAhead();
7681
- while (isA_SymbolToken(nextToken) && nextToken[1] === 'of') {
7012
+ while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7682
7013
  forLoopBindings.push(this.parseForLoopBinding());
7683
- nextToken = this.peekAhead();
7014
+ if (isA_OperatorToken(this.peek(), ',')) {
7015
+ this.advance();
7016
+ }
7684
7017
  }
7685
- var expression = this.parseExpression();
7686
7018
  assertRParenToken(this.peek());
7687
7019
  this.advance();
7020
+ var expression = this.parseExpression();
7021
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7022
+ this.advance();
7688
7023
  return {
7689
7024
  t: AstNodeType.SpecialExpression,
7690
- n: 'for',
7025
+ n: isDoseq ? 'doseq' : 'for',
7691
7026
  p: [expression],
7692
- token: getTokenDebugData(forSymbol.token) && forSymbol.token,
7027
+ token: getTokenDebugData(token) && token,
7693
7028
  l: forLoopBindings,
7694
7029
  };
7695
7030
  };
7696
- // export interface LoopBindingNode {
7697
- // b: BindingNode // Binding
7698
- // m: Array<'&let' | '&when' | '&while'> // Modifiers
7699
- // l?: BindingNode[] // Let-Bindings
7700
- // wn?: AstNode // When Node
7701
- // we?: AstNode // While Node
7702
- // }
7703
7031
  AlgebraicParser.prototype.parseForLoopBinding = function () {
7704
7032
  var _a;
7705
7033
  var bindingNode = this.parseBinding();
7706
- if (isA_OperatorToken(this.peek(), ',')) {
7707
- this.advance();
7034
+ if (isRParenToken(this.peek()) || isA_OperatorToken(this.peek(), ',')) {
7035
+ if (isA_OperatorToken(this.peek(), ',')) {
7036
+ this.advance();
7037
+ }
7708
7038
  return {
7709
7039
  b: bindingNode,
7710
7040
  m: [],
@@ -7712,33 +7042,26 @@ var AlgebraicParser = /** @class */ (function () {
7712
7042
  }
7713
7043
  var modifiers = [];
7714
7044
  var token = this.peek();
7715
- if (!isA_SymbolToken(token)) {
7045
+ if (!isA_SymbolToken(token, 'let')
7046
+ && !isA_ReservedSymbolToken(token, 'when')
7047
+ && !isA_ReservedSymbolToken(token, 'while')) {
7716
7048
  throw new LitsError('Expected symbol let, when or while', (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7717
7049
  }
7718
7050
  var letBindings;
7719
7051
  if (token[1] === 'let') {
7720
7052
  modifiers.push('&let');
7721
7053
  letBindings = [];
7722
- this.advance();
7723
- var letObject = this.parseObject();
7724
- letBindings = arrayToPairs(letObject.p).map(function (pair) {
7725
- var key = pair[0];
7726
- var value = pair[1];
7727
- return {
7728
- t: AstNodeType.Binding,
7729
- n: key.v,
7730
- v: value,
7731
- p: [],
7732
- token: getTokenDebugData(key.token) && key.token,
7733
- };
7734
- });
7054
+ while (isA_SymbolToken(token, 'let')) {
7055
+ var letNode = this.parseLet(token);
7056
+ letBindings.push(letNode.bs[0]);
7057
+ token = this.peek();
7058
+ }
7735
7059
  }
7736
7060
  token = this.peek();
7737
7061
  var whenNode;
7738
7062
  var whileNode;
7739
- while (isA_SymbolToken(token)
7740
- && ((token[1] === 'when' && !modifiers.includes('&when'))
7741
- || (token[1] === 'while' && !modifiers.includes('&while')))) {
7063
+ while (isA_ReservedSymbolToken(token, 'when')
7064
+ || isA_ReservedSymbolToken(token, 'while')) {
7742
7065
  this.advance();
7743
7066
  if (token[1] === 'when') {
7744
7067
  modifiers.push('&when');
@@ -7748,37 +7071,173 @@ var AlgebraicParser = /** @class */ (function () {
7748
7071
  modifiers.push('&while');
7749
7072
  whileNode = this.parseExpression();
7750
7073
  }
7751
- token = this.peek();
7074
+ token = this.peek();
7075
+ }
7076
+ if (isA_OperatorToken(token, ',')) {
7077
+ this.advance();
7078
+ }
7079
+ return {
7080
+ b: bindingNode,
7081
+ m: modifiers,
7082
+ l: letBindings,
7083
+ wn: whenNode,
7084
+ we: whileNode,
7085
+ };
7086
+ };
7087
+ AlgebraicParser.prototype.parseBinding = function () {
7088
+ var _a;
7089
+ var firstToken = asA_SymbolToken(this.peek());
7090
+ var name = firstToken[1];
7091
+ this.advance();
7092
+ var ofSymbol = asA_SymbolToken(this.peek());
7093
+ if (ofSymbol[1] !== 'of') {
7094
+ throw new LitsError('Expected "of"', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7095
+ }
7096
+ this.advance();
7097
+ var value = this.parseExpression();
7098
+ var node = {
7099
+ t: AstNodeType.Binding,
7100
+ n: name,
7101
+ v: value,
7102
+ p: [],
7103
+ token: getTokenDebugData(firstToken) && firstToken,
7104
+ };
7105
+ return node;
7106
+ };
7107
+ AlgebraicParser.prototype.parseIfOrUnless = function (token) {
7108
+ var isUnless = token[1] === 'unless';
7109
+ this.advance();
7110
+ var condition = this.parseExpression();
7111
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7112
+ this.advance();
7113
+ var thenExpressions = [];
7114
+ while (!this.isAtEnd()
7115
+ && !isA_ReservedSymbolToken(this.peek(), 'else')
7116
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7117
+ thenExpressions.push(this.parseExpression());
7118
+ if (isA_OperatorToken(this.peek(), ';')) {
7119
+ this.advance();
7120
+ }
7121
+ }
7122
+ var thenExpression = thenExpressions.length === 1
7123
+ ? thenExpressions[0]
7124
+ : {
7125
+ t: AstNodeType.SpecialExpression,
7126
+ n: 'do',
7127
+ p: thenExpressions,
7128
+ token: getTokenDebugData(token) && token,
7129
+ };
7130
+ var elseExpression;
7131
+ if (isA_ReservedSymbolToken(this.peek(), 'else')) {
7132
+ this.advance();
7133
+ var elseExpressions = [];
7134
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7135
+ elseExpressions.push(this.parseExpression());
7136
+ if (isA_OperatorToken(this.peek(), ';')) {
7137
+ this.advance();
7138
+ }
7139
+ }
7140
+ elseExpression = elseExpressions.length === 1
7141
+ ? elseExpressions[0]
7142
+ : {
7143
+ t: AstNodeType.SpecialExpression,
7144
+ n: 'do',
7145
+ p: elseExpressions,
7146
+ token: getTokenDebugData(token) && token,
7147
+ };
7148
+ }
7149
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7150
+ this.advance();
7151
+ var params = [condition, thenExpression];
7152
+ if (elseExpression) {
7153
+ params.push(elseExpression);
7154
+ }
7155
+ return {
7156
+ t: AstNodeType.SpecialExpression,
7157
+ n: isUnless ? 'unless' : 'if',
7158
+ p: params,
7159
+ token: getTokenDebugData(token) && token,
7160
+ };
7161
+ };
7162
+ AlgebraicParser.prototype.parseCond = function (token) {
7163
+ this.advance();
7164
+ var params = [];
7165
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7166
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7167
+ this.advance();
7168
+ params.push(this.parseExpression());
7169
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7170
+ this.advance();
7171
+ var expressions = [];
7172
+ while (!this.isAtEnd()
7173
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7174
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7175
+ expressions.push(this.parseExpression());
7176
+ if (isA_OperatorToken(this.peek(), ';')) {
7177
+ this.advance();
7178
+ }
7179
+ }
7180
+ params.push(expressions.length === 1
7181
+ ? expressions[0]
7182
+ : {
7183
+ t: AstNodeType.SpecialExpression,
7184
+ n: 'do',
7185
+ p: expressions,
7186
+ token: getTokenDebugData(token) && token,
7187
+ });
7188
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7189
+ break;
7190
+ }
7191
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7192
+ }
7193
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7194
+ this.advance();
7195
+ return {
7196
+ t: AstNodeType.SpecialExpression,
7197
+ n: 'cond',
7198
+ p: params,
7199
+ token: getTokenDebugData(token) && token,
7200
+ };
7201
+ };
7202
+ AlgebraicParser.prototype.parseSwitch = function (token) {
7203
+ this.advance();
7204
+ var params = [this.parseExpression()];
7205
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7206
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7207
+ this.advance();
7208
+ params.push(this.parseExpression());
7209
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7210
+ this.advance();
7211
+ var expressions = [];
7212
+ while (!this.isAtEnd()
7213
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7214
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7215
+ expressions.push(this.parseExpression());
7216
+ if (isA_OperatorToken(this.peek(), ';')) {
7217
+ this.advance();
7218
+ }
7219
+ }
7220
+ params.push(expressions.length === 1
7221
+ ? expressions[0]
7222
+ : {
7223
+ t: AstNodeType.SpecialExpression,
7224
+ n: 'do',
7225
+ p: expressions,
7226
+ token: getTokenDebugData(token) && token,
7227
+ });
7228
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7229
+ break;
7230
+ }
7231
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7752
7232
  }
7753
- assertA_OperatorToken(token, ',');
7233
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7754
7234
  this.advance();
7755
7235
  return {
7756
- b: bindingNode,
7757
- m: modifiers,
7758
- l: letBindings,
7759
- wn: whenNode,
7760
- we: whileNode,
7761
- };
7762
- };
7763
- AlgebraicParser.prototype.parseBinding = function () {
7764
- var _a;
7765
- var firstToken = asA_SymbolToken(this.peek());
7766
- var name = firstToken[1];
7767
- this.advance();
7768
- var ofSymbol = asA_SymbolToken(this.peek());
7769
- if (ofSymbol[1] !== 'of') {
7770
- throw new LitsError('Expected "of"', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7771
- }
7772
- this.advance();
7773
- var value = this.parseExpression();
7774
- var node = {
7775
- t: AstNodeType.Binding,
7776
- n: name,
7777
- v: value,
7778
- p: [],
7779
- token: getTokenDebugData(firstToken) && firstToken,
7236
+ t: AstNodeType.SpecialExpression,
7237
+ n: 'switch',
7238
+ p: params,
7239
+ token: getTokenDebugData(token) && token,
7780
7240
  };
7781
- return node;
7782
7241
  };
7783
7242
  AlgebraicParser.prototype.parseDef = function (token) {
7784
7243
  this.advance();
@@ -7794,22 +7253,17 @@ var AlgebraicParser = /** @class */ (function () {
7794
7253
  };
7795
7254
  };
7796
7255
  AlgebraicParser.prototype.parseDefn = function (token) {
7797
- var _a;
7798
7256
  this.advance();
7799
7257
  var symbol = parseSymbol(this.tokenStream, this.parseState);
7800
- var _b = this.parseFunctionArguments(), functionArguments = _b.functionArguments, arity = _b.arity;
7801
- assertLBraceToken(this.peek());
7802
- this.advance();
7258
+ var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
7803
7259
  var body = [];
7804
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
7260
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7805
7261
  body.push(this.parseExpression());
7806
7262
  if (isA_OperatorToken(this.peek(), ';')) {
7807
7263
  this.advance();
7808
7264
  }
7809
7265
  }
7810
- if (!isRBraceToken(this.peek())) {
7811
- throw new LitsError('Expected closing brace', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7812
- }
7266
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7813
7267
  this.advance();
7814
7268
  return {
7815
7269
  t: AstNodeType.SpecialExpression,
@@ -7827,12 +7281,25 @@ var AlgebraicParser = /** @class */ (function () {
7827
7281
  AlgebraicParser.prototype.isAtEnd = function () {
7828
7282
  return this.parseState.position >= this.tokenStream.tokens.length;
7829
7283
  };
7284
+ AlgebraicParser.prototype.isAtExpressionEnd = function () {
7285
+ if (this.isAtEnd()) {
7286
+ return true;
7287
+ }
7288
+ var token = this.peek();
7289
+ if (isA_OperatorToken(token)) {
7290
+ return [';', ','].includes(token[1]);
7291
+ }
7292
+ if (isA_SymbolToken(token)) {
7293
+ return ['catch'].includes(token[1]);
7294
+ }
7295
+ if (isA_ReservedSymbolToken(token)) {
7296
+ return ['else', 'when', 'while', 'then', 'end', 'case'].includes(token[1]);
7297
+ }
7298
+ return false;
7299
+ };
7830
7300
  AlgebraicParser.prototype.peek = function () {
7831
7301
  return this.tokenStream.tokens[this.parseState.position];
7832
7302
  };
7833
- AlgebraicParser.prototype.peekAhead = function () {
7834
- return this.tokenStream.tokens[this.parseState.position + 1];
7835
- };
7836
7303
  return AlgebraicParser;
7837
7304
  }());
7838
7305
 
@@ -8205,8 +7672,8 @@ function parseToken(tokenStream, parseState) {
8205
7672
  return parsePolishToken(tokenStream, parseState);
8206
7673
  }
8207
7674
 
8208
- var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:-]';
8209
- var polishIdentifierFirstCharacterClass = '[a-zA-Z_@%^?=!$<>+*/-]';
7675
+ var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:&\|~-]';
7676
+ var polishIdentifierFirstCharacterClass = '[a-zA-Z_@%^?=!$<>+*/&\|~-]';
8210
7677
  var algebraicIdentifierCharacterClass = '[\\w$:!?]';
8211
7678
  var algebraicIdentifierFirstCharacterClass = '[a-zA-Z_$]';
8212
7679
 
@@ -8286,22 +7753,23 @@ var commonTokenizers = [
8286
7753
  tokenizeString,
8287
7754
  ];
8288
7755
 
8289
- var algebraicReservedNamesRecord = {
8290
- 'true': { value: true },
8291
- 'false': { value: false },
8292
- 'nil': { value: null },
8293
- 'null': { value: null },
8294
- 'if-let': { value: null, forbidden: true },
8295
- 'when-let': { value: null, forbidden: true },
8296
- 'when-first': { value: null, forbidden: true },
8297
- 'fn': { value: null, forbidden: true },
8298
- 'defns': { value: null, forbidden: true },
8299
- 'try': { value: null, forbidden: true },
8300
- 'recur': { value: null, forbidden: true },
8301
- 'loop': { value: null, forbidden: true },
8302
- 'time!': { value: null, forbidden: true },
8303
- 'doseq': { value: null, forbidden: true },
7756
+ var validAlgebraicReservedNamesRecord = {
7757
+ true: { value: true, forbidden: false },
7758
+ false: { value: false, forbidden: false },
7759
+ nil: { value: null, forbidden: false },
7760
+ null: { value: null, forbidden: false },
7761
+ then: { value: null, forbidden: false },
7762
+ else: { value: null, forbidden: false },
7763
+ end: { value: null, forbidden: false },
7764
+ case: { value: null, forbidden: false },
7765
+ when: { value: null, forbidden: false },
7766
+ while: { value: null, forbidden: false },
8304
7767
  };
7768
+ var forbiddenAlgebraicReservedNamesRecord = {
7769
+ fn: { value: null, forbidden: true },
7770
+ defns: { value: null, forbidden: true },
7771
+ };
7772
+ var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
8305
7773
 
8306
7774
  var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
8307
7775
  var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
@@ -8373,45 +7841,19 @@ var tokenizeA_BasePrefixedNumber = function (input, position) {
8373
7841
  }
8374
7842
  return [length, ['A_BasePrefixedNumber', input.substring(position, i)]];
8375
7843
  };
8376
- var tokenizeA_ReservedSymbolToken = function (input, position) {
8377
- var e_1, _a;
8378
- try {
8379
- for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8380
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8381
- var length_1 = reservedName.length;
8382
- var nextChar = input[position + length_1];
8383
- if (nextChar && identifierRegExp.test(nextChar))
8384
- continue;
8385
- var name_1 = input.substring(position, position + length_1);
8386
- if (name_1 === reservedName) {
8387
- if (forbidden)
8388
- throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
8389
- return [length_1, ['A_ReservedSymbol', reservedName]];
8390
- }
8391
- }
8392
- }
8393
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8394
- finally {
8395
- try {
8396
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8397
- }
8398
- finally { if (e_1) throw e_1.error; }
8399
- }
8400
- return NO_MATCH;
8401
- };
8402
7844
  var tokenizeA_Symbol = function (input, position) {
8403
7845
  var value = input[position];
8404
7846
  if (!value) {
8405
7847
  return NO_MATCH;
8406
7848
  }
8407
7849
  if (value === '\'') {
8408
- var length_2 = 1;
8409
- var char = input[position + length_2];
7850
+ var length_1 = 1;
7851
+ var char = input[position + length_1];
8410
7852
  var escaping = false;
8411
7853
  while (char !== '\'' || escaping) {
8412
7854
  if (char === undefined)
8413
7855
  throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
8414
- length_2 += 1;
7856
+ length_1 += 1;
8415
7857
  if (escaping) {
8416
7858
  escaping = false;
8417
7859
  value += char;
@@ -8422,10 +7864,10 @@ var tokenizeA_Symbol = function (input, position) {
8422
7864
  }
8423
7865
  value += char;
8424
7866
  }
8425
- char = input[position + length_2];
7867
+ char = input[position + length_1];
8426
7868
  }
8427
7869
  value += '\''; // closing quote
8428
- return [length_2 + 1, ['A_Symbol', value]];
7870
+ return [length_1 + 1, ['A_Symbol', value]];
8429
7871
  }
8430
7872
  if (identifierFirstCharacterRegExp.test(value)) {
8431
7873
  var initialPosition = position;
@@ -8440,6 +7882,22 @@ var tokenizeA_Symbol = function (input, position) {
8440
7882
  }
8441
7883
  return NO_MATCH;
8442
7884
  };
7885
+ var tokenizeA_ReservedSymbolToken = function (input, position) {
7886
+ var symbolMeta = tokenizeA_Symbol(input, position);
7887
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
7888
+ return NO_MATCH;
7889
+ }
7890
+ var symbolName = symbolMeta[1][1];
7891
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
7892
+ var info = algebraicReservedNamesRecord[symbolName];
7893
+ if (!info) {
7894
+ return NO_MATCH;
7895
+ }
7896
+ if (info.forbidden) {
7897
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
7898
+ }
7899
+ return [symbolMeta[0], ['A_ReservedSymbol', symbolName]];
7900
+ };
8443
7901
  var tokenizeA_Operator = function (input, position) {
8444
7902
  var _a;
8445
7903
  var threeChars = input.slice(position, position + 3);
@@ -8458,30 +7916,30 @@ var tokenizeA_Operator = function (input, position) {
8458
7916
  };
8459
7917
  var tokenizeA_MultiLineComment = function (input, position) {
8460
7918
  if (input[position] === '/' && input[position + 1] === '*') {
8461
- var length_3 = 2;
7919
+ var length_2 = 2;
8462
7920
  var value = '/*';
8463
- while (input[position + length_3] !== '*' && input[position + length_3 + 1] !== '/' && position + length_3 + 1 < input.length) {
8464
- value += input[position + length_3];
8465
- length_3 += 1;
7921
+ while (input[position + length_2] !== '*' && input[position + length_2 + 1] !== '/' && position + length_2 + 1 < input.length) {
7922
+ value += input[position + length_2];
7923
+ length_2 += 1;
8466
7924
  }
8467
- if (position + length_3 + 1 >= input.length) {
7925
+ if (position + length_2 + 1 >= input.length) {
8468
7926
  throw new LitsError('Comment not closed', undefined);
8469
7927
  }
8470
7928
  value += '*/';
8471
- length_3 += 2;
8472
- return [length_3, ['A_MultiLineComment', value]];
7929
+ length_2 += 2;
7930
+ return [length_2, ['A_MultiLineComment', value]];
8473
7931
  }
8474
7932
  return NO_MATCH;
8475
7933
  };
8476
7934
  var tokenizeA_SingleLineComment = function (input, position) {
8477
7935
  if (input[position] === '/' && input[position + 1] === '/') {
8478
- var length_4 = 2;
7936
+ var length_3 = 2;
8479
7937
  var value = '//';
8480
- while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
8481
- value += input[position + length_4];
8482
- length_4 += 1;
7938
+ while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
7939
+ value += input[position + length_3];
7940
+ length_3 += 1;
8483
7941
  }
8484
- return [length_4, ['A_SingleLineComment', value]];
7942
+ return [length_3, ['A_SingleLineComment', value]];
8485
7943
  }
8486
7944
  return NO_MATCH;
8487
7945
  };
@@ -8641,31 +8099,20 @@ var tokenizeP_FnShorthand = function (input, position) {
8641
8099
  return [1, ['P_FnShorthand']];
8642
8100
  };
8643
8101
  var tokenizeP_ReservedSymbol = function (input, position) {
8644
- var e_1, _a;
8645
- try {
8646
- for (var _b = __values(Object.entries(polishReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8647
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8648
- var length_3 = reservedName.length;
8649
- var nextChar = input[position + length_3];
8650
- if (nextChar && P_symbolRegExp.test(nextChar)) {
8651
- continue;
8652
- }
8653
- var symbol = input.substring(position, position + length_3);
8654
- if (symbol === reservedName) {
8655
- if (forbidden)
8656
- throw new LitsError("".concat(symbol, " is forbidden!"), undefined);
8657
- return [length_3, ['P_ReservedSymbol', reservedName]];
8658
- }
8659
- }
8102
+ var symbolMeta = tokenizeP_Symbol(input, position);
8103
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
8104
+ return NO_MATCH;
8660
8105
  }
8661
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8662
- finally {
8663
- try {
8664
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8665
- }
8666
- finally { if (e_1) throw e_1.error; }
8106
+ var symbolName = symbolMeta[1][1];
8107
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
8108
+ var info = polishReservedNamesRecord[symbolName];
8109
+ if (!info) {
8110
+ return NO_MATCH;
8667
8111
  }
8668
- return NO_MATCH;
8112
+ if (info.forbidden) {
8113
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
8114
+ }
8115
+ return [symbolMeta[0], ['P_ReservedSymbol', symbolName]];
8669
8116
  };
8670
8117
  var tokenizeP_StringShorthand = function (input, position) {
8671
8118
  if (input[position] !== ':')
@@ -8678,24 +8125,24 @@ var tokenizeP_StringShorthand = function (input, position) {
8678
8125
  return [symbolDescription[0] + 1, ['P_StringShorthand', ":".concat(symbolToken[1])]];
8679
8126
  };
8680
8127
  var tokenizeP_Modifier = function (input, position) {
8681
- var e_2, _a;
8128
+ var e_1, _a;
8682
8129
  try {
8683
8130
  for (var modifierNames_1 = __values(modifierNames), modifierNames_1_1 = modifierNames_1.next(); !modifierNames_1_1.done; modifierNames_1_1 = modifierNames_1.next()) {
8684
8131
  var modifierName = modifierNames_1_1.value;
8685
- var length_4 = modifierName.length;
8686
- var charAfterModifier = input[position + length_4];
8687
- if (input.substring(position, position + length_4) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8132
+ var length_3 = modifierName.length;
8133
+ var charAfterModifier = input[position + length_3];
8134
+ if (input.substring(position, position + length_3) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8688
8135
  var value = modifierName;
8689
- return [length_4, ['P_Modifier', value]];
8136
+ return [length_3, ['P_Modifier', value]];
8690
8137
  }
8691
8138
  }
8692
8139
  }
8693
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
8140
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8694
8141
  finally {
8695
8142
  try {
8696
8143
  if (modifierNames_1_1 && !modifierNames_1_1.done && (_a = modifierNames_1.return)) _a.call(modifierNames_1);
8697
8144
  }
8698
- finally { if (e_2) throw e_2.error; }
8145
+ finally { if (e_1) throw e_1.error; }
8699
8146
  }
8700
8147
  return NO_MATCH;
8701
8148
  };
@@ -8732,8 +8179,8 @@ var polishTokenizers = __spreadArray(__spreadArray([
8732
8179
  tokenizeP_StringShorthand,
8733
8180
  tokenizeP_Number,
8734
8181
  tokenizeP_ReservedSymbol,
8735
- tokenizeP_Symbol,
8736
8182
  tokenizeP_Modifier,
8183
+ tokenizeP_Symbol,
8737
8184
  tokenizeP_RegexpShorthand,
8738
8185
  tokenizeP_FnShorthand,
8739
8186
  tokenizeP_CollectionAccessor,
@@ -9141,7 +8588,7 @@ var collectionReference = {
9141
8588
  },
9142
8589
  args: {
9143
8590
  coll: {
9144
- type: ['collection', 'string', 'nil'],
8591
+ type: ['collection', 'string', 'null'],
9145
8592
  },
9146
8593
  },
9147
8594
  variants: [
@@ -9230,7 +8677,7 @@ var collectionReference = {
9230
8677
  },
9231
8678
  args: {
9232
8679
  coll: {
9233
- type: ['collection', 'nil'],
8680
+ type: ['collection', 'null'],
9234
8681
  },
9235
8682
  key: {
9236
8683
  type: ['string', 'number'],
@@ -9258,7 +8705,7 @@ var collectionReference = {
9258
8705
  },
9259
8706
  args: {
9260
8707
  coll: {
9261
- type: ['collection', 'nil'],
8708
+ type: ['collection', 'null'],
9262
8709
  },
9263
8710
  value: {
9264
8711
  type: ['any'],
@@ -9461,7 +8908,7 @@ var collectionReference = {
9461
8908
  },
9462
8909
  args: {
9463
8910
  coll: {
9464
- type: ['collection', 'nil'],
8911
+ type: ['collection', 'null'],
9465
8912
  },
9466
8913
  },
9467
8914
  variants: [
@@ -10019,7 +9466,7 @@ var arrayReference = {
10019
9466
  description: 'Takes a nested array $x and flattens it.',
10020
9467
  examples: [
10021
9468
  '(flatten [1 2 [3 4] 5])',
10022
- "\n(let [foo :bar]\n (flatten\n [1\n \" 2 A \"\n [foo [4 [:ABC]]] 6]))",
9469
+ "\n(let [foo :bar])\n(flatten\n [1\n \" 2 A \"\n [foo [4 [:ABC]]] 6])",
10023
9470
  '(flatten 12)',
10024
9471
  ],
10025
9472
  },
@@ -10062,7 +9509,7 @@ var sequenceReference = {
10062
9509
  },
10063
9510
  args: {
10064
9511
  'seq': {
10065
- type: ['sequence', 'nil'],
9512
+ type: ['sequence', 'null'],
10066
9513
  },
10067
9514
  'n': {
10068
9515
  type: 'integer',
@@ -10124,7 +9571,7 @@ var sequenceReference = {
10124
9571
  category: 'Sequence',
10125
9572
  linkName: 'pop',
10126
9573
  returns: {
10127
- type: ['sequence', 'nil'],
9574
+ type: ['sequence', 'null'],
10128
9575
  array: true,
10129
9576
  },
10130
9577
  args: {
@@ -10177,7 +9624,7 @@ var sequenceReference = {
10177
9624
  linkName: 'shift',
10178
9625
  clojureDocs: null,
10179
9626
  returns: {
10180
- type: ['sequence', 'nil'],
9627
+ type: ['sequence', 'null'],
10181
9628
  array: true,
10182
9629
  },
10183
9630
  args: {
@@ -10374,11 +9821,11 @@ var sequenceReference = {
10374
9821
  linkName: 'position',
10375
9822
  clojureDocs: null,
10376
9823
  returns: {
10377
- type: ['number', 'nil'],
9824
+ type: ['number', 'null'],
10378
9825
  },
10379
9826
  args: {
10380
9827
  seq: {
10381
- type: ['sequence', 'nil'],
9828
+ type: ['sequence', 'null'],
10382
9829
  },
10383
9830
  fn: {
10384
9831
  type: 'function',
@@ -10401,11 +9848,11 @@ var sequenceReference = {
10401
9848
  linkName: 'index_of',
10402
9849
  clojureDocs: null,
10403
9850
  returns: {
10404
- type: ['number', 'nil'],
9851
+ type: ['number', 'null'],
10405
9852
  },
10406
9853
  args: {
10407
9854
  seq: {
10408
- type: ['sequence', 'nil'],
9855
+ type: ['sequence', 'null'],
10409
9856
  },
10410
9857
  x: {
10411
9858
  type: 'any',
@@ -10431,7 +9878,7 @@ var sequenceReference = {
10431
9878
  },
10432
9879
  args: {
10433
9880
  seq: {
10434
- type: ['sequence', 'nil'],
9881
+ type: ['sequence', 'null'],
10435
9882
  },
10436
9883
  fn: {
10437
9884
  type: 'function',
@@ -10454,11 +9901,11 @@ var sequenceReference = {
10454
9901
  category: 'Sequence',
10455
9902
  linkName: 'reverse',
10456
9903
  returns: {
10457
- type: ['sequence', 'nil'],
9904
+ type: ['sequence', 'null'],
10458
9905
  },
10459
9906
  args: {
10460
9907
  seq: {
10461
- type: ['sequence', 'nil'],
9908
+ type: ['sequence', 'null'],
10462
9909
  },
10463
9910
  },
10464
9911
  variants: [
@@ -10481,7 +9928,7 @@ var sequenceReference = {
10481
9928
  },
10482
9929
  args: {
10483
9930
  seq: {
10484
- type: ['sequence', 'nil'],
9931
+ type: ['sequence', 'null'],
10485
9932
  },
10486
9933
  },
10487
9934
  variants: [
@@ -10503,7 +9950,7 @@ var sequenceReference = {
10503
9950
  },
10504
9951
  args: {
10505
9952
  seq: {
10506
- type: ['sequence', 'nil'],
9953
+ type: ['sequence', 'null'],
10507
9954
  },
10508
9955
  },
10509
9956
  variants: [
@@ -10526,7 +9973,7 @@ var sequenceReference = {
10526
9973
  },
10527
9974
  args: {
10528
9975
  seq: {
10529
- type: ['sequence', 'nil'],
9976
+ type: ['sequence', 'null'],
10530
9977
  },
10531
9978
  },
10532
9979
  variants: [
@@ -10546,7 +9993,7 @@ var sequenceReference = {
10546
9993
  category: 'Sequence',
10547
9994
  linkName: 'rest',
10548
9995
  returns: {
10549
- type: ['sequence', 'nil'],
9996
+ type: ['sequence', 'null'],
10550
9997
  },
10551
9998
  args: {
10552
9999
  seq: {
@@ -10599,7 +10046,7 @@ var sequenceReference = {
10599
10046
  category: 'Sequence',
10600
10047
  linkName: 'next',
10601
10048
  returns: {
10602
- type: ['sequence', 'nil'],
10049
+ type: ['sequence', 'null'],
10603
10050
  },
10604
10051
  args: {
10605
10052
  seq: {
@@ -10624,7 +10071,7 @@ var sequenceReference = {
10624
10071
  category: 'Sequence',
10625
10072
  linkName: 'nthnext',
10626
10073
  returns: {
10627
- type: ['sequence', 'nil'],
10074
+ type: ['sequence', 'null'],
10628
10075
  array: true,
10629
10076
  },
10630
10077
  args: {
@@ -10848,7 +10295,7 @@ var sequenceReference = {
10848
10295
  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`.',
10849
10296
  examples: [
10850
10297
  '(sort_by ["Albert" "Mojir" "Nina"] count)',
10851
- '(sort_by "Albert" lower-case #(compare %2 %1))',
10298
+ '(sort_by "Albert" lower_case #(compare %2 %1))',
10852
10299
  ],
10853
10300
  },
10854
10301
  distinct: {
@@ -11113,7 +10560,7 @@ var sequenceReference = {
11113
10560
  ],
11114
10561
  description: 'Applies $fn to each value in $seq, splitting it each time $fn returns a new value. Returns an array of sequences.',
11115
10562
  examples: [
11116
- '(partition_by [1 2 3 4 5] #(= 3 %1))',
10563
+ '(partition_by [1 2 3 4 5] #(== 3 %1))',
11117
10564
  '(partition_by [1 1 1 2 2 3 3] odd?)',
11118
10565
  '(partition_by "Leeeeeerrroyyy" identity)',
11119
10566
  ],
@@ -11219,10 +10666,11 @@ var mathReference = {
11219
10666
  description: 'Modulus of `dividend` and `divisor`. Truncates toward negative infinity.',
11220
10667
  examples: ['(mod 5 3)', '(mod 5.2 3.1)', '(mod -5 3)', '(mod 5 -3)', '(mod -5 -3)'],
11221
10668
  },
11222
- 'rem': {
11223
- title: 'rem',
10669
+ '%': {
10670
+ title: '%',
11224
10671
  category: 'Math',
11225
- linkName: 'rem',
10672
+ linkName: '-percent',
10673
+ clojureDocs: 'rem',
11226
10674
  returns: {
11227
10675
  type: 'number',
11228
10676
  },
@@ -11238,7 +10686,7 @@ var mathReference = {
11238
10686
  { argumentNames: ['a', 'b'] },
11239
10687
  ],
11240
10688
  description: 'Remainder of dividing `dividend` and `divisor`.',
11241
- examples: ['(rem 5 3)', '(rem 5.2 3.1)', '(rem -5 3)', '(rem 5 -3)', '(rem -5 -3)'],
10689
+ examples: ['(% 5 3)', '(% 5.2 3.1)', '(% -5 3)', '(% 5 -3)', '(% -5 -3)'],
11242
10690
  },
11243
10691
  'quot': {
11244
10692
  title: 'quot',
@@ -11335,10 +10783,10 @@ var mathReference = {
11335
10783
  description: 'Computes cube root of $x.',
11336
10784
  examples: ['(cbrt 0)', '(cbrt 27)', '(cbrt 2)', '(cbrt 1)'],
11337
10785
  },
11338
- 'pow': {
11339
- title: 'pow',
10786
+ '**': {
10787
+ title: '**',
11340
10788
  category: 'Math',
11341
- linkName: 'pow',
10789
+ linkName: '-star-star',
11342
10790
  clojureDocs: null,
11343
10791
  returns: {
11344
10792
  type: 'number',
@@ -11355,7 +10803,7 @@ var mathReference = {
11355
10803
  { argumentNames: ['a', 'b'] },
11356
10804
  ],
11357
10805
  description: 'Computes returns $a raised to the power of $b.',
11358
- examples: ['(pow 2 3)', '(pow 2 0)', '(pow 2 -3)', '(pow -2 3)', '(pow -2 -3)'],
10806
+ examples: ['(** 2 3)', '(** 2 0)', '(** 2 -3)', '(** -2 3)', '(** -2 -3)'],
11359
10807
  },
11360
10808
  'exp': {
11361
10809
  title: 'exp',
@@ -11725,7 +11173,7 @@ var mathReference = {
11725
11173
  { argumentNames: ['x'] },
11726
11174
  ],
11727
11175
  description: 'Returns the base `2` logarithm of a number.',
11728
- examples: ['(log2 0.01)', '(log2 (pow 2 12))', '(log2 2.5)'],
11176
+ examples: ['(log2 0.01)', '(log2 (** 2 12))', '(log2 2.5)'],
11729
11177
  },
11730
11178
  'log10': {
11731
11179
  title: 'log10',
@@ -11744,7 +11192,7 @@ var mathReference = {
11744
11192
  { argumentNames: ['x'] },
11745
11193
  ],
11746
11194
  description: 'Returns the `10` logarithm of a number.',
11747
- examples: ['(log10 0.01)', '(log10 (pow 10 12))', '(log10 2.5)'],
11195
+ examples: ['(log10 0.01)', '(log10 (** 10 12))', '(log10 2.5)'],
11748
11196
  },
11749
11197
  'sin': {
11750
11198
  title: 'sin',
@@ -11998,13 +11446,14 @@ var miscReference = {
11998
11446
  { argumentNames: ['x'] },
11999
11447
  { argumentNames: ['x', 'ys'] },
12000
11448
  ],
12001
- 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 `(not (= a b))`.',
11449
+ 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))`.',
12002
11450
  examples: ['(!= 3)', '(!= 3 2)', '(!= :3 3)', '(!= 3 3 2)', '(!= :3 :2 :1 :0)', '(!= 0 -0)'],
12003
11451
  },
12004
- '=': {
12005
- title: '=',
11452
+ '==': {
11453
+ title: '==',
12006
11454
  category: 'Misc',
12007
- linkName: '-equal',
11455
+ linkName: '-equal-equal',
11456
+ clojureDocs: '=',
12008
11457
  returns: {
12009
11458
  type: 'boolean',
12010
11459
  },
@@ -12022,7 +11471,7 @@ var miscReference = {
12022
11471
  { argumentNames: ['x', 'ys'] },
12023
11472
  ],
12024
11473
  description: 'Compares `values` according to \'equal\' predicate. Result is `true` if every specified value is equal to each other, otherwise result is `false`.',
12025
- examples: ['(= 1 1)', '(= 1.01 1)', '(= :1 1)', '(= :2 :2 :2 :2)', '(= 2 2 1 2)'],
11474
+ examples: ['(== 1 1)', '(== 1.01 1)', '(== :1 1)', '(== :2 :2 :2 :2)', '(== 2 2 1 2)'],
12026
11475
  },
12027
11476
  '<': {
12028
11477
  title: '<',
@@ -12116,10 +11565,11 @@ var miscReference = {
12116
11565
  description: 'Returns `true` if the number $x and $ys are in non increasing order, `false` otherwise.',
12117
11566
  examples: ['(>= 1 0)', '(>= 1.01 1)', '(>= 1 1)', '(>= 4 3 2 1)', '(>= 3 2 2 1)'],
12118
11567
  },
12119
- 'not': {
12120
- title: 'not',
11568
+ '!': {
11569
+ title: '!',
12121
11570
  category: 'Misc',
12122
- linkName: 'not',
11571
+ linkName: '-exclamation',
11572
+ clojureDocs: 'not',
12123
11573
  returns: {
12124
11574
  type: 'boolean',
12125
11575
  },
@@ -12132,7 +11582,7 @@ var miscReference = {
12132
11582
  { argumentNames: ['x'] },
12133
11583
  ],
12134
11584
  description: 'Computes logical negation. Note that any other $x than `false`, `0`, `nil` and `\'\'` is truthy.',
12135
- examples: ['(not 3)', '(not true)', '(not "A string")', '(not 0)', '(not false)', '(not nil)', '(not "")'],
11585
+ examples: ['(! 3)', '(! true)', '(! "A string")', '(! 0)', '(! false)', '(! nil)', '(! "")'],
12136
11586
  },
12137
11587
  'write!': {
12138
11588
  title: 'write!',
@@ -12161,25 +11611,10 @@ var miscReference = {
12161
11611
  '(write! nil true false)',
12162
11612
  ],
12163
11613
  },
12164
- 'inst-ms!': {
12165
- title: 'inst-ms!',
12166
- category: 'Misc',
12167
- linkName: 'inst-ms-exclamation',
12168
- clojureDocs: 'inst-ms',
12169
- returns: {
12170
- type: 'number',
12171
- },
12172
- args: {},
12173
- variants: [
12174
- { argumentNames: [] },
12175
- ],
12176
- description: 'Returns milliseconds elapsed since the UNIX epoch.',
12177
- examples: ['(inst-ms!)'],
12178
- },
12179
- 'iso-date-time->inst-ms': {
12180
- title: 'iso-date-time->inst-ms',
11614
+ 'iso_date>epoch': {
11615
+ title: 'iso_date>epoch',
12181
11616
  category: 'Misc',
12182
- linkName: 'iso-date-time--gtinst-ms',
11617
+ linkName: 'iso_date-gtepoch',
12183
11618
  returns: {
12184
11619
  type: 'number',
12185
11620
  },
@@ -12193,14 +11628,14 @@ var miscReference = {
12193
11628
  ],
12194
11629
  description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',
12195
11630
  examples: [
12196
- '(iso-date-time->inst-ms "2022-04-12T09:37:10.899Z")',
12197
- '(iso-date-time->inst-ms "1980-01-01")',
11631
+ '(iso_date>epoch "2022-04-12T09:37:10.899Z")',
11632
+ '(iso_date>epoch "1980-01-01")',
12198
11633
  ],
12199
11634
  },
12200
- 'inst-ms->iso-date-time': {
12201
- title: 'inst-ms->iso-date-time',
11635
+ 'epoch>iso_date': {
11636
+ title: 'epoch>iso_date',
12202
11637
  category: 'Misc',
12203
- linkName: 'inst-ms--gtiso-date-time',
11638
+ linkName: 'epoch-gtiso_date',
12204
11639
  returns: {
12205
11640
  type: 'string',
12206
11641
  },
@@ -12214,8 +11649,8 @@ var miscReference = {
12214
11649
  ],
12215
11650
  description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',
12216
11651
  examples: [
12217
- '(inst-ms->iso-date-time 1649756230899)',
12218
- '(inst-ms->iso-date-time 0)',
11652
+ '(epoch>iso_date 1649756230899)',
11653
+ '(epoch>iso_date 0)',
12219
11654
  ],
12220
11655
  },
12221
11656
  'boolean': {
@@ -12271,34 +11706,6 @@ var miscReference = {
12271
11706
  '(compare + -)',
12272
11707
  ],
12273
11708
  },
12274
- 'lits-version!': {
12275
- title: 'lits-version!',
12276
- category: 'Misc',
12277
- linkName: 'lits-version-exclamation',
12278
- returns: {
12279
- type: 'string',
12280
- },
12281
- args: {},
12282
- variants: [
12283
- { argumentNames: [] },
12284
- ],
12285
- description: 'Returns the lits version.',
12286
- examples: ['(lits-version!)'],
12287
- },
12288
- 'uuid!': {
12289
- title: 'uuid!',
12290
- category: 'Misc',
12291
- linkName: 'uuid-exclamation',
12292
- returns: {
12293
- type: 'string',
12294
- },
12295
- args: {},
12296
- variants: [
12297
- { argumentNames: [] },
12298
- ],
12299
- description: 'Returns random UUID string.',
12300
- examples: ['(uuid!)'],
12301
- },
12302
11709
  'equal?': {
12303
11710
  title: 'equal?',
12304
11711
  category: 'Misc',
@@ -12324,14 +11731,14 @@ var miscReference = {
12324
11731
  '(equal? [1 true nil] [1 true nil])',
12325
11732
  '(equal? {:a 10 :b [1 2 {:b 20}]} {:b [1 2 {:b 20}] :a 10})',
12326
11733
  '(equal? {:a 10 :b [1 2 {:b 20}]} {:b [1 2 {:b 21}] :a 10})',
12327
- '(= 0.3 (+ 0.1 0.2))',
11734
+ '(== 0.3 (+ 0.1 0.2))',
12328
11735
  '(equal? 0.3 (+ 0.1 0.2))',
12329
11736
  ],
12330
11737
  },
12331
- 'json-parse': {
12332
- title: 'json-parse',
11738
+ 'json_parse': {
11739
+ title: 'json_parse',
12333
11740
  category: 'Misc',
12334
- linkName: 'json-parse',
11741
+ linkName: 'json_parse',
12335
11742
  clojureDocs: null,
12336
11743
  returns: {
12337
11744
  type: 'any',
@@ -12346,13 +11753,13 @@ var miscReference = {
12346
11753
  ],
12347
11754
  description: 'Returns `JSON.parse(`$x`)`.',
12348
11755
  examples: [
12349
- '(json-parse "[1, 2, 3]")',
11756
+ '(json_parse "[1, 2, 3]")',
12350
11757
  ],
12351
11758
  },
12352
- 'json-stringify': {
12353
- title: 'json-stringify',
11759
+ 'json_stringify': {
11760
+ title: 'json_stringify',
12354
11761
  category: 'Misc',
12355
- linkName: 'json-stringify',
11762
+ linkName: 'json_stringify',
12356
11763
  clojureDocs: null,
12357
11764
  returns: {
12358
11765
  type: 'string',
@@ -12372,8 +11779,8 @@ var miscReference = {
12372
11779
  ],
12373
11780
  description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',
12374
11781
  examples: [
12375
- '(json-stringify [1, 2, 3])',
12376
- '(json-stringify {:a {:b 10}} 2)',
11782
+ '(json_stringify [1, 2, 3])',
11783
+ '(json_stringify {:a {:b 10}} 2)',
12377
11784
  ],
12378
11785
  },
12379
11786
  };
@@ -12405,7 +11812,7 @@ var assertReference = { 'assert': {
12405
11812
  linkName: 'assert-equal',
12406
11813
  clojureDocs: null,
12407
11814
  returns: {
12408
- type: 'nil',
11815
+ type: 'null',
12409
11816
  },
12410
11817
  args: {
12411
11818
  a: {
@@ -12434,7 +11841,7 @@ var assertReference = { 'assert': {
12434
11841
  linkName: 'assert-exclamation-equal',
12435
11842
  clojureDocs: null,
12436
11843
  returns: {
12437
- type: 'nil',
11844
+ type: 'null',
12438
11845
  },
12439
11846
  args: {
12440
11847
  a: {
@@ -12463,7 +11870,7 @@ var assertReference = { 'assert': {
12463
11870
  linkName: 'assert_equal',
12464
11871
  clojureDocs: null,
12465
11872
  returns: {
12466
- type: 'nil',
11873
+ type: 'null',
12467
11874
  },
12468
11875
  args: {
12469
11876
  a: {
@@ -12492,7 +11899,7 @@ var assertReference = { 'assert': {
12492
11899
  linkName: 'assert_not_equal',
12493
11900
  clojureDocs: null,
12494
11901
  returns: {
12495
- type: 'nil',
11902
+ type: 'null',
12496
11903
  },
12497
11904
  args: {
12498
11905
  a: {
@@ -12521,7 +11928,7 @@ var assertReference = { 'assert': {
12521
11928
  linkName: 'assert_gt',
12522
11929
  clojureDocs: null,
12523
11930
  returns: {
12524
- type: 'nil',
11931
+ type: 'null',
12525
11932
  },
12526
11933
  args: {
12527
11934
  a: {
@@ -12550,7 +11957,7 @@ var assertReference = { 'assert': {
12550
11957
  linkName: 'assert_lt',
12551
11958
  clojureDocs: null,
12552
11959
  returns: {
12553
- type: 'nil',
11960
+ type: 'null',
12554
11961
  },
12555
11962
  args: {
12556
11963
  a: {
@@ -12579,7 +11986,7 @@ var assertReference = { 'assert': {
12579
11986
  linkName: 'assert_gte',
12580
11987
  clojureDocs: null,
12581
11988
  returns: {
12582
- type: 'nil',
11989
+ type: 'null',
12583
11990
  },
12584
11991
  args: {
12585
11992
  a: {
@@ -12608,7 +12015,7 @@ var assertReference = { 'assert': {
12608
12015
  linkName: 'assert_lte',
12609
12016
  clojureDocs: null,
12610
12017
  returns: {
12611
- type: 'nil',
12018
+ type: 'null',
12612
12019
  },
12613
12020
  args: {
12614
12021
  a: {
@@ -12637,7 +12044,7 @@ var assertReference = { 'assert': {
12637
12044
  linkName: 'assert_true',
12638
12045
  clojureDocs: null,
12639
12046
  returns: {
12640
- type: 'nil',
12047
+ type: 'null',
12641
12048
  },
12642
12049
  args: {
12643
12050
  value: {
@@ -12663,7 +12070,7 @@ var assertReference = { 'assert': {
12663
12070
  linkName: 'assert_false',
12664
12071
  clojureDocs: null,
12665
12072
  returns: {
12666
- type: 'nil',
12073
+ type: 'null',
12667
12074
  },
12668
12075
  args: {
12669
12076
  value: {
@@ -12689,7 +12096,7 @@ var assertReference = { 'assert': {
12689
12096
  linkName: 'assert_truthy',
12690
12097
  clojureDocs: null,
12691
12098
  returns: {
12692
- type: 'nil',
12099
+ type: 'null',
12693
12100
  },
12694
12101
  args: {
12695
12102
  value: {
@@ -12722,7 +12129,7 @@ var assertReference = { 'assert': {
12722
12129
  linkName: 'assert_falsy',
12723
12130
  clojureDocs: null,
12724
12131
  returns: {
12725
- type: 'nil',
12132
+ type: 'null',
12726
12133
  },
12727
12134
  args: {
12728
12135
  value: {
@@ -12754,7 +12161,7 @@ var assertReference = { 'assert': {
12754
12161
  linkName: 'assert_null',
12755
12162
  clojureDocs: null,
12756
12163
  returns: {
12757
- type: 'nil',
12164
+ type: 'null',
12758
12165
  },
12759
12166
  args: {
12760
12167
  value: {
@@ -12786,7 +12193,7 @@ var assertReference = { 'assert': {
12786
12193
  linkName: 'assert_throws',
12787
12194
  clojureDocs: null,
12788
12195
  returns: {
12789
- type: 'nil',
12196
+ type: 'null',
12790
12197
  },
12791
12198
  args: {
12792
12199
  fn: {
@@ -12808,7 +12215,7 @@ var assertReference = { 'assert': {
12808
12215
  linkName: 'assert_throws_error',
12809
12216
  clojureDocs: null,
12810
12217
  returns: {
12811
- type: 'nil',
12218
+ type: 'null',
12812
12219
  },
12813
12220
  args: {
12814
12221
  'fn': {
@@ -12837,7 +12244,7 @@ var assertReference = { 'assert': {
12837
12244
  linkName: 'assert_not_throws',
12838
12245
  clojureDocs: null,
12839
12246
  returns: {
12840
- type: 'nil',
12247
+ type: 'null',
12841
12248
  },
12842
12249
  args: {
12843
12250
  fn: {
@@ -12856,7 +12263,7 @@ var assertReference = { 'assert': {
12856
12263
  } };
12857
12264
 
12858
12265
  var objectReference = {
12859
- 'dissoc': {
12266
+ dissoc: {
12860
12267
  title: 'dissoc',
12861
12268
  category: 'Object',
12862
12269
  linkName: 'dissoc',
@@ -12881,7 +12288,7 @@ var objectReference = {
12881
12288
  "\n(def o { :a 5 }) (dissoc o :a)\no",
12882
12289
  ],
12883
12290
  },
12884
- 'object': {
12291
+ object: {
12885
12292
  title: 'object',
12886
12293
  category: 'Object',
12887
12294
  linkName: 'object',
@@ -12907,7 +12314,7 @@ var objectReference = {
12907
12314
  '{:a 1 :b 2}',
12908
12315
  ],
12909
12316
  },
12910
- 'keys': {
12317
+ keys: {
12911
12318
  title: 'keys',
12912
12319
  category: 'Object',
12913
12320
  linkName: 'keys',
@@ -12929,7 +12336,7 @@ var objectReference = {
12929
12336
  '(keys (object :x 10 :y true :z "A string"))',
12930
12337
  ],
12931
12338
  },
12932
- 'vals': {
12339
+ vals: {
12933
12340
  title: 'vals',
12934
12341
  category: 'Object',
12935
12342
  linkName: 'vals',
@@ -12951,7 +12358,7 @@ var objectReference = {
12951
12358
  '(vals (object :x 10 :y true :z "A string"))',
12952
12359
  ],
12953
12360
  },
12954
- 'entries': {
12361
+ entries: {
12955
12362
  title: 'entries',
12956
12363
  category: 'Object',
12957
12364
  linkName: 'entries',
@@ -12973,12 +12380,12 @@ var objectReference = {
12973
12380
  '(entries (object :x 10 :y true :z "A string"))',
12974
12381
  ],
12975
12382
  },
12976
- 'find': {
12383
+ find: {
12977
12384
  title: 'find',
12978
12385
  category: 'Object',
12979
12386
  linkName: 'find',
12980
12387
  returns: {
12981
- type: ['array', 'nil'],
12388
+ type: ['array', 'null'],
12982
12389
  },
12983
12390
  args: {
12984
12391
  obj: {
@@ -12997,7 +12404,7 @@ var objectReference = {
12997
12404
  '(find (object :a 1 :b 2) :c)',
12998
12405
  ],
12999
12406
  },
13000
- 'merge': {
12407
+ merge: {
13001
12408
  title: 'merge',
13002
12409
  category: 'Object',
13003
12410
  linkName: 'merge',
@@ -13019,10 +12426,10 @@ var objectReference = {
13019
12426
  '(merge (object :x 10) (object :x 15 :y 20))',
13020
12427
  ],
13021
12428
  },
13022
- 'merge-with': {
13023
- title: 'merge-with',
12429
+ merge_with: {
12430
+ title: 'merge_with',
13024
12431
  category: 'Object',
13025
- linkName: 'merge-with',
12432
+ linkName: 'merge_with',
13026
12433
  returns: {
13027
12434
  type: 'object',
13028
12435
  },
@@ -13040,12 +12447,12 @@ var objectReference = {
13040
12447
  ],
13041
12448
  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.",
13042
12449
  examples: [
13043
- '(merge-with (object :x 10) (object :y 20) +)',
13044
- '(merge-with (object :x 10) (object :x 15 :y 20) +)',
13045
- '(merge-with (object :x 10) (object :x 20) (object :x 30) (object :x 40) -)',
12450
+ '(merge_with (object :x 10) (object :y 20) +)',
12451
+ '(merge_with (object :x 10) (object :x 15 :y 20) +)',
12452
+ '(merge_with (object :x 10) (object :x 20) (object :x 30) (object :x 40) -)',
13046
12453
  ],
13047
12454
  },
13048
- 'zipmap': {
12455
+ zipmap: {
13049
12456
  title: 'zipmap',
13050
12457
  category: 'Object',
13051
12458
  linkName: 'zipmap',
@@ -13072,10 +12479,10 @@ var objectReference = {
13072
12479
  '(zipmap [] [10 nil [1 2 3]])',
13073
12480
  ],
13074
12481
  },
13075
- 'select-keys': {
13076
- title: 'select-keys',
12482
+ select_keys: {
12483
+ title: 'select_keys',
13077
12484
  category: 'Object',
13078
- linkName: 'select-keys',
12485
+ linkName: 'select_keys',
13079
12486
  returns: {
13080
12487
  type: 'object',
13081
12488
  },
@@ -13093,8 +12500,8 @@ var objectReference = {
13093
12500
  ],
13094
12501
  description: 'Returns an object containing only those entries in $obj whose key is in $keys.',
13095
12502
  examples: [
13096
- '(select-keys {:a 1 :b 2 :c 3} [:a :b])',
13097
- '(select-keys {:a 1} [:a :b])',
12503
+ '(select_keys {:a 1 :b 2 :c 3} [:a :b])',
12504
+ '(select_keys {:a 1} [:a :b])',
13098
12505
  ],
13099
12506
  },
13100
12507
  };
@@ -13543,7 +12950,7 @@ var predicateReference = {
13543
12950
  variants: [
13544
12951
  { argumentNames: ['x'] },
13545
12952
  ],
13546
- description: 'Returns `true` if $x is NaN (not a number), otherwise `false`.',
12953
+ description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
13547
12954
  examples: [
13548
12955
  '(nan? 1.0)',
13549
12956
  '(nan? (/ 1 0))',
@@ -13654,7 +13061,7 @@ var predicateReference = {
13654
13061
  },
13655
13062
  args: {
13656
13063
  x: {
13657
- type: ['collection', 'string', 'nil'],
13064
+ type: ['collection', 'string', 'null'],
13658
13065
  },
13659
13066
  },
13660
13067
  variants: [
@@ -13681,7 +13088,7 @@ var predicateReference = {
13681
13088
  },
13682
13089
  args: {
13683
13090
  x: {
13684
- type: ['collection', 'string', 'nil'],
13091
+ type: ['collection', 'string', 'null'],
13685
13092
  },
13686
13093
  },
13687
13094
  variants: [
@@ -13793,10 +13200,10 @@ var regularExpressionReference = {
13793
13200
  };
13794
13201
 
13795
13202
  var specialExpressionsReference = {
13796
- 'and': {
13797
- title: 'and',
13203
+ '&&': {
13204
+ title: '&&',
13798
13205
  category: 'Special expression',
13799
- linkName: 'and',
13206
+ linkName: '-and-and',
13800
13207
  returns: {
13801
13208
  type: 'boolean',
13802
13209
  },
@@ -13809,19 +13216,20 @@ var specialExpressionsReference = {
13809
13216
  variants: [
13810
13217
  { argumentNames: ['expressions'] },
13811
13218
  ],
13812
- description: "\nComputes logical `and` function. 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.",
13219
+ 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.",
13813
13220
  examples: [
13814
- '(and 1 1)',
13815
- '(and (> 3 2) "string")',
13816
- '(and (< 3 2) "string")',
13817
- '(and true true true true)',
13818
- '(and true true 0 true)',
13221
+ '(&& 1 1)',
13222
+ '(&& (> 3 2) "string")',
13223
+ '(&& (< 3 2) "string")',
13224
+ '(&& true true true true)',
13225
+ '(&& true true 0 true)',
13819
13226
  ],
13820
13227
  },
13821
- 'or': {
13822
- title: 'or',
13228
+ '||': {
13229
+ title: '||',
13823
13230
  category: 'Special expression',
13824
- linkName: 'or',
13231
+ linkName: '-or-or',
13232
+ clojureDocs: 'or',
13825
13233
  returns: {
13826
13234
  type: 'boolean',
13827
13235
  },
@@ -13834,13 +13242,13 @@ var specialExpressionsReference = {
13834
13242
  variants: [
13835
13243
  { argumentNames: ['expressions'] },
13836
13244
  ],
13837
- description: "\nComputes logical `or` function. 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.",
13245
+ 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.",
13838
13246
  examples: [
13839
- '(or 1 1)',
13840
- '(or (> 3 2) "string")',
13841
- '(or (< 3 2) "string")',
13842
- '(or true true true true)',
13843
- '(or 1 2 3 4)',
13247
+ '(|| 1 1)',
13248
+ '(|| (> 3 2) "string")',
13249
+ '(|| (< 3 2) "string")',
13250
+ '(|| true true true true)',
13251
+ '(|| 1 2 3 4)',
13844
13252
  ],
13845
13253
  },
13846
13254
  'def': {
@@ -13905,97 +13313,12 @@ var specialExpressionsReference = {
13905
13313
  type: '*binding',
13906
13314
  rest: true,
13907
13315
  },
13908
- expressions: {
13909
- type: '*expression',
13910
- rest: true,
13911
- },
13912
- },
13913
- variants: [
13914
- { argumentNames: ['bindings', 'expressions'] },
13915
- ],
13916
- description: "\nBinds local variables. The variables lives only within $expressions.\nIt returns evaluation of the last expression in $expressions.",
13917
- examples: ["\n (let [a (+ 1 2 3 4) \n b (* 1 2 3 4)]\n (write! a b))"],
13918
- },
13919
- 'if-let': {
13920
- title: 'if-let',
13921
- category: 'Special expression',
13922
- linkName: 'if-let',
13923
- returns: {
13924
- type: 'any',
13925
- },
13926
- args: {
13927
- 'binding': {
13928
- type: '*binding',
13929
- },
13930
- 'then-expr': {
13931
- type: '*expression',
13932
- },
13933
- 'else-expr': {
13934
- type: '*expression',
13935
- },
13936
- },
13937
- variants: [
13938
- { argumentNames: ['binding', 'then-expr'] },
13939
- { argumentNames: ['binding', 'then-expr', 'else-expr'] },
13940
- ],
13941
- 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).",
13942
- examples: [
13943
- "\n(if-let [a (> (count \"Albert\") 4)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
13944
- "\n(if-let [a (> (count \"Albert\") 10)]\n (write! (str a \", is big enough\"))\n (write! \"Sorry, not big enough.\"))",
13945
- ],
13946
- },
13947
- 'when-let': {
13948
- title: 'when-let',
13949
- category: 'Special expression',
13950
- linkName: 'when-let',
13951
- returns: {
13952
- type: 'any',
13953
- },
13954
- args: {
13955
- binding: {
13956
- type: '*binding',
13957
- },
13958
- expressions: {
13959
- type: '*expression',
13960
- rest: true,
13961
- },
13962
- },
13963
- variants: [
13964
- { argumentNames: ['binding', 'expressions'] },
13965
- ],
13966
- 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.",
13967
- examples: [
13968
- "\n(when-let [a (> (count \"Albert\") 4)]\n (write! a))",
13969
- ],
13970
- },
13971
- 'when-first': {
13972
- title: 'when-first',
13973
- category: 'Special expression',
13974
- linkName: 'when-first',
13975
- returns: {
13976
- type: 'any',
13977
- },
13978
- args: {
13979
- binding: {
13980
- type: '*binding',
13981
- rest: true,
13982
- },
13983
- expressions: {
13984
- type: '*expression',
13985
- rest: true,
13986
- },
13987
13316
  },
13988
13317
  variants: [
13989
- { argumentNames: ['binding', 'expressions'] },
13990
- ],
13991
- 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.',
13992
- examples: [
13993
- "\n(when-first [x [1 2 3]]\n (write! x)\n x)",
13994
- "\n(when-first [x \"Albert\"]\n (write! x)\n x)",
13995
- "\n(when-first [x [0]]\n (write! x)\n x)",
13996
- "\n(when-first [x [nil]]\n (write! x)\n x)",
13997
- "\n(when-first [x []]\n (write! x)\n x)",
13318
+ { argumentNames: ['bindings'] },
13998
13319
  ],
13320
+ description: "\nBinds local variables.",
13321
+ examples: ["\n(let [a (+ 1 2 3 4) \n b (* 1 2 3 4)])\n(write! a b)"],
13999
13322
  },
14000
13323
  'fn': {
14001
13324
  title: 'fn',
@@ -14159,10 +13482,11 @@ var specialExpressionsReference = {
14159
13482
  '(if false (write! "TRUE"))',
14160
13483
  ],
14161
13484
  },
14162
- 'if-not': {
14163
- title: 'if-not',
13485
+ 'unless': {
13486
+ title: 'unless',
14164
13487
  category: 'Special expression',
14165
- linkName: 'if-not',
13488
+ linkName: 'unless',
13489
+ clojureDocs: 'if-not',
14166
13490
  returns: {
14167
13491
  type: 'any',
14168
13492
  },
@@ -14183,10 +13507,10 @@ var specialExpressionsReference = {
14183
13507
  ],
14184
13508
  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.',
14185
13509
  examples: [
14186
- '(if-not true (write! "TRUE") (write! "FALSE"))',
14187
- '(if-not false (write! "TRUE") (write! "FALSE"))',
14188
- '(if-not true (write! "TRUE"))',
14189
- '(if-not false (write! "TRUE"))',
13510
+ '(unless true (write! "TRUE") (write! "FALSE"))',
13511
+ '(unless false (write! "TRUE") (write! "FALSE"))',
13512
+ '(unless true (write! "TRUE"))',
13513
+ '(unless false (write! "TRUE"))',
14190
13514
  ],
14191
13515
  },
14192
13516
  'cond': {
@@ -14211,58 +13535,29 @@ var specialExpressionsReference = {
14211
13535
  "\n(cond\n false (write! \"FALSE\")\n nil (write! \"nil\"))",
14212
13536
  ],
14213
13537
  },
14214
- 'when': {
14215
- title: 'when',
14216
- category: 'Special expression',
14217
- linkName: 'when',
14218
- returns: {
14219
- type: 'any',
14220
- },
14221
- args: {
14222
- test: {
14223
- type: '*expression',
14224
- },
14225
- expressions: {
14226
- type: '*expression',
14227
- rest: true,
14228
- },
14229
- },
14230
- variants: [
14231
- { argumentNames: ['test', 'expressions'] },
14232
- ],
14233
- 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.",
14234
- examples: [
14235
- "(when true\n (write! \"Hi\")\n (write! \"There\"))",
14236
- "(when false\n (write! \"Hi\")\n (write! \"There\"))",
14237
- '(when true)',
14238
- '(when false)',
14239
- ],
14240
- },
14241
- 'when-not': {
14242
- title: 'when-not',
13538
+ 'switch': {
13539
+ title: 'switch',
14243
13540
  category: 'Special expression',
14244
- linkName: 'when-not',
13541
+ linkName: 'switch',
14245
13542
  returns: {
14246
13543
  type: 'any',
14247
13544
  },
14248
13545
  args: {
14249
- test: {
14250
- type: '*expression',
13546
+ value: {
13547
+ type: 'any',
14251
13548
  },
14252
- expressions: {
14253
- type: '*expression',
14254
- rest: true,
13549
+ conds: {
13550
+ type: '*conditions',
14255
13551
  },
14256
13552
  },
14257
13553
  variants: [
14258
- { argumentNames: ['test', 'expressions'] },
13554
+ { argumentNames: ['value', 'conds'] },
14259
13555
  ],
14260
- description: "If $test yields a falsy value, the expressions are evaluated\nand the value returned by the last `expression` is returned.\nOtherwise, if $test yields a truthy value, the $expressions are not evaluated,\nand `nil` is returned. If no `expression` is provided, `nil` is returned.",
13556
+ description: 'Used for branching. $conds are tested sequentially from the top against $value. If no branch is tested truthy, `nil` is returned.',
14261
13557
  examples: [
14262
- '(when-not true (write! "Hi") (write! "There"))',
14263
- '(when-not false (write! "Hi") (write! "There"))',
14264
- '(when-not true)',
14265
- '(when-not false)',
13558
+ "\n(switch 1\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
13559
+ "\n(switch 2\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
13560
+ "\n(switch 3\n 1 (write! \"FALSE\")\n 2 (write! \"nil\"))",
14266
13561
  ],
14267
13562
  },
14268
13563
  'comment': {
@@ -14270,7 +13565,7 @@ var specialExpressionsReference = {
14270
13565
  category: 'Special expression',
14271
13566
  linkName: 'comment',
14272
13567
  returns: {
14273
- type: 'nil',
13568
+ type: 'null',
14274
13569
  },
14275
13570
  args: {
14276
13571
  expressions: {
@@ -14311,7 +13606,7 @@ var specialExpressionsReference = {
14311
13606
  category: 'Special expression',
14312
13607
  linkName: 'recur',
14313
13608
  returns: {
14314
- type: 'nil',
13609
+ type: 'null',
14315
13610
  },
14316
13611
  args: {
14317
13612
  expressions: {
@@ -14324,9 +13619,9 @@ var specialExpressionsReference = {
14324
13619
  ],
14325
13620
  description: 'Recursevly calls enclosing function or loop with its evaluated $expressions.',
14326
13621
  examples: [
14327
- "\n(defn foo [n]\n (write! n)\n (when (not (zero? n))\n (recur\n (dec n))))\n(foo 3)",
14328
- "\n(\n (fn [n]\n (write! n)\n (when (not (zero? n))\n (recur\n (dec n))))\n 3)",
14329
- "\n(\n loop [n 3]\n (write! n)\n (when\n (not (zero? n))\n (recur (dec n))))",
13622
+ "\n(defn foo [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n(foo 3)",
13623
+ "\n(\n (fn [n]\n (write! n)\n (if (! (zero? n))\n (recur\n (dec n))))\n 3)",
13624
+ "\n(\n loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
14330
13625
  ],
14331
13626
  },
14332
13627
  'loop': {
@@ -14351,35 +13646,16 @@ var specialExpressionsReference = {
14351
13646
  ],
14352
13647
  description: 'Executes $expressions with initial $bindings. The $bindings will be replaced with the recur parameters for subsequent recursions.',
14353
13648
  examples: [
14354
- "\n(loop [n 3]\n (write! n)\n (when\n (not (zero? n))\n (recur (dec n))))",
14355
- "\n(loop [n 3]\n (write! n)\n (if\n (not (zero? n))\n (recur (dec n))\n n))",
14356
- ],
14357
- },
14358
- 'time!': {
14359
- title: 'time!',
14360
- category: 'Special expression',
14361
- linkName: 'time-exclamation',
14362
- clojureDocs: 'time',
14363
- returns: {
14364
- type: 'any',
14365
- },
14366
- args: {
14367
- expression: {
14368
- type: '*expression',
14369
- },
14370
- },
14371
- variants: [
14372
- { argumentNames: ['expression'] },
13649
+ "\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))))",
13650
+ "\n(loop [n 3]\n (write! n)\n (if\n (! (zero? n))\n (recur (dec n))\n n))",
14373
13651
  ],
14374
- description: 'Prints the time it took to evaluate $expression. Returns $expression evaluated.',
14375
- 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))"],
14376
13652
  },
14377
13653
  'doseq': {
14378
13654
  title: 'doseq',
14379
13655
  category: 'Special expression',
14380
13656
  linkName: 'doseq',
14381
13657
  returns: {
14382
- type: 'nil',
13658
+ type: 'null',
14383
13659
  },
14384
13660
  args: {
14385
13661
  bindings: {
@@ -14429,10 +13705,10 @@ var specialExpressionsReference = {
14429
13705
  "\n(for\n [x [1 2 3] y [1 2 3] z [1 2 3]\n &while (<= x y)]\n \n [x y z])",
14430
13706
  ],
14431
13707
  },
14432
- 'declared?': {
14433
- title: 'declared?',
13708
+ 'defined?': {
13709
+ title: 'defined?',
14434
13710
  category: 'Special expression',
14435
- linkName: 'declared-question',
13711
+ linkName: 'defined-question',
14436
13712
  returns: {
14437
13713
  type: 'boolean',
14438
13714
  },
@@ -14446,11 +13722,11 @@ var specialExpressionsReference = {
14446
13722
  ],
14447
13723
  description: 'Returns `true` if $n is a declared variable or a builtin function, otherwise `false`.',
14448
13724
  examples: [
14449
- '(declared? foo)',
14450
- "\n(def foo :foo)\n(declared? foo)",
14451
- '(declared? +)',
14452
- "\n(def foo nil)\n(declared? foo)",
14453
- '(declared? if)',
13725
+ '(defined? foo)',
13726
+ "\n(def foo :foo)\n(defined? foo)",
13727
+ '(defined? +)',
13728
+ "\n(def foo nil)\n(defined? foo)",
13729
+ '(defined? if)',
14454
13730
  ],
14455
13731
  },
14456
13732
  '??': {
@@ -14519,10 +13795,10 @@ var stringReference = {
14519
13795
  '(subs "A string" 100)',
14520
13796
  ],
14521
13797
  },
14522
- 'string-repeat': {
14523
- title: 'string-repeat',
13798
+ 'string_repeat': {
13799
+ title: 'string_repeat',
14524
13800
  category: 'String',
14525
- linkName: 'string-repeat',
13801
+ linkName: 'string_repeat',
14526
13802
  clojureDocs: null,
14527
13803
  returns: {
14528
13804
  type: 'number',
@@ -14540,8 +13816,8 @@ var stringReference = {
14540
13816
  ],
14541
13817
  description: 'Repeates $s $n times.',
14542
13818
  examples: [
14543
- '(string-repeat "*" 10)',
14544
- '(string-repeat "***" 0)',
13819
+ '(string_repeat "*" 10)',
13820
+ '(string_repeat "***" 0)',
14545
13821
  ],
14546
13822
  },
14547
13823
  'str': {
@@ -14591,41 +13867,10 @@ var stringReference = {
14591
13867
  '(number "-1.01")',
14592
13868
  ],
14593
13869
  },
14594
- 'number-to-string': {
14595
- title: 'number-to-string',
13870
+ 'lower_case': {
13871
+ title: 'lower_case',
14596
13872
  category: 'String',
14597
- linkName: 'number-to-string',
14598
- clojureDocs: null,
14599
- returns: {
14600
- type: 'string',
14601
- },
14602
- args: {
14603
- n: {
14604
- type: 'number',
14605
- },
14606
- base: {
14607
- type: 'number',
14608
- description: '2, 8, 10 or 16',
14609
- },
14610
- },
14611
- variants: [
14612
- { argumentNames: ['n'] },
14613
- { argumentNames: ['n', 'base'] },
14614
- ],
14615
- description: 'Converts $n to a string. If $base is not equal to `10`, $n must be a non negative integer.',
14616
- examples: [
14617
- '(number-to-string 10)',
14618
- '(number-to-string -1.01)',
14619
- '(number-to-string -.01)',
14620
- '(number-to-string 15 2)',
14621
- '(number-to-string 15 8)',
14622
- '(number-to-string 15 16)',
14623
- ],
14624
- },
14625
- 'lower-case': {
14626
- title: 'lower-case',
14627
- category: 'String',
14628
- linkName: 'lower-case',
13873
+ linkName: 'lower_case',
14629
13874
  returns: {
14630
13875
  type: 'string',
14631
13876
  },
@@ -14639,14 +13884,14 @@ var stringReference = {
14639
13884
  ],
14640
13885
  description: 'Returns $s converted to lower case.',
14641
13886
  examples: [
14642
- '(lower-case "Albert")',
14643
- '(lower-case "")',
13887
+ '(lower_case "Albert")',
13888
+ '(lower_case "")',
14644
13889
  ],
14645
13890
  },
14646
- 'upper-case': {
14647
- title: 'upper-case',
13891
+ 'upper_case': {
13892
+ title: 'upper_case',
14648
13893
  category: 'String',
14649
- linkName: 'upper-case',
13894
+ linkName: 'upper_case',
14650
13895
  clojureDocs: null,
14651
13896
  returns: {
14652
13897
  type: 'string',
@@ -14661,8 +13906,8 @@ var stringReference = {
14661
13906
  ],
14662
13907
  description: 'Returns $s converted to upper case.',
14663
13908
  examples: [
14664
- '(upper-case "Albert")',
14665
- '(upper-case "")',
13909
+ '(upper_case "Albert")',
13910
+ '(upper_case "")',
14666
13911
  ],
14667
13912
  },
14668
13913
  'trim': {
@@ -14688,10 +13933,10 @@ var stringReference = {
14688
13933
  '(trim "")',
14689
13934
  ],
14690
13935
  },
14691
- 'trim-left': {
14692
- title: 'trim-left',
13936
+ 'trim_left': {
13937
+ title: 'trim_left',
14693
13938
  category: 'String',
14694
- linkName: 'trim-left',
13939
+ linkName: 'trim_left',
14695
13940
  clojureDocs: null,
14696
13941
  returns: {
14697
13942
  type: 'string',
@@ -14706,15 +13951,15 @@ var stringReference = {
14706
13951
  ],
14707
13952
  description: 'Returns a new string with leading whitespaces removed.',
14708
13953
  examples: [
14709
- '(trim-left " Albert ")',
14710
- '(trim-left " ")',
14711
- '(trim-left "")',
13954
+ '(trim_left " Albert ")',
13955
+ '(trim_left " ")',
13956
+ '(trim_left "")',
14712
13957
  ],
14713
13958
  },
14714
- 'trim-right': {
14715
- title: 'trim-right',
13959
+ 'trim_right': {
13960
+ title: 'trim_right',
14716
13961
  category: 'String',
14717
- linkName: 'trim-right',
13962
+ linkName: 'trim_right',
14718
13963
  clojureDocs: null,
14719
13964
  returns: {
14720
13965
  type: 'string',
@@ -14729,15 +13974,15 @@ var stringReference = {
14729
13974
  ],
14730
13975
  description: 'Returns a new string with trailing whitespaces removed.',
14731
13976
  examples: [
14732
- '(trim-right " Albert ")',
14733
- '(trim-right " ")',
14734
- '(trim-right "")',
13977
+ '(trim_right " Albert ")',
13978
+ '(trim_right " ")',
13979
+ '(trim_right "")',
14735
13980
  ],
14736
13981
  },
14737
- 'pad-left': {
14738
- title: 'pad-left',
13982
+ 'pad_left': {
13983
+ title: 'pad_left',
14739
13984
  category: 'String',
14740
- linkName: 'pad-left',
13985
+ linkName: 'pad_left',
14741
13986
  clojureDocs: null,
14742
13987
  returns: {
14743
13988
  type: 'string',
@@ -14759,16 +14004,16 @@ var stringReference = {
14759
14004
  ],
14760
14005
  description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.',
14761
14006
  examples: [
14762
- '(pad-left "Albert" 20)',
14763
- '(pad-left "Albert" 20 "-*-")',
14764
- '(pad-left "Albert" 5)',
14765
- '(pad-left "Albert" -1)',
14007
+ '(pad_left "Albert" 20)',
14008
+ '(pad_left "Albert" 20 "-*-")',
14009
+ '(pad_left "Albert" 5)',
14010
+ '(pad_left "Albert" -1)',
14766
14011
  ],
14767
14012
  },
14768
- 'pad-right': {
14769
- title: 'pad-right',
14013
+ 'pad_right': {
14014
+ title: 'pad_right',
14770
14015
  category: 'String',
14771
- linkName: 'pad-right',
14016
+ linkName: 'pad_right',
14772
14017
  clojureDocs: null,
14773
14018
  returns: {
14774
14019
  type: 'string',
@@ -14790,10 +14035,10 @@ var stringReference = {
14790
14035
  ],
14791
14036
  description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.',
14792
14037
  examples: [
14793
- '(pad-right "Albert" 20)',
14794
- '(pad-right "Albert" 20 "-*-")',
14795
- '(pad-right "Albert" 5)',
14796
- '(pad-right "Albert" -1)',
14038
+ '(pad_right "Albert" 20)',
14039
+ '(pad_right "Albert" 20 "-*-")',
14040
+ '(pad_right "Albert" 5)',
14041
+ '(pad_right "Albert" -1)',
14797
14042
  ],
14798
14043
  },
14799
14044
  'split': {
@@ -14864,10 +14109,10 @@ var stringReference = {
14864
14109
  '(template "No book||||One book||||Two books||||Three books||||$1 books" 4)',
14865
14110
  ],
14866
14111
  },
14867
- 'to-char-code': {
14868
- title: 'to-char-code',
14112
+ 'to_char_code': {
14113
+ title: 'to_char_code',
14869
14114
  category: 'String',
14870
- linkName: 'to-char-code',
14115
+ linkName: 'to_char_code',
14871
14116
  clojureDocs: null,
14872
14117
  returns: {
14873
14118
  type: 'number',
@@ -14882,14 +14127,14 @@ var stringReference = {
14882
14127
  ],
14883
14128
  description: 'Return code point for first character in $c.',
14884
14129
  examples: [
14885
- '(to-char-code :A)',
14886
- '(to-char-code "Albert")',
14130
+ '(to_char_code :A)',
14131
+ '(to_char_code "Albert")',
14887
14132
  ],
14888
14133
  },
14889
- 'from-char-code': {
14890
- title: 'from-char-code',
14134
+ 'from_char_code': {
14135
+ title: 'from_char_code',
14891
14136
  category: 'String',
14892
- linkName: 'from-char-code',
14137
+ linkName: 'from_char_code',
14893
14138
  clojureDocs: null,
14894
14139
  returns: {
14895
14140
  type: 'string',
@@ -14904,14 +14149,14 @@ var stringReference = {
14904
14149
  ],
14905
14150
  description: 'Return character for code point $code.',
14906
14151
  examples: [
14907
- '(from-char-code 65)',
14908
- '(from-char-code 0)',
14152
+ '(from_char_code 65)',
14153
+ '(from_char_code 0)',
14909
14154
  ],
14910
14155
  },
14911
- 'encode-base64': {
14912
- title: 'encode-base64',
14156
+ 'encode_base64': {
14157
+ title: 'encode_base64',
14913
14158
  category: 'String',
14914
- linkName: 'encode-base64',
14159
+ linkName: 'encode_base64',
14915
14160
  clojureDocs: null,
14916
14161
  returns: {
14917
14162
  type: 'string',
@@ -14926,13 +14171,13 @@ var stringReference = {
14926
14171
  ],
14927
14172
  description: 'Returns a Base64 encoded string from $s.',
14928
14173
  examples: [
14929
- '(encode-base64 "Albert")',
14174
+ '(encode_base64 "Albert")',
14930
14175
  ],
14931
14176
  },
14932
- 'decode-base64': {
14933
- title: 'decode-base64',
14177
+ 'decode_base64': {
14178
+ title: 'decode_base64',
14934
14179
  category: 'String',
14935
- linkName: 'decode-base64',
14180
+ linkName: 'decode_base64',
14936
14181
  clojureDocs: null,
14937
14182
  returns: {
14938
14183
  type: 'string',
@@ -14947,13 +14192,13 @@ var stringReference = {
14947
14192
  ],
14948
14193
  description: 'Returns a Base64 decoded string from $base64string.',
14949
14194
  examples: [
14950
- '(decode-base64 "QWxiZXJ0IPCfkLs=")',
14195
+ '(decode_base64 "QWxiZXJ0IPCfkLs=")',
14951
14196
  ],
14952
14197
  },
14953
- 'encode-uri-component': {
14954
- title: 'encode-uri-component',
14198
+ 'encode_uri_component': {
14199
+ title: 'encode_uri_component',
14955
14200
  category: 'String',
14956
- linkName: 'encode-uri-component',
14201
+ linkName: 'encode_uri_component',
14957
14202
  clojureDocs: null,
14958
14203
  returns: {
14959
14204
  type: 'string',
@@ -14968,13 +14213,13 @@ var stringReference = {
14968
14213
  ],
14969
14214
  description: 'Returns an escaped `URI` string.',
14970
14215
  examples: [
14971
- '(encode-uri-component "Hi everyone!?")',
14216
+ '(encode_uri_component "Hi everyone!?")',
14972
14217
  ],
14973
14218
  },
14974
- 'decode-uri-component': {
14975
- title: 'decode-uri-component',
14219
+ 'decode_uri_component': {
14220
+ title: 'decode_uri_component',
14976
14221
  category: 'String',
14977
- linkName: 'decode-uri-component',
14222
+ linkName: 'decode_uri_component',
14978
14223
  clojureDocs: null,
14979
14224
  returns: {
14980
14225
  type: 'string',
@@ -14989,7 +14234,7 @@ var stringReference = {
14989
14234
  ],
14990
14235
  description: 'Returns an un-escaped `URI` string.',
14991
14236
  examples: [
14992
- '(decode-uri-component "Hi%20everyone!%3F%20%F0%9F%91%8D")',
14237
+ '(decode_uri_component "Hi%20everyone!%3F%20%F0%9F%91%8D")',
14993
14238
  ],
14994
14239
  },
14995
14240
  'join': {
@@ -15014,15 +14259,42 @@ var stringReference = {
15014
14259
  description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',
15015
14260
  examples: [
15016
14261
  '(join ["Albert" "Mojir"] " ")',
15017
- '(join (map number-to-string [0 1 2 3 4 5 6 7 8 9]) ", ")',
14262
+ '(join (map [0 1 2 3 4 5 6 7 8 9] str) ", ")',
14263
+ ],
14264
+ },
14265
+ '++': {
14266
+ title: '++',
14267
+ category: 'String',
14268
+ linkName: '-plus-plus',
14269
+ clojureDocs: null,
14270
+ returns: {
14271
+ type: 'string',
14272
+ },
14273
+ args: {
14274
+ strings: {
14275
+ type: ['string', 'number', 'null'],
14276
+ rest: true,
14277
+ },
14278
+ },
14279
+ variants: [{
14280
+ argumentNames: ['strings'],
14281
+ }],
14282
+ description: 'Concatenats $strings into one string.',
14283
+ examples: [
14284
+ '(++ "Albert" " " "Mojir")',
14285
+ '(++ "Albert" "Mojir")',
14286
+ '(++ "Albert" null "Mojir")',
14287
+ '(++ "Albert")',
14288
+ '(++)',
15018
14289
  ],
15019
14290
  },
15020
14291
  };
15021
14292
 
15022
- var bitwiseReference = { 'bit-shift-left': {
15023
- title: 'bit-shift-left',
14293
+ var bitwiseReference = { '<<': {
14294
+ title: '<<',
15024
14295
  category: 'Bitwise',
15025
- linkName: 'bit-shift-left',
14296
+ linkName: '-lt-lt',
14297
+ clojureDocs: 'bit-shift-left',
15026
14298
  returns: {
15027
14299
  type: 'integer',
15028
14300
  },
@@ -15038,11 +14310,12 @@ var bitwiseReference = { 'bit-shift-left': {
15038
14310
  { argumentNames: ['x', 'n'] },
15039
14311
  ],
15040
14312
  description: 'Shifts $x arithmetically left by $n bit positions.',
15041
- examples: ['(bit-shift-left 1 10)', '(bit-shift-left -4 2)'],
15042
- }, 'bit-shift-right': {
15043
- title: 'bit-shift-right',
14313
+ examples: ['(<< 1 10)', '(<< -4 2)'],
14314
+ }, '>>': {
14315
+ title: '>>',
15044
14316
  category: 'Bitwise',
15045
- linkName: 'bit-shift-right',
14317
+ linkName: '-gt-gt',
14318
+ clojureDocs: 'bit-shift-right',
15046
14319
  returns: {
15047
14320
  type: 'integer',
15048
14321
  },
@@ -15058,11 +14331,12 @@ var bitwiseReference = { 'bit-shift-left': {
15058
14331
  { argumentNames: ['x', 'n'] },
15059
14332
  ],
15060
14333
  description: 'Shifts $x arithmetically right by $n bit positions.',
15061
- examples: ['(bit-shift-right 2048 10)', '(bit-shift-right 4 10)'],
15062
- }, 'unsigned-bit-shift-right': {
15063
- title: 'unsigned-bit-shift-right',
14334
+ examples: ['(>> 2048 10)', '(>> 4 10)'],
14335
+ }, '>>>': {
14336
+ title: '>>>',
15064
14337
  category: 'Bitwise',
15065
- linkName: 'unsigned-bit-shift-right',
14338
+ linkName: '-gt-gt-gt',
14339
+ clojureDocs: 'unsigned-bit-shift-right',
15066
14340
  returns: {
15067
14341
  type: 'integer',
15068
14342
  },
@@ -15078,11 +14352,12 @@ var bitwiseReference = { 'bit-shift-left': {
15078
14352
  { argumentNames: ['x', 'n'] },
15079
14353
  ],
15080
14354
  description: 'Shifts $x arithmetically right by $n bit positions without sign extension.',
15081
- examples: ['(unsigned-bit-shift-right 2048 10)', '(unsigned-bit-shift-right 4 10)', '(unsigned-bit-shift-right -1 10)'],
15082
- }, 'bit-not': {
15083
- title: 'bit-not',
14355
+ examples: ['(>>> 2048 10)', '(>>> 4 10)', '(>>> -1 10)'],
14356
+ }, '~': {
14357
+ title: '~',
15084
14358
  category: 'Bitwise',
15085
- linkName: 'bit-not',
14359
+ linkName: '-tilde',
14360
+ clojureDocs: 'bit-not',
15086
14361
  returns: {
15087
14362
  type: 'integer',
15088
14363
  },
@@ -15095,11 +14370,12 @@ var bitwiseReference = { 'bit-shift-left': {
15095
14370
  { argumentNames: ['x'] },
15096
14371
  ],
15097
14372
  description: 'Returns bitwise `not` of $x.',
15098
- examples: ['(bit-not 0)', '(bit-not 255)'],
15099
- }, 'bit-and': {
15100
- title: 'bit-and',
14373
+ examples: ['(~ 0)', '(~ 255)'],
14374
+ }, '&': {
14375
+ title: '&',
15101
14376
  category: 'Bitwise',
15102
- linkName: 'bit-and',
14377
+ linkName: '-and',
14378
+ clojureDocs: 'bit-and',
15103
14379
  returns: {
15104
14380
  type: 'integer',
15105
14381
  },
@@ -15121,13 +14397,14 @@ var bitwiseReference = { 'bit-shift-left': {
15121
14397
  ],
15122
14398
  description: 'Returns bitwise `and` of all arguments.',
15123
14399
  examples: [
15124
- '(bit-and 0b0011 0b0110)',
15125
- '(bit-and 0b0011 0b0110 0b1001)',
14400
+ '(& 0b0011 0b0110)',
14401
+ '(& 0b0011 0b0110 0b1001)',
15126
14402
  ],
15127
- }, 'bit-and-not': {
15128
- title: 'bit-and-not',
14403
+ }, '&!': {
14404
+ title: '&!',
15129
14405
  category: 'Bitwise',
15130
- linkName: 'bit-and-not',
14406
+ linkName: '-and-exclamation',
14407
+ clojureDocs: 'bit-and-not',
15131
14408
  returns: {
15132
14409
  type: 'integer',
15133
14410
  },
@@ -15148,11 +14425,12 @@ var bitwiseReference = { 'bit-shift-left': {
15148
14425
  { argumentNames: ['x', 'y', 'rest'] },
15149
14426
  ],
15150
14427
  description: 'Returns bitwise `and` with complement.',
15151
- examples: ['(bit-and-not 0b0011 0b0110)', '(bit-and-not 0b0011 0b0110 0b1001)'],
15152
- }, 'bit-or': {
15153
- title: 'bit-or',
14428
+ examples: ['(&! 0b0011 0b0110)', '(&! 0b0011 0b0110 0b1001)'],
14429
+ }, '|': {
14430
+ title: '|',
15154
14431
  category: 'Bitwise',
15155
- linkName: 'bit-or',
14432
+ linkName: '-or',
14433
+ clojureDocs: 'bit-or',
15156
14434
  returns: {
15157
14435
  type: 'integer',
15158
14436
  },
@@ -15173,11 +14451,12 @@ var bitwiseReference = { 'bit-shift-left': {
15173
14451
  { argumentNames: ['x', 'y', 'rest'] },
15174
14452
  ],
15175
14453
  description: 'Returns bitwise `or` of all arguments.',
15176
- examples: ['(bit-or 0b0011 0b0110)', '(bit-or 0b1000 0b0100 0b0010)'],
15177
- }, 'bit-xor': {
15178
- title: 'bit-xor',
14454
+ examples: ['(| 0b0011 0b0110)', '(| 0b1000 0b0100 0b0010)'],
14455
+ }, '^': {
14456
+ title: '^',
15179
14457
  category: 'Bitwise',
15180
- linkName: 'bit-xor',
14458
+ linkName: '-caret',
14459
+ clojureDocs: 'bit-xor',
15181
14460
  returns: {
15182
14461
  type: 'integer',
15183
14462
  },
@@ -15198,11 +14477,11 @@ var bitwiseReference = { 'bit-shift-left': {
15198
14477
  { argumentNames: ['x', 'y', 'rest'] },
15199
14478
  ],
15200
14479
  description: 'Returns bitwise `xor` of all arguments.',
15201
- examples: ['(bit-xor 0b0011 0b0110)', '(bit-xor 0b11110000 0b00111100 0b10101010)'],
15202
- }, 'bit-flip': {
15203
- title: 'bit-flip',
14480
+ examples: ['(^ 0b0011 0b0110)', '(^ 0b11110000 0b00111100 0b10101010)'],
14481
+ }, 'bit_flip': {
14482
+ title: 'bit_flip',
15204
14483
  category: 'Bitwise',
15205
- linkName: 'bit-flip',
14484
+ linkName: 'bit_flip',
15206
14485
  returns: {
15207
14486
  type: 'integer',
15208
14487
  },
@@ -15218,11 +14497,11 @@ var bitwiseReference = { 'bit-shift-left': {
15218
14497
  { argumentNames: ['x', 'n'] },
15219
14498
  ],
15220
14499
  description: 'Flips bit number $n.',
15221
- examples: ['(bit-flip 0b0011 1)', '(bit-flip 0b1100 1)'],
15222
- }, 'bit-clear': {
15223
- title: 'bit-clear',
14500
+ examples: ['(bit_flip 0b0011 1)', '(bit_flip 0b1100 1)'],
14501
+ }, 'bit_clear': {
14502
+ title: 'bit_clear',
15224
14503
  category: 'Bitwise',
15225
- linkName: 'bit-clear',
14504
+ linkName: 'bit_clear',
15226
14505
  returns: {
15227
14506
  type: 'integer',
15228
14507
  },
@@ -15238,11 +14517,11 @@ var bitwiseReference = { 'bit-shift-left': {
15238
14517
  { argumentNames: ['x', 'n'] },
15239
14518
  ],
15240
14519
  description: 'Clears bit number $n.',
15241
- examples: ['(bit-clear 0b0011 1)', '(bit-clear 0b1100 1)'],
15242
- }, 'bit-set': {
15243
- title: 'bit-set',
14520
+ examples: ['(bit_clear 0b0011 1)', '(bit_clear 0b1100 1)'],
14521
+ }, 'bit_set': {
14522
+ title: 'bit_set',
15244
14523
  category: 'Bitwise',
15245
- linkName: 'bit-set',
14524
+ linkName: 'bit_set',
15246
14525
  returns: {
15247
14526
  type: 'integer',
15248
14527
  },
@@ -15258,11 +14537,11 @@ var bitwiseReference = { 'bit-shift-left': {
15258
14537
  { argumentNames: ['x', 'n'] },
15259
14538
  ],
15260
14539
  description: 'Sets bit number $n.',
15261
- examples: ['(bit-set 0b0011 1)', '(bit-set 0b1100 1)'],
15262
- }, 'bit-test': {
15263
- title: 'bit-test',
14540
+ examples: ['(bit_set 0b0011 1)', '(bit_set 0b1100 1)'],
14541
+ }, 'bit_test': {
14542
+ title: 'bit_test',
15264
14543
  category: 'Bitwise',
15265
- linkName: 'bit-test',
14544
+ linkName: 'bit_test',
15266
14545
  returns: {
15267
14546
  type: 'boolean',
15268
14547
  },
@@ -15278,7 +14557,7 @@ var bitwiseReference = { 'bit-shift-left': {
15278
14557
  { argumentNames: ['x', 'n'] },
15279
14558
  ],
15280
14559
  description: 'Checks if bit number $n is set.',
15281
- examples: ['(bit-test 0b0011 1)', '(bit-test 0b1100 1)'],
14560
+ examples: ['(bit_test 0b0011 1)', '(bit_test 0b1100 1)'],
15282
14561
  } };
15283
14562
 
15284
14563
  var shorthand = {
@@ -15606,13 +14885,13 @@ var api = {
15606
14885
  '*',
15607
14886
  '/',
15608
14887
  'mod',
15609
- 'rem',
14888
+ '%',
15610
14889
  'quot',
15611
14890
  'inc',
15612
14891
  'dec',
15613
14892
  'sqrt',
15614
14893
  'cbrt',
15615
- 'pow',
14894
+ '**',
15616
14895
  'exp',
15617
14896
  'round',
15618
14897
  'trunc',
@@ -15662,23 +14941,20 @@ var api = {
15662
14941
  ],
15663
14942
  misc: [
15664
14943
  '!=',
15665
- '=',
14944
+ '==',
15666
14945
  '<',
15667
14946
  '>',
15668
14947
  '<=',
15669
14948
  '>=',
15670
- 'not',
14949
+ '!',
15671
14950
  'write!',
15672
- 'inst-ms!',
15673
- 'iso-date-time->inst-ms',
15674
- 'inst-ms->iso-date-time',
14951
+ 'iso_date>epoch',
14952
+ 'epoch>iso_date',
15675
14953
  'boolean',
15676
14954
  'compare',
15677
- 'lits-version!',
15678
- 'uuid!',
15679
14955
  'equal?',
15680
- 'json-parse',
15681
- 'json-stringify',
14956
+ 'json_parse',
14957
+ 'json_stringify',
15682
14958
  ],
15683
14959
  object: [
15684
14960
  'dissoc',
@@ -15688,9 +14964,9 @@ var api = {
15688
14964
  'entries',
15689
14965
  'find',
15690
14966
  'merge',
15691
- 'merge-with',
14967
+ 'merge_with',
15692
14968
  'zipmap',
15693
- 'select-keys',
14969
+ 'select_keys',
15694
14970
  ],
15695
14971
  predicate: [
15696
14972
  'boolean?',
@@ -15724,70 +15000,65 @@ var api = {
15724
15000
  'replace',
15725
15001
  ],
15726
15002
  specialExpressions: [
15727
- 'and',
15728
- 'or',
15003
+ '&&',
15004
+ '||',
15729
15005
  'def',
15730
15006
  'defs',
15731
15007
  'let',
15732
- 'if-let',
15733
- 'when-let',
15734
- 'when-first',
15735
15008
  'fn',
15736
15009
  'defn',
15737
15010
  'defns',
15738
15011
  'try',
15739
15012
  'throw',
15740
15013
  'if',
15741
- 'if-not',
15014
+ 'unless',
15742
15015
  'cond',
15743
- 'when',
15744
- 'when-not',
15016
+ 'switch',
15745
15017
  'comment',
15746
15018
  'do',
15747
15019
  'recur',
15748
15020
  'loop',
15749
- 'time!',
15750
15021
  'doseq',
15751
15022
  'for',
15752
- 'declared?',
15023
+ 'defined?',
15753
15024
  '??',
15754
15025
  ],
15755
15026
  string: [
15756
15027
  'subs',
15757
- 'string-repeat',
15028
+ 'string_repeat',
15758
15029
  'str',
15759
15030
  'number',
15760
- 'number-to-string',
15761
- 'lower-case',
15762
- 'upper-case',
15031
+ 'lower_case',
15032
+ 'upper_case',
15763
15033
  'trim',
15764
- 'trim-left',
15765
- 'trim-right',
15766
- 'pad-left',
15767
- 'pad-right',
15034
+ 'trim_left',
15035
+ 'trim_right',
15036
+ 'pad_left',
15037
+ 'pad_right',
15768
15038
  'split',
15769
15039
  'template',
15770
- 'to-char-code',
15771
- 'from-char-code',
15772
- 'encode-base64',
15773
- 'decode-base64',
15774
- 'encode-uri-component',
15775
- 'decode-uri-component',
15040
+ 'to_char_code',
15041
+ 'from_char_code',
15042
+ 'encode_base64',
15043
+ 'decode_base64',
15044
+ 'encode_uri_component',
15045
+ 'decode_uri_component',
15776
15046
  'join',
15047
+ '++',
15777
15048
  ],
15778
15049
  bitwise: [
15779
- 'bit-shift-left',
15780
- 'bit-shift-right',
15781
- 'unsigned-bit-shift-right',
15782
- 'bit-not',
15783
- 'bit-and',
15784
- 'bit-and-not',
15785
- 'bit-or',
15786
- 'bit-xor',
15787
- 'bit-flip',
15788
- 'bit-clear',
15789
- 'bit-set',
15790
- 'bit-test',
15050
+ '<<',
15051
+ '>>',
15052
+ '>>>',
15053
+ '~',
15054
+ '&',
15055
+ '&!',
15056
+ '|',
15057
+ '^',
15058
+ 'bit_flip',
15059
+ 'bit_clear',
15060
+ 'bit_set',
15061
+ 'bit_test',
15791
15062
  ],
15792
15063
  assert: [
15793
15064
  'assert',
@@ -15874,7 +15145,7 @@ var dataTypes = [
15874
15145
  'function',
15875
15146
  'integer',
15876
15147
  'any',
15877
- 'nil',
15148
+ 'null',
15878
15149
  'collection',
15879
15150
  'sequence',
15880
15151
  'regexp',