@mojir/lits 2.0.13 → 2.0.15

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 (66) hide show
  1. package/dist/cli/cli.js +978 -819
  2. package/dist/cli/reference/api.d.ts +8 -8
  3. package/dist/cli/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +1 -1
  4. package/dist/cli/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +1 -1
  5. package/dist/cli/src/analyze/calculateOutcomes/calculateSwitchOutcomes.d.ts +3 -0
  6. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +1 -1
  7. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +1 -1
  8. package/dist/cli/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +1 -1
  9. package/dist/cli/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +14 -14
  10. package/dist/cli/src/builtin/index.d.ts +9 -9
  11. package/dist/cli/src/builtin/specialExpressions/and.d.ts +1 -1
  12. package/dist/cli/src/builtin/specialExpressions/{if-let.d.ts → if_let.d.ts} +1 -1
  13. package/dist/{src/builtin/specialExpressions/if-not.d.ts → cli/src/builtin/specialExpressions/if_not.d.ts} +1 -1
  14. package/dist/cli/src/builtin/specialExpressions/or.d.ts +1 -1
  15. package/dist/{src/builtin/specialExpressions/time.d.ts → cli/src/builtin/specialExpressions/switch.d.ts} +2 -2
  16. package/dist/cli/src/builtin/specialExpressions/{when-first.d.ts → when_first.d.ts} +1 -1
  17. package/dist/{src/builtin/specialExpressions/when-let.d.ts → cli/src/builtin/specialExpressions/when_let.d.ts} +1 -1
  18. package/dist/cli/src/builtin/specialExpressions/{when-not.d.ts → when_not.d.ts} +1 -1
  19. package/dist/cli/src/identifier.d.ts +2 -2
  20. package/dist/cli/src/parser/AlgebraicParser.d.ts +17 -2
  21. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +106 -7
  22. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  23. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +6 -5
  24. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
  25. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +1 -1
  26. package/dist/cli/src/tokenizer/utils.d.ts +1 -1
  27. package/dist/cli/src/typeGuards/index.d.ts +1 -0
  28. package/dist/index.esm.js +978 -821
  29. package/dist/index.esm.js.map +1 -1
  30. package/dist/index.js +978 -821
  31. package/dist/index.js.map +1 -1
  32. package/dist/lits.iife.js +978 -821
  33. package/dist/lits.iife.js.map +1 -1
  34. package/dist/reference/api.d.ts +8 -8
  35. package/dist/src/analyze/calculateOutcomes/calculateIfLetOutcomes.d.ts +1 -1
  36. package/dist/src/analyze/calculateOutcomes/calculateIfNotOutcomes.d.ts +1 -1
  37. package/dist/src/analyze/calculateOutcomes/calculateSwitchOutcomes.d.ts +3 -0
  38. package/dist/src/analyze/calculateOutcomes/calculateWhenFirstOutcomes.d.ts +1 -1
  39. package/dist/src/analyze/calculateOutcomes/calculateWhenLetOutcomes.d.ts +1 -1
  40. package/dist/src/analyze/calculateOutcomes/calculateWhenNotOutcomes.d.ts +1 -1
  41. package/dist/src/analyze/calculateOutcomes/specialExpressionCalculators.d.ts +14 -14
  42. package/dist/src/builtin/index.d.ts +9 -9
  43. package/dist/src/builtin/specialExpressions/and.d.ts +1 -1
  44. package/dist/src/builtin/specialExpressions/{if-let.d.ts → if_let.d.ts} +1 -1
  45. package/dist/{cli/src/builtin/specialExpressions/if-not.d.ts → src/builtin/specialExpressions/if_not.d.ts} +1 -1
  46. package/dist/src/builtin/specialExpressions/or.d.ts +1 -1
  47. package/dist/{cli/src/builtin/specialExpressions/time.d.ts → src/builtin/specialExpressions/switch.d.ts} +2 -2
  48. package/dist/src/builtin/specialExpressions/{when-first.d.ts → when_first.d.ts} +1 -1
  49. package/dist/{cli/src/builtin/specialExpressions/when-let.d.ts → src/builtin/specialExpressions/when_let.d.ts} +1 -1
  50. package/dist/src/builtin/specialExpressions/{when-not.d.ts → when_not.d.ts} +1 -1
  51. package/dist/src/identifier.d.ts +2 -2
  52. package/dist/src/parser/AlgebraicParser.d.ts +17 -2
  53. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +106 -7
  54. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  55. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +6 -5
  56. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +1 -1
  57. package/dist/src/tokenizer/polish/polishTokens.d.ts +1 -1
  58. package/dist/src/tokenizer/utils.d.ts +1 -1
  59. package/dist/src/typeGuards/index.d.ts +1 -0
  60. package/dist/testFramework.esm.js +595 -405
  61. package/dist/testFramework.esm.js.map +1 -1
  62. package/dist/testFramework.js +595 -405
  63. package/dist/testFramework.js.map +1 -1
  64. package/package.json +1 -1
  65. package/dist/cli/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
  66. package/dist/src/analyze/calculateOutcomes/calculateTimeOutcomes.d.ts +0 -3
@@ -236,6 +236,12 @@ function isFunctionType(type) {
236
236
  return typeof type === 'number' && functionTypeName.has(type);
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
 
@@ -408,28 +418,28 @@ var otherSymbolicOperators = [
408
418
  '.', // property accessor
409
419
  ',', // item separator
410
420
  '=', // property assignment
421
+ ';', // statement terminator
411
422
  ];
412
423
  var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(symbolicUnaryOperators), false), __read(symbolicBinaryOperators), false), __read(otherSymbolicOperators), false);
