@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
@@ -238,6 +238,12 @@ function isFunctionType(type) {
238
238
  return typeof type === 'number' && functionTypeName.has(type);
239
239
  }
240
240
 
241
+ function getSourceCodeInfo(anyValue, sourceCodeInfo) {
242
+ var _a;
243
+ // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
244
+ return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
245
+ }
246
+
241
247
  function isTokenDebugData(tokenDebugData) {
242
248
  return (typeof tokenDebugData === 'object'
243
249
  && tokenDebugData !== null
@@ -256,8 +262,12 @@ function addTokenDebugData(token, debugData) {
256
262
  }
257
263
  token.push(debugData);
258
264
  }
259
- function throwUnexpectedToken(expected, actual) {
260
- throw new LitsError("Unexpected token: ".concat(actual, ", expected ").concat(expected), undefined);
265
+ function throwUnexpectedToken(expected, expectedValue, actual) {
266
+ if (actual === undefined) {
267
+ throw new LitsError("Unexpected end of input, expected ".concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), undefined);
268
+ }
269
+ var actualOutput = "".concat(actual[0]).concat(actual[1] ? " '".concat(actual[1], "'") : '');
270
+ throw new LitsError("Unexpected token: ".concat(actualOutput, ", expected ").concat(expected).concat(expectedValue ? " '".concat(expectedValue, "'") : ''), getSourceCodeInfo(actual));
261
271
  }
262
272
 
263
273
  var commonSimpleTokenTypes = [
@@ -279,7 +289,7 @@ function isLParenToken(token) {
279
289
  }
280
290
  function assertLParenToken(token) {
281
291
  if (!isLParenToken(token)) {
282
- throwUnexpectedToken('LParen', token);
292
+ throwUnexpectedToken('LParen', undefined, token);
283
293
  }
284
294
  }
285
295
  function asLParenToken(token) {
@@ -291,7 +301,7 @@ function isRParenToken(token) {
291
301
  }
292
302
  function assertRParenToken(token) {
293
303
  if (!isRParenToken(token)) {
294
- throwUnexpectedToken('RParen', token);
304
+ throwUnexpectedToken('RParen', undefined, token);
295
305
  }
296
306
  }
297
307
  function isLBracketToken(token) {
@@ -299,7 +309,7 @@ function isLBracketToken(token) {
299
309
  }
300
310
  function assertLBracketToken(token) {
301
311
  if (!isLBracketToken(token)) {
302
- throwUnexpectedToken('LBracket', token);
312
+ throwUnexpectedToken('LBracket', undefined, token);
303
313
  }
304
314
  }
305
315
  function asLBracketToken(token) {
@@ -311,7 +321,7 @@ function isRBracketToken(token) {
311
321
  }
312
322
  function assertRBracketToken(token) {
313
323
  if (!isRBracketToken(token)) {
314
- throwUnexpectedToken('RBracket', token);
324
+ throwUnexpectedToken('RBracket', undefined, token);
315
325
  }
316
326
  }
317
327
  function isLBraceToken(token) {
@@ -319,7 +329,7 @@ function isLBraceToken(token) {
319
329
  }
320
330
  function assertLBraceToken(token) {
321
331
  if (!isLBraceToken(token)) {
322
- throwUnexpectedToken('LBrace', token);
332
+ throwUnexpectedToken('LBrace', undefined, token);
323
333
  }
324
334
  }
325
335
  function asLBraceToken(token) {
@@ -331,7 +341,7 @@ function isRBraceToken(token) {
331
341
  }
332
342
  function assertRBraceToken(token) {
333
343
  if (!isRBraceToken(token)) {
334
- throwUnexpectedToken('RBrace', token);
344
+ throwUnexpectedToken('RBrace', undefined, token);
335
345
  }
336
346
  }
337
347
  function isStringToken(token) {
@@ -339,7 +349,7 @@ function isStringToken(token) {
339
349
  }
340
350
  function assertStringToken(token) {
341
351
  if (!isStringToken(token)) {
342
- throwUnexpectedToken('String', token);
352
+ throwUnexpectedToken('String', undefined, token);
343
353
  }
344
354
  }
345
355
  function asStringToken(token) {
@@ -357,7 +367,7 @@ function isEndNotationToken(token) {
357
367
  }
358
368
  function assertEndNotationToken(token) {
359
369
  if (!isEndNotationToken(token)) {
360
- throwUnexpectedToken('EndNotation', token);
370
+ throwUnexpectedToken('EndNotation', undefined, token);
361
371
  }
362
372
  }
363
373
 
@@ -410,28 +420,28 @@ var otherSymbolicOperators = [
410
420
  '.', // property accessor
411
421
  ',', // item separator
412
422
  '=', // property assignment
423
+ ';', // statement terminator
413
424
  ];
414
425
  var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(symbolicUnaryOperators), false), __read(symbolicBinaryOperators), false), __read(otherSymbolicOperators), false);
415
426
  var nonFunctionOperators = [
416
427
  '??',
417
- 'and',
428
+ '&&',
418
429
  'comment',
419
430
  'cond',
420
431
  'declared?',
421
432
  'if',
422
- 'if-not',
423
- 'or',
433
+ 'if_not',
434
+ '||',
424
435
  'when',
425
- 'when-not',
436
+ 'when_not',
426
437
  'do',
427
- 'time!',
428
438
  'throw',
429
439
  'let',
430
440
  'def',
431
441
  'defs',
432
- 'if-let',
433
- 'when-let',
434
- 'when-first',
442
+ 'if_let',
443
+ 'when_let',
444
+ 'when_first',
435
445
  'fn',
436
446
  'defn',
437
447
  'defns',
@@ -462,7 +472,7 @@ function isA_SymbolToken(token) {
462
472
  }
463
473
  function assertA_SymbolToken(token) {
464
474
  if (!isA_SymbolToken(token)) {
465
- throwUnexpectedToken('A_Symbol', token);
475
+ throwUnexpectedToken('A_Symbol', undefined, token);
466
476
  }
467
477
  }
468
478
  function asA_SymbolToken(token) {
@@ -472,8 +482,19 @@ function asA_SymbolToken(token) {
472
482
  function isA_BinaryOperatorToken(token) {
473
483
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_Operator' && isSymbolicBinaryOperator(token[1]);
474
484
  }
475
- function isA_ReservedSymbolToken(token) {
476
- return (token === null || token === void 0 ? void 0 : token[0]) === 'A_ReservedSymbol';
485
+ function isA_ReservedSymbolToken(token, symbolName) {
486
+ if ((token === null || token === void 0 ? void 0 : token[0]) !== 'A_ReservedSymbol') {
487
+ return false;
488
+ }
489
+ if (symbolName && token[1] !== symbolName) {
490
+ return false;
491
+ }
492
+ return true;
493
+ }
494
+ function assertA_ReservedSymbolToken(token, symbolName) {
495
+ if (!isA_ReservedSymbolToken(token, symbolName)) {
496
+ throwUnexpectedToken('A_ReservedSymbol', symbolName, token);
497
+ }
477
498
  }
478
499
  function isA_CommentToken(token) {
479
500
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_SingleLineComment';
@@ -492,10 +513,9 @@ function isA_OperatorToken(token, operatorName) {
492
513
  }
493
514
  function assertA_OperatorToken(token, operatorName) {
494
515
  if (!isA_OperatorToken(token, operatorName)) {
495
- if (operatorName) {
516
+ {
496
517
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
497
518
  }
498
- throwUnexpectedToken('A_Operator', token);
499
519
  }
500
520
  }
501
521
  function isA_WhitespaceToken(token) {
@@ -508,7 +528,7 @@ function isA_BasePrefixedNumberToken(token) {
508
528
  return (token === null || token === void 0 ? void 0 : token[0]) === 'A_BasePrefixedNumber';
509
529
  }
510
530
 
511
- var modifierNames = ['&', '&let', '&when', '&while'];
531
+ var modifierNames = ['&rest', '&let', '&when', '&while'];
512
532
  var polishOnlySimpleTokenTypes = [
513
533
  'P_FnShorthand',
514
534
  ];
@@ -531,7 +551,7 @@ function isP_StringShorthandToken(token) {
531
551
  }
532
552
  function assertP_StringShorthandToken(token) {
533
553
  if (!isP_StringShorthandToken(token)) {
534
- throwUnexpectedToken('P_StringShorthand', token);
554
+ throwUnexpectedToken('P_StringShorthand', undefined, token);
535
555
  }
536
556
  }
537
557
  function asP_StringShorthandToken(token) {
@@ -543,7 +563,7 @@ function isP_SymbolToken(token) {
543
563
  }
544
564
  function assertP_SymbolToken(token) {
545
565
  if (!isP_SymbolToken(token)) {
546
- throwUnexpectedToken('P_Symbol', token);
566
+ throwUnexpectedToken('P_Symbol', undefined, token);
547
567
  }
548
568
  }
549
569
  function asP_SymbolToken(token) {
@@ -561,7 +581,7 @@ function isP_RegexpShorthandToken(token) {
561
581
  }
562
582
  function assertP_RegexpShorthandToken(token) {
563
583
  if (!isP_RegexpShorthandToken(token)) {
564
- throwUnexpectedToken('P_RegexpShorthand', token);
584
+ throwUnexpectedToken('P_RegexpShorthand', undefined, token);
565
585
  }
566
586
  }
567
587
  function asP_RegexpShorthandToken(token) {
@@ -576,7 +596,7 @@ function isP_CollectionAccessorToken(token) {
576
596
  }
577
597
  function assertP_CollectionAccessorToken(token) {
578
598
  if (!isP_CollectionAccessorToken(token)) {
579
- throwUnexpectedToken('P_CollectionAccessor', token);
599
+ throwUnexpectedToken('P_CollectionAccessor', undefined, token);
580
600
  }
581
601
  }
582
602
  function asP_CollectionAccessorToken(token) {
@@ -588,7 +608,7 @@ function isP_CommentToken(token) {
588
608
  }
589
609
  function assertP_CommentToken(token) {
590
610
  if (!isP_CommentToken(token)) {
591
- throwUnexpectedToken('P_Comment', token);
611
+ throwUnexpectedToken('P_Comment', undefined, token);
592
612
  }
593
613
  }
594
614
  function asP_CommentToken(token) {
@@ -603,7 +623,7 @@ function isP_NumberToken(token) {
603
623
  }
604
624
  function assertP_NumberToken(token) {
605
625
  if (!isP_NumberToken(token)) {
606
- throwUnexpectedToken('P_Number', token);
626
+ throwUnexpectedToken('P_Number', undefined, token);
607
627
  }
608
628
  }
609
629
 
@@ -671,12 +691,6 @@ function valueToString(value) {
671
691
  return JSON.stringify(value);
672
692
  }
673
693
 
674
- function getSourceCodeInfo(anyValue, sourceCodeInfo) {
675
- var _a;
676
- // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access
677
- return (_a = anyValue === null || anyValue === void 0 ? void 0 : anyValue.sourceCodeInfo) !== null && _a !== void 0 ? _a : sourceCodeInfo;
678
- }
679
-
680
694
  function getRangeString(options) {
681
695
  var hasUpperAndLowerBound = (typeof options.gt === 'number' || typeof options.gte === 'number')
682
696
  && (typeof options.lt === 'number' || typeof options.lte === 'number');
@@ -809,7 +823,7 @@ function isExpressionNode(value) {
809
823
  }
810
824
 
811
825
  var specialExpressionCommentRemovers = {
812
- 'and': function (node, removeOptions) {
826
+ '&&': function (node, removeOptions) {
813
827
  removeOptions.removeCommenNodesFromArray(node.p);
814
828
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
815
829
  },
@@ -821,6 +835,10 @@ var specialExpressionCommentRemovers = {
821
835
  removeOptions.removeCommenNodesFromArray(node.p);
822
836
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
823
837
  },
838
+ 'switch': function (node, removeOptions) {
839
+ removeOptions.removeCommenNodesFromArray(node.p);
840
+ node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
841
+ },
824
842
  'declared?': function (node, removeOptions) {
825
843
  removeOptions.removeCommenNodesFromArray(node.p);
826
844
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
@@ -842,12 +860,12 @@ var specialExpressionCommentRemovers = {
842
860
  'doseq': function (_node, _removeOptions) { },
843
861
  'fn': function (_node, _removeOptions) { },
844
862
  'for': function (_node, _removeOptions) { },
845
- 'if-let': function (_node, _removeOptions) { },
863
+ 'if_let': function (_node, _removeOptions) { },
846
864
  'if': function (node, removeOptions) {
847
865
  removeOptions.removeCommenNodesFromArray(node.p);
848
866
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
849
867
  },
850
- 'if-not': function (node, removeOptions) {
868
+ 'if_not': function (node, removeOptions) {
851
869
  removeOptions.removeCommenNodesFromArray(node.p);
852
870
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
853
871
  },
@@ -859,7 +877,7 @@ var specialExpressionCommentRemovers = {
859
877
  });
860
878
  },
861
879
  'loop': function (_node, _removeOptions) { },
862
- 'or': function (node, removeOptions) {
880
+ '||': function (node, removeOptions) {
863
881
  removeOptions.removeCommenNodesFromArray(node.p);
864
882
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
865
883
  },
@@ -871,19 +889,15 @@ var specialExpressionCommentRemovers = {
871
889
  removeOptions.removeCommenNodesFromArray(node.p);
872
890
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
873
891
  },
874
- 'time!': function (node, removeOptions) {
875
- removeOptions.removeCommenNodesFromArray(node.p);
876
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
877
- },
878
892
  'throw': function (node, removeOptions) {
879
893
  removeOptions.removeCommenNodesFromArray(node.p);
880
894
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
881
895
  },
882
896
  'try': function (_node, _removeOptions) { },
883
- 'when-first': function (_node, _removeOptions) { },
884
- 'when-let': function (_node, _removeOptions) { },
897
+ 'when_first': function (_node, _removeOptions) { },
898
+ 'when_let': function (_node, _removeOptions) { },
885
899
  'when': function (_node, _removeOptions) { },
886
- 'when-not': function (_node, _removeOptions) { },
900
+ 'when_not': function (_node, _removeOptions) { },
887
901
  };
888
902
  function removeCommentNodesFromSpecialExpression(node, removeOptions) {
889
903
  var uncommenter = specialExpressionCommentRemovers[node.n];
@@ -925,6 +939,13 @@ function assertEvenNumberOfParams(node) {
925
939
  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);
926
940
  }
927
941
  }
942
+ function assertOddNumberOfParams(node) {
943
+ var _a;
944
+ var length = withoutCommentNodes(node.p).length;
945
+ if (length % 2 !== 1) {
946
+ 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);
947
+ }
948
+ }
928
949
  function assertNumberOfParams(count, node) {
929
950
  var _a, _b;
930
951
  assertCount({
@@ -969,7 +990,7 @@ function assertCount(_a) {
969
990
  }
970
991
 
971
992
  var bitwiseNormalExpression = {
972
- 'bit-shift-left': {
993
+ '<<': {
973
994
  evaluate: function (_a, sourceCodeInfo) {
974
995
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
975
996
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -978,7 +999,7 @@ var bitwiseNormalExpression = {
978
999
  },
979
1000
  validate: function (node) { return assertNumberOfParams(2, node); },
980
1001
  },
981
- 'bit-shift-right': {
1002
+ '>>': {
982
1003
  evaluate: function (_a, sourceCodeInfo) {
983
1004
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
984
1005
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -987,7 +1008,7 @@ var bitwiseNormalExpression = {
987
1008
  },
988
1009
  validate: function (node) { return assertNumberOfParams(2, node); },
989
1010
  },
990
- 'unsigned-bit-shift-right': {
1011
+ '>>>': {
991
1012
  evaluate: function (_a, sourceCodeInfo) {
992
1013
  var _b = __read(_a, 2), num = _b[0], count = _b[1];
993
1014
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -996,7 +1017,7 @@ var bitwiseNormalExpression = {
996
1017
  },
997
1018
  validate: function (node) { return assertNumberOfParams(2, node); },
998
1019
  },
999
- 'bit-not': {
1020
+ '~': {
1000
1021
  evaluate: function (_a, sourceCodeInfo) {
1001
1022
  var _b = __read(_a, 1), num = _b[0];
1002
1023
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1004,7 +1025,7 @@ var bitwiseNormalExpression = {
1004
1025
  },
1005
1026
  validate: function (node) { return assertNumberOfParams(1, node); },
1006
1027
  },
1007
- 'bit-and': {
1028
+ '&': {
1008
1029
  evaluate: function (_a, sourceCodeInfo) {
1009
1030
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1010
1031
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1015,7 +1036,7 @@ var bitwiseNormalExpression = {
1015
1036
  },
1016
1037
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1017
1038
  },
1018
- 'bit-and-not': {
1039
+ '&!': {
1019
1040
  evaluate: function (_a, sourceCodeInfo) {
1020
1041
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1021
1042
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1026,7 +1047,7 @@ var bitwiseNormalExpression = {
1026
1047
  },
1027
1048
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1028
1049
  },
1029
- 'bit-or': {
1050
+ '|': {
1030
1051
  evaluate: function (_a, sourceCodeInfo) {
1031
1052
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1032
1053
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1037,7 +1058,7 @@ var bitwiseNormalExpression = {
1037
1058
  },
1038
1059
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1039
1060
  },
1040
- 'bit-xor': {
1061
+ '^': {
1041
1062
  evaluate: function (_a, sourceCodeInfo) {
1042
1063
  var _b = __read(_a), first = _b[0], rest = _b.slice(1);
1043
1064
  assertNumber(first, sourceCodeInfo, { integer: true });
@@ -1048,7 +1069,7 @@ var bitwiseNormalExpression = {
1048
1069
  },
1049
1070
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
1050
1071
  },
1051
- 'bit-flip': {
1072
+ 'bit_flip': {
1052
1073
  evaluate: function (_a, sourceCodeInfo) {
1053
1074
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1054
1075
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1058,7 +1079,7 @@ var bitwiseNormalExpression = {
1058
1079
  },
1059
1080
  validate: function (node) { return assertNumberOfParams(2, node); },
1060
1081
  },
1061
- 'bit-set': {
1082
+ 'bit_set': {
1062
1083
  evaluate: function (_a, sourceCodeInfo) {
1063
1084
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1064
1085
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1068,7 +1089,7 @@ var bitwiseNormalExpression = {
1068
1089
  },
1069
1090
  validate: function (node) { return assertNumberOfParams(2, node); },
1070
1091
  },
1071
- 'bit-clear': {
1092
+ 'bit_clear': {
1072
1093
  evaluate: function (_a, sourceCodeInfo) {
1073
1094
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1074
1095
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -1078,7 +1099,7 @@ var bitwiseNormalExpression = {
1078
1099
  },
1079
1100
  validate: function (node) { return assertNumberOfParams(2, node); },
1080
1101
  },
1081
- 'bit-test': {
1102
+ 'bit_test': {
1082
1103
  evaluate: function (_a, sourceCodeInfo) {
1083
1104
  var _b = __read(_a, 2), num = _b[0], index = _b[1];
1084
1105
  assertNumber(num, sourceCodeInfo, { integer: true });
@@ -2779,7 +2800,7 @@ var mathNormalExpression = {
2779
2800
  },
2780
2801
  validate: function (node) { return assertNumberOfParams(2, node); },
2781
2802
  },
2782
- 'rem': {
2803
+ '%': {
2783
2804
  evaluate: function (_a, sourceCodeInfo) {
2784
2805
  var _b = __read(_a, 2), dividend = _b[0], divisor = _b[1];
2785
2806
  assertNumber(dividend, sourceCodeInfo);
@@ -2805,7 +2826,7 @@ var mathNormalExpression = {
2805
2826
  },
2806
2827
  validate: function (node) { return assertNumberOfParams(1, node); },
2807
2828
  },
2808
- 'pow': {
2829
+ '**': {
2809
2830
  evaluate: function (_a, sourceCodeInfo) {
2810
2831
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
2811
2832
  assertNumber(first, sourceCodeInfo);
@@ -3082,10 +3103,6 @@ var mathNormalExpression = {
3082
3103
  },
3083
3104
  };
3084
3105
 
3085
- var version = "2.0.13";
3086
-
3087
- var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
3088
- var xyRegexp = /[xy]/g;
3089
3106
  var miscNormalExpression = {
3090
3107
  '!=': {
3091
3108
  evaluate: function (params) {
@@ -3099,7 +3116,7 @@ var miscNormalExpression = {
3099
3116
  },
3100
3117
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3101
3118
  },
3102
- '=': {
3119
+ '==': {
3103
3120
  evaluate: function (_a) {
3104
3121
  var e_1, _b;
3105
3122
  var _c = __read(_a), first = _c[0], rest = _c.slice(1);
@@ -3224,20 +3241,14 @@ var miscNormalExpression = {
3224
3241
  },
3225
3242
  validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
3226
3243
  },
3227
- 'not': {
3244
+ '!': {
3228
3245
  evaluate: function (_a) {
3229
3246
  var _b = __read(_a, 1), first = _b[0];
3230
3247
  return !first;
3231
3248
  },
3232
3249
  validate: function (node) { return assertNumberOfParams(1, node); },
3233
3250
  },
3234
- 'inst-ms!': {
3235
- evaluate: function () {
3236
- return Date.now();
3237
- },
3238
- validate: function (node) { return assertNumberOfParams(0, node); },
3239
- },
3240
- 'inst-ms->iso-date-time': {
3251
+ 'epoch>iso_date': {
3241
3252
  evaluate: function (_a, sourceCodeInfo) {
3242
3253
  var _b = __read(_a, 1), ms = _b[0];
3243
3254
  assertNumber(ms, sourceCodeInfo);
@@ -3245,7 +3256,7 @@ var miscNormalExpression = {
3245
3256
  },
3246
3257
  validate: function (node) { return assertNumberOfParams(1, node); },
3247
3258
  },
3248
- 'iso-date-time->inst-ms': {
3259
+ 'iso_date>epoch': {
3249
3260
  evaluate: function (_a, sourceCodeInfo) {
3250
3261
  var _b = __read(_a, 1), dateTime = _b[0];
3251
3262
  assertString(dateTime, sourceCodeInfo);
@@ -3278,23 +3289,7 @@ var miscNormalExpression = {
3278
3289
  },
3279
3290
  validate: function (node) { return assertNumberOfParams(2, node); },
3280
3291
  },
3281
- 'uuid!': {
3282
- evaluate: function () {
3283
- return uuidTemplate.replace(xyRegexp, function (character) {
3284
- var randomNbr = Math.floor(Math.random() * 16);
3285
- var newValue = character === 'x' ? randomNbr : (randomNbr & 0x3) | 0x8;
3286
- return newValue.toString(16);
3287
- });
3288
- },
3289
- validate: function (node) { return assertNumberOfParams(0, node); },
3290
- },
3291
- 'lits-version!': {
3292
- evaluate: function () {
3293
- return version;
3294
- },
3295
- validate: function (node) { return assertNumberOfParams(0, node); },
3296
- },
3297
- 'json-parse': {
3292
+ 'json_parse': {
3298
3293
  evaluate: function (_a, sourceCodeInfo) {
3299
3294
  var _b = __read(_a, 1), first = _b[0];
3300
3295
  assertString(first, sourceCodeInfo);
@@ -3303,7 +3298,7 @@ var miscNormalExpression = {
3303
3298
  },
3304
3299
  validate: function (node) { return assertNumberOfParams(1, node); },
3305
3300
  },
3306
- 'json-stringify': {
3301
+ 'json_stringify': {
3307
3302
  evaluate: function (_a, sourceCodeInfo) {
3308
3303
  var _b = __read(_a, 2), first = _b[0], second = _b[1];
3309
3304
  assertAny(first, sourceCodeInfo);
@@ -3516,7 +3511,7 @@ var assertNormalExpression = {
3516
3511
  };
3517
3512
 
3518
3513
  var objectNormalExpression = {
3519
- 'object': {
3514
+ object: {
3520
3515
  evaluate: function (params, sourceCodeInfo) {
3521
3516
  var result = {};
3522
3517
  for (var i = 0; i < params.length; i += 2) {
@@ -3529,7 +3524,7 @@ var objectNormalExpression = {
3529
3524
  },
3530
3525
  validate: function (node) { return assertEvenNumberOfParams(node); },
3531
3526
  },
3532
- 'keys': {
3527
+ keys: {
3533
3528
  evaluate: function (_a, sourceCodeInfo) {
3534
3529
  var _b = __read(_a, 1), obj = _b[0];
3535
3530
  assertObj(obj, sourceCodeInfo);
@@ -3537,7 +3532,7 @@ var objectNormalExpression = {
3537
3532
  },
3538
3533
  validate: function (node) { return assertNumberOfParams(1, node); },
3539
3534
  },
3540
- 'vals': {
3535
+ vals: {
3541
3536
  evaluate: function (_a, sourceCodeInfo) {
3542
3537
  var _b = __read(_a, 1), obj = _b[0];
3543
3538
  assertObj(obj, sourceCodeInfo);
@@ -3545,7 +3540,7 @@ var objectNormalExpression = {
3545
3540
  },
3546
3541
  validate: function (node) { return assertNumberOfParams(1, node); },
3547
3542
  },
3548
- 'entries': {
3543
+ entries: {
3549
3544
  evaluate: function (_a, sourceCodeInfo) {
3550
3545
  var _b = __read(_a, 1), obj = _b[0];
3551
3546
  assertObj(obj, sourceCodeInfo);
@@ -3553,7 +3548,7 @@ var objectNormalExpression = {
3553
3548
  },
3554
3549
  validate: function (node) { return assertNumberOfParams(1, node); },
3555
3550
  },
3556
- 'find': {
3551
+ find: {
3557
3552
  evaluate: function (_a, sourceCodeInfo) {
3558
3553
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3559
3554
  assertObj(obj, sourceCodeInfo);
@@ -3564,7 +3559,7 @@ var objectNormalExpression = {
3564
3559
  },
3565
3560
  validate: function (node) { return assertNumberOfParams(2, node); },
3566
3561
  },
3567
- 'dissoc': {
3562
+ dissoc: {
3568
3563
  evaluate: function (_a, sourceCodeInfo) {
3569
3564
  var _b = __read(_a, 2), obj = _b[0], key = _b[1];
3570
3565
  assertObj(obj, sourceCodeInfo);
@@ -3575,7 +3570,7 @@ var objectNormalExpression = {
3575
3570
  },
3576
3571
  validate: function (node) { return assertNumberOfParams(2, node); },
3577
3572
  },
3578
- 'merge': {
3573
+ merge: {
3579
3574
  evaluate: function (params, sourceCodeInfo) {
3580
3575
  if (params.length === 0)
3581
3576
  return null;
@@ -3588,7 +3583,7 @@ var objectNormalExpression = {
3588
3583
  },
3589
3584
  validate: function (node) { return assertNumberOfParams({ min: 0 }, node); },
3590
3585
  },
3591
- 'merge-with': {
3586
+ merge_with: {
3592
3587
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
3593
3588
  var executeFunction = _a.executeFunction;
3594
3589
  var first = params[0];
@@ -3611,7 +3606,7 @@ var objectNormalExpression = {
3611
3606
  },
3612
3607
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
3613
3608
  },
3614
- 'zipmap': {
3609
+ zipmap: {
3615
3610
  evaluate: function (_a, sourceCodeInfo) {
3616
3611
  var _b = __read(_a, 2), keys = _b[0], values = _b[1];
3617
3612
  assertStringArray(keys, sourceCodeInfo);
@@ -3626,7 +3621,7 @@ var objectNormalExpression = {
3626
3621
  },
3627
3622
  validate: function (node) { return assertNumberOfParams(2, node); },
3628
3623
  },
3629
- 'select-keys': {
3624
+ select_keys: {
3630
3625
  evaluate: function (_a, sourceCodeInfo) {
3631
3626
  var _b = __read(_a, 2), obj = _b[0], keys = _b[1];
3632
3627
  assertStringArray(keys, sourceCodeInfo);
@@ -3892,7 +3887,7 @@ var stringNormalExpression = {
3892
3887
  },
3893
3888
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
3894
3889
  },
3895
- 'string-repeat': {
3890
+ 'string_repeat': {
3896
3891
  evaluate: function (_a, sourceCodeInfo) {
3897
3892
  var _b = __read(_a, 2), str = _b[0], count = _b[1];
3898
3893
  assertString(str, sourceCodeInfo);
@@ -3926,27 +3921,7 @@ var stringNormalExpression = {
3926
3921
  },
3927
3922
  validate: function (node) { return assertNumberOfParams(1, node); },
3928
3923
  },
3929
- 'number-to-string': {
3930
- evaluate: function (params, sourceCodeInfo) {
3931
- var _a = __read(params, 2), num = _a[0], base = _a[1];
3932
- assertNumber(num, sourceCodeInfo, { finite: true });
3933
- if (params.length === 1) {
3934
- return "".concat(num);
3935
- }
3936
- else {
3937
- assertNumber(base, sourceCodeInfo, { finite: true });
3938
- if (base !== 2 && base !== 8 && base !== 10 && base !== 16) {
3939
- throw new LitsError("Expected \"number-to-string\" base argument to be 2, 8, 10 or 16, got: ".concat(base), sourceCodeInfo);
3940
- }
3941
- if (base === 10)
3942
- return "".concat(num);
3943
- assertNumber(num, sourceCodeInfo, { integer: true, nonNegative: true });
3944
- return Number(num).toString(base);
3945
- }
3946
- },
3947
- validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
3948
- },
3949
- 'from-char-code': {
3924
+ 'from_char_code': {
3950
3925
  evaluate: function (_a, sourceCodeInfo) {
3951
3926
  var _b = __read(_a, 1), num = _b[0];
3952
3927
  assertNumber(num, sourceCodeInfo, { finite: true });
@@ -3960,7 +3935,7 @@ var stringNormalExpression = {
3960
3935
  },
3961
3936
  validate: function (node) { return assertNumberOfParams(1, node); },
3962
3937
  },
3963
- 'to-char-code': {
3938
+ 'to_char_code': {
3964
3939
  evaluate: function (_a, sourceCodeInfo) {
3965
3940
  var _b = __read(_a, 1), str = _b[0];
3966
3941
  assertString(str, sourceCodeInfo, { nonEmpty: true });
@@ -3968,7 +3943,7 @@ var stringNormalExpression = {
3968
3943
  },
3969
3944
  validate: function (node) { return assertNumberOfParams(1, node); },
3970
3945
  },
3971
- 'lower-case': {
3946
+ 'lower_case': {
3972
3947
  evaluate: function (_a, sourceCodeInfo) {
3973
3948
  var _b = __read(_a, 1), str = _b[0];
3974
3949
  assertString(str, sourceCodeInfo);
@@ -3976,7 +3951,7 @@ var stringNormalExpression = {
3976
3951
  },
3977
3952
  validate: function (node) { return assertNumberOfParams(1, node); },
3978
3953
  },
3979
- 'upper-case': {
3954
+ 'upper_case': {
3980
3955
  evaluate: function (_a, sourceCodeInfo) {
3981
3956
  var _b = __read(_a, 1), str = _b[0];
3982
3957
  assertString(str, sourceCodeInfo);
@@ -3992,7 +3967,7 @@ var stringNormalExpression = {
3992
3967
  },
3993
3968
  validate: function (node) { return assertNumberOfParams(1, node); },
3994
3969
  },
3995
- 'trim-left': {
3970
+ 'trim_left': {
3996
3971
  evaluate: function (_a, sourceCodeInfo) {
3997
3972
  var _b = __read(_a, 1), str = _b[0];
3998
3973
  assertString(str, sourceCodeInfo);
@@ -4000,7 +3975,7 @@ var stringNormalExpression = {
4000
3975
  },
4001
3976
  validate: function (node) { return assertNumberOfParams(1, node); },
4002
3977
  },
4003
- 'trim-right': {
3978
+ 'trim_right': {
4004
3979
  evaluate: function (_a, sourceCodeInfo) {
4005
3980
  var _b = __read(_a, 1), str = _b[0];
4006
3981
  assertString(str, sourceCodeInfo);
@@ -4008,6 +3983,30 @@ var stringNormalExpression = {
4008
3983
  },
4009
3984
  validate: function (node) { return assertNumberOfParams(1, node); },
4010
3985
  },
3986
+ '++': {
3987
+ evaluate: function (params, sourceCodeInfo) {
3988
+ if (params.length === 0) {
3989
+ return '';
3990
+ }
3991
+ var first = params[0];
3992
+ if (first !== null) {
3993
+ assertStringOrNumber(first, sourceCodeInfo);
3994
+ }
3995
+ if (params.length === 1) {
3996
+ return first === null ? '' : "".concat(first);
3997
+ }
3998
+ return params.slice(1).reduce(function (acc, str) {
3999
+ if (str !== null) {
4000
+ assertStringOrNumber(str, sourceCodeInfo);
4001
+ }
4002
+ if (str === null) {
4003
+ return acc;
4004
+ }
4005
+ return "".concat(acc).concat(str);
4006
+ }, first === null ? '' : "".concat(first));
4007
+ },
4008
+ validate: function () { return undefined; },
4009
+ },
4011
4010
  'join': {
4012
4011
  evaluate: function (_a, sourceCodeInfo) {
4013
4012
  var _b = __read(_a, 2), stringList = _b[0], delimiter = _b[1];
@@ -4032,7 +4031,7 @@ var stringNormalExpression = {
4032
4031
  },
4033
4032
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4034
4033
  },
4035
- 'pad-left': {
4034
+ 'pad_left': {
4036
4035
  evaluate: function (_a, sourceCodeInfo) {
4037
4036
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4038
4037
  assertString(str, sourceCodeInfo);
@@ -4043,7 +4042,7 @@ var stringNormalExpression = {
4043
4042
  },
4044
4043
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4045
4044
  },
4046
- 'pad-right': {
4045
+ 'pad_right': {
4047
4046
  evaluate: function (_a, sourceCodeInfo) {
4048
4047
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
4049
4048
  assertString(str, sourceCodeInfo);
@@ -4085,7 +4084,7 @@ var stringNormalExpression = {
4085
4084
  },
4086
4085
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 10 }, node); },
4087
4086
  },
4088
- 'encode-base64': {
4087
+ 'encode_base64': {
4089
4088
  evaluate: function (_a, sourceCodeInfo) {
4090
4089
  var _b = __read(_a, 1), value = _b[0];
4091
4090
  assertString(value, sourceCodeInfo);
@@ -4096,7 +4095,7 @@ var stringNormalExpression = {
4096
4095
  },
4097
4096
  validate: function (node) { return assertNumberOfParams(1, node); },
4098
4097
  },
4099
- 'decode-base64': {
4098
+ 'decode_base64': {
4100
4099
  evaluate: function (_a, sourceCodeInfo) {
4101
4100
  var _b = __read(_a, 1), value = _b[0];
4102
4101
  assertString(value, sourceCodeInfo);
@@ -4114,7 +4113,7 @@ var stringNormalExpression = {
4114
4113
  },
4115
4114
  validate: function (node) { return assertNumberOfParams(1, node); },
4116
4115
  },
4117
- 'encode-uri-component': {
4116
+ 'encode_uri_component': {
4118
4117
  evaluate: function (_a, sourceCodeInfo) {
4119
4118
  var _b = __read(_a, 1), value = _b[0];
4120
4119
  assertString(value, sourceCodeInfo);
@@ -4122,7 +4121,7 @@ var stringNormalExpression = {
4122
4121
  },
4123
4122
  validate: function (node) { return assertNumberOfParams(1, node); },
4124
4123
  },
4125
- 'decode-uri-component': {
4124
+ 'decode_uri_component': {
4126
4125
  evaluate: function (_a, sourceCodeInfo) {
4127
4126
  var _b = __read(_a, 1), value = _b[0];
4128
4127
  assertString(value, sourceCodeInfo);
@@ -4291,7 +4290,7 @@ var andSpecialExpression = {
4291
4290
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4292
4291
  var node = {
4293
4292
  t: AstNodeType.SpecialExpression,
4294
- n: 'and',
4293
+ n: '&&',
4295
4294
  p: params,
4296
4295
  token: getTokenDebugData(firstToken) && firstToken,
4297
4296
  };
@@ -4376,6 +4375,37 @@ var condSpecialExpression = {
4376
4375
  },
4377
4376
  };
4378
4377
 
4378
+ var switchSpecialExpression = {
4379
+ polishParse: getCommonPolishSpecialExpressionParser('switch'),
4380
+ validateParameterCount: function (node) { return assertOddNumberOfParams(node); },
4381
+ evaluate: function (node, contextStack, _a) {
4382
+ var e_1, _b;
4383
+ var evaluateAstNode = _a.evaluateAstNode;
4384
+ var switchValue = evaluateAstNode(node.p[0], contextStack);
4385
+ try {
4386
+ for (var _c = __values(arrayToPairs(node.p.slice(1))), _d = _c.next(); !_d.done; _d = _c.next()) {
4387
+ var _e = __read(_d.value, 2), test = _e[0], form = _e[1];
4388
+ var value = evaluateAstNode(test, contextStack);
4389
+ if (value === switchValue) {
4390
+ return evaluateAstNode(form, contextStack);
4391
+ }
4392
+ }
4393
+ }
4394
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
4395
+ finally {
4396
+ try {
4397
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
4398
+ }
4399
+ finally { if (e_1) throw e_1.error; }
4400
+ }
4401
+ return null;
4402
+ },
4403
+ findUnresolvedIdentifiers: function (node, contextStack, _a) {
4404
+ var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
4405
+ return findUnresolvedIdentifiers(node.p, contextStack, builtin);
4406
+ },
4407
+ };
4408
+
4379
4409
  var declaredSpecialExpression = {
4380
4410
  polishParse: getCommonPolishSpecialExpressionParser('declared?'),
4381
4411
  validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
@@ -4847,7 +4877,7 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
4847
4877
  tkn = asToken(tokenStream.tokens[parseState.position]);
4848
4878
  if (node.t === AstNodeType.Modifier) {
4849
4879
  switch (node.v) {
4850
- case '&':
4880
+ case '&rest':
4851
4881
  if (state === 'rest')
4852
4882
  throw new LitsError('& can only appear once', (_a = getTokenDebugData(tkn)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
4853
4883
  state = 'rest';
@@ -4922,7 +4952,7 @@ var ifLetSpecialExpression = {
4922
4952
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4923
4953
  var node = {
4924
4954
  t: AstNodeType.SpecialExpression,
4925
- n: 'if-let',
4955
+ n: 'if_let',
4926
4956
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
4927
4957
  p: params,
4928
4958
  token: getTokenDebugData(firstToken) && firstToken,
@@ -4959,7 +4989,7 @@ var ifLetSpecialExpression = {
4959
4989
  };
4960
4990
 
4961
4991
  var ifNotSpecialExpression = {
4962
- polishParse: getCommonPolishSpecialExpressionParser('if-not'),
4992
+ polishParse: getCommonPolishSpecialExpressionParser('if_not'),
4963
4993
  validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4964
4994
  evaluate: function (node, contextStack, _a) {
4965
4995
  var _b;
@@ -5169,7 +5199,7 @@ function parseLoopBinding(tokenStream, parseState, _a) {
5169
5199
  loopBinding.we = parseToken(tokenStream, parseState);
5170
5200
  loopBinding.m.push('&while');
5171
5201
  break;
5172
- case '&':
5202
+ case '&rest':
5173
5203
  throw new LitsError("Illegal modifier: ".concat(modifier), (_e = getTokenDebugData(tkn)) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
5174
5204
  default:
5175
5205
  throw new LitsError("Illegal modifier: ".concat(modifier), (_f = getTokenDebugData(tkn)) === null || _f === void 0 ? void 0 : _f.sourceCodeInfo);
@@ -5369,7 +5399,7 @@ var doseqSpecialExpression = {
5369
5399
  };
5370
5400
 
5371
5401
  var orSpecialExpression = {
5372
- polishParse: getCommonPolishSpecialExpressionParser('or'),
5402
+ polishParse: getCommonPolishSpecialExpressionParser('||'),
5373
5403
  validateParameterCount: function () { return undefined; },
5374
5404
  evaluate: function (node, contextStack, _a) {
5375
5405
  var e_1, _b;
@@ -5461,25 +5491,6 @@ var throwSpecialExpression = {
5461
5491
  },
5462
5492
  };
5463
5493
 
5464
- var timeSpecialExpression = {
5465
- polishParse: getCommonPolishSpecialExpressionParser('time!'),
5466
- validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5467
- evaluate: function (node, contextStack, _a) {
5468
- var evaluateAstNode = _a.evaluateAstNode;
5469
- var param = node.p[0];
5470
- var startTime = Date.now();
5471
- var result = evaluateAstNode(param, contextStack);
5472
- var totalTime = Date.now() - startTime;
5473
- // eslint-disable-next-line no-console
5474
- console.log("Elapsed time: ".concat(totalTime, " ms"));
5475
- return result;
5476
- },
5477
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
5478
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
5479
- return findUnresolvedIdentifiers(node.p, contextStack, builtin);
5480
- },
5481
- };
5482
-
5483
5494
  var trySpecialExpression = {
5484
5495
  polishParse: function (tokenStream, parseState, firstToken, _a) {
5485
5496
  var _b, _c, _d;
@@ -5580,7 +5591,7 @@ var whenFirstSpecialExpression = {
5580
5591
  assertRParenToken(tokenStream.tokens[parseState.position++]);
5581
5592
  var node = {
5582
5593
  t: AstNodeType.SpecialExpression,
5583
- n: 'when-first',
5594
+ n: 'when_first',
5584
5595
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5585
5596
  p: params,
5586
5597
  token: getTokenDebugData(firstToken) && firstToken,
@@ -5642,7 +5653,7 @@ var whenLetSpecialExpression = {
5642
5653
  assertRParenToken(tokenStream.tokens[parseState.position++]);
5643
5654
  var node = {
5644
5655
  t: AstNodeType.SpecialExpression,
5645
- n: 'when-let',
5656
+ n: 'when_let',
5646
5657
  b: asNonUndefined(bindings[0], (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo),
5647
5658
  p: params,
5648
5659
  token: getTokenDebugData(firstToken) && firstToken,
@@ -5688,7 +5699,7 @@ var whenLetSpecialExpression = {
5688
5699
  };
5689
5700
 
5690
5701
  var whenNotSpecialExpression = {
5691
- polishParse: getCommonPolishSpecialExpressionParser('when-not'),
5702
+ polishParse: getCommonPolishSpecialExpressionParser('when_not'),
5692
5703
  validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5693
5704
  evaluate: function (node, contextStack, _a) {
5694
5705
  var e_1, _b;
@@ -5721,9 +5732,10 @@ var whenNotSpecialExpression = {
5721
5732
  };
5722
5733
 
5723
5734
  var specialExpressions = {
5724
- 'and': andSpecialExpression,
5735
+ '&&': andSpecialExpression,
5725
5736
  'comment': commentSpecialExpression,
5726
5737
  'cond': condSpecialExpression,
5738
+ 'switch': switchSpecialExpression,
5727
5739
  'def': defSpecialExpression,
5728
5740
  'defn': defnSpecialExpression,
5729
5741
  'defns': defnsSpecialExpression,
@@ -5733,19 +5745,18 @@ var specialExpressions = {
5733
5745
  'for': forSpecialExpression,
5734
5746
  'fn': fnSpecialExpression,
5735
5747
  'if': ifSpecialExpression,
5736
- 'if-let': ifLetSpecialExpression,
5737
- 'if-not': ifNotSpecialExpression,
5748
+ 'if_let': ifLetSpecialExpression,
5749
+ 'if_not': ifNotSpecialExpression,
5738
5750
  'let': letSpecialExpression,
5739
5751
  'loop': loopSpecialExpression,
5740
- 'or': orSpecialExpression,
5752
+ '||': orSpecialExpression,
5741
5753
  'recur': recurSpecialExpression,
5742
5754
  'throw': throwSpecialExpression,
5743
- 'time!': timeSpecialExpression,
5744
5755
  'try': trySpecialExpression,
5745
5756
  'when': whenSpecialExpression,
5746
- 'when-first': whenFirstSpecialExpression,
5747
- 'when-let': whenLetSpecialExpression,
5748
- 'when-not': whenNotSpecialExpression,
5757
+ 'when_first': whenFirstSpecialExpression,
5758
+ 'when_let': whenLetSpecialExpression,
5759
+ 'when_not': whenNotSpecialExpression,
5749
5760
  'declared?': declaredSpecialExpression,
5750
5761
  '??': qqSpecialExpression,
5751
5762
  };
@@ -6302,7 +6313,7 @@ var calculateAndOutcomes = function (_a) {
6302
6313
  var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6303
6314
  return combinateAstNodes(astNode.p)
6304
6315
  .map(function (p) { return ({
6305
- n: 'and',
6316
+ n: '&&',
6306
6317
  t: AstNodeType.SpecialExpression,
6307
6318
  p: p,
6308
6319
  token: astNode.token,
@@ -6424,7 +6435,7 @@ var calculateIfNotOutcomes = function (_a) {
6424
6435
  if (isAstComputable(condition)) {
6425
6436
  return combinateAstNodes(astNode.p)
6426
6437
  .map(function (p) { return ({
6427
- n: 'if-not',
6438
+ n: 'if_not',
6428
6439
  t: astNode.t,
6429
6440
  p: p,
6430
6441
  token: astNode.token,
@@ -6537,7 +6548,7 @@ var calculateOrOutcomes = function (_a) {
6537
6548
  var astNode = _a.astNode, combinateAstNodes = _a.combinateAstNodes;
6538
6549
  return combinateAstNodes(astNode.p)
6539
6550
  .map(function (p) { return ({
6540
- n: 'or',
6551
+ n: '||',
6541
6552
  t: AstNodeType.SpecialExpression,
6542
6553
  p: p,
6543
6554
  token: astNode.token,
@@ -6557,12 +6568,6 @@ var calculateThrowOutcomes = function (_a) {
6557
6568
  return calculatePossibleAstNodes(astNode.p[0]).map(function (m) { return (__assign(__assign({}, astNode), { p: [m] })); });
6558
6569
  };
6559
6570
 
6560
- var calculateTimeOutcomes = function (_a) {
6561
- var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6562
- return calculatePossibleAstNodes(astNode.p[0])
6563
- .map(function (p) { return (__assign(__assign({}, astNode), { n: 'do', p: [p] })); });
6564
- };
6565
-
6566
6571
  var calculateTryOutcomes = function (_a) {
6567
6572
  var astNode = _a.astNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6568
6573
  var _b = calculatePossibleAstNodes(astNode.p[0]).reduce(function (acc, node) {
@@ -6636,7 +6641,7 @@ var calculateWhenNotOutcomes = function (_a) {
6636
6641
  if (isAstComputable(condition)) {
6637
6642
  return combinateAstNodes(astNode.p)
6638
6643
  .map(function (p) { return ({
6639
- n: 'when-not',
6644
+ n: 'when_not',
6640
6645
  t: astNode.t,
6641
6646
  p: p,
6642
6647
  token: astNode.token,
@@ -6695,10 +6700,22 @@ var calculateLoopOutcomes = function (_a) {
6695
6700
  .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6696
6701
  };
6697
6702
 
6703
+ var calculateSwitchOutcomes = function (_a) {
6704
+ var astNode = _a.astNode, nilNode = _a.nilNode, calculatePossibleAstNodes = _a.calculatePossibleAstNodes;
6705
+ // TODO be smarter about this
6706
+ return __spreadArray(__spreadArray([], __read(arrayToPairs(astNode.p.slice(1)).flatMap(function (_a) {
6707
+ var _b = __read(_a, 2); _b[0]; var form = _b[1];
6708
+ return calculatePossibleAstNodes(form);
6709
+ })), false), [
6710
+ nilNode,
6711
+ ], false);
6712
+ };
6713
+
6698
6714
  var specialExpressionCalculator = {
6699
- 'and': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6715
+ '&&': function (astNode, helperOptions) { return calculateAndOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6700
6716
  'comment': function (astNode, helperOptions) { return calculateCommentOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6701
6717
  'cond': function (astNode, helperOptions) { return calculateCondOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6718
+ 'switch': function (astNode, helperOptions) { return calculateSwitchOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6702
6719
  'declared?': function (astNode, helperOptions) { return calculateDeclaredOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6703
6720
  'defn': function (astNode, helperOptions) { return calculateDefnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6704
6721
  'def': function (astNode, helperOptions) { return calculateDefOutcomes(__assign({ astNode: astNode }, helperOptions)); },
@@ -6708,27 +6725,22 @@ var specialExpressionCalculator = {
6708
6725
  'doseq': function (astNode, helperOptions) { return calculateDoSeqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6709
6726
  'fn': function (astNode, helperOptions) { return calculateFnOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6710
6727
  'for': function (astNode, helperOptions) { return calculateForOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6711
- 'if-let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6728
+ 'if_let': function (astNode, helperOptions) { return calculateIfLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6712
6729
  'if': function (astNode, helperOptions) { return calculateIfOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6713
- 'if-not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6730
+ 'if_not': function (astNode, helperOptions) { return calculateIfNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6714
6731
  'let': function (astNode, helperOptions) { return calculateLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6715
6732
  'loop': function (astNode, helperOptions) { return calculateLoopOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6716
- 'or': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6733
+ '||': function (astNode, helperOptions) { return calculateOrOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6717
6734
  '??': function (astNode, helperOptions) { return calculateQqOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6718
6735
  'recur': function (astNode, helperOptions) { return calculateRecurOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6719
- 'time!': function (astNode, helperOptions) { return calculateTimeOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6720
6736
  'throw': function (astNode, helperOptions) { return calculateThrowOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6721
6737
  'try': function (astNode, helperOptions) { return calculateTryOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6722
- 'when-first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6723
- 'when-let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6738
+ 'when_first': function (astNode, helperOptions) { return calculateWhenFirstOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6739
+ 'when_let': function (astNode, helperOptions) { return calculateWhenLetOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6724
6740
  'when': function (astNode, helperOptions) { return calculateWhenOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6725
- 'when-not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6741
+ 'when_not': function (astNode, helperOptions) { return calculateWhenNotOutcomes(__assign({ astNode: astNode }, helperOptions)); },
6726
6742
  };
6727
6743
 
6728
- function isIdempotent(normalExpressionName) {
6729
- return !normalExpressionName.endsWith('!')
6730
- || normalExpressionName === 'write!';
6731
- }
6732
6744
  function calculateOutcomes(contextStack, astNodes) {
6733
6745
  // First, we try to calculate outcomes for the whole astNodes array.
6734
6746
  // If that fails, we try to calculate outcomes for the array without the first element.
@@ -6803,8 +6815,6 @@ function calculatePossibleAstNodes(contextStack, astNode, newIndentifiers) {
6803
6815
  : undefined;
6804
6816
  var newContextStack = newContext ? contextStack.create(newContext) : contextStack;
6805
6817
  if (astNode.t === AstNodeType.NormalExpression) {
6806
- if (astNode.n && !isIdempotent(astNode.n))
6807
- throw new Error("NormalExpressionNode with name ".concat(astNode.n, " is not idempotent. Cannot calculate possible ASTs."));
6808
6818
  return combinate(astNode.p.map(function (n) { return calculatePossibleAstNodes(newContextStack, n); }))
6809
6819
  .map(function (p) { return (__assign(__assign({}, astNode), { p: p })); });
6810
6820
  }
@@ -7031,13 +7041,10 @@ function fromUnaryAlgebraicToAstNode(operator, operand) {
7031
7041
  var operatorName = operator[1];
7032
7042
  switch (operatorName) {
7033
7043
  case '+':
7034
- return createNamedNormalExpressionNode('+', [operand], token);
7035
7044
  case '-':
7036
- return createNamedNormalExpressionNode('-', [operand], token);
7037
7045
  case '!':
7038
- return createNamedNormalExpressionNode('not', [operand], token);
7039
7046
  case '~':
7040
- return createNamedNormalExpressionNode('bit-not', [operand], token);
7047
+ return createNamedNormalExpressionNode(operatorName, [operand], token);
7041
7048
  /* v8 ignore next 2 */
7042
7049
  default:
7043
7050
  throw new Error("Unknown operator: ".concat(operatorName));
@@ -7050,68 +7057,36 @@ function fromBinaryOperatorToAstNode(operator, left, right, token) {
7050
7057
  case '.':
7051
7058
  return createAccessorNode(left, fromSymbolToStringNode(asSymbolNode(right, (_a = getTokenDebugData(token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo)), token);
7052
7059
  case '**': // exponentiation
7053
- return createNamedNormalExpressionNode('pow', [left, right], token);
7054
7060
  case '*':
7055
- return createNamedNormalExpressionNode('*', [left, right], token);
7056
7061
  case '/':
7057
- return createNamedNormalExpressionNode('/', [left, right], token);
7058
7062
  case '%':
7059
- return createNamedNormalExpressionNode('rem', [left, right], token);
7060
7063
  case '+':
7061
- return createNamedNormalExpressionNode('+', [left, right], token);
7062
7064
  case '-':
7063
- return createNamedNormalExpressionNode('-', [left, right], token);
7064
7065
  case '<<':
7065
- return createNamedNormalExpressionNode('bit-shift-left', [left, right], token);
7066
7066
  case '>>':
7067
- return createNamedNormalExpressionNode('bit-shift-right', [left, right], token);
7068
7067
  case '>>>':
7069
- return createNamedNormalExpressionNode('unsigned-bit-shift-right', [left, right], token);
7070
- case '++': {
7071
- var leftString = createNamedNormalExpressionNode('str', [left], token);
7072
- var rightString = createNamedNormalExpressionNode('str', [right], token);
7073
- return createNamedNormalExpressionNode('str', [leftString, rightString], token);
7074
- }
7068
+ case '++':
7075
7069
  case '<':
7076
- return createNamedNormalExpressionNode('<', [left, right], token);
7077
7070
  case '<=':
7078
- return createNamedNormalExpressionNode('<=', [left, right], token);
7079
7071
  case '>':
7080
- return createNamedNormalExpressionNode('>', [left, right], token);
7081
7072
  case '>=':
7082
- return createNamedNormalExpressionNode('>=', [left, right], token);
7083
7073
  case '==':
7084
- return createNamedNormalExpressionNode('=', [left, right], token);
7085
7074
  case '!=':
7086
- return createNamedNormalExpressionNode('!=', [left, right], token);
7087
7075
  case '&':
7088
- return createNamedNormalExpressionNode('bit-and', [left, right], token);
7089
7076
  case '^':
7090
- return createNamedNormalExpressionNode('bit-xor', [left, right], token);
7091
7077
  case '|':
7092
- return createNamedNormalExpressionNode('bit-or', [left, right], token);
7078
+ return createNamedNormalExpressionNode(operatorName, [left, right], token);
7093
7079
  case '&&':
7094
- return {
7095
- t: AstNodeType.SpecialExpression,
7096
- n: 'and',
7097
- p: [left, right],
7098
- token: getTokenDebugData(token) && token,
7099
- };
7100
7080
  case '||':
7101
- return {
7102
- t: AstNodeType.SpecialExpression,
7103
- n: 'or',
7104
- p: [left, right],
7105
- token: getTokenDebugData(token) && token,
7106
- };
7107
7081
  case '??':
7108
7082
  return {
7109
7083
  t: AstNodeType.SpecialExpression,
7110
- n: '??',
7084
+ n: operatorName,
7111
7085
  p: [left, right],
7112
7086
  token: getTokenDebugData(token) && token,
7113
7087
  };
7114
7088
  /* v8 ignore next 8 */
7089
+ case ';':
7115
7090
  case '!':
7116
7091
  case '~':
7117
7092
  case '=':
@@ -7132,14 +7107,52 @@ var AlgebraicParser = /** @class */ (function () {
7132
7107
  this.parseState.position += 1;
7133
7108
  };
7134
7109
  AlgebraicParser.prototype.parse = function () {
7135
- return this.parseExpression();
7110
+ var nodes = [];
7111
+ while (!this.isAtEnd()) {
7112
+ nodes.push(this.parseExpression());
7113
+ if (!isA_OperatorToken(this.peek(), ';')) {
7114
+ break;
7115
+ }
7116
+ this.advance();
7117
+ }
7118
+ return nodes;
7136
7119
  };
7137
7120
  AlgebraicParser.prototype.parseExpression = function (precedence) {
7138
7121
  var _a;
7139
7122
  if (precedence === void 0) { precedence = 0; }
7140
- var left = this.parseOperand();
7141
- while (!this.isAtEnd() && !isA_OperatorToken(this.peek(), ',') && !isRBracketToken(this.peek()) && !isRParenToken(this.peek())) {
7142
- var operator = this.peek();
7123
+ var firstToken = this.peek();
7124
+ if (isA_SymbolToken(firstToken) && firstToken[1] === 'def') {
7125
+ return this.parseDef(firstToken);
7126
+ }
7127
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'defn') {
7128
+ return this.parseDefn(firstToken);
7129
+ }
7130
+ var left;
7131
+ if (isA_SymbolToken(firstToken) && firstToken[1] === 'if') {
7132
+ left = this.parseIf(firstToken);
7133
+ }
7134
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'cond') {
7135
+ left = this.parseCond(firstToken);
7136
+ }
7137
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'switch') {
7138
+ left = this.parseSwitch(firstToken);
7139
+ }
7140
+ else if (isA_SymbolToken(firstToken) && firstToken[1] === 'for') {
7141
+ left = this.parseFor(firstToken);
7142
+ }
7143
+ else {
7144
+ left = this.parseOperand();
7145
+ }
7146
+ var operator = this.peek();
7147
+ while (!this.isAtEnd()
7148
+ && !isA_OperatorToken(operator, ',')
7149
+ && !isA_OperatorToken(operator, ';')
7150
+ && !isRBracketToken(operator)
7151
+ && !isA_ReservedSymbolToken(operator, 'else')
7152
+ && !isA_ReservedSymbolToken(operator, 'then')
7153
+ && !isA_ReservedSymbolToken(operator, 'end')
7154
+ && !isA_ReservedSymbolToken(operator, 'case')
7155
+ && !isRParenToken(operator)) {
7143
7156
  if (isA_BinaryOperatorToken(operator)) {
7144
7157
  var name_1 = operator[1];
7145
7158
  var newPrecedece = getPrecedence(name_1);
@@ -7169,6 +7182,7 @@ var AlgebraicParser = /** @class */ (function () {
7169
7182
  else {
7170
7183
  break;
7171
7184
  }
7185
+ operator = this.peek();
7172
7186
  }
7173
7187
  if (!left) {
7174
7188
  throw new LitsError('Expected operand', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
@@ -7369,9 +7383,6 @@ var AlgebraicParser = /** @class */ (function () {
7369
7383
  var _a, _b;
7370
7384
  var isNamedFunction = symbol.t === AstNodeType.Symbol;
7371
7385
  this.advance();
7372
- if (isNamedFunction && symbol.v === 'for') {
7373
- return this.parseFor(symbol);
7374
- }
7375
7386
  var params = [];
7376
7387
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7377
7388
  params.push(this.parseExpression());
@@ -7392,17 +7403,14 @@ var AlgebraicParser = /** @class */ (function () {
7392
7403
  var name_2 = symbol.v;
7393
7404
  switch (name_2) {
7394
7405
  case '??':
7395
- case 'and':
7406
+ case '&&':
7396
7407
  case 'comment':
7397
- case 'cond':
7398
7408
  case 'declared?':
7399
- case 'if':
7400
- case 'if-not':
7401
- case 'or':
7409
+ case 'if_not':
7410
+ case '||':
7402
7411
  case 'when':
7403
- case 'when-not':
7412
+ case 'when_not':
7404
7413
  case 'do':
7405
- case 'time!':
7406
7414
  case 'throw': {
7407
7415
  var node = {
7408
7416
  t: AstNodeType.SpecialExpression,
@@ -7415,13 +7423,11 @@ var AlgebraicParser = /** @class */ (function () {
7415
7423
  }
7416
7424
  case 'let':
7417
7425
  return this.parseLet(symbol, params);
7418
- case 'def':
7419
7426
  case 'defs':
7420
- case 'if-let':
7421
- case 'when-let':
7422
- case 'when-first':
7427
+ case 'if_let':
7428
+ case 'when_let':
7429
+ case 'when_first':
7423
7430
  case 'fn':
7424
- case 'defn':
7425
7431
  case 'defns':
7426
7432
  case 'try':
7427
7433
  case 'recur':
@@ -7444,8 +7450,32 @@ var AlgebraicParser = /** @class */ (function () {
7444
7450
  }
7445
7451
  };
7446
7452
  AlgebraicParser.prototype.parseLambdaFunction = function () {
7447
- var _a, _b;
7448
7453
  var firstToken = this.peek();
7454
+ try {
7455
+ var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
7456
+ if (!isA_OperatorToken(this.peek(), '=>')) {
7457
+ return null;
7458
+ }
7459
+ this.advance();
7460
+ var body = this.parseExpression();
7461
+ return {
7462
+ t: AstNodeType.SpecialExpression,
7463
+ n: 'fn',
7464
+ p: [],
7465
+ o: [{
7466
+ as: functionArguments,
7467
+ b: [body],
7468
+ a: arity,
7469
+ }],
7470
+ token: getTokenDebugData(firstToken) && firstToken,
7471
+ };
7472
+ }
7473
+ catch (_b) {
7474
+ return null;
7475
+ }
7476
+ };
7477
+ AlgebraicParser.prototype.parseFunctionArguments = function () {
7478
+ var _a, _b, _c, _d, _e;
7449
7479
  this.advance();
7450
7480
  var rest = false;
7451
7481
  var letBindingObject;
@@ -7468,7 +7498,7 @@ var AlgebraicParser = /** @class */ (function () {
7468
7498
  }
7469
7499
  var symbolToken = this.peek();
7470
7500
  if (!isA_SymbolToken(symbolToken)) {
7471
- return null;
7501
+ throw new LitsError('Expected symbol', (_c = getTokenDebugData(this.peek())) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
7472
7502
  }
7473
7503
  if (rest) {
7474
7504
  restArg = symbolToken[1];
@@ -7479,47 +7509,36 @@ var AlgebraicParser = /** @class */ (function () {
7479
7509
  this.advance();
7480
7510
  }
7481
7511
  if (!isA_OperatorToken(this.peek(), ',') && !isRParenToken(this.peek())) {
7482
- return null;
7512
+ throw new LitsError('Expected comma or closing parenthesis', (_d = getTokenDebugData(this.peek())) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo);
7483
7513
  }
7484
7514
  if (isA_OperatorToken(this.peek(), ',')) {
7485
7515
  this.advance();
7486
7516
  }
7487
7517
  }
7518
+ var arity = restArg !== undefined ? { min: args.length } : args.length;
7488
7519
  if (!isRParenToken(this.peek())) {
7489
- return null;
7490
- }
7491
- this.advance();
7492
- if (!isA_OperatorToken(this.peek(), '=>')) {
7493
- return null;
7520
+ throw new LitsError('Expected closing parenthesis', (_e = getTokenDebugData(this.peek())) === null || _e === void 0 ? void 0 : _e.sourceCodeInfo);
7494
7521
  }
7495
- this.advance();
7496
7522
  var letBindings = letBindingObject ? arrayToPairs(letBindingObject.p) : [];
7497
- var body = this.parseExpression();
7498
- var arity = restArg !== undefined ? { min: args.length } : args.length;
7523
+ var functionArguments = {
7524
+ m: args,
7525
+ r: restArg,
7526
+ b: letBindings.map(function (pair) {
7527
+ var key = pair[0];
7528
+ var value = pair[1];
7529
+ return {
7530
+ t: AstNodeType.Binding,
7531
+ n: key.v,
7532
+ v: value,
7533
+ p: [],
7534
+ token: getTokenDebugData(key.token) && key.token,
7535
+ };
7536
+ }),
7537
+ };
7538
+ this.advance();
7499
7539
  return {
7500
- t: AstNodeType.SpecialExpression,
7501
- n: 'fn',
7502
- p: [],
7503
- o: [{
7504
- as: {
7505
- m: args,
7506
- r: restArg,
7507
- b: letBindings.map(function (pair) {
7508
- var key = pair[0];
7509
- var value = pair[1];
7510
- return {
7511
- t: AstNodeType.Binding,
7512
- n: key.v,
7513
- v: value,
7514
- p: [],
7515
- token: getTokenDebugData(key.token) && key.token,
7516
- };
7517
- }),
7518
- },
7519
- b: [body],
7520
- a: arity,
7521
- }],
7522
- token: getTokenDebugData(firstToken) && firstToken,
7540
+ functionArguments: functionArguments,
7541
+ arity: arity,
7523
7542
  };
7524
7543
  };
7525
7544
  AlgebraicParser.prototype.parseShorthandLamdaFunction = function () {
@@ -7604,38 +7623,39 @@ var AlgebraicParser = /** @class */ (function () {
7604
7623
  }),
7605
7624
  };
7606
7625
  };
7607
- AlgebraicParser.prototype.parseFor = function (forSymbol) {
7626
+ AlgebraicParser.prototype.parseFor = function (token) {
7627
+ this.advance();
7628
+ assertLParenToken(this.peek());
7629
+ this.advance();
7608
7630
  var forLoopBindings = [
7609
7631
  this.parseForLoopBinding(),
7610
7632
  ];
7611
- var nextToken = this.peekAhead();
7612
- while (isA_SymbolToken(nextToken) && nextToken[1] === 'of') {
7633
+ while (!this.isAtEnd() && !isRParenToken(this.peek())) {
7613
7634
  forLoopBindings.push(this.parseForLoopBinding());
7614
- nextToken = this.peekAhead();
7635
+ if (isA_OperatorToken(this.peek(), ',')) {
7636
+ this.advance();
7637
+ }
7615
7638
  }
7616
- var expression = this.parseExpression();
7617
7639
  assertRParenToken(this.peek());
7618
7640
  this.advance();
7641
+ var expression = this.parseExpression();
7642
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7643
+ this.advance();
7619
7644
  return {
7620
7645
  t: AstNodeType.SpecialExpression,
7621
7646
  n: 'for',
7622
7647
  p: [expression],
7623
- token: getTokenDebugData(forSymbol.token) && forSymbol.token,
7648
+ token: getTokenDebugData(token) && token,
7624
7649
  l: forLoopBindings,
7625
7650
  };
7626
7651
  };
7627
- // export interface LoopBindingNode {
7628
- // b: BindingNode // Binding
7629
- // m: Array<'&let' | '&when' | '&while'> // Modifiers
7630
- // l?: BindingNode[] // Let-Bindings
7631
- // wn?: AstNode // When Node
7632
- // we?: AstNode // While Node
7633
- // }
7634
7652
  AlgebraicParser.prototype.parseForLoopBinding = function () {
7635
7653
  var _a;
7636
7654
  var bindingNode = this.parseBinding();
7637
- if (isA_OperatorToken(this.peek(), ',')) {
7638
- this.advance();
7655
+ if (isRParenToken(this.peek()) || isA_OperatorToken(this.peek(), ',')) {
7656
+ if (isA_OperatorToken(this.peek(), ',')) {
7657
+ this.advance();
7658
+ }
7639
7659
  return {
7640
7660
  b: bindingNode,
7641
7661
  m: [],
@@ -7681,8 +7701,9 @@ var AlgebraicParser = /** @class */ (function () {
7681
7701
  }
7682
7702
  token = this.peek();
7683
7703
  }
7684
- assertA_OperatorToken(token, ',');
7685
- this.advance();
7704
+ if (isA_OperatorToken(token, ',')) {
7705
+ this.advance();
7706
+ }
7686
7707
  return {
7687
7708
  b: bindingNode,
7688
7709
  m: modifiers,
@@ -7711,15 +7732,185 @@ var AlgebraicParser = /** @class */ (function () {
7711
7732
  };
7712
7733
  return node;
7713
7734
  };
7735
+ AlgebraicParser.prototype.parseIf = function (token) {
7736
+ this.advance();
7737
+ var condition = this.parseExpression();
7738
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7739
+ this.advance();
7740
+ var thenExpressions = [];
7741
+ while (!this.isAtEnd()
7742
+ && !isA_ReservedSymbolToken(this.peek(), 'else')
7743
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7744
+ thenExpressions.push(this.parseExpression());
7745
+ if (isA_OperatorToken(this.peek(), ';')) {
7746
+ this.advance();
7747
+ }
7748
+ }
7749
+ var thenExpression = thenExpressions.length === 1
7750
+ ? thenExpressions[0]
7751
+ : {
7752
+ t: AstNodeType.SpecialExpression,
7753
+ n: 'do',
7754
+ p: thenExpressions,
7755
+ token: getTokenDebugData(token) && token,
7756
+ };
7757
+ var elseExpression;
7758
+ if (isA_ReservedSymbolToken(this.peek(), 'else')) {
7759
+ this.advance();
7760
+ var elseExpressions = [];
7761
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7762
+ elseExpressions.push(this.parseExpression());
7763
+ if (isA_OperatorToken(this.peek(), ';')) {
7764
+ this.advance();
7765
+ }
7766
+ }
7767
+ elseExpression = elseExpressions.length === 1
7768
+ ? elseExpressions[0]
7769
+ : {
7770
+ t: AstNodeType.SpecialExpression,
7771
+ n: 'do',
7772
+ p: elseExpressions,
7773
+ token: getTokenDebugData(token) && token,
7774
+ };
7775
+ }
7776
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7777
+ this.advance();
7778
+ var params = [condition, thenExpression];
7779
+ if (elseExpression) {
7780
+ params.push(elseExpression);
7781
+ }
7782
+ return {
7783
+ t: AstNodeType.SpecialExpression,
7784
+ n: 'if',
7785
+ p: params,
7786
+ token: getTokenDebugData(token) && token,
7787
+ };
7788
+ };
7789
+ AlgebraicParser.prototype.parseCond = function (token) {
7790
+ this.advance();
7791
+ var params = [];
7792
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7793
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7794
+ this.advance();
7795
+ params.push(this.parseExpression());
7796
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7797
+ this.advance();
7798
+ var expressions = [];
7799
+ while (!this.isAtEnd()
7800
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7801
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7802
+ expressions.push(this.parseExpression());
7803
+ if (isA_OperatorToken(this.peek(), ';')) {
7804
+ this.advance();
7805
+ }
7806
+ }
7807
+ params.push(expressions.length === 1
7808
+ ? expressions[0]
7809
+ : {
7810
+ t: AstNodeType.SpecialExpression,
7811
+ n: 'do',
7812
+ p: expressions,
7813
+ token: getTokenDebugData(token) && token,
7814
+ });
7815
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7816
+ break;
7817
+ }
7818
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7819
+ }
7820
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7821
+ this.advance();
7822
+ return {
7823
+ t: AstNodeType.SpecialExpression,
7824
+ n: 'cond',
7825
+ p: params,
7826
+ token: getTokenDebugData(token) && token,
7827
+ };
7828
+ };
7829
+ AlgebraicParser.prototype.parseSwitch = function (token) {
7830
+ this.advance();
7831
+ var params = [this.parseExpression()];
7832
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7833
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7834
+ this.advance();
7835
+ params.push(this.parseExpression());
7836
+ assertA_ReservedSymbolToken(this.peek(), 'then');
7837
+ this.advance();
7838
+ var expressions = [];
7839
+ while (!this.isAtEnd()
7840
+ && !isA_ReservedSymbolToken(this.peek(), 'case')
7841
+ && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7842
+ expressions.push(this.parseExpression());
7843
+ if (isA_OperatorToken(this.peek(), ';')) {
7844
+ this.advance();
7845
+ }
7846
+ }
7847
+ params.push(expressions.length === 1
7848
+ ? expressions[0]
7849
+ : {
7850
+ t: AstNodeType.SpecialExpression,
7851
+ n: 'do',
7852
+ p: expressions,
7853
+ token: getTokenDebugData(token) && token,
7854
+ });
7855
+ if (isA_ReservedSymbolToken(this.peek(), 'end')) {
7856
+ break;
7857
+ }
7858
+ assertA_ReservedSymbolToken(this.peek(), 'case');
7859
+ }
7860
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7861
+ this.advance();
7862
+ return {
7863
+ t: AstNodeType.SpecialExpression,
7864
+ n: 'switch',
7865
+ p: params,
7866
+ token: getTokenDebugData(token) && token,
7867
+ };
7868
+ };
7869
+ AlgebraicParser.prototype.parseDef = function (token) {
7870
+ this.advance();
7871
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7872
+ assertA_OperatorToken(this.peek(), '=');
7873
+ this.advance();
7874
+ var value = this.parseExpression();
7875
+ return {
7876
+ t: AstNodeType.SpecialExpression,
7877
+ n: 'def',
7878
+ p: [symbol, value],
7879
+ token: getTokenDebugData(token) && token,
7880
+ };
7881
+ };
7882
+ AlgebraicParser.prototype.parseDefn = function (token) {
7883
+ this.advance();
7884
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7885
+ var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
7886
+ var body = [];
7887
+ while (!this.isAtEnd() && !isA_ReservedSymbolToken(this.peek(), 'end')) {
7888
+ body.push(this.parseExpression());
7889
+ if (isA_OperatorToken(this.peek(), ';')) {
7890
+ this.advance();
7891
+ }
7892
+ }
7893
+ assertA_ReservedSymbolToken(this.peek(), 'end');
7894
+ this.advance();
7895
+ return {
7896
+ t: AstNodeType.SpecialExpression,
7897
+ n: 'defn',
7898
+ f: symbol,
7899
+ p: [],
7900
+ o: [{
7901
+ as: functionArguments,
7902
+ b: body,
7903
+ a: arity,
7904
+ }],
7905
+ token: getTokenDebugData(token) && token,
7906
+ };
7907
+ };
7714
7908
  AlgebraicParser.prototype.isAtEnd = function () {
7715
7909
  return this.parseState.position >= this.tokenStream.tokens.length;
7716
7910
  };
7717
7911
  AlgebraicParser.prototype.peek = function () {
7718
7912
  return this.tokenStream.tokens[this.parseState.position];
7719
7913
  };
7720
- AlgebraicParser.prototype.peekAhead = function () {
7721
- return this.tokenStream.tokens[this.parseState.position + 1];
7722
- };
7723
7914
  return AlgebraicParser;
7724
7915
  }());
7725
7916
 
@@ -8000,10 +8191,18 @@ function parsePolishToken(tokenStream, parseState) {
8000
8191
  parseState.position += 1;
8001
8192
  parseState.algebraic = true;
8002
8193
  var algebraicParser = new AlgebraicParser(tokenStream, parseState);
8003
- var node = algebraicParser.parse();
8194
+ var nodes = algebraicParser.parse();
8004
8195
  assertEndNotationToken(tokenStream.tokens[parseState.position++]);
8005
8196
  parseState.algebraic = false;
8006
- return node;
8197
+ if (nodes.length === 1) {
8198
+ return nodes[0];
8199
+ }
8200
+ return {
8201
+ t: AstNodeType.SpecialExpression,
8202
+ n: 'do',
8203
+ p: nodes,
8204
+ token: nodes[0].token,
8205
+ };
8007
8206
  }
8008
8207
  case 'PolNotation': {
8009
8208
  var astNodes = [];
@@ -8070,12 +8269,21 @@ function removeUnnecessaryTokens(tokenStream) {
8070
8269
  function parseToken(tokenStream, parseState) {
8071
8270
  if (parseState.algebraic) {
8072
8271
  var algebraicParser = new AlgebraicParser(tokenStream, parseState);
8073
- return algebraicParser.parse();
8272
+ var nodes = algebraicParser.parse();
8273
+ if (nodes.length === 1) {
8274
+ return nodes[0];
8275
+ }
8276
+ return {
8277
+ t: AstNodeType.SpecialExpression,
8278
+ n: 'do',
8279
+ p: nodes,
8280
+ token: nodes[0].token,
8281
+ };
8074
8282
  }
8075
8283
  return parsePolishToken(tokenStream, parseState);
8076
8284
  }
8077
8285
 
8078
- var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:-]';
8286
+ var polishIdentifierCharacterClass = '[\\w@%^?=!$<>+*/:&\|~-]';
8079
8287
  var algebraicIdentifierCharacterClass = '[\\w$:!?]';
8080
8288
  var algebraicIdentifierFirstCharacterClass = '[a-zA-Z_$]';
8081
8289
 
@@ -8155,25 +8363,28 @@ var commonTokenizers = [
8155
8363
  tokenizeString,
8156
8364
  ];
8157
8365
 
8158
- var algebraicReservedNamesRecord = {
8159
- 'true': { value: true },
8160
- 'false': { value: false },
8161
- 'nil': { value: null },
8162
- 'null': { value: null },
8163
- 'def': { value: null, forbidden: true },
8164
- 'defs': { value: null, forbidden: true },
8165
- 'if-let': { value: null, forbidden: true },
8166
- 'when-let': { value: null, forbidden: true },
8167
- 'when-first': { value: null, forbidden: true },
8168
- 'fn': { value: null, forbidden: true },
8169
- 'defn': { value: null, forbidden: true },
8170
- 'defns': { value: null, forbidden: true },
8171
- 'try': { value: null, forbidden: true },
8172
- 'recur': { value: null, forbidden: true },
8173
- 'loop': { value: null, forbidden: true },
8174
- 'time!': { value: null, forbidden: true },
8175
- 'doseq': { value: null, forbidden: true },
8366
+ var validAlgebraicReservedNamesRecord = {
8367
+ true: { value: true, forbidden: false },
8368
+ false: { value: false, forbidden: false },
8369
+ nil: { value: null, forbidden: false },
8370
+ null: { value: null, forbidden: false },
8371
+ then: { value: null, forbidden: false },
8372
+ else: { value: null, forbidden: false },
8373
+ end: { value: null, forbidden: false },
8374
+ case: { value: null, forbidden: false },
8375
+ };
8376
+ var forbiddenAlgebraicReservedNamesRecord = {
8377
+ if_let: { value: null, forbidden: true },
8378
+ when_let: { value: null, forbidden: true },
8379
+ when_first: { value: null, forbidden: true },
8380
+ fn: { value: null, forbidden: true },
8381
+ defns: { value: null, forbidden: true },
8382
+ try: { value: null, forbidden: true },
8383
+ recur: { value: null, forbidden: true },
8384
+ loop: { value: null, forbidden: true },
8385
+ doseq: { value: null, forbidden: true },
8176
8386
  };
8387
+ var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
8177
8388
 
8178
8389
  var identifierRegExp = new RegExp(algebraicIdentifierCharacterClass);
8179
8390
  var identifierFirstCharacterRegExp = new RegExp(algebraicIdentifierFirstCharacterClass);
@@ -8245,45 +8456,19 @@ var tokenizeA_BasePrefixedNumber = function (input, position) {
8245
8456
  }
8246
8457
  return [length, ['A_BasePrefixedNumber', input.substring(position, i)]];
8247
8458
  };
8248
- var tokenizeA_ReservedSymbolToken = function (input, position) {
8249
- var e_1, _a;
8250
- try {
8251
- for (var _b = __values(Object.entries(algebraicReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8252
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8253
- var length_1 = reservedName.length;
8254
- var nextChar = input[position + length_1];
8255
- if (nextChar && identifierRegExp.test(nextChar))
8256
- continue;
8257
- var name_1 = input.substring(position, position + length_1);
8258
- if (name_1 === reservedName) {
8259
- if (forbidden)
8260
- throw new LitsError("".concat(name_1, " is forbidden!"), undefined);
8261
- return [length_1, ['A_ReservedSymbol', reservedName]];
8262
- }
8263
- }
8264
- }
8265
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8266
- finally {
8267
- try {
8268
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8269
- }
8270
- finally { if (e_1) throw e_1.error; }
8271
- }
8272
- return NO_MATCH;
8273
- };
8274
8459
  var tokenizeA_Symbol = function (input, position) {
8275
8460
  var value = input[position];
8276
8461
  if (!value) {
8277
8462
  return NO_MATCH;
8278
8463
  }
8279
8464
  if (value === '\'') {
8280
- var length_2 = 1;
8281
- var char = input[position + length_2];
8465
+ var length_1 = 1;
8466
+ var char = input[position + length_1];
8282
8467
  var escaping = false;
8283
8468
  while (char !== '\'' || escaping) {
8284
8469
  if (char === undefined)
8285
8470
  throw new LitsError("Unclosed string at position ".concat(position, "."), undefined);
8286
- length_2 += 1;
8471
+ length_1 += 1;
8287
8472
  if (escaping) {
8288
8473
  escaping = false;
8289
8474
  value += char;
@@ -8294,10 +8479,10 @@ var tokenizeA_Symbol = function (input, position) {
8294
8479
  }
8295
8480
  value += char;
8296
8481
  }
8297
- char = input[position + length_2];
8482
+ char = input[position + length_1];
8298
8483
  }
8299
8484
  value += '\''; // closing quote
8300
- return [length_2 + 1, ['A_Symbol', value]];
8485
+ return [length_1 + 1, ['A_Symbol', value]];
8301
8486
  }
8302
8487
  if (identifierFirstCharacterRegExp.test(value)) {
8303
8488
  var initialPosition = position;
@@ -8312,6 +8497,22 @@ var tokenizeA_Symbol = function (input, position) {
8312
8497
  }
8313
8498
  return NO_MATCH;
8314
8499
  };
8500
+ var tokenizeA_ReservedSymbolToken = function (input, position) {
8501
+ var symbolMeta = tokenizeA_Symbol(input, position);
8502
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
8503
+ return NO_MATCH;
8504
+ }
8505
+ var symbolName = symbolMeta[1][1];
8506
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
8507
+ var info = algebraicReservedNamesRecord[symbolName];
8508
+ if (!info) {
8509
+ return NO_MATCH;
8510
+ }
8511
+ if (info.forbidden) {
8512
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
8513
+ }
8514
+ return [symbolMeta[0], ['A_ReservedSymbol', symbolName]];
8515
+ };
8315
8516
  var tokenizeA_Operator = function (input, position) {
8316
8517
  var _a;
8317
8518
  var threeChars = input.slice(position, position + 3);
@@ -8330,30 +8531,30 @@ var tokenizeA_Operator = function (input, position) {
8330
8531
  };
8331
8532
  var tokenizeA_MultiLineComment = function (input, position) {
8332
8533
  if (input[position] === '/' && input[position + 1] === '*') {
8333
- var length_3 = 2;
8534
+ var length_2 = 2;
8334
8535
  var value = '/*';
8335
- while (input[position + length_3] !== '*' && input[position + length_3 + 1] !== '/' && position + length_3 + 1 < input.length) {
8336
- value += input[position + length_3];
8337
- length_3 += 1;
8536
+ while (input[position + length_2] !== '*' && input[position + length_2 + 1] !== '/' && position + length_2 + 1 < input.length) {
8537
+ value += input[position + length_2];
8538
+ length_2 += 1;
8338
8539
  }
8339
- if (position + length_3 + 1 >= input.length) {
8540
+ if (position + length_2 + 1 >= input.length) {
8340
8541
  throw new LitsError('Comment not closed', undefined);
8341
8542
  }
8342
8543
  value += '*/';
8343
- length_3 += 2;
8344
- return [length_3, ['A_MultiLineComment', value]];
8544
+ length_2 += 2;
8545
+ return [length_2, ['A_MultiLineComment', value]];
8345
8546
  }
8346
8547
  return NO_MATCH;
8347
8548
  };
8348
8549
  var tokenizeA_SingleLineComment = function (input, position) {
8349
8550
  if (input[position] === '/' && input[position + 1] === '/') {
8350
- var length_4 = 2;
8551
+ var length_3 = 2;
8351
8552
  var value = '//';
8352
- while (input[position + length_4] !== '\n' && position + length_4 < input.length) {
8353
- value += input[position + length_4];
8354
- length_4 += 1;
8553
+ while (input[position + length_3] !== '\n' && position + length_3 < input.length) {
8554
+ value += input[position + length_3];
8555
+ length_3 += 1;
8355
8556
  }
8356
- return [length_4, ['A_SingleLineComment', value]];
8557
+ return [length_3, ['A_SingleLineComment', value]];
8357
8558
  }
8358
8559
  return NO_MATCH;
8359
8560
  };
@@ -8513,31 +8714,20 @@ var tokenizeP_FnShorthand = function (input, position) {
8513
8714
  return [1, ['P_FnShorthand']];
8514
8715
  };
8515
8716
  var tokenizeP_ReservedSymbol = function (input, position) {
8516
- var e_1, _a;
8517
- try {
8518
- for (var _b = __values(Object.entries(polishReservedNamesRecord)), _c = _b.next(); !_c.done; _c = _b.next()) {
8519
- var _d = __read(_c.value, 2), reservedName = _d[0], forbidden = _d[1].forbidden;
8520
- var length_3 = reservedName.length;
8521
- var nextChar = input[position + length_3];
8522
- if (nextChar && P_symbolRegExp.test(nextChar)) {
8523
- continue;
8524
- }
8525
- var symbol = input.substring(position, position + length_3);
8526
- if (symbol === reservedName) {
8527
- if (forbidden)
8528
- throw new LitsError("".concat(symbol, " is forbidden!"), undefined);
8529
- return [length_3, ['P_ReservedSymbol', reservedName]];
8530
- }
8531
- }
8717
+ var symbolMeta = tokenizeP_Symbol(input, position);
8718
+ if (symbolMeta[0] === 0 || !symbolMeta[1]) {
8719
+ return NO_MATCH;
8532
8720
  }
8533
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
8534
- finally {
8535
- try {
8536
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8537
- }
8538
- finally { if (e_1) throw e_1.error; }
8721
+ var symbolName = symbolMeta[1][1];
8722
+ symbolName = symbolName.startsWith('\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName;
8723
+ var info = polishReservedNamesRecord[symbolName];
8724
+ if (!info) {
8725
+ return NO_MATCH;
8539
8726
  }
8540
- return NO_MATCH;
8727
+ if (info.forbidden) {
8728
+ throw new LitsError("".concat(symbolName, " is forbidden!"), undefined);
8729
+ }
8730
+ return [symbolMeta[0], ['P_ReservedSymbol', symbolName]];
8541
8731
  };
8542
8732
  var tokenizeP_StringShorthand = function (input, position) {
8543
8733
  if (input[position] !== ':')
@@ -8550,24 +8740,24 @@ var tokenizeP_StringShorthand = function (input, position) {
8550
8740
  return [symbolDescription[0] + 1, ['P_StringShorthand', ":".concat(symbolToken[1])]];
8551
8741
  };
8552
8742
  var tokenizeP_Modifier = function (input, position) {
8553
- var e_2, _a;
8743
+ var e_1, _a;
8554
8744
  try {
8555
8745
  for (var modifierNames_1 = __values(modifierNames), modifierNames_1_1 = modifierNames_1.next(); !modifierNames_1_1.done; modifierNames_1_1 = modifierNames_1.next()) {
8556
8746
  var modifierName = modifierNames_1_1.value;
8557
- var length_4 = modifierName.length;
8558
- var charAfterModifier = input[position + length_4];
8559
- if (input.substring(position, position + length_4) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8747
+ var length_3 = modifierName.length;
8748
+ var charAfterModifier = input[position + length_3];
8749
+ if (input.substring(position, position + length_3) === modifierName && (!charAfterModifier || !P_symbolRegExp.test(charAfterModifier))) {
8560
8750
  var value = modifierName;
8561
- return [length_4, ['P_Modifier', value]];
8751
+ return [length_3, ['P_Modifier', value]];
8562
8752
  }
8563
8753
  }
8564
8754
  }
8565
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
8755
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
8566
8756
  finally {
8567
8757
  try {
8568
8758
  if (modifierNames_1_1 && !modifierNames_1_1.done && (_a = modifierNames_1.return)) _a.call(modifierNames_1);
8569
8759
  }
8570
- finally { if (e_2) throw e_2.error; }
8760
+ finally { if (e_1) throw e_1.error; }
8571
8761
  }
8572
8762
  return NO_MATCH;
8573
8763
  };
@@ -8604,8 +8794,8 @@ var polishTokenizers = __spreadArray(__spreadArray([
8604
8794
  tokenizeP_StringShorthand,
8605
8795
  tokenizeP_Number,
8606
8796
  tokenizeP_ReservedSymbol,
8607
- tokenizeP_Symbol,
8608
8797
  tokenizeP_Modifier,
8798
+ tokenizeP_Symbol,
8609
8799
  tokenizeP_RegexpShorthand,
8610
8800
  tokenizeP_FnShorthand,
8611
8801
  tokenizeP_CollectionAccessor,