413
424
  var nonFunctionOperators = [
414
425
  '??',
415
- 'and',
426
+ '&&',
416
427
  'comment',
417
428
  'cond',
418
429
  'declared?',
419
430
  'if',
420
- 'if-not',
421
- 'or',
431
+ 'if_not',
432
+ '||',
422
433
  'when',
423
- 'when-not',
434
+ 'when_not',
424
435
  'do',
425
- 'time!',
426
436
  'throw',
427
437
  'let',
428
438
  'def',
429
439
  'defs',
430
- 'if-let',
431
- 'when-let',
432
- 'when-first',
440
+ 'if_let',
441
+ 'when_let',
442
+ 'when_first',
433
443
  'fn',
434
444
  'defn',
435
445
  'defns',
@@ -460,7 +470,7 @@ function isA_SymbolToken(token) {
460
470
  }
461
471
  function assertA_SymbolToken(token) {
462
472
  if (!isA_SymbolToken(token)) {
463
- throwUnexpectedToken('A_Symbol', token);
473
+ throwUnexpectedToken('A_Symbol', undefined, token);
464
474
  }
465
475
  }
466
476
  function asA_SymbolToken(token) {
@@ -470,8 +480,19 @@ function asA_SymbolToken(token) {
470
480
  function isA_BinaryOperatorToken(token) {
471
481
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Operator' && isSymbolicBinaryOperator(token[1]);
472
482
  }
473
- function isA_ReservedSymbolToken(token) {
474
- return (token === null || token === void 0 ? void 0 : token[0]) === 'A_ReservedSymbol';
483
+ function isA_ReservedSymbolToken(token, symbolName) {
484
+ if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_ReservedSymbol') {
485
+ return false;
486
+ }
487
+ if (symbolName && token[1] !== symbolName) {
488
+ return false;
489
+ }
490
+ return true;
491
+ }
492
+ function assertA_ReservedSymbolToken(token, symbolName) {
493
+ if (!isA_ReservedSymbolToken(token, symbolName)) {
494
+ throwUnexpectedToken('A_ReservedSymbol', symbolName, token);
495
+ }
475
496
  }
476
497
  function isA_CommentToken(token) {
477
498
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_SingleLineComment';
@@ -490,10 +511,9 @@ function isA_OperatorToken(token, operatorName) {
490
511
  }
491
512
  function assertA_OperatorToken(token, operatorName) {
492
513
  if (!isA_OperatorToken(token, operatorName)) {
493
- if (operatorName) {
514
+ {
494
515
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
495
516
  }
496
- throwUnexpectedToken('A_Operator', token);
497
517
  }
498
518
  }
499
519
  function isA_WhitespaceToken(token) {
@@ -506,7 +526,7 @@ function isA_BasePrefixedNumberToken(token) {
506
526
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_BasePrefixedNumber';
507
527
  }
508
528
 
509
- var modifierNames = ['&', '&let', '&when', '&while'];
529
+ var modifierNames = ['&rest', '&let', '&when', '&while'];
510
530
  var polishOnlySimpleTokenTypes = [
511
531
  'P_FnShorthand',
512
532
  ];
@@ -529,7 +549,7 @@ function isP_StringShorthandToken(token) {
529
549
  }
530
550
  function assertP_StringShorthandToken(token) {
531
551
  if (!isP_StringShorthandToken(token)) {
532
- throwUnexpectedToken('P_StringShorthand', token);
552
+ throwUnexpectedToken('P_StringShorthand', undefined, token);
533
553
  }
534
554
  }
535
555
  function asP_StringShorthandToken(token) {
@@ -541,7 +561,7 @@ function isP_SymbolToken(token) {
541
561
  }
542
562
  function assertP_SymbolToken(token) {
543
563
  if (!isP_SymbolToken(token)) {
544
- throwUnexpectedToken('P_Symbol', token);
564
+ throwUnexpectedToken('P_Symbol', undefined, token);
545
565
  }
546
566
  }
547
567
  function asP_SymbolToken(token) {
@@ -559,7 +579,7 @@ function isP_RegexpShorthandToken(token) {
559
579
  }
560
580
  function assertP_RegexpShorthandToken(token) {
561
581
  if (!isP_RegexpShorthandToken(token)) {
562
- throwUnexpectedToken('P_RegexpShorthand', token);
582
+ throwUnexpectedToken('P_RegexpShorthand', undefined, token);
563
583
  }
564
584
  }
565
585
  function asP_RegexpShorthandToken(token) {
@@ -574,7 +594,7 @@ function isP_CollectionAccessorToken(token) {
574
594
  }
575
595
  function assertP_CollectionAccessorToken(token) {
576
596
  if (!isP_CollectionAccessorToken(token)) {
577
- throwUnexpectedToken('P_CollectionAccessor', token);
597
+ throwUnexpectedToken('P_CollectionAccessor', undefined, token);
578
598
  }
579
599
  }
580
600
  function asP_CollectionAccessorToken(token) {
@@ -586,7 +606,7 @@ function isP_CommentToken(token) {
586
606
  }
587
607
  function assertP_CommentToken(token) {
588
608
  if (!isP_CommentToken(token)) {
589
- throwUnexpectedToken('P_Comment', token);
609
+ throwUnexpectedToken('P_Comment', undefined, token);
590
610
  }
591
611
  }
592
612
  function asP_CommentToken(token) {
@@ -601,7 +621,7 @@ function isP_NumberToken(token) {
601
621
  }
602
622
  function assertP_NumberToken(token) {
603
623
  if (!isP_NumberToken(token)) {
604
- throwUnexpectedToken('P_Number', token);
624
+ throwUnexpectedToken('P_Number', undefined, token);
605
625
  }
606
626
  }
607
627
 
@@ -669,12 +689,6 @@ function valueToString(value) {
669
689
  return JSON.stringify(value);
670
690
  }
671
691
 
672
- function getSourceCodeInfo(anyValue, sourceCodeInfo) {
673
- var _a;
674
- // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
675
- return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
676
- }
677
-
678
692
  function getRangeString(options) {
679
693
  var hasUpperAndLowerBound = (typeof options.gt === 'number' || typeof options.gte === 'number')
680
694
  && (typeof options.lt === 'number' || typeof options.lte === 'number');
@@ -807,7 +821,7 @@ function isExpressionNode(value) {
807
821
  }
808
822
 
809
823
  var specialExpressionCommentRemovers = {
810
- 'and': function (node, removeOptions) {
824
+ '&&': function (node, removeOptions) {
811
825
  removeOptions.removeCommenNodesFromArray(node.p);
812
826
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
813
827
  },
@@ -819,6 +833,10 @@ var specialExpressionCommentRemovers = {
819
833
  removeOptions.removeCommenNodesFromArray(node.p);
820
834
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
821
835
  },
836
+ 'switch': function (node, removeOptions) {
837
+ removeOptions.removeCommenNodesFromArray(node.p);
838
+ node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
839
+ },
822
840
  'declared?': function (node, removeOptions) {
823
841
  removeOptions.removeCommenNodesFromArray(node.p);
824
842
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
@@ -840,12 +858,12 @@ var specialExpressionCommentRemovers = {
840
858
  'doseq': function (_node, _removeOptions) { },
841
859
  'fn': function (_node, _removeOptions) { },
842
860
  'for': function (_node, _removeOptions) { },
843
- 'if-let': function (_node, _removeOptions) { },
861
+ 'if_let': function (_node, _removeOptions) { },
844
862
  'if': function (node, removeOptions) {
845
863
  removeOptions.removeCommenNodesFromArray(node.p);
846
864
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
847
865
  },
848
- 'if-not': function (node, removeOptions) {
866
+ 'if_not': function (node, removeOptions) {
849
867
  removeOptions.removeCommenNodesFromArray(node.p);
850
868
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
851
869
  },
@@ -857,7 +875,7 @@ var specialExpressionCommentRemovers = {
857
875
  });
858
876
  },
859
877
  'loop': function (_node, _removeOptions) { },
860
- 'or': function (node, removeOptions) {
878
+ '||': function (node, removeOptions) {
861
879
  removeOptions.removeCommenNodesFromArray(node.p);
862
880
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
863
881
  },
@@ -869,19 +887,15 @@ var specialExpressionCommentRemovers = {
869
887
  removeOptions.removeCommenNodesFromArray(node.p);
870
888
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
871
889
  },
872
- 'time!': function (node, removeOptions) {
873
- removeOptions.removeCommenNodesFromArray(node.p);
874
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
875
- },
876
890
  'throw': function (node, removeOptions) {
877
891
  removeOptions.removeCommenNodesFromArray(node.p);
878
892
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
879
893
  },
880
894
  'try': function (_node, _removeOptions) { },
881
- 'when-first': function (_node, _removeOptions) { },
882
- 'when-let': function (_node, _removeOptions) { },
895
+ 'when_first': function (_node, _removeOptions) { },
896
+ 'when_let': function (_node, _removeOptions) { },
883
897
  'when': function (_node, _removeOptions) { },
884
- 'when-not': function (_node, _removeOptions) { },
898
+ 'when_not': function (_node, _removeOptions) { },
885
899
  };
886
900
  function removeCommentNodesFromSpecialExpression(node, removeOptions) {
887
901
  var uncommenter = specialExpressionCommentRemovers[node.n];
@@ -923,6 +937,13 @@ function assertEvenNumberOfParams(node) {
923
937
  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);
924
938
  }
925
939
  }
940
+ function assertOddNumberOfParams(node) {
941
+ var _a;
942
+ var length = withoutCommentNodes(node.p).length;
943
+ if (length % 2 !== 1) {
944
+ 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);
945
+ }
946
+ }
926
947
  function assertNumberOfParams(count, node) {
927
948
  var _a, _b;
928
949
  assertCount({
@@ -967,7 +988,7 @@ function assertCount(_a) {
967
988
  }
968
989
 
969
990
  var bitwiseNormalExpression = {
970
- 'bit-shift-left': {
991
+ '<<': {
971
992
  evaluate: function (_a, sourceCodeInfo) {
972
993
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
973
994
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -976,7 +997,7 @@ var bitwiseNormalExpression = {
976
997
  },
977
998
  validate: function (node) { return assertNumberOfParams(2, node); },
978
999
  },
979
- 'bit-shift-right': {
1000
+ '>>': {
980
1001
  evaluate: function (_a, sourceCodeInfo) {
981
1002
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
982
1003
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -985,7 +1006,7 @@ var bitwiseNormalExpression = {
985
1006
  },
986
1007
  validate: function (node) { return assertNumberOfParams(2, node); },
987
1008
  },
988
- 'unsigned-bit-shift-right': {
1009
+ '>>>': {
989
1010
  evaluate: function (_a, sourceCodeInfo) {
990
1011
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
991
1012
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -994,7 +1015,7 @@ var bitwiseNormalExpression = {
994
1015
  },
995
1016
  validate: function (node) { return assertNumberOfParams(2, node); },
996
1017
  },
997
- 'bit-not': {
1018
+ '~': {
998
1019
  evaluate: function (_a, sourceCodeInfo) {
999
1020
  var _b = __read(_a, 1), num = _b[0];
1000
1021
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1002,7 +1023,7 @@ var bitwiseNormalExpression = {
1002
1023
  },
1003
1024
  validate: function (node) { return assertNumberOfParams(1, node); },
1004
1025
  },
1005
- 'bit-and': {
1026
+ '&': {
1006
1027
  evaluate: function (_a, sourceCodeInfo) {
1007
1028
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1008
1029
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1013,7 +1034,7 @@ var bitwiseNormalExpression = {
1013
1034
  },
1014
1035
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1015
1036
  },
1016
- 'bit-and-not': {
1037
+ '&!': {
1017
1038
  evaluate: function (_a, sourceCodeInfo) {
1018
1039
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1019
1040
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1024,7 +1045,7 @@ var bitwiseNormalExpression = {
1024
1045
  },
1025
1046
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1026
1047
  },
1027
- 'bit-or': {
1048
+ '|': {
1028
1049
  evaluate: function (_a, sourceCodeInfo) {
1029
1050
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1030
1051
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1035,7 +1056,7 @@ var bitwiseNormalExpression = {
1035
1056
  },
1036
1057
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1037
1058
  },
1038
- 'bit-xor': {
1059
+ '^': {
1039
1060
  evaluate: function (_a, sourceCodeInfo) {
1040
1061
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1041
1062
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1046,7 +1067,7 @@ var bitwiseNormalExpression = {
1046
1067
  },
1047
1068
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1048
1069
  },
1049
- 'bit-flip': {
1070
+ 'bit_flip': {
1050
1071
  evaluate: function (_a, sourceCodeInfo) {
1051
1072
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1052
1073
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1056,7 +1077,7 @@ var bitwiseNormalExpression = {
1056
1077
  },
1057
1078
  validate: function (node) { return assertNumberOfParams(2, node); },
1058
1079
  },
1059
- 'bit-set': {
1080
+ 'bit_set': {
1060
1081
  evaluate: function (_a, sourceCodeInfo) {
1061
1082
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1062
1083
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1066,7 +1087,7 @@ var bitwiseNormalExpression = {
1066
1087
  },
1067
1088
  validate: function (node) { return assertNumberOfParams(2, node); },
1068
1089
  },
1069
- 'bit-clear': {
1090
+ 'bit_clear': {
1070
1091
  evaluate: function (_a, sourceCodeInfo) {
1071
1092
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1072
1093
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1076,7 +1097,7 @@ var bitwiseNormalExpression = {
1076
1097
  },
1077
1098
  validate: function (node) { return assertNumberOfParams(2, node); },
1078
1099
  },
1079
- 'bit-test': {
1100
+ 'bit_test': {
1080
1101
  evaluate: function (_a, sourceCodeInfo) {
1081
1102
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1082
1103
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -2777,7 +2798,7 @@ var mathNormalExpression = {
2777
2798
  },
2778
2799
  validate: function (node) { return assertNumberOfParams(2, node); },
2779
2800
  },
2780
- 'rem': {
2801
+ '%': {
2781
2802
  evaluate: function (_a, sourceCodeInfo) {
2782
2803
  var _b = __read(_a, 2), dividend = _b[0], divisor = _b[1];
2783
2804
  assertNumber(dividend, sourceCodeInfo);
@@ -2803,7 +2824,7 @@ var mathNormalExpression = {
2803
2824
  },
2804
2825
  validate: function (node) { return assertNumberOfParams(1, node); },
2805
2826
  },
2806
- 'pow': {
2827
+ '**': {
2807
2828
  evaluate: function (_a, sourceCodeInfo) {
2808
2829
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
2809
2830
  assertNumber(first, sourceCodeInfo);
@@ -3080,10 +3101,6 @@ var mathNormalExpression = {
3080
3101
  },
3081
3102
  };
3082
3103
 
3083
- var version = "2.0.13";
3084
-
3085
- var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
3086
- var xyRegexp = /[xy]/g;
3087
3104
  var miscNormalExpression = {
3088
3105
  '!=': {
3089
3106
  evaluate: function (params) {
@@ -3097,7 +3114,7 @@ var miscNormalExpression = {
3097
3114
  },
3098
3115
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3099
3116
  },
3100
- '=': {
3117
+ '==': {
3101
3118
  evaluate: function (_a) {
3102
3119
  var e_1, _b;
3103
3120
  var _c = __read(_a), first = _c[0], rest = _c.slice(1);
@@ -3222,20 +3239,14 @@ var miscNormalExpression = {
3222
3239
  },
3223
3240
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3224
3241
  },
3225
- 'not': {
3242
+ '!': {
3226
3243
  evaluate: function (_a) {
3227
3244
  var _b = __read(_a, 1), first = _b[0];
3228
3245
  return !first;
3229
3246
  },
3230
3247
  validate: function (node) { return assertNumberOfParams(1, node); },
3231
3248
  },
3232
- 'inst-ms!': {
3233
- evaluate: function () {
3234
- return Date.now();
3235
- },
3236
- validate: function (node) { return assertNumberOfParams(0, node); },
3237
- },
3238
- 'inst-ms->iso-date-time': {
3249
+ 'epoch>iso_date': {
3239
3250
  evaluate: function (_a, sourceCodeInfo) {
3240
3251
  var _b = __read(_a, 1), ms = _b[0];
3241
3252
  assertNumber(ms, sourceCodeInfo);
@@ -3243,7 +3254,7 @@ var miscNormalExpression = {
3243
3254
  },
3244
3255
  validate: function (node) { return assertNumberOfParams(1, node); },
3245
3256
  },
3246
- 'iso-date-time->inst-ms': {
3257
+ 'iso_date>epoch': {
3247
3258
  evaluate: function (_a, sourceCodeInfo) {
3248
3259
  var _b = __read(_a, 1), dateTime = _b[0];
3249
3260
  assertString(dateTime, sourceCodeInfo);
@@ -3276,23 +3287,7 @@ var miscNormalExpression = {
3276
3287
  },
3277
3288
  validate: function (node) { return assertNumberOfParams(2, node); },
3278
3289
  },
3279
- 'uuid!': {
3280
- evaluate: function () {
3281
- return uuidTemplate.replace(xyRegexp, function (character) {
3282
- var randomNbr = Math.floor(Math.random() * 16);
3283
- var newValue = character === 'x' ? randomNbr : (randomNbr & 0x3) | 0x8;
3284
- return newValue.toString(16);
3285
- });
3286
- },
3287
- validate: function (node) { return assertNumberOfParams(0, node); },
3288
- },
3289
- 'lits-version!': {
3290
- evaluate: function () {
3291
- return version;
3292
- },
3293
- validate: function (node) { return assertNumberOfParams(0, node); },
3294
- },
3295
- 'json-parse': {
3290
+ 'json_parse': {
3296
3291
  evaluate: function (_a, sourceCodeInfo) {
3297
3292
  var _b = __read(_a, 1), first = _b[0];
3298
3293
  assertString(first, sourceCodeInfo);
@@ -3301,7 +3296,7 @@ var miscNormalExpression = {
3301
3296
  },
3302
3297
  validate: function (node) { return assertNumberOfParams(1, node); },
3303
3298
  },
3304
- 'json-stringify': {
3299
+ 'json_stringify': {
3305
3300
  evaluate: function (_a, sourceCodeInfo) {
3306
3301
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
3307
3302
  assertAny(first, sourceCodeInfo);
@@ -3514,7 +3509,7 @@ var assertNormalExpression = {
3514
3509
  };
3515
3510
 
3516
3511
  var objectNormalExpression = {
3517
- 'object': {
3512
+ object: {
3518
3513
  evaluate: function (params, sourceCodeInfo) {
3519
3514
  var result = {};
3520
3515
  for (var i = 0; i < params.length; i += 2) {
@@ -3527,7 +3522,7 @@ var objectNormalExpression = {
3527
3522
  },
3528
3523
  validate: function (node) { return assertEvenNumberOfParams(node); },
3529
3524
  },
3530
- 'keys': {
3525
+ keys: {
3531
3526
  evaluate: function (_a, sourceCodeInfo) {
3532
3527
  var _b = __read(_a, 1), obj = _b[0];
3533
3528
  assertObj(obj, sourceCodeInfo);
@@ -3535,7 +3530,7 @@ var objectNormalExpression = {
3535
3530
  },
3536
3531
  validate: function (node) { return assertNumberOfParams(1, node); },
3537
3532
  },
3538
- 'vals': {
3533
+ vals: {
3539
3534
  evaluate: function (_a, sourceCodeInfo) {
3540
3535
  var _b = __read(_a, 1), obj = _b[0];
3541
3536
  assertObj(obj, sourceCodeInfo);
@@ -3543,7 +3538,7 @@ var objectNormalExpression = {
3543
3538
  },
3544
3539
  validate: function (node) { return assertNumberOfParams(1, node); },
3545
3540
  },
3546
- 'entries': {
3541
+ entries: {
3547
3542
  evaluate: function (_a, sourceCodeInfo) {
3548
3543
  var _b = __read(_a, 1), obj = _b[0];
3549
3544
  assertObj(obj, sourceCodeInfo);
@@ -3551,7 +3546,7 @@ var objectNormalExpression = {
3551
3546
  },
3552
3547
  validate: function (node) { return assertNumberOfParams(1, node); },
3553
3548
  },
3554
- 'find': {
3549
+ find: {
3555
3550
  evaluate: function (_a, sourceCodeInfo) {
3556
3551
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3557
3552
  assertObj(obj, sourceCodeInfo);
@@ -3562,7 +3557,7 @@ var objectNormalExpression = {
3562
3557
  },
3563
3558
  validate: function (node) { return assertNumberOfParams(2, node); },
3564
3559
  },
3565
- 'dissoc': {
3560
+ dissoc: {
3566
3561
  evaluate: function (_a, sourceCodeInfo) {
3567
3562
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3568
3563
  assertObj(obj, sourceCodeInfo);
@@ -3573,7 +3568,7 @@ var objectNormalExpression = {
3573
3568
  },
3574
3569
  validate: function (node) { return assertNumberOfParams(2, node); },
3575
3570
  },
3576
- 'merge': {
3571
+ merge: {
3577
3572
  evaluate: function (params, sourceCodeInfo) {
3578
3573
  if (params.length === 0)
3579
3574
  return null;
@@ -3586,7 +3581,7 @@ var objectNormalExpression = {
3586
3581
  },
3587
3582
  validate: function (node) { return assertNumberOfParams({ min: 0 }, node); },
3588
3583
  },
3589
- 'merge-with': {
3584
+ merge_with: {
3590
3585
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
3591
3586
  var executeFunction = _a.executeFunction;
3592
3587
  var first = params[0];
@@ -3609,7 +3604,7 @@ var objectNormalExpression = {
3609
3604
  },
3610
3605
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
3611
3606
  },
3612
- 'zipmap': {
3607
+ zipmap: {
3613
3608
  evaluate: function (_a, sourceCodeInfo) {
3614
3609
  var _b = __read(_a, 2), keys = _b[0], values = _b[1];
3615
3610
  assertStringArray(keys, sourceCodeInfo);
@@ -3624,7 +3619,7 @@ var objectNormalExpression = {
3624
3619
  },
3625
3620
  validate: function (node) { return assertNumberOfParams(2, node); },
3626
3621
  },
3627
- 'select-keys': {
3622
+ select_keys: {
3628
3623
  evaluate: function (_a, sourceCodeInfo) {
3629
3624
  var _b = __read(_a, 2), obj = _b[0], keys = _b[1];
3630
3625
  assertStringArray(keys, sourceCodeInfo);
@@ -3890,7 +3885,7 @@ var stringNormalExpression = {
3890
3885
  },
3891
3886
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
3892
3887
  },
3893
- 'string-repeat': {
3888
+ 'string_repeat': {
3894
3889
  evaluate: function (_a, sourceCodeInfo) {
3895
3890
  var _b = __read(_a, 2), str = _b[0], count = _b[1];
3896
3891
  assertString(str, sourceCodeInfo);
@@ -3924,27 +3919,7 @@ var stringNormalExpression = {
3924
3919
  },
3925
3920
  validate: function (node) { return assertNumberOfParams(1, node); },
3926
3921
  },
3927
- 'number-to-string': {
3928
- evaluate: function (params, sourceCodeInfo) {
3929
- var _a = __read(params, 2), num = _a[0], base = _a[1];
3930
- assertNumber(num, sourceCodeInfo, { finite: true });
3931
- if (params.length === 1) {
3932
- return "".concat(num);
3933
- }
3934
- else {
3935
- assertNumber(base, sourceCodeInfo, { finite: true });
3936
- if (base !== 2 && base !== 8 && base !== 10 && base !== 16) {
3937
- throw new LitsError("Expected \"number-to-string\" base argument to be 2, 8, 10 or 16, got: ".concat(base), sourceCodeInfo);
3938
- }
3939
- if (base === 10)
3940
- return "".concat(num);
3941
- assertNumber(num, sourceCodeInfo, { integer: true, nonNegative: true });
3942
- return Number(num).toString(base);
3943
- }
3944
- },
3945
- validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
3946
- },
3947
- 'from-char-code': {
3922
+ 'from_char_code': {
3948
3923
  evaluate: function (_a, sourceCodeInfo) {
3949
3924
  var _b = __read(_a, 1), num = _b[0];
3950
3925
  assertNumber(num, sourceCodeInfo, { finite: true });
@@ -3958,7 +3933,7 @@ var stringNormalExpression = {
3958
3933
  },
3959
3934
  validate: function (node) { return assertNumberOfParams(1, node); },
3960
3935
  },
3961
- 'to-char-code': {
3936
+ 'to_char_code': {
3962
3937
  evaluate: function (_a, sourceCodeInfo) {
3963
3938
  var _b = __read(_a, 1), str = _b[0];
3964
3939
  assertString(str, sourceCodeInfo, { nonEmpty: true });
@@ -3966,7 +3941,7 @@ var stringNormalExpression = {
3966
3941
  },
3967
3942
  validate: function (node) { return assertNumberOfParams(1, node); },
3968
3943
  },
3969
- 'lower-case': {
3944
+ 'lower_case': {
3970
3945
  evaluate: function (_a, sourceCodeInfo) {
3971
3946
  var _b = __read(_a, 1), str = _b[0];
3972
3947
  assertString(str, sourceCodeInfo);
@@ -3974,7 +3949,7 @@ var stringNormalExpression = {
3974
3949
  },
3975
3950
  validate: function (node) { return assertNumberOfParams(1, node); },
3976
3951
  },
3977
- 'upper-case': {
3952
+ 'upper_case': {
3978
3953
  evaluate: function (_a, sourceCodeInfo) {
3979
3954
  var _b = __read(_a, 1), str = _b[0];
3980
3955
  assertString(str, sourceCodeInfo);
@@ -3990,7 +3965,7 @@ var stringNormalExpression = {
3990
3965
  },
3991
3966
  validate: function (node) { return assertNumberOfParams(1, node); },
3992
3967
  },
3993
- 'trim-left': {
3968
+ 'trim_left': {
3994
3969
  evaluate: function (_a, sourceCodeInfo) {
3995
3970
  var _b = __read(_a, 1), str = _b[0];
3996
3971
  assertString(str, sourceCodeInfo);
@@ -3998,7 +3973,7 @@ var stringNormalExpression = {
3998
3973
  },
3999
3974
  validate: function (node) { return assertNumberOfParams(1, node); },
4000
3975
  },
4001
- 'trim-right': {
3976
+ 'trim_right': {
4002
3977
  evaluate: function (_a, sourceCodeInfo) {
4003
3978
  var _b = __read(_a, 1), str = _b[0];
4004
3979
  assertString(str, sourceCodeInfo);
@@ -4006,6 +3981,30 @@ var stringNormalExpression = {
4006
3981
  },
4007
3982
  validate: function (node) { return assertNumberOfParams(1, node); },
4008
3983
  },
3984
+ '++': {
3985
+ evaluate: function (params, sourceCodeInfo) {
3986
+ if (params.length === 0) {
3987
+ return '';
3988
+ }
3989
+ var first = params[0];
3990
+ if (first !== null) {
3991
+ assertStringOrNumber(first, sourceCodeInfo);
3992
+ }
3993
+ if (params.length === 1) {
3994
+ return first === null ? '' : "".concat(first);
3995
+ }
3996
+ return params.slice(1).reduce(function (acc, str) {
3997
+ if (str !== null) {
3998
+ assertStringOrNumber(str, sourceCodeInfo);
3999
+ }
4000
+ if (str === null) {
4001
+ return acc;
4002
+ }
4003
+ return "".concat(acc).concat(str);
4004
+ }, first === null ? '' : "".concat(first));
4005
+ },
4006
+ validate: function () { return undefined; },
4007
+ },
4009
4008
  'join': {
4010
4009
  evaluate: function (_a, sourceCodeInfo) {
4011
4010
  var _b = __read(_a, 2), stringList = _b[0], delimiter = _b[1];
@@ -4030,7 +4029,7 @@ var stringNormalExpression = {
4030
4029
  },
4031
4030
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4032
4031
  },
4033
- 'pad-left': {
4032
+ 'pad_left': {
4034
4033
  evaluate: function (_a, sourceCodeInfo) {
4035
4034
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4036
4035
  assertString(str, sourceCodeInfo);
@@ -4041,7 +4040,7 @@ var stringNormalExpression = {
4041
4040
  },
4042
4041
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4043
4042
  },
4044
- 'pad-right': {
4043
+ 'pad_right': {
4045
4044
  evaluate: function (_a, sourceCodeInfo) {
4046
4045
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4047
4046
  assertString(str, sourceCodeInfo);
@@ -4083,7 +4082,7 @@ var stringNormalExpression = {
4083
4082
  },
4084
4083
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 10 }, node); },
4085
4084
  },
4086
- 'encode-base64': {
4085
+ 'encode_base64': {
4087
4086
  evaluate: function (_a, sourceCodeInfo) {
4088
4087
  var _b = __read(_a, 1), value = _b[0];
4089
4088
  assertString(value, sourceCodeInfo);
@@ -4094,7 +4093,7 @@ var stringNormalExpression = {
4094
4093
  },
4095
4094
  validate: function (node) { return assertNumberOfParams(1, node); },
4096
4095
  },
4097
- 'decode-base64': {
4096
+ 'decode_base64': {
4098
4097
  evaluate: function (_a, sourceCodeInfo) {
4099
4098
  var _b = __read(_a, 1), value = _b[0];
4100
4099
  assertString(value, sourceCodeInfo);
@@ -4112,7 +4111,7 @@ var stringNormalExpression = {
4112
4111
  },
4113
4112
  validate: function (node) { return assertNumberOfParams(1, node); },
4114
4113
  },
4115
- 'encode-uri-component': {
4114
+ 'encode_uri_component': {
4116
4115
  evaluate: function (_a, sourceCodeInfo) {
4117
4116
  var _b = __read(_a, 1), value = _b[0];
4118
4117
  assertString(value, sourceCodeInfo);
@@ -4120,7 +4119,7 @@ var stringNormalExpression = {
4120
4119
  },
4121
4120
  validate: function (node) { return assertNumberOfParams(1, node); },
4122
4121
  },
4123
- 'decode-uri-component': {
4122
+ 'decode_uri_component': {
4124
4123
  evaluate: function (_a, sourceCodeInfo) {
4125
4124
  var _b = __read(_a, 1), value = _b[0];
4126
4125
  assertString(value, sourceCodeInfo);
@@ -4289,7 +4288,7 @@ var andSpecialExpression = {
4289
4288
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4290
4289
  var node = {
4291
4290
  t: AstNodeType.SpecialExpression,
4292
- n: 'and',
4291
+ n: '&&',
4293
4292
  p: params,
4294
4293
  token: getTokenDebugData(firstToken) && firstToken,
4295
4294
  };
@@ -4374,6 +4373,37 @@ var condSpecialExpression = {
4374
4373
  },
4375
4374
  };
4376
4375
 
4376
+ var switchSpecialExpression = {
4377
+ polishParse: getCommonPolishSpecialExpressionParser('switch'),
4378
+ validateParameterCount: function (node) { return assertOddNumberOfParams(node); },
4379
+ evaluate: function (node, contextStack, _a) {
4380
+ var e_1, _b;
4381
+ var evaluateAstNode = _a.evaluateAstNode;
4382
+ var switchValue = evaluateAstNode(node.p[0], contextStack);
4383
+ try {
4384
+ for (var _c = __values(arrayToPairs(node.p.slice(1))), _d = _c.next(); !_d.done; _d = _c.next()) {
4385
+ var _e = __read(_d.value, 2), test = _e[0], form = _e[1];
4386
+ var value = evaluateAstNode(test, contextStack);
4387
+ if (value === switchValue) {
4388
+ return evaluateAstNode(form, contextStack);
4389
+ }
4390
+ }
4391
+ }
4392
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4393
+ finally {
4394
+ try {
4395
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
4396
+ }
4397
+ finally { if (e_1) throw e_1.error; }
4398
+ }
4399
+ return null;
4400
+ },
4401
+ findUnresolvedIdentifiers: function (node, contextStack, _a) {
4402
+ var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4403
+ return findUnresolvedIdentifiers(node.p, contextStack, builtin);
4404
+ },
4405
+ };
4406
+
4377
4407
  var declaredSpecialExpression = {
4378
4408
  polishParse: getCommonPolishSpecialExpressionParser('declared?'),
4379
4409
  validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
@@ -4845,7 +4875,7 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
4845
4875
  tkn = asToken(tokenStream.tokens[parseState.position]);
4846
4876
  if (node.t === AstNodeType.Modifier) {
4847
4877
  switch (node.v) {
4848
- case '&':
4878
+ case '&rest':
4849
4879
  if (state === 'rest')
4850
4880
  throw new LitsError('& can only appear once', (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
4851
4881
  state = 'rest';
@@ -4920,7 +4950,7 @@ var ifLetSpecialExpression = {
4920
4950
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4921
4951
  var node = {
4922
4952
  t: AstNodeType.SpecialExpression,
4923
- n: 'if-let',
4953
+ n: 'if_let',
4924
4954
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
4925
4955
  p: params,
4926
4956
  token: getTokenDebugData(firstToken) && firstToken,
@@ -4957,7 +4987,7 @@ var ifLetSpecialExpression = {
4957
4987
  };
4958
4988
 
4959
4989
  var ifNotSpecialExpression = {
4960
- polishParse: getCommonPolishSpecialExpressionParser('if-not'),
4990
+ polishParse: getCommonPolishSpecialExpressionParser('if_not'),
4961
4991
  validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4962
4992
  evaluate: function (node, contextStack, _a) {
4963
4993
  var _b;
@@ -5167,7 +5197,7 @@ function parseLoopBinding(tokenStream, parseState, _a) {
5167
5197
  loopBinding.we = parseToken(tokenStream, parseState);
5168
5198
  loopBinding.m.push('&while');
5169
5199
  break;
5170
- case '&':
5200
+ case '&rest':
5171
5201
  throw new LitsError("Illegal modifier: ".concat(modifier), (_e = getTokenDebugData(tkn)) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
5172
5202
  default:
5173
5203
  throw new LitsError("Illegal modifier: ".concat(modifier), (_f = getTokenDebugData(tkn)) === null || _f === void 0 ? void 0 : _f.sourceCodeInfo);
@@ -5367,7 +5397,7 @@ var doseqSpecialExpression = {
5367
5397
  };
5368
5398
 
5369
5399
  var orSpecialExpression = {
5370
- polishParse: getCommonPolishSpecialExpressionParser('or'),
5400
+ polishParse: getCommonPolishSpecialExpressionParser('||'),
5371
5401
  validateParameterCount: function () { return undefined; },
5372
5402
  evaluate: function (node, contextStack, _a) {
5373
5403
  var e_1, _b;
@@ -5459,25 +5489,6 @@ var throwSpecialExpression = {
5459
5489
  },
5460
5490
  };
5461
5491
 
5462
- var timeSpecialExpression = {
5463
- polishParse: getCommonPolishSpecialExpressionParser('time!'),
5464
- validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5465
- evaluate: function (node, contextStack, _a) {
5466
- var evaluateAstNode = _a.evaluateAstNode;
5467
- var param = node.p[0];
5468
- var startTime = Date.now();
5469
- var result = evaluateAstNode(param, contextStack);
5470
- var totalTime = Date.now() - startTime;
5471
- // eslint-disable-next-line no-console
5472
- console.log("Elapsed time: ".concat(totalTime, " ms"));
5473
- return result;
5474
- },
5475
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5476
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5477
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
5478
- },
5479
- };
5480
-
5481
5492
  var trySpecialExpression = {
5482
5493
  polishParse: function (tokenStream, parseState, firstToken, _a) {
5483
5494
  var _b, _c, _d;
@@ -5578,7 +5589,7 @@ var whenFirstSpecialExpression = {
5578
5589
  assertRParenToken(tokenStream.tokens[parseState.position++]);
5579
5590
  var node = {
5580
5591
  t: AstNodeType.SpecialExpression,
5581
- n: 'when-first',
5592
+ n: 'when_first',
5582
5593
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5583
5594
  p: params,
5584
5595
  token: getTokenDebugData(firstToken) && firstToken,
@@ -5640,7 +5651,7 @@ var whenLetSpecialExpression = {
5640
5651
  assertRParenToken(tokenStream.tokens[parseState.position++]);
5641
5652
  var node = {
5642
5653
  t: AstNodeType.SpecialExpression,
5643
- n: 'when-let',
5654
+ n: 'when_let',
5644
5655
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5645
5656
  p: params,
5646
5657
  token: getTokenDebugData(firstToken) && firstToken,
@@ -5686,7 +5697,7 @@ var whenLetSpecialExpression = {
5686
5697
  };
5687
5698
 
5688
5699
  var whenNotSpecialExpression = {
5689
- polishParse: getCommonPolishSpecialExpressionParser('when-not'),
5700
+ polishParse: getCommonPolishSpecialExpressionParser('when_not'),
5690
5701
  validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5691
5702
  evaluate: function (node, contextStack, _a) {
5692
5703
  var e_1, _b;
@@ -5719,9 +5730,10 @@ var whenNotSpecialExpression = {
5719
5730
  };
5720
5731
 
5721
5732
  var specialExpressions = {
5722
- 'and': andSpecialExpression,
5733
+ '&&': andSpecialExpression,
5723
5734
  'comment': commentSpecialExpression,
5724
5735
  'cond': condSpecialExpression,
5736
+ 'switch': switchSpecialExpression,
5725
5737
  'def': defSpecialExpression,
5726
5738
  'defn': defnSpecialExpression,
5727
5739
  'defns': defnsSpecialExpression,
@@ -5731,19 +5743,18 @@ var specialExpressions = {
5731
5743
  'for': forSpecialExpression,
5732
5744
  'fn': fnSpecialExpression,
5733
5745
  'if': ifSpecialExpression,
5734
- 'if-let': ifLetSpecialExpression,
5735
- 'if-not': ifNotSpecialExpression,
5746
+ 'if_let': ifLetSpecialExpression,
5747
+ 'if_not': ifNotSpecialExpression,
5736
5748
  'let': letSpecialExpression,
5737
5749
  'loop': loopSpecialExpression,
5738
- 'or': orSpecialExpression,
5750
+ '||': orSpecialExpression,
5739
5751
  'recur': recurSpecialExpression,
5740
5752
  'throw': throwSpecialExpression,
5741
- 'time!': timeSpecialExpression,
5742
5753
  'try': trySpecialExpression,
5743
5754
  'when': whenSpecialExpression,
5744
- 'when-first': whenFirstSpecialExpression,
5745
- 'when-let': whenLetSpecialExpression,
5746
- 'when-not': whenNotSpecialExpression,
5755
+ 'when_first': whenFirstSpecialExpression,
5756
+ 'when_let': whenLetSpecialExpression,
5757
+ 'when_not': whenNotSpecialExpression,
5747
5758
  'declared?': declaredSpecialExpression,
5748
5759
  '??': qqSpecialExpression,
5749
5760
  };
@@ -6300,7 +6311,7 @@ var calculateAndOutcomes = function (_a) {
6300
6311
  var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6301
6312
  return combinateAstNodes(astNode.p)
6302
6313
  .map(function (p) { return ({
6303
- n: 'and',
6314
+ n: '&&',
6304
6315
  t: AstNodeType.SpecialExpression,
6305
6316
  p: p,
6306
6317
  token: astNode.token,
@@ -6422,7 +6433,7 @@ var calculateIfNotOutcomes = function (_a) {
6422
6433
  if (isAstComputable(condition)) {
6423
6434
  return combinateAstNodes(astNode.p)
6424
6435
  .map(function (p) { return ({
6425
- n: 'if-not',
6436
+ n: 'if_not',
6426
6437
  t: astNode.t,
6427
6438
  p: p,
6428
6439
  token: astNode.token,
@@ -6535,7 +6546,7 @@ var calculateOrOutcomes = function (_a) {
6535
6546
  var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6536
6547
  return combinateAstNodes(astNode.p)
6537
6548
  .map(function (p) { return ({
6538
- n: 'or',
6549
+ n: '||',
6539
6550
  t: AstNodeType.SpecialExpression,
6540
6551
  p: p,
6541
6552
  token: astNode.token,
@@ -6555,12 +6566,6 @@ var calculateThrowOutcomes = function (_a) {
6555
6566
  return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
6556
6567
  };
6557
6568
 
6558
- var calculateTimeOutcomes = function (_a) {
6559
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6560
- return calculatePossibleAstNodes(astNode.p[0])
6561
- .map(function (p) { return (__assign(__assign({}, astNode), { n: 'do', p: [p] })); });
6562
- };
6563
-
6564
6569
  var calculateTryOutcomes = function (_a) {
6565
6570
  var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6566
6571
  var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
@@ -6634,7 +6639,7 @@ var calculateWhenNotOutcomes = function (_a) {
6634
6639
  if (isAstComputable(condition)) {
6635
6640
  return combinateAstNodes(astNode.p)
6636
6641
  .map(function (p) { return ({
6637
- n: 'when-not',
6642
+ n: 'when_not',
6638
6643
  t: astNode.t,
6639
6644
  p: p,
6640
6645
  token: astNode.token,
@@ -6693,10 +6698,22 @@ var calculateLoopOutcomes = function (_a) {
6693
6698
  .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6694
6699
  };
6695
6700
 
6701
+ var calculateSwitchOutcomes = function (_a) {
6702
+ var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6703
+ // TODO be smarter about this
6704
+ return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p.slice(1)).flatMap(function (_a) {
6705
+ var _b = __read(_a, 2); _b[0]; var form = _b[1];
6706
+ return calculatePossibleAstNodes(form);
6707
+ })), false), [
6708
+ nilNode,
6709
+ ], false);
6710
+ };
6711
+
6696
6712
  var specialExpressionCalculator = {
6697
- 'and': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6713
+ '&&': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6698
6714
  'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6699
6715
  'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6716
+ 'switch': function (astNode, helperOptions) { return calculateSwitchOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6700
6717
  'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6701
6718
  'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6702
6719
  'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
@@ -6706,27 +6723,22 @@ var specialExpressionCalculator = {
6706
6723
  'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6707
6724
  'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6708
6725
  'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6709
- 'if-let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6726
+ 'if_let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6710
6727
  'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6711
- 'if-not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6728
+ 'if_not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6712
6729
  'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6713
6730
  'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6714
- 'or': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6731
+ '||': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6715
6732
  '??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6716
6733
  'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6717
- 'time!': function (astNode, helperOptions) { return calculateTimeOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6718
6734
  'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6719
6735
  'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6720
- 'when-first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6721
- 'when-let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6736
+ 'when_first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6737
+ 'when_let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6722
6738
  'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6723
- 'when-not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6739
+ 'when_not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6724
6740
  };
6725
6741
 
6726
- function isIdempotent(normalExpressionName) {
6727
- return !normalExpressionName.endsWith('!')
6728
- || normalExpressionName === 'write!';
6729
- }
6730
6742
  function calculateOutcomes(contextStack, astNodes) {
6731
6743
  // First, we try to calculate outcomes for the whole astNodes array.
6732
6744
  // If that fails, we try to calculate outcomes for the array without the first element.
@@ -6801,8 +6813,6 @@ function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
6801
6813
  : undefined;
6802
6814
  var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
6803
6815
  if (astNode.t === AstNodeType.NormalExpression) {
6804
- if (astNode.n && !isIdempotent(astNode.n))
6805
- throw new Error("NormalExpressionNode with name ".concat(astNode.n, " is not idempotent. Cannot calculate possible ASTs."));
6806
6816
  return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
6807
6817
  .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6808
6818
  }
@@ -7029,13 +7039,10 @@ function fromUnaryAlgebraicToAstNode(operator, operand) {
7029
7039
  var operatorName = operator[1];
7030
7040
  switch (operatorName) {
7031
7041
  case '+':
7032
- return createNamedNormalExpressionNode('+', [operand], token);
7033
7042
  case '-':
7034
- return createNamedNormalExpressionNode('-', [operand], token);
7035
7043
  case '!':
7036
- return createNamedNormalExpressionNode('not', [operand], token);
7037
7044
  case '~':
7038
- return createNamedNormalExpressionNode('bit-not', [operand], token);
7045
+ return createNamedNormalExpressionNode(operatorName, [operand], token);
7039
7046
  /* v8 ignore next 2 */
7040
7047
  default:
7041
7048
  throw new Error("Unknown operator: ".concat(operatorName));
@@ -7048,68 +7055,36 @@ function fromBinaryOperatorToAstNode(operator, left, right, token) {
7048
7055
  case '.':
7049
7056
  return createAccessorNode(left, fromSymbolToStringNode(asSymbolNode(right, (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo)), token);
7050
7057
  case '**': // exponentiation
7051
- return createNamedNormalExpressionNode('pow', [left, right], token);
7052
7058
  case '*':
7053
- return createNamedNormalExpressionNode('*', [left, right], token);
7054
7059
  case '/':
7055
- return createNamedNormalExpressionNode('/', [left, right], token);
7056
7060
  case '%':
7057
- return createNamedNormalExpressionNode('rem', [left, right], token);
7058
7061
  case '+':
7059
- return createNamedNormalExpressionNode('+', [left, right], token);
7060
7062
  case '-':
7061
- return createNamedNormalExpressionNode('-', [left, right], token);
7062
7063
  case '<<':
7063
- return createNamedNormalExpressionNode('bit-shift-left', [left, right], token);
7064
7064
  case '>>':
7065
- return createNamedNormalExpressionNode('bit-shift-right', [left, right], token);
7066
7065
  case '>>>':
7067
- return createNamedNormalExpressionNode('unsigned-bit-shift-right', [left, right], token);
7068
- case '++': {
7069
- var leftString = createNamedNormalExpressionNode('str', [left], token);
7070
- var rightString = createNamedNormalExpressionNode('str', [right], token);
7071
- return createNamedNormalExpressionNode('str', [leftString, rightString], token);
7072
- }
7066
+ case '++':
7073
7067
  case '<':
7074
- return createNamedNormalExpressionNode('<', [left, right], token);
7075
7068
  case '<=':
7076
- return createNamedNormalExpressionNode('<=', [left, right], token);
7077
7069
  case '>':
7078
- return createNamedNormalExpressionNode('>', [left, right], token);
7079
7070
  case '>=':
7080
- return createNamedNormalExpressionNode('>=', [left, right], token);
7081
7071
  case '==':
7082
- return createNamedNormalExpressionNode('=', [left, right], token);
7083
7072
  case '!=':
7084
- return createNamedNormalExpressionNode('!=', [left, right], token);
7085
7073
  case '&':
7086
- return createNamedNormalExpressionNode('bit-and', [left, right], token);
7087
7074
  case '^':
7088
- return createNamedNormalExpressionNode('bit-xor', [left, right], token);
7089
7075
  case '|':
7090
- return createNamedNormalExpressionNode('bit-or', [left, right], token);
7076
+ return createNamedNormalExpressionNode(operatorName, [left, right], token);
7091
7077
  case '&&':
7092
- return {
7093
- t: AstNodeType.SpecialExpression,
7094
- n: 'and',
7095
- p: [left, right],
7096
- token: getTokenDebugData(token) && token,
7097
- };
7098
7078
  case '||':
7099
- return {
7100
- t: AstNodeType.SpecialExpression,
7101
- n: 'or',
7102
- p: [left, right],
7103
- token: getTokenDebugData(token) && token,
7104
- };
7105
7079
  case '??':
7106
7080
  return {
7107
7081
  t: AstNodeType.SpecialExpression,
7108
- n: '??',
7082
+ n: operatorName,
7109
7083
  p: [left, right],
7110
7084
  token: getTokenDebugData(token) && token,
7111
7085
  };
7112
7086
  /* v8 ignore next 8 */
7087
+ case ';':
7113
7088
  case '!':
7114
7089
  case '~':
7115
7090
  case '=':
@@ -7130,14 +7105,52 @@ var AlgebraicParser = /** @class */ (function () {
7130
7105
  this.parseState.position += 1;
7131
7106
  };
7132
7107
  AlgebraicParser.prototype.parse = function () {
7133
- return this.parseExpression();
7108
+ var nodes = [];
7109
+ while (!this.isAtEnd()) {
7110
+ nodes.push(this.parseExpression());
7111
+ if (!isA_OperatorToken(this.peek(), ';')) {
7112
+ break;
7113
+ }
7114
+ this.advance();
7115
+ }
7116
+ return nodes;
7134
7117
  };
7135
7118
  AlgebraicParser.prototype.parseExpression = function (precedence) {
7136
7119
  var _a;
7137
7120
  if (precedence === void 0) { precedence = 0; }
7138
- var left = this.parseOperand();
7139
- while (!this.isAtEnd() && !isA_OperatorToken(this.peek(), ',') && !isRBracketToken(this.peek()) && !isRParenToken(this.peek())) {
7140
- var operator = this.peek();
7121
+ var firstToken = this.peek();
7122
+ if (isA_SymbolToken(firstToken) && firstToken[1] === 'def') {
7123
+ return this.parseDef(firstToken);
7124
+ }
7125
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'defn') {
7126
+ return this.parseDefn(firstToken);
7127
+ }
7128
+ var left;
7129
+ if (isA_SymbolToken(firstToken) && firstToken[1] === 'if') {
7130
+ left = this.parseIf(firstToken);
7131
+ }
7132
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'cond') {
7133
+ left = this.parseCond(firstToken);
7134
+ }
7135
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'switch') {
7136
+ left = this.parseSwitch(firstToken);
7137
+ }
7138
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'for') {
7139
+ left = this.parseFor(firstToken);
7140
+ }
7141
+ else {
7142
+ left = this.parseOperand();
7143
+ }
7144
+ var operator = this.peek();
7145
+ while (!this.isAtEnd()
7146
+ && !isA_OperatorToken(operator, ',')
7147
+ && !isA_OperatorToken(operator, ';')
7148
+ && !isRBracketToken(operator)
7149
+ && !isA_ReservedSymbolToken(operator, 'else')
7150
+ && !isA_ReservedSymbolToken(operator, 'then')
7151
+ && !isA_ReservedSymbolToken(operator, 'end')
7152
+ && !isA_ReservedSymbolToken(operator, 'case')
7153
+ && !isRParenToken(operator)) {
7141
7154
  if (isA_BinaryOperatorToken(operator)) {
7142
7155
  var name_1 = operator[1];
7143
7156
  var newPrecedece = getPrecedence(name_1);
@@ -7167,6 +7180,7 @@ var AlgebraicParser = /** @class */ (function () {
7167
7180
  else {
7168
7181
  break;
7169
7182
  }
7183
+ operator = this.peek();
7170
7184
  }
7171
7185
  if (!left) {
7172
7186
  throw new LitsError('Expected operand', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
@@ -7367,9 +7381,6 @@ var AlgebraicParser = /** @class */ (function () {
7367
7381
  var _a, _b;
7368
7382
  var isNamedFunction = symbol.t === AstNodeType.Symbol;
7369
7383
  this.advance();
7370
- if (isNamedFunction && symbol.v === 'for') {
7371
- return this.parseFor(symbol);
7372
- }
7373
7384
  var params = [];
7374
7385
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7375
7386
  params.push(this.parseExpression());
@@ -7390,17 +7401,14 @@ var AlgebraicParser = /** @class */ (function () {
7390
7401
  var name_2 = symbol.v;
7391
7402
  switch (name_2) {
7392
7403
  case '??':
7393
- case 'and':
7404
+ case '&&':
7394
7405
  case 'comment':
7395
- case 'cond':
7396
7406
  case 'declared?':
7397
- case 'if':
7398
- case 'if-not':
7399
- case 'or':
7407
+ case 'if_not':
7408
+ case '||':
7400
7409
  case 'when':
7401
- case 'when-not':
7410
+ case 'when_not':
7402
7411
  case 'do':
7403
- case 'time!':
7404
7412
  case 'throw': {
7405
7413
  var node = {
7406
7414
  t: AstNodeType.SpecialExpression,
@@ -7413,13 +7421,11 @@ var AlgebraicParser = /** @class */ (function () {
7413
7421
  }
7414
7422
  case 'let':
7415
7423
  return this.parseLet(symbol, params);
7416
- case 'def':
7417
7424
  case 'defs':
7418
- case 'if-let':
7419
- case 'when-let':
7420
- case 'when-first':
7425
+ case 'if_let':
7426
+ case 'when_let':
7427
+ case 'when_first':
7421
7428
  case 'fn':
7422
- case 'defn':
7423
7429
  case 'defns':
7424
7430
  case 'try':
7425
7431
  case 'recur':
@@ -7442,8 +7448,32 @@ var AlgebraicParser = /** @class */ (function () {
7442
7448
  }
7443
7449
  };
7444
7450
  AlgebraicParser.prototype.parseLambdaFunction = function () {
7445
- var _a, _b;
7446
7451
  var firstToken = this.peek();
7452
+ try {
7453
+ var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
7454
+ if (!isA_OperatorToken(this.peek(), '=>')) {
7455
+ return null;
7456
+ }
7457
+ this.advance();
7458
+ var body = this.parseExpression();
7459
+ return {
7460
+ t: AstNodeType.SpecialExpression,
7461
+ n: 'fn',
7462
+ p: [],
7463
+ o: [{
7464
+ as: functionArguments,
7465
+ b: [body],
7466
+ a: arity,
7467
+ }],
7468
+ token: getTokenDebugData(firstToken) && firstToken,
7469
+ };
7470
+ }
7471
+ catch (_b) {
7472
+ return null;
7473
+ }
7474
+ };
7475
+ AlgebraicParser.prototype.parseFunctionArguments = function () {
7476
+ var _a, _b, _c, _d, _e;
7447
7477
  this.advance();
7448
7478
  var rest = false;
7449
7479
  var letBindingObject;
@@ -7466,7 +7496,7 @@ var AlgebraicParser = /** @class */ (function () {
7466
7496
  }
7467
7497
  var symbolToken = this.peek();
7468
7498
  if (!isA_SymbolToken(symbolToken)) {
7469
- return null;
7499
+ throw new LitsError('Expected symbol', (_c = getTokenDebugData(this.peek())) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
7470
7500
  }
7471
7501
  if (rest) {
7472
7502
  restArg = symbolToken[1];
@@ -7477,47 +7507,36 @@ var AlgebraicParser = /** @class */ (function () {
7477
7507
  this.advance();
7478
7508
  }
7479
7509
  if (!isA_OperatorToken(this.peek(), ',') && !isRParenToken(this.peek())) {
7480
- return null;
7510
+ throw new LitsError('Expected comma or closing parenthesis', (_d = getTokenDebugData(this.peek())) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo);
7481
7511
  }
7482
7512
  if (isA_OperatorToken(this.peek(), ',')) {
7483
7513
  this.advance();
7484
7514
  }
7485
7515
  }
7516
+ var arity = restArg !== undefined ? { min: args.length } : args.length;
7486
7517
  if (!isRParenToken(this.peek())) {
7487
- return null;
7488
- }
7489
- this.advance();
7490
- if (!isA_OperatorToken(this.peek(), '=>')) {
7491
- return null;
7518
+ throw new LitsError('Expected closing parenthesis', (_e = getTokenDebugData(this.peek())) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
7492
7519
  }
7493
- this.advance();
7494
7520
  var letBindings = letBindingObject ? arrayToPairs(letBindingObject.p) : [];
7495
- var body = this.parseExpression();
7496
- var arity = restArg !== undefined ? { min: args.length } : args.length;
7521
+ var functionArguments = {
7522
+ m: args,
7523
+ r: restArg,
7524
+ b: letBindings.map(function (pair) {
7525
+ var key = pair[0];
7526
+ var value = pair[1];
7527
+ return {
7528
+ t: AstNodeType.Binding,
7529
+ n: key.v,
7530
+ v: value,
7531
+ p: [],
7532
+ token: getTokenDebugData(key.token) && key.token,
7533
+ };
7534
+ }),
7535
+ };
7536
+ this.advance();
7497
7537
  return {
7498
- t: AstNodeType.SpecialExpression,
7499
- n: 'fn',
7500
- p: [],
7501
- o: [{
7502
- as: {
7503
- m: args,
7504
- r: restArg,
7505
- b: letBindings.map(function (pair) {
7506
- var key = pair[0];
7507
- var value = pair[1];
7508
- return {
7509
- t: AstNodeType.Binding,
7510
- n: key.v,
7511
- v: value,
7512
- p: [],
7513
- token: getTokenDebugData(key.token) && key.token,
7514
- };
7515
- }),
7516
- },
7517
- b: [body],
7518
- a: arity,
7519
- }],
7520
- token: getTokenDebugData(firstToken) && firstToken,
7538
+ functionArguments: functionArguments,
7539
+ arity: arity,
7521
7540
  };
7522
7541
  };
7523
7542
  AlgebraicParser.prototype.parseShorthandLamdaFunction = function () {
@@ -7602,38 +7621,39 @@ var AlgebraicParser = /** @class */ (function () {
7602
7621
  }),
7603
7622
  };
7604
7623
  };
7605
- AlgebraicParser.prototype.parseFor = function (forSymbol) {
7624
+ AlgebraicParser.prototype.parseFor = function (token) {
7625
+ this.advance();
7626
+ assertLParenToken(this.peek());
7627
+ this.advance();
7606
7628
  var forLoopBindings = [
7607
7629
  this.parseForLoopBinding(),
7608
7630
  ];
7609
- var nextToken = this.peekAhead();
7610
- while (isA_SymbolToken(nextToken) && nextToken[1] === 'of') {
7631
+ while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7611
7632
  forLoopBindings.push(this.parseForLoopBinding());
7612
- nextToken = this.peekAhead();
7633
+ if (isA_OperatorToken(this.peek(), ',')) {
7634
+ this.advance();
7635
+ }
7613
7636
  }
7614
- var expression = this.parseExpression();
7615
7637
  assertRParenToken(this.peek());
7616
7638
  this.advance();
7639
+ var expression = this.parseExpression();
7640
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7641
+ this.advance();
7617
7642
  return {
7618
7643
  t: AstNodeType.SpecialExpression,
7619
7644
  n: 'for',
7620
7645
  p: [expression],
7621
- token: getTokenDebugData(forSymbol.token) && forSymbol.token,
7646
+ token: getTokenDebugData(token) && token,
7622
7647
  l: forLoopBindings,
7623
7648
  };
7624
7649
  };
7625
- // export interface LoopBindingNode {
7626
- // b: BindingNode // Binding
7627
- // m: Array<'&let' | '&when' | '&while'> // Modifiers
7628
- // l?: BindingNode[] // Let-Bindings
7629
- // wn?: AstNode // When Node
7630
- // we?: AstNode // While Node
7631
- // }
7632
7650
  AlgebraicParser.prototype.parseForLoopBinding = function () {
7633
7651
  var _a;
7634
7652
  var bindingNode = this.parseBinding();
7635
- if (isA_OperatorToken(this.peek(), ',')) {
7636
- this.advance();
7653
+ if (isRParenToken(this.peek()) || isA_OperatorToken(this.peek(), ',')) {
7654
+ if (isA_OperatorToken(this.peek(), ',')) {
7655
+ this.advance();
7656
+ }
7637
7657
  return {
7638
7658
  b: bindingNode,
7639
7659
  m: [],
@@ -7679,8 +7699,9 @@ var AlgebraicParser = /** @class */ (function () {
7679
7699
  }
7680
7700
  token = this.peek();
7681
7701
  }
7682
- assertA_OperatorToken(token, ',');
7683
- this.advance();
7702
+ if (isA_OperatorToken(token, ',')) {
7703
+ this.advance();
7704
+ }
7684
7705
  return {
7685
7706
  b: bindingNode,
7686
7707
  m: modifiers,
@@ -7709,15 +7730,185 @@ var AlgebraicParser = /** @class */ (function () {
7709
7730
  };
7710
7731
  return node;
7711
7732
  };
7733
+ AlgebraicParser.prototype.parseIf = function (token) {
7734
+ this.advance();
7735
+ var condition = this.parseExpression();
7736
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7737
+ this.advance();
7738
+ var thenExpressions = [];
7739
+ while (!this.isAtEnd()
7740
+ && !isA_ReservedSymbolToken(this.peek(), 'else')
7741
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7742
+ thenExpressions.push(this.parseExpression());
7743
+ if (isA_OperatorToken(this.peek(), ';')) {
7744
+ this.advance();
7745
+ }
7746
+ }
7747
+ var thenExpression = thenExpressions.length === 1
7748
+ ? thenExpressions[0]
7749
+ : {
7750
+ t: AstNodeType.SpecialExpression,
7751
+ n: 'do',
7752
+ p: thenExpressions,
7753
+ token: getTokenDebugData(token) && token,
7754
+ };
7755
+ var elseExpression;
7756
+ if (isA_ReservedSymbolToken(this.peek(), 'else')) {
7757
+ this.advance();
7758
+ var elseExpressions = [];
7759
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7760
+ elseExpressions.push(this.parseExpression());
7761
+ if (isA_OperatorToken(this.peek(), ';')) {
7762
+ this.advance();
7763
+ }
7764
+ }
7765
+ elseExpression = elseExpressions.length === 1
7766
+ ? elseExpressions[0]
7767
+ : {
7768
+ t: AstNodeType.SpecialExpression,
7769
+ n: 'do',
7770
+ p: elseExpressions,
7771
+ token: getTokenDebugData(token) && token,
7772
+ };
7773
+ }
7774
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7775
+ this.advance();
7776
+ var params = [condition, thenExpression];
7777
+ if (elseExpression) {
7778
+ params.push(elseExpression);
7779
+ }
7780
+ return {
7781
+ t: AstNodeType.SpecialExpression,
7782
+ n: 'if',
7783
+ p: params,
7784
+ token: getTokenDebugData(token) && token,
7785
+ };
7786
+ };
7787
+ AlgebraicParser.prototype.parseCond = function (token) {
7788
+ this.advance();
7789
+ var params = [];
7790
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7791
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7792
+ this.advance();
7793
+ params.push(this.parseExpression());
7794
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7795
+ this.advance();
7796
+ var expressions = [];
7797
+ while (!this.isAtEnd()
7798
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7799
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7800
+ expressions.push(this.parseExpression());
7801
+ if (isA_OperatorToken(this.peek(), ';')) {
7802
+ this.advance();
7803
+ }
7804
+ }
7805
+ params.push(expressions.length === 1
7806
+ ? expressions[0]
7807
+ : {
7808
+ t: AstNodeType.SpecialExpression,
7809
+ n: 'do',
7810
+ p: expressions,
7811
+ token: getTokenDebugData(token) && token,
7812
+ });
7813
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7814
+ break;
7815
+ }
7816
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7817
+ }
7818
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7819
+ this.advance();
7820
+ return {
7821
+ t: AstNodeType.SpecialExpression,
7822
+ n: 'cond',
7823
+ p: params,
7824
+ token: getTokenDebugData(token) && token,
7825
+ };
7826
+ };
7827
+ AlgebraicParser.prototype.parseSwitch = function (token) {
7828
+ this.advance();
7829
+ var params = [this.parseExpression()];
7830
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7831
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7832
+ this.advance();
7833
+ params.push(this.parseExpression());
7834
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7835
+ this.advance();
7836
+ var expressions = [];
7837
+ while (!this.isAtEnd()
7838
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7839
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7840
+ expressions.push(this.parseExpression());
7841
+ if (isA_OperatorToken(this.peek(), ';')) {
7842
+ this.advance();
7843
+ }
7844
+ }
7845
+ params.push(expressions.length === 1
7846
+ ? expressions[0]
7847
+ : {
7848
+ t: AstNodeType.SpecialExpression,
7849
+ n: 'do',
7850
+ p: expressions,
7851
+ token: getTokenDebugData(token) && token,
7852
+ });
7853
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7854
+ break;
7855
+ }
7856
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7857
+ }
7858
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7859
+ this.advance();
7860
+ return {
7861
+ t: AstNodeType.SpecialExpression,
7862
+ n: 'switch',
7863
+ p: params,
7864
+ token: getTokenDebugData(token) && token,
7865
+ };
7866
+ };
7867
+ AlgebraicParser.prototype.parseDef = function (token) {
7868
+ this.advance();
7869
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7870
+ assertA_OperatorToken(this.peek(), '=');
7871
+ this.advance();
7872
+ var value = this.parseExpression();
7873
+ return {
7874
+ t: AstNodeType.SpecialExpression,
7875
+ n: 'def',
7876
+ p: [symbol, value],
7877
+ token: getTokenDebugData(token) && token,
7878
+ };
7879
+ };
7880
+ AlgebraicParser.prototype.parseDefn = function (token) {
7881
+ this.advance();
7882
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7883
+ var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
7884
+ var body = [];
7885
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7886
+ body.push(this.parseExpression());
7887
+ if (isA_OperatorToken(this.peek(), ';')) {
7888
+ this.advance();
7889
+ }
7890
+ }
7891
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7892
+ this.advance();
7893
+ return {
7894
+ t: AstNodeType.SpecialExpression,
7895
+ n: 'defn',
7896
+ f: symbol,
7897
+ p: [],
7898
+ o: [{
7899
+ as: functionArguments,
7900
+ b: body,
7901
+ a: arity,
7902
+ }],
7903
+ token: getTokenDebugData(token) && token,
7904
+ };
7905
+ };
7712
7906
  AlgebraicParser.prototype.isAtEnd = function () {
7713
7907
  return this.parseState.position >= this.tokenStream.tokens.length;
7714
7908
  };
7715
7909
  AlgebraicParser.prototype.peek = function () {
7716
7910
  return this.tokenStream.tokens[this.parseState.position];
7717
7911
  };
7718
- AlgebraicParser.prototype.peekAhead = function () {
7719
- return this.tokenStream.tokens[this.parseState.position + 1];
7720
- };
7721
7912
  return AlgebraicParser;
7722
7913
  }());
7723
7914
 
@@ -7998,10 +8189,18 @@ function parsePolishToken(tokenStream, parseState) {
7998
8189
  parseState.position += 1;
7999
8190
  parseState.algebraic = true;
8000
8191
  var algebraicParser = new AlgebraicParser(tokenStream, parseState);
8001
- var node = algebraicParser.parse();
8192
+ var nodes = algebraicParser.parse();
8002
8193
  assertEndNotationToken(tokenStream.tokens[parseState.position++]);
8003
8194
  parseState.algebraic = false;
8004
- return node;
8195
+ if (nodes.length === 1) {
8196
+ return nodes[0];
8197
+ }
8198
+ return {
8199
+ t: AstNodeType.SpecialExpression,
8200
+ n: 'do',
8201
+ p: nodes,
8202
+ token: nodes[0].token,
8203
+ };
8005
8204
  }
8006
8205
  case 'PolNotation': {
8007
8206
  var astNodes = [];
@@ -8068,12 +8267,21 @@ function removeUnnecessaryTokens(tokenStream) {
8068
8267
  function parseToken(tokenStream, parseState) {
8069
8268
  if (parseState.algebraic) {
8070
8269
  var algebraicParser = new AlgebraicParser(tokenStream, parseState);
8071
- return algebraicParser.parse();
8270
+ var nodes = algebraicParser.parse();
8271
+ if (nodes.length === 1) {
8272
+ return nodes[0];
8273
+ }
8274
+ return {
8275
+ t: AstNodeType.SpecialExpression,
8276
+ n: 'do',
8277
+ p: nodes,
8278
+ token: nodes[0].token,
8279
+ };
8072
8280
  }
8073
8281
  return parsePolishToken(tokenStream, parseState);
8074
8282
  }
8075
8283
 
8076
- var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:-]';
8284
+ var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:&\|~-]';
8077
8285
  var algebraicIdentifierCharacterClass = '[\\w$:!?]';
8078
8286
  var algebraicIdentifierFirstCharacterClass = '[a-zA-Z_$]';
8079
8287
 
@@ -8153,25 +8361,28 @@ var commonTokenizers = [
8153
8361
  tokenizeString,
8154
8362
  ];
8155
8363
 
8156
- var algebraicReservedNamesRecord = {
8157
- 'true': { value: true },
8158
- 'false': { value: false },
8159
- 'nil': { value: null },
8160
- 'null': { value: null },
8161
- 'def': { value: null, forbidden: true },
8162
- 'defs': { value: null, forbidden: true },
8163
- 'if-let': { value: null, forbidden: true },
8164
- 'when-let': { value: null, forbidden: true },
8165
- 'when-first': { value: null, forbidden: true },
8166
- 'fn': { value: null, forbidden: true },
8167
- 'defn': { value: null, forbidden: true },
8168
- 'defns': { value: null, forbidden: true },
8169
- 'try': { value: null, forbidden: true },
8170
- 'recur': { value: null, forbidden: true },
8171
- 'loop': { value: null, forbidden: true },
8172
- 'time!': { value: null, forbidden: true },
8173
- 'doseq': { value: null, forbidden: true },
8364
+ var validAlgebraicReservedNamesRecord = {
8365
+ true: { value: true, forbidden: false },
8366
+ false: { value: false, forbidden: false },
8367
+ nil: { value: null, forbidden: false },
8368
+ null: { value: null, forbidden: false },
8369
+ then: { value: null, forbidden: false },
8370
+ else: { value: null, forbidden: false },
8371
+ end: { value: null, forbidden: false },
8372
+ case: { value: null, forbidden: false },
8373
+ };
8374
+ var forbiddenAlgebraicReservedNamesRecord = {
8375
+ if_let: { value: null, forbidden: true },
8376
+ when_let: { value: null, forbidden: true },
8377
+ when_first: { value: null, forbidden: true },
8378
+ fn: { value: null, forbidden: true },
8379
+ defns: { value: null, forbidden: true },
8380
+ try: { value: null, forbidden: true },
8381
+ recur: { value: null, forbidden: true },
8382
+ loop: { value: null, forbidden: true },
8383
+ doseq: { value: null, forbidden: true },
8174
8384
  };
8385
+ var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
8175
8386
 
8176
8387
  var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
8177
8388
  var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
@@ -8243,45 +8454,19 @@ var tokenizeA_BasePrefixedNumber = function (input, position) {
8243
8454
  }
8244
8455
  return [length, ['A_BasePrefixedNumber', input.substring(position, i)]];
8245
8456
  };
8246
- var tokenizeA_ReservedSymbolToken = function (input, position) {
8247
- var e_1, _a;
8248
- try {
8249
- for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8250
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8251
- var length_1 = reservedName.length;
8252
- var nextChar = input[position + length_1];
8253
- if (nextChar && identifierRegExp.test(nextChar))
8254
- continue;
8255
- var name_1 = input.substring(position, position + length_1);
8256
- if (name_1 === reservedName) {
8257
- if (forbidden)
8258
- throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
8259
- return [length_1, ['A_ReservedSymbol', reservedName]];
8260
- }
8261
- }
8262
- }
8263
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8264
- finally {
8265
- try {
8266
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8267
- }
8268
- finally { if (e_1) throw e_1.error; }
8269
- }
8270
- return NO_MATCH;
8271
- };
8272
8457
  var tokenizeA_Symbol = function (input, position) {
8273
8458
  var value = input[position];
8274
8459
  if (!value) {
8275
8460
  return NO_MATCH;
8276
8461
  }
8277
8462
  if (value === '\'') {
8278
- var length_2 = 1;
8279
- var char = input[position + length_2];
8463
+ var length_1 = 1;
8464
+ var char = input[position + length_1];
8280
8465
  var escaping = false;
8281
8466
  while (char !== '\'' || escaping) {
8282
8467
  if (char === undefined)
8283
8468
  throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
8284
- length_2 += 1;
8469
+ length_1 += 1;
8285
8470
  if (escaping) {
8286
8471
  escaping = false;
8287
8472
  value += char;
@@ -8292,10 +8477,10 @@ var tokenizeA_Symbol = function (input, position) {
8292
8477
  }
8293
8478
  value += char;
8294
8479
  }
8295
- char = input[position + length_2];
8480
+ char = input[position + length_1];
8296
8481
  }
8297
8482
  value += '\''; // closing quote
8298
- return [length_2 + 1, ['A_Symbol', value]];
8483
+ return [length_1 + 1, ['A_Symbol', value]];
8299
8484
  }
8300
8485
  if (identifierFirstCharacterRegExp.test(value)) {
8301
8486
  var initialPosition = position;
@@ -8310,6 +8495,22 @@ var tokenizeA_Symbol = function (input, position) {
8310
8495
  }
8311
8496
  return NO_MATCH;
8312
8497
  };
8498
+ var tokenizeA_ReservedSymbolToken = function (input, position) {
8499
+ var symbolMeta = tokenizeA_Symbol(input, position);
8500
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
8501
+ return NO_MATCH;
8502
+ }
8503
+ var symbolName = symbolMeta[1][1];
8504
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
8505
+ var info = algebraicReservedNamesRecord[symbolName];
8506
+ if (!info) {
8507
+ return NO_MATCH;
8508
+ }
8509
+ if (info.forbidden) {
8510
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
8511
+ }
8512
+ return [symbolMeta[0], ['A_ReservedSymbol', symbolName]];
8513
+ };
8313
8514
  var tokenizeA_Operator = function (input, position) {
8314
8515
  var _a;
8315
8516
  var threeChars = input.slice(position, position + 3);
@@ -8328,30 +8529,30 @@ var tokenizeA_Operator = function (input, position) {
8328
8529
  };
8329
8530
  var tokenizeA_MultiLineComment = function (input, position) {
8330
8531
  if (input[position] === '/' && input[position + 1] === '*') {
8331
- var length_3 = 2;
8532
+ var length_2 = 2;
8332
8533
  var value = '/*';
8333
- while (input[position + length_3] !== '*' && input[position + length_3 + 1] !== '/' && position + length_3 + 1 < input.length) {
8334
- value += input[position + length_3];
8335
- length_3 += 1;
8534
+ while (input[position + length_2] !== '*' && input[position + length_2 + 1] !== '/' && position + length_2 + 1 < input.length) {
8535
+ value += input[position + length_2];
8536
+ length_2 += 1;
8336
8537
  }
8337
- if (position + length_3 + 1 >= input.length) {
8538
+ if (position + length_2 + 1 >= input.length) {
8338
8539
  throw new LitsError('Comment not closed', undefined);
8339
8540
  }
8340
8541
  value += '*/';
8341
- length_3 += 2;
8342
- return [length_3, ['A_MultiLineComment', value]];
8542
+ length_2 += 2;
8543
+ return [length_2, ['A_MultiLineComment', value]];
8343
8544
  }
8344
8545
  return NO_MATCH;
8345
8546
  };
8346
8547
  var tokenizeA_SingleLineComment = function (input, position) {
8347
8548
  if (input[position] === '/' && input[position + 1] === '/') {
8348
- var length_4 = 2;
8549
+ var length_3 = 2;
8349
8550
  var value = '//';
8350
- while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
8351
- value += input[position + length_4];
8352
- length_4 += 1;
8551
+ while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
8552
+ value += input[position + length_3];
8553
+ length_3 += 1;
8353
8554
  }
8354
- return [length_4, ['A_SingleLineComment', value]];
8555
+ return [length_3, ['A_SingleLineComment', value]];
8355
8556
  }
8356
8557
  return NO_MATCH;
8357
8558
  };
@@ -8511,31 +8712,20 @@ var tokenizeP_FnShorthand = function (input, position) {
8511
8712
  return [1, ['P_FnShorthand']];
8512
8713
  };
8513
8714
  var tokenizeP_ReservedSymbol = function (input, position) {
8514
- var e_1, _a;
8515
- try {
8516
- for (var _b = __values(Object.entries(polishReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8517
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8518
- var length_3 = reservedName.length;
8519
- var nextChar = input[position + length_3];
8520
- if (nextChar && P_symbolRegExp.test(nextChar)) {
8521
- continue;
8522
- }
8523
- var symbol = input.substring(position, position + length_3);
8524
- if (symbol === reservedName) {
8525
- if (forbidden)
8526
- throw new LitsError("".concat(symbol, " is forbidden!"), undefined);
8527
- return [length_3, ['P_ReservedSymbol', reservedName]];
8528
- }
8529
- }
8715
+ var symbolMeta = tokenizeP_Symbol(input, position);
8716
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
8717
+ return NO_MATCH;
8530
8718
  }
8531
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8532
- finally {
8533
- try {
8534
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8535
- }
8536
- finally { if (e_1) throw e_1.error; }
8719
+ var symbolName = symbolMeta[1][1];
8720
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
8721
+ var info = polishReservedNamesRecord[symbolName];
8722
+ if (!info) {
8723
+ return NO_MATCH;
8537
8724
  }
8538
- return NO_MATCH;
8725
+ if (info.forbidden) {
8726
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
8727
+ }
8728
+ return [symbolMeta[0], ['P_ReservedSymbol', symbolName]];
8539
8729
  };
8540
8730
  var tokenizeP_StringShorthand = function (input, position) {
8541
8731
  if (input[position] !== ':')
@@ -8548,24 +8738,24 @@ var tokenizeP_StringShorthand = function (input, position) {
8548
8738
  return [symbolDescription[0] + 1, ['P_StringShorthand', ":".concat(symbolToken[1])]];
8549
8739
  };
8550
8740
  var tokenizeP_Modifier = function (input, position) {
8551
- var e_2, _a;
8741
+ var e_1, _a;
8552
8742
  try {
8553
8743
  for (var modifierNames_1 = __values(modifierNames), modifierNames_1_1 = modifierNames_1.next(); !modifierNames_1_1.done; modifierNames_1_1 = modifierNames_1.next()) {
8554
8744
  var modifierName = modifierNames_1_1.value;
8555
- var length_4 = modifierName.length;
8556
- var charAfterModifier = input[position + length_4];
8557
- if (input.substring(position, position + length_4) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8745
+ var length_3 = modifierName.length;
8746
+ var charAfterModifier = input[position + length_3];
8747
+ if (input.substring(position, position + length_3) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8558
8748
  var value = modifierName;
8559
- return [length_4, ['P_Modifier', value]];
8749
+ return [length_3, ['P_Modifier', value]];
8560
8750
  }
8561
8751
  }
8562
8752
  }
8563
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
8753
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8564
8754
  finally {
8565
8755
  try {
8566
8756
  if (modifierNames_1_1 && !modifierNames_1_1.done && (_a = modifierNames_1.return)) _a.call(modifierNames_1);
8567
8757
  }
8568
- finally { if (e_2) throw e_2.error; }
8758
+ finally { if (e_1) throw e_1.error; }
8569
8759
  }
8570
8760
  return NO_MATCH;
8571
8761
  };
@@ -8602,8 +8792,8 @@ var polishTokenizers = __spreadArray(__spreadArray([
8602
8792
  tokenizeP_StringShorthand,
8603
8793
  tokenizeP_Number,
8604
8794
  tokenizeP_ReservedSymbol,
8605
- tokenizeP_Symbol,
8606
8795
  tokenizeP_Modifier,
8796
+ tokenizeP_Symbol,
8607
8797
  tokenizeP_RegexpShorthand,
8608
8798
  tokenizeP_FnShorthand,
8609
8799
  tokenizeP_CollectionAccessor,