@mojir/lits 2.0.16 → 2.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cli/cli.js +667 -380
  2. package/dist/cli/reference/api.d.ts +5 -5
  3. package/dist/cli/src/builtin/index.d.ts +0 -2
  4. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -5
  5. package/dist/cli/src/parser/AlgebraicParser.d.ts +6 -6
  6. package/dist/cli/src/parser/commonTokenParsers.d.ts +2 -1
  7. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
  8. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  9. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
  10. package/dist/cli/src/tokenizer/common/commonTokenizers.d.ts +3 -2
  11. package/dist/cli/src/tokenizer/common/commonTokens.d.ts +6 -2
  12. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
  13. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +4 -8
  14. package/dist/cli/src/tokenizer/tokens.d.ts +2 -2
  15. package/dist/index.esm.js +663 -378
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/index.js +663 -378
  18. package/dist/index.js.map +1 -1
  19. package/dist/lits.iife.js +663 -378
  20. package/dist/lits.iife.js.map +1 -1
  21. package/dist/reference/api.d.ts +5 -5
  22. package/dist/src/builtin/index.d.ts +0 -2
  23. package/dist/src/builtin/specialExpressions/functions.d.ts +0 -5
  24. package/dist/src/parser/AlgebraicParser.d.ts +6 -6
  25. package/dist/src/parser/commonTokenParsers.d.ts +2 -1
  26. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
  27. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  28. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
  29. package/dist/src/tokenizer/common/commonTokenizers.d.ts +3 -2
  30. package/dist/src/tokenizer/common/commonTokens.d.ts +6 -2
  31. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
  32. package/dist/src/tokenizer/polish/polishTokens.d.ts +4 -8
  33. package/dist/src/tokenizer/tokens.d.ts +2 -2
  34. package/dist/testFramework.esm.js +361 -271
  35. package/dist/testFramework.esm.js.map +1 -1
  36. package/dist/testFramework.js +361 -271
  37. package/dist/testFramework.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/cli/src/builtin/specialExpressions/defs.d.ts +0 -5
  40. package/dist/src/builtin/specialExpressions/defs.d.ts +0 -5
@@ -283,6 +283,7 @@ var commonSimpleTokenTypes = [
283
283
  ];
284
284
  var commomValueTokenTypes = [
285
285
  'String',
286
+ 'RegexpShorthand',
286
287
  ];
287
288
  function isLParenToken(token) {
288
289
  return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
@@ -356,6 +357,18 @@ function asStringToken(token) {
356
357
  assertStringToken(token);
357
358
  return token;
358
359
  }
360
+ function isRegexpShorthandToken(token) {
361
+ return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
362
+ }
363
+ function assertRegexpShorthandToken(token) {
364
+ if (!isRegexpShorthandToken(token)) {
365
+ throwUnexpectedToken('RegexpShorthand', undefined, token);
366
+ }
367
+ }
368
+ function asRegexpShorthandToken(token) {
369
+ assertRegexpShorthandToken(token);
370
+ return token;
371
+ }
359
372
  function isAlgebraicNotationToken(token) {
360
373
  return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
361
374
  }
@@ -426,24 +439,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
426
439
  var nonFunctionOperators = [
427
440
  '??',
428
441
  '&&',
442
+ '||',
429
443
  'comment',
430
444
  'cond',
445
+ 'def',
431
446
  'defined?',
432
- 'if',
433
- 'unless',
434
- '||',
447
+ 'defn',
435
448
  'do',
436
- 'throw',
437
- 'let',
438
- 'def',
439
- 'defs',
449
+ 'doseq',
440
450
  'fn',
441
- 'defn',
442
- 'defns',
443
- 'try',
444
- 'recur',
451
+ 'if',
452
+ 'let',
445
453
  'loop',
446
- 'doseq',
454
+ 'recur',
455
+ 'throw',
456
+ 'try',
457
+ 'unless',
447
458
  'while',
448
459
  ];
449
460
  var nonFunctionOperatorSet = new Set(nonFunctionOperators);
@@ -514,9 +525,10 @@ function isA_OperatorToken(token, operatorName) {
514
525
  }
515
526
  function assertA_OperatorToken(token, operatorName) {
516
527
  if (!isA_OperatorToken(token, operatorName)) {
517
- {
528
+ if (operatorName) {
518
529
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
519
530
  }
531
+ throwUnexpectedToken('A_Operator', operatorName, token);
520
532
  }
521
533
  }
522
534
  function isA_WhitespaceToken(token) {
@@ -539,7 +551,6 @@ var polishOnlyValueTokenTypes = [
539
551
  'P_StringShorthand',
540
552
  'P_Symbol',
541
553
  'P_ReservedSymbol',
542
- 'P_RegexpShorthand',
543
554
  'P_CollectionAccessor',
544
555
  'P_Comment',
545
556
  'P_Whitespace',
@@ -577,18 +588,6 @@ function isP_ReservedSymbolToken(token) {
577
588
  function isP_ModifierToken(token) {
578
589
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
579
590
  }
580
- function isP_RegexpShorthandToken(token) {
581
- return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
582
- }
583
- function assertP_RegexpShorthandToken(token) {
584
- if (!isP_RegexpShorthandToken(token)) {
585
- throwUnexpectedToken('P_RegexpShorthand', undefined, token);
586
- }
587
- }
588
- function asP_RegexpShorthandToken(token) {
589
- assertP_RegexpShorthandToken(token);
590
- return token;
591
- }
592
591
  function isP_FnShorthandToken(token) {
593
592
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
594
593
  }
@@ -849,11 +848,6 @@ var specialExpressionCommentRemovers = {
849
848
  removeOptions.removeCommenNodesFromArray(node.p);
850
849
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
851
850
  },
852
- 'defns': function (_node, _removeOptions) { },
853
- 'defs': function (node, removeOptions) {
854
- removeOptions.removeCommenNodesFromArray(node.p);
855
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
856
- },
857
851
  'do': function (node, removeOptions) {
858
852
  removeOptions.removeCommenNodesFromArray(node.p);
859
853
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
@@ -1941,7 +1935,7 @@ var arrayNormalExpression = {
1941
1935
  };
1942
1936
 
1943
1937
  var sequenceNormalExpression = {
1944
- nth: {
1938
+ 'nth': {
1945
1939
  evaluate: function (params, sourceCodeInfo) {
1946
1940
  var _a = __read(params, 2), seq = _a[0], i = _a[1];
1947
1941
  var defaultValue = toAny(params[2]);
@@ -1953,7 +1947,7 @@ var sequenceNormalExpression = {
1953
1947
  },
1954
1948
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
1955
1949
  },
1956
- filter: {
1950
+ 'filter': {
1957
1951
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1958
1952
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1959
1953
  var executeFunction = _b.executeFunction;
@@ -1968,7 +1962,7 @@ var sequenceNormalExpression = {
1968
1962
  },
1969
1963
  validate: function (node) { return assertNumberOfParams(2, node); },
1970
1964
  },
1971
- first: {
1965
+ 'first': {
1972
1966
  evaluate: function (_a, sourceCodeInfo) {
1973
1967
  var _b = __read(_a, 1), array = _b[0];
1974
1968
  if (array === null)
@@ -1978,7 +1972,7 @@ var sequenceNormalExpression = {
1978
1972
  },
1979
1973
  validate: function (node) { return assertNumberOfParams(1, node); },
1980
1974
  },
1981
- last: {
1975
+ 'last': {
1982
1976
  evaluate: function (_a, sourceCodeInfo) {
1983
1977
  var _b = __read(_a, 1), array = _b[0];
1984
1978
  if (array === null)
@@ -1988,7 +1982,7 @@ var sequenceNormalExpression = {
1988
1982
  },
1989
1983
  validate: function (node) { return assertNumberOfParams(1, node); },
1990
1984
  },
1991
- map: {
1985
+ 'map': {
1992
1986
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1993
1987
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1994
1988
  var executeFunction = _b.executeFunction;
@@ -2010,7 +2004,7 @@ var sequenceNormalExpression = {
2010
2004
  },
2011
2005
  validate: function (node) { return assertNumberOfParams(2, node); },
2012
2006
  },
2013
- pop: {
2007
+ 'pop': {
2014
2008
  evaluate: function (_a, sourceCodeInfo) {
2015
2009
  var _b = __read(_a, 1), seq = _b[0];
2016
2010
  assertSeq(seq, sourceCodeInfo);
@@ -2021,7 +2015,7 @@ var sequenceNormalExpression = {
2021
2015
  },
2022
2016
  validate: function (node) { return assertNumberOfParams(1, node); },
2023
2017
  },
2024
- position: {
2018
+ 'position': {
2025
2019
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2026
2020
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2027
2021
  var executeFunction = _b.executeFunction;
@@ -2040,7 +2034,7 @@ var sequenceNormalExpression = {
2040
2034
  },
2041
2035
  validate: function (node) { return assertNumberOfParams(2, node); },
2042
2036
  },
2043
- index_of: {
2037
+ 'index_of': {
2044
2038
  evaluate: function (_a, sourceCodeInfo) {
2045
2039
  var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2046
2040
  assertAny(value, sourceCodeInfo);
@@ -2059,7 +2053,26 @@ var sequenceNormalExpression = {
2059
2053
  },
2060
2054
  validate: function (node) { return assertNumberOfParams(2, node); },
2061
2055
  },
2062
- push: {
2056
+ 'last_index_of': {
2057
+ evaluate: function (_a, sourceCodeInfo) {
2058
+ var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2059
+ assertAny(value, sourceCodeInfo);
2060
+ if (seq === null)
2061
+ return null;
2062
+ assertSeq(seq, sourceCodeInfo);
2063
+ if (typeof seq === 'string') {
2064
+ assertString(value, sourceCodeInfo);
2065
+ var index = seq.lastIndexOf(value);
2066
+ return index !== -1 ? index : null;
2067
+ }
2068
+ else {
2069
+ var index = seq.lastIndexOf(value);
2070
+ return index !== -1 ? index : null;
2071
+ }
2072
+ },
2073
+ validate: function (node) { return assertNumberOfParams(2, node); },
2074
+ },
2075
+ 'push': {
2063
2076
  evaluate: function (_a, sourceCodeInfo) {
2064
2077
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2065
2078
  assertSeq(seq, sourceCodeInfo);
@@ -2073,7 +2086,7 @@ var sequenceNormalExpression = {
2073
2086
  },
2074
2087
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2075
2088
  },
2076
- reductions: {
2089
+ 'reductions': {
2077
2090
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2078
2091
  var executeFunction = _a.executeFunction;
2079
2092
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2134,7 +2147,7 @@ var sequenceNormalExpression = {
2134
2147
  },
2135
2148
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2136
2149
  },
2137
- reduce: {
2150
+ 'reduce': {
2138
2151
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2139
2152
  var executeFunction = _a.executeFunction;
2140
2153
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2181,7 +2194,7 @@ var sequenceNormalExpression = {
2181
2194
  },
2182
2195
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2183
2196
  },
2184
- reduce_right: {
2197
+ 'reduce_right': {
2185
2198
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2186
2199
  var executeFunction = _a.executeFunction;
2187
2200
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2229,7 +2242,7 @@ var sequenceNormalExpression = {
2229
2242
  },
2230
2243
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2231
2244
  },
2232
- rest: {
2245
+ 'rest': {
2233
2246
  evaluate: function (_a, sourceCodeInfo) {
2234
2247
  var _b = __read(_a, 1), seq = _b[0];
2235
2248
  assertSeq(seq, sourceCodeInfo);
@@ -2242,7 +2255,7 @@ var sequenceNormalExpression = {
2242
2255
  },
2243
2256
  validate: function (node) { return assertNumberOfParams(1, node); },
2244
2257
  },
2245
- nthrest: {
2258
+ 'nthrest': {
2246
2259
  evaluate: function (_a, sourceCodeInfo) {
2247
2260
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2248
2261
  assertSeq(seq, sourceCodeInfo);
@@ -2254,7 +2267,7 @@ var sequenceNormalExpression = {
2254
2267
  },
2255
2268
  validate: function (node) { return assertNumberOfParams(2, node); },
2256
2269
  },
2257
- next: {
2270
+ 'next': {
2258
2271
  evaluate: function (_a, sourceCodeInfo) {
2259
2272
  var _b = __read(_a, 1), seq = _b[0];
2260
2273
  assertSeq(seq, sourceCodeInfo);
@@ -2269,7 +2282,7 @@ var sequenceNormalExpression = {
2269
2282
  },
2270
2283
  validate: function (node) { return assertNumberOfParams(1, node); },
2271
2284
  },
2272
- nthnext: {
2285
+ 'nthnext': {
2273
2286
  evaluate: function (_a, sourceCodeInfo) {
2274
2287
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2275
2288
  assertSeq(seq, sourceCodeInfo);
@@ -2283,7 +2296,7 @@ var sequenceNormalExpression = {
2283
2296
  },
2284
2297
  validate: function (node) { return assertNumberOfParams(2, node); },
2285
2298
  },
2286
- reverse: {
2299
+ 'reverse': {
2287
2300
  evaluate: function (_a, sourceCodeInfo) {
2288
2301
  var _b = __read(_a, 1), seq = _b[0];
2289
2302
  if (seq === null)
@@ -2295,7 +2308,7 @@ var sequenceNormalExpression = {
2295
2308
  },
2296
2309
  validate: function (node) { return assertNumberOfParams(1, node); },
2297
2310
  },
2298
- second: {
2311
+ 'second': {
2299
2312
  evaluate: function (_a, sourceCodeInfo) {
2300
2313
  var _b = __read(_a, 1), seq = _b[0];
2301
2314
  if (seq === null)
@@ -2305,7 +2318,7 @@ var sequenceNormalExpression = {
2305
2318
  },
2306
2319
  validate: function (node) { return assertNumberOfParams(1, node); },
2307
2320
  },
2308
- shift: {
2321
+ 'shift': {
2309
2322
  evaluate: function (_a, sourceCodeInfo) {
2310
2323
  var _b = __read(_a, 1), seq = _b[0];
2311
2324
  assertSeq(seq, sourceCodeInfo);
@@ -2317,7 +2330,7 @@ var sequenceNormalExpression = {
2317
2330
  },
2318
2331
  validate: function (node) { return assertNumberOfParams(1, node); },
2319
2332
  },
2320
- slice: {
2333
+ 'slice': {
2321
2334
  evaluate: function (params, sourceCodeInfo) {
2322
2335
  var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
2323
2336
  assertSeq(seq, sourceCodeInfo);
@@ -2331,7 +2344,7 @@ var sequenceNormalExpression = {
2331
2344
  },
2332
2345
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
2333
2346
  },
2334
- some: {
2347
+ 'some': {
2335
2348
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2336
2349
  var _c;
2337
2350
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2348,7 +2361,7 @@ var sequenceNormalExpression = {
2348
2361
  },
2349
2362
  validate: function (node) { return assertNumberOfParams(2, node); },
2350
2363
  },
2351
- sort: {
2364
+ 'sort': {
2352
2365
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2353
2366
  var executeFunction = _a.executeFunction;
2354
2367
  var _b = __read(params, 1), seq = _b[0];
@@ -2386,7 +2399,7 @@ var sequenceNormalExpression = {
2386
2399
  },
2387
2400
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
2388
2401
  },
2389
- sort_by: {
2402
+ 'sort_by': {
2390
2403
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2391
2404
  var executeFunction = _a.executeFunction;
2392
2405
  var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
@@ -2437,7 +2450,7 @@ var sequenceNormalExpression = {
2437
2450
  },
2438
2451
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2439
2452
  },
2440
- take: {
2453
+ 'take': {
2441
2454
  evaluate: function (_a, sourceCodeInfo) {
2442
2455
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2443
2456
  assertNumber(n, sourceCodeInfo);
@@ -2447,7 +2460,7 @@ var sequenceNormalExpression = {
2447
2460
  },
2448
2461
  validate: function (node) { return assertNumberOfParams(2, node); },
2449
2462
  },
2450
- take_last: {
2463
+ 'take_last': {
2451
2464
  evaluate: function (_a, sourceCodeInfo) {
2452
2465
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2453
2466
  assertSeq(array, sourceCodeInfo);
@@ -2458,7 +2471,7 @@ var sequenceNormalExpression = {
2458
2471
  },
2459
2472
  validate: function (node) { return assertNumberOfParams(2, node); },
2460
2473
  },
2461
- take_while: {
2474
+ 'take_while': {
2462
2475
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2463
2476
  var e_1, _c;
2464
2477
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2486,7 +2499,7 @@ var sequenceNormalExpression = {
2486
2499
  },
2487
2500
  validate: function (node) { return assertNumberOfParams(2, node); },
2488
2501
  },
2489
- drop: {
2502
+ 'drop': {
2490
2503
  evaluate: function (_a, sourceCodeInfo) {
2491
2504
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2492
2505
  assertNumber(n, sourceCodeInfo);
@@ -2496,7 +2509,7 @@ var sequenceNormalExpression = {
2496
2509
  },
2497
2510
  validate: function (node) { return assertNumberOfParams(2, node); },
2498
2511
  },
2499
- drop_last: {
2512
+ 'drop_last': {
2500
2513
  evaluate: function (_a, sourceCodeInfo) {
2501
2514
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2502
2515
  assertSeq(array, sourceCodeInfo);
@@ -2507,7 +2520,7 @@ var sequenceNormalExpression = {
2507
2520
  },
2508
2521
  validate: function (node) { return assertNumberOfParams(2, node); },
2509
2522
  },
2510
- drop_while: {
2523
+ 'drop_while': {
2511
2524
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2512
2525
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2513
2526
  var executeFunction = _b.executeFunction;
@@ -2523,7 +2536,7 @@ var sequenceNormalExpression = {
2523
2536
  },
2524
2537
  validate: function (node) { return assertNumberOfParams(2, node); },
2525
2538
  },
2526
- unshift: {
2539
+ 'unshift': {
2527
2540
  evaluate: function (_a, sourceCodeInfo) {
2528
2541
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2529
2542
  assertSeq(seq, sourceCodeInfo);
@@ -2537,7 +2550,7 @@ var sequenceNormalExpression = {
2537
2550
  },
2538
2551
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2539
2552
  },
2540
- distinct: {
2553
+ 'distinct': {
2541
2554
  evaluate: function (_a, sourceCodeInfo) {
2542
2555
  var _b = __read(_a, 1), input = _b[0];
2543
2556
  assertSeq(input, sourceCodeInfo);
@@ -2547,9 +2560,9 @@ var sequenceNormalExpression = {
2547
2560
  },
2548
2561
  validate: function (node) { return assertNumberOfParams(1, node); },
2549
2562
  },
2550
- remove: {
2563
+ 'remove': {
2551
2564
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2552
- var _c = __read(_a, 2), fn = _c[0], input = _c[1];
2565
+ var _c = __read(_a, 2), input = _c[0], fn = _c[1];
2553
2566
  var executeFunction = _b.executeFunction;
2554
2567
  assertLitsFunction(fn, sourceCodeInfo);
2555
2568
  assertSeq(input, sourceCodeInfo);
@@ -2562,9 +2575,9 @@ var sequenceNormalExpression = {
2562
2575
  },
2563
2576
  validate: function (node) { return assertNumberOfParams(2, node); },
2564
2577
  },
2565
- remove_at: {
2578
+ 'remove_at': {
2566
2579
  evaluate: function (_a, sourceCodeInfo) {
2567
- var _b = __read(_a, 2), index = _b[0], input = _b[1];
2580
+ var _b = __read(_a, 2), input = _b[0], index = _b[1];
2568
2581
  assertNumber(index, sourceCodeInfo);
2569
2582
  assertSeq(input, sourceCodeInfo);
2570
2583
  var intIndex = Math.ceil(index);
@@ -2579,9 +2592,9 @@ var sequenceNormalExpression = {
2579
2592
  },
2580
2593
  validate: function (node) { return assertNumberOfParams(2, node); },
2581
2594
  },
2582
- split_at: {
2595
+ 'split_at': {
2583
2596
  evaluate: function (_a, sourceCodeInfo) {
2584
- var _b = __read(_a, 2), pos = _b[0], seq = _b[1];
2597
+ var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
2585
2598
  assertNumber(pos, sourceCodeInfo, { finite: true });
2586
2599
  var intPos = toNonNegativeInteger(pos);
2587
2600
  assertSeq(seq, sourceCodeInfo);
@@ -2589,9 +2602,9 @@ var sequenceNormalExpression = {
2589
2602
  },
2590
2603
  validate: function (node) { return assertNumberOfParams(2, node); },
2591
2604
  },
2592
- split_with: {
2605
+ 'split_with': {
2593
2606
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2594
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2607
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2595
2608
  var executeFunction = _b.executeFunction;
2596
2609
  assertLitsFunction(fn, sourceCodeInfo);
2597
2610
  assertSeq(seq, sourceCodeInfo);
@@ -2604,7 +2617,7 @@ var sequenceNormalExpression = {
2604
2617
  },
2605
2618
  validate: function (node) { return assertNumberOfParams(2, node); },
2606
2619
  },
2607
- frequencies: {
2620
+ 'frequencies': {
2608
2621
  evaluate: function (_a, sourceCodeInfo) {
2609
2622
  var _b = __read(_a, 1), seq = _b[0];
2610
2623
  assertSeq(seq, sourceCodeInfo);
@@ -2620,9 +2633,9 @@ var sequenceNormalExpression = {
2620
2633
  },
2621
2634
  validate: function (node) { return assertNumberOfParams(1, node); },
2622
2635
  },
2623
- group_by: {
2636
+ 'group_by': {
2624
2637
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2625
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2638
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2626
2639
  var executeFunction = _b.executeFunction;
2627
2640
  assertAny(fn, sourceCodeInfo);
2628
2641
  assertSeq(seq, sourceCodeInfo);
@@ -2638,34 +2651,30 @@ var sequenceNormalExpression = {
2638
2651
  },
2639
2652
  validate: function (node) { return assertNumberOfParams(2, node); },
2640
2653
  },
2641
- partition: {
2654
+ 'partition': {
2642
2655
  evaluate: function (params, sourceCodeInfo) {
2643
- var len = params.length;
2644
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2645
- var seq = len === 2
2646
- ? asSeq(params[1], sourceCodeInfo)
2647
- : len === 3
2648
- ? asSeq(params[2], sourceCodeInfo)
2649
- : asSeq(params[3], sourceCodeInfo);
2650
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2651
- var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
2656
+ var seq = asSeq(params[0], sourceCodeInfo);
2657
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2658
+ var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2659
+ var pad = params.length === 4
2660
+ ? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
2661
+ : undefined;
2652
2662
  return partition(n, step, seq, pad, sourceCodeInfo);
2653
2663
  },
2654
2664
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
2655
2665
  },
2656
- partition_all: {
2666
+ 'partition_all': {
2657
2667
  evaluate: function (params, sourceCodeInfo) {
2658
- var len = params.length;
2659
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2660
- var seq = len === 2 ? asSeq(params[1], sourceCodeInfo) : asSeq(params[2], sourceCodeInfo);
2661
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2668
+ var seq = asSeq(params[0], sourceCodeInfo);
2669
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2670
+ var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2662
2671
  return partition(n, step, seq, [], sourceCodeInfo);
2663
2672
  },
2664
2673
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2665
2674
  },
2666
- partition_by: {
2675
+ 'partition_by': {
2667
2676
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2668
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2677
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2669
2678
  var executeFunction = _b.executeFunction;
2670
2679
  assertLitsFunction(fn, sourceCodeInfo);
2671
2680
  assertSeq(seq, sourceCodeInfo);
@@ -2682,7 +2691,88 @@ var sequenceNormalExpression = {
2682
2691
  }, []);
2683
2692
  return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
2684
2693
  },
2685
- validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2694
+ validate: function (node) { return assertNumberOfParams(2, node); },
2695
+ },
2696
+ 'ends_with?': {
2697
+ evaluate: function (_a, sourceCodeInfo) {
2698
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2699
+ assertSeq(str, sourceCodeInfo);
2700
+ if (typeof str === 'string') {
2701
+ assertString(search, sourceCodeInfo);
2702
+ return str.endsWith(search);
2703
+ }
2704
+ return str.at(-1) === search;
2705
+ },
2706
+ validate: function (node) { return assertNumberOfParams(2, node); },
2707
+ },
2708
+ 'starts_with?': {
2709
+ evaluate: function (_a, sourceCodeInfo) {
2710
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2711
+ assertSeq(str, sourceCodeInfo);
2712
+ if (typeof str === 'string') {
2713
+ assertString(search, sourceCodeInfo);
2714
+ return str.startsWith(search);
2715
+ }
2716
+ return str[0] === search;
2717
+ },
2718
+ validate: function (node) { return assertNumberOfParams(2, node); },
2719
+ },
2720
+ 'interleave': {
2721
+ evaluate: function (_a, sourceCodeInfo) {
2722
+ var e_2, _b;
2723
+ var _c = __read(_a), seqs = _c.slice(0);
2724
+ var isStringSeq = typeof seqs[0] === 'string';
2725
+ var seqsArr = isStringSeq
2726
+ ? seqs.map(function (seq) {
2727
+ assertString(seq, sourceCodeInfo);
2728
+ if (typeof seq === 'string')
2729
+ return seq.split('');
2730
+ return seq;
2731
+ })
2732
+ : seqs.map(function (seq) {
2733
+ assertArray(seq, sourceCodeInfo);
2734
+ return seq;
2735
+ });
2736
+ var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
2737
+ var result = [];
2738
+ for (var i = 0; i < maxLength; i += 1) {
2739
+ try {
2740
+ for (var seqsArr_1 = (e_2 = void 0, __values(seqsArr)), seqsArr_1_1 = seqsArr_1.next(); !seqsArr_1_1.done; seqsArr_1_1 = seqsArr_1.next()) {
2741
+ var seq = seqsArr_1_1.value;
2742
+ if (i < seq.length)
2743
+ result.push(seq[i]);
2744
+ }
2745
+ }
2746
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2747
+ finally {
2748
+ try {
2749
+ if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
2750
+ }
2751
+ finally { if (e_2) throw e_2.error; }
2752
+ }
2753
+ }
2754
+ return isStringSeq ? result.join('') : result;
2755
+ },
2756
+ validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
2757
+ },
2758
+ 'interpose': {
2759
+ evaluate: function (_a, sourceCodeInfo) {
2760
+ var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
2761
+ assertSeq(seq, sourceCodeInfo);
2762
+ if (typeof seq === 'string') {
2763
+ assertString(separator, sourceCodeInfo);
2764
+ return seq.split('').join(separator);
2765
+ }
2766
+ if (seq.length === 0)
2767
+ return [];
2768
+ var result = [];
2769
+ for (var i = 0; i < seq.length - 1; i += 1) {
2770
+ result.push(seq[i], separator);
2771
+ }
2772
+ result.push(seq[seq.length - 1]);
2773
+ return result;
2774
+ },
2775
+ validate: function (node) { return assertNumberOfParams(2, node); },
2686
2776
  },
2687
2777
  };
2688
2778
  function partition(n, step, seq, pad, sourceCodeInfo) {
@@ -3845,7 +3935,7 @@ var regexpNormalExpression = {
3845
3935
  },
3846
3936
  match: {
3847
3937
  evaluate: function (_a, sourceCodeInfo) {
3848
- var _b = __read(_a, 2), regexp = _b[0], text = _b[1];
3938
+ var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
3849
3939
  assertRegularExpression(regexp, sourceCodeInfo);
3850
3940
  if (!isString(text))
3851
3941
  return null;
@@ -3861,15 +3951,27 @@ var regexpNormalExpression = {
3861
3951
  evaluate: function (_a, sourceCodeInfo) {
3862
3952
  var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
3863
3953
  assertString(str, sourceCodeInfo);
3864
- assertRegularExpression(regexp, sourceCodeInfo);
3954
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
3865
3955
  assertString(value, sourceCodeInfo);
3866
- var regExp = new RegExp(regexp.s, regexp.f);
3867
- return str.replace(regExp, value);
3956
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
3957
+ return str.replace(matcher, value);
3958
+ },
3959
+ validate: function (node) { return assertNumberOfParams(3, node); },
3960
+ },
3961
+ replace_all: {
3962
+ evaluate: function (_a, sourceCodeInfo) {
3963
+ var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
3964
+ assertString(str, sourceCodeInfo);
3965
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
3966
+ assertString(value, sourceCodeInfo);
3967
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
3968
+ return str.replaceAll(matcher, value);
3868
3969
  },
3869
3970
  validate: function (node) { return assertNumberOfParams(3, node); },
3870
3971
  },
3871
3972
  };
3872
3973
 
3974
+ var blankRegexp = /^\s*$/;
3873
3975
  var stringNormalExpression = {
3874
3976
  'subs': {
3875
3977
  evaluate: function (_a, sourceCodeInfo) {
@@ -4027,6 +4129,14 @@ var stringNormalExpression = {
4027
4129
  },
4028
4130
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4029
4131
  },
4132
+ 'split_lines': {
4133
+ evaluate: function (_a, sourceCodeInfo) {
4134
+ var _b = __read(_a, 1), str = _b[0];
4135
+ assertString(str, sourceCodeInfo);
4136
+ return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
4137
+ },
4138
+ validate: function (node) { return assertNumberOfParams(1, node); },
4139
+ },
4030
4140
  'pad_left': {
4031
4141
  evaluate: function (_a, sourceCodeInfo) {
4032
4142
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
@@ -4130,6 +4240,25 @@ var stringNormalExpression = {
4130
4240
  },
4131
4241
  validate: function (node) { return assertNumberOfParams(1, node); },
4132
4242
  },
4243
+ 'blank?': {
4244
+ evaluate: function (_a, sourceCodeInfo) {
4245
+ var _b = __read(_a, 1), value = _b[0];
4246
+ if (value === null) {
4247
+ return true;
4248
+ }
4249
+ assertString(value, sourceCodeInfo);
4250
+ return blankRegexp.test(value);
4251
+ },
4252
+ validate: function (node) { return assertNumberOfParams(1, node); },
4253
+ },
4254
+ 'capitalize': {
4255
+ evaluate: function (_a, sourceCodeInfo) {
4256
+ var _b = __read(_a, 1), str = _b[0];
4257
+ assertString(str, sourceCodeInfo);
4258
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
4259
+ },
4260
+ validate: function (node) { return assertNumberOfParams(1, node); },
4261
+ },
4133
4262
  };
4134
4263
  var doubleDollarRegexp = /\$\$/g;
4135
4264
  function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
@@ -4474,44 +4603,6 @@ var defSpecialExpression = {
4474
4603
  },
4475
4604
  };
4476
4605
 
4477
- var defsSpecialExpression = {
4478
- polishParse: function (tokenStream, parseState, firstToken, _a) {
4479
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4480
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4481
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4482
- var node = {
4483
- t: AstNodeType.SpecialExpression,
4484
- n: 'defs',
4485
- p: params,
4486
- token: getTokenDebugData(firstToken) && firstToken,
4487
- };
4488
- return node;
4489
- },
4490
- validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4491
- evaluate: function (node, contextStack, _a) {
4492
- var _b, _c;
4493
- var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
4494
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4495
- var name = evaluateAstNode(node.p[0], contextStack);
4496
- assertString(name, sourceCodeInfo);
4497
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4498
- contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
4499
- return null;
4500
- },
4501
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4502
- var _b;
4503
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4504
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4505
- var subNode = node.p[1];
4506
- var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
4507
- var name = evaluateAstNode(node.p[0], contextStack);
4508
- assertString(name, sourceCodeInfo);
4509
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4510
- contextStack.exportValue(name, true);
4511
- return result;
4512
- },
4513
- };
4514
-
4515
4606
  var doSpecialExpression = {
4516
4607
  polishParse: getCommonPolishSpecialExpressionParser('do'),
4517
4608
  validateParameterCount: function () { return undefined; },
@@ -4591,7 +4682,7 @@ var defnSpecialExpression = {
4591
4682
  var _b;
4592
4683
  var _c, _d;
4593
4684
  var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4594
- var name = getFunctionName('defn', node, contextStack, evaluateAstNode);
4685
+ var name = node.f.v;
4595
4686
  assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4596
4687
  var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4597
4688
  var litsFunction = (_b = {},
@@ -4612,53 +4703,6 @@ var defnSpecialExpression = {
4612
4703
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4613
4704
  },
4614
4705
  };
4615
- var defnsSpecialExpression = {
4616
- polishParse: function (tokenStream, parseState, firstToken, parsers) {
4617
- var parseToken = parsers.parseToken;
4618
- var functionName = parseToken(tokenStream, parseState);
4619
- var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
4620
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4621
- var node = {
4622
- t: AstNodeType.SpecialExpression,
4623
- n: 'defns',
4624
- p: [],
4625
- f: functionName,
4626
- o: functionOverloades,
4627
- token: getTokenDebugData(firstToken) && firstToken,
4628
- };
4629
- return node;
4630
- },
4631
- validateParameterCount: function () { return undefined; },
4632
- evaluate: function (node, contextStack, _a) {
4633
- var _b;
4634
- var _c, _d;
4635
- var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4636
- var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
4637
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4638
- var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4639
- var litsFunction = (_b = {},
4640
- _b[FUNCTION_SYMBOL] = true,
4641
- _b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
4642
- _b.t = FunctionType.UserDefined,
4643
- _b.n = name,
4644
- _b.o = evaluatedFunctionOverloades,
4645
- _b);
4646
- contextStack.exportValue(name, litsFunction);
4647
- return null;
4648
- },
4649
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4650
- var _b;
4651
- var _c;
4652
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4653
- var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
4654
- var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
4655
- assertString(name, sourceCodeInfo);
4656
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4657
- contextStack.exportValue(name, true);
4658
- var newContext = (_b = {}, _b[name] = { value: true }, _b);
4659
- return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4660
- },
4661
- };
4662
4706
  var fnSpecialExpression = {
4663
4707
  polishParse: function (tokenStream, parseState, firstToken, parsers) {
4664
4708
  var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
@@ -4692,14 +4736,6 @@ var fnSpecialExpression = {
4692
4736
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
4693
4737
  },
4694
4738
  };
4695
- function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
4696
- var _a;
4697
- var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
4698
- if (expressionName === 'defn')
4699
- return (node.f).v;
4700
- var name = evaluateAstNode(node.f, contextStack);
4701
- return asString(name, sourceCodeInfo);
4702
- }
4703
4739
  function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
4704
4740
  var e_1, _a, e_2, _b;
4705
4741
  var evaluatedFunctionOverloades = [];
@@ -5477,8 +5513,6 @@ var specialExpressions = {
5477
5513
  'switch': switchSpecialExpression,
5478
5514
  'def': defSpecialExpression,
5479
5515
  'defn': defnSpecialExpression,
5480
- 'defns': defnsSpecialExpression,
5481
- 'defs': defsSpecialExpression,
5482
5516
  'do': doSpecialExpression,
5483
5517
  'doseq': doseqSpecialExpression,
5484
5518
  'for': forSpecialExpression,
@@ -5540,7 +5574,6 @@ var ContextStackImpl = /** @class */ (function () {
5540
5574
  if (normalExpressionKeys.includes(name)) {
5541
5575
  throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
5542
5576
  }
5543
- this.addValue(name, value);
5544
5577
  this.globalContext[name] = { value: value };
5545
5578
  };
5546
5579
  ContextStackImpl.prototype.addValue = function (name, value) {
@@ -6204,6 +6237,33 @@ function parseString(tokenStream, parseState) {
6204
6237
  token: getTokenDebugData(tkn) && tkn,
6205
6238
  };
6206
6239
  }
6240
+ function parseRegexpShorthand(tokenStream, parseState) {
6241
+ var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
6242
+ var endStringPosition = tkn[1].lastIndexOf('"');
6243
+ var regexpString = tkn[1].substring(2, endStringPosition);
6244
+ var optionsString = tkn[1].substring(endStringPosition + 1);
6245
+ var stringNode = {
6246
+ t: AstNodeType.String,
6247
+ v: regexpString,
6248
+ p: [],
6249
+ n: undefined,
6250
+ token: getTokenDebugData(tkn) && tkn,
6251
+ };
6252
+ var optionsNode = {
6253
+ t: AstNodeType.String,
6254
+ v: optionsString,
6255
+ p: [],
6256
+ n: undefined,
6257
+ token: getTokenDebugData(tkn) && tkn,
6258
+ };
6259
+ var node = {
6260
+ t: AstNodeType.NormalExpression,
6261
+ n: 'regexp',
6262
+ p: [stringNode, optionsNode],
6263
+ token: getTokenDebugData(tkn) && tkn,
6264
+ };
6265
+ return node;
6266
+ }
6207
6267
 
6208
6268
  var exponentiationPrecedence = 10;
6209
6269
  var binaryFunctionalOperatorPrecedence = 1;
@@ -6345,6 +6405,12 @@ var AlgebraicParser = /** @class */ (function () {
6345
6405
  this.tokenStream = tokenStream;
6346
6406
  this.parseState = parseState;
6347
6407
  }
6408
+ AlgebraicParser.prototype.peek = function () {
6409
+ return this.tokenStream.tokens[this.parseState.position];
6410
+ };
6411
+ AlgebraicParser.prototype.peekAhead = function (count) {
6412
+ return this.tokenStream.tokens[this.parseState.position + count];
6413
+ };
6348
6414
  AlgebraicParser.prototype.advance = function () {
6349
6415
  this.parseState.position += 1;
6350
6416
  };
@@ -6366,10 +6432,6 @@ var AlgebraicParser = /** @class */ (function () {
6366
6432
  var left;
6367
6433
  if (isA_SymbolToken(firstToken)) {
6368
6434
  switch (firstToken[1]) {
6369
- case 'def':
6370
- return this.parseDef(firstToken);
6371
- case 'defn':
6372
- return this.parseDefn(firstToken);
6373
6435
  case 'let':
6374
6436
  return this.parseLet(firstToken);
6375
6437
  case 'if':
@@ -6397,6 +6459,12 @@ var AlgebraicParser = /** @class */ (function () {
6397
6459
  break;
6398
6460
  }
6399
6461
  }
6462
+ else if (isA_ReservedSymbolToken(firstToken, 'function')) {
6463
+ return this.parseFunction(firstToken);
6464
+ }
6465
+ else if (isA_ReservedSymbolToken(firstToken, 'export')) {
6466
+ return this.parseExport(firstToken);
6467
+ }
6400
6468
  left || (left = this.parseOperand());
6401
6469
  var operator = this.peek();
6402
6470
  while (!this.isAtExpressionEnd()) {
@@ -6528,10 +6596,18 @@ var AlgebraicParser = /** @class */ (function () {
6528
6596
  case 'String':
6529
6597
  return parseString(this.tokenStream, this.parseState);
6530
6598
  case 'A_Symbol': {
6599
+ var positionBefore = this.parseState.position;
6600
+ var lamdaFunction = this.parseLambdaFunction();
6601
+ if (lamdaFunction) {
6602
+ return lamdaFunction;
6603
+ }
6604
+ this.parseState.position = positionBefore;
6531
6605
  return parseSymbol(this.tokenStream, this.parseState);
6532
6606
  }
6533
6607
  case 'A_ReservedSymbol':
6534
6608
  return parseReservedSymbol(this.tokenStream, this.parseState);
6609
+ case 'RegexpShorthand':
6610
+ return parseRegexpShorthand(this.tokenStream, this.parseState);
6535
6611
  case 'PolNotation': {
6536
6612
  this.parseState.algebraic = false;
6537
6613
  var astNodes = [];
@@ -6665,11 +6741,9 @@ var AlgebraicParser = /** @class */ (function () {
6665
6741
  builtin.specialExpressions[node.n].validateParameterCount(node);
6666
6742
  return node;
6667
6743
  }
6668
- case 'defs':
6669
6744
  case 'fn':
6670
- case 'defns':
6671
- case 'try':
6672
- case 'doseq':
6745
+ case 'def':
6746
+ case 'defn':
6673
6747
  throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
6674
6748
  default:
6675
6749
  throw new Error("Unknown special expression: ".concat(name_2));
@@ -6688,6 +6762,11 @@ var AlgebraicParser = /** @class */ (function () {
6688
6762
  };
6689
6763
  AlgebraicParser.prototype.parseLambdaFunction = function () {
6690
6764
  var firstToken = this.peek();
6765
+ if (isLParenToken(firstToken)
6766
+ && isA_SymbolToken(this.peekAhead(1))
6767
+ && isA_OperatorToken(this.peekAhead(2), '=>')) {
6768
+ return null;
6769
+ }
6691
6770
  try {
6692
6771
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
6693
6772
  if (!isA_OperatorToken(this.peek(), '=>')) {
@@ -6713,6 +6792,18 @@ var AlgebraicParser = /** @class */ (function () {
6713
6792
  };
6714
6793
  AlgebraicParser.prototype.parseFunctionArguments = function () {
6715
6794
  var _a, _b, _c, _d, _e;
6795
+ var firstToken = this.peek();
6796
+ if (isA_SymbolToken(firstToken)) {
6797
+ this.advance();
6798
+ return {
6799
+ functionArguments: {
6800
+ m: [firstToken[1]],
6801
+ b: [],
6802
+ r: undefined,
6803
+ },
6804
+ arity: 1,
6805
+ };
6806
+ }
6716
6807
  this.advance();
6717
6808
  var rest = false;
6718
6809
  var letBindingObject;
@@ -6831,17 +6922,20 @@ var AlgebraicParser = /** @class */ (function () {
6831
6922
  };
6832
6923
  return node;
6833
6924
  };
6834
- AlgebraicParser.prototype.parseLet = function (token) {
6925
+ AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
6926
+ if (optionalSemicolon === void 0) { optionalSemicolon = false; }
6835
6927
  this.advance();
6836
6928
  var letSymbol = parseSymbol(this.tokenStream, this.parseState);
6837
6929
  assertA_OperatorToken(this.peek(), '=');
6838
6930
  this.advance();
6839
6931
  var value = this.parseExpression();
6932
+ if (!optionalSemicolon) {
6933
+ assertA_OperatorToken(this.peek(), ';');
6934
+ }
6840
6935
  return {
6841
6936
  t: AstNodeType.SpecialExpression,
6842
6937
  n: 'let',
6843
6938
  p: [],
6844
- token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6845
6939
  bs: [{
6846
6940
  t: AstNodeType.Binding,
6847
6941
  n: letSymbol.v,
@@ -6849,6 +6943,7 @@ var AlgebraicParser = /** @class */ (function () {
6849
6943
  p: [],
6850
6944
  token: getTokenDebugData(token) && token,
6851
6945
  }],
6946
+ token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6852
6947
  };
6853
6948
  };
6854
6949
  AlgebraicParser.prototype.parseDo = function (token) {
@@ -7016,7 +7111,7 @@ var AlgebraicParser = /** @class */ (function () {
7016
7111
  modifiers.push('&let');
7017
7112
  letBindings = [];
7018
7113
  while (isA_SymbolToken(token, 'let')) {
7019
- var letNode = this.parseLet(token);
7114
+ var letNode = this.parseLet(token, true);
7020
7115
  letBindings.push(letNode.bs[0]);
7021
7116
  token = this.peek();
7022
7117
  }
@@ -7203,20 +7298,7 @@ var AlgebraicParser = /** @class */ (function () {
7203
7298
  token: getTokenDebugData(token) && token,
7204
7299
  };
7205
7300
  };
7206
- AlgebraicParser.prototype.parseDef = function (token) {
7207
- this.advance();
7208
- var symbol = parseSymbol(this.tokenStream, this.parseState);
7209
- assertA_OperatorToken(this.peek(), '=');
7210
- this.advance();
7211
- var value = this.parseExpression();
7212
- return {
7213
- t: AstNodeType.SpecialExpression,
7214
- n: 'def',
7215
- p: [symbol, value],
7216
- token: getTokenDebugData(token) && token,
7217
- };
7218
- };
7219
- AlgebraicParser.prototype.parseDefn = function (token) {
7301
+ AlgebraicParser.prototype.parseFunction = function (token) {
7220
7302
  this.advance();
7221
7303
  var symbol = parseSymbol(this.tokenStream, this.parseState);
7222
7304
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
@@ -7229,10 +7311,9 @@ var AlgebraicParser = /** @class */ (function () {
7229
7311
  }
7230
7312
  assertA_ReservedSymbolToken(this.peek(), 'end');
7231
7313
  this.advance();
7232
- return {
7314
+ var fnNode = {
7233
7315
  t: AstNodeType.SpecialExpression,
7234
- n: 'defn',
7235
- f: symbol,
7316
+ n: 'fn',
7236
7317
  p: [],
7237
7318
  o: [{
7238
7319
  as: functionArguments,
@@ -7241,6 +7322,19 @@ var AlgebraicParser = /** @class */ (function () {
7241
7322
  }],
7242
7323
  token: getTokenDebugData(token) && token,
7243
7324
  };
7325
+ return {
7326
+ t: AstNodeType.SpecialExpression,
7327
+ n: 'let',
7328
+ p: [],
7329
+ bs: [{
7330
+ t: AstNodeType.Binding,
7331
+ n: symbol.v,
7332
+ v: fnNode,
7333
+ p: [],
7334
+ token: getTokenDebugData(symbol.token) && symbol.token,
7335
+ }],
7336
+ token: getTokenDebugData(token) && token,
7337
+ };
7244
7338
  };
7245
7339
  AlgebraicParser.prototype.isAtEnd = function () {
7246
7340
  return this.parseState.position >= this.tokenStream.tokens.length;
@@ -7261,8 +7355,30 @@ var AlgebraicParser = /** @class */ (function () {
7261
7355
  }
7262
7356
  return false;
7263
7357
  };
7264
- AlgebraicParser.prototype.peek = function () {
7265
- return this.tokenStream.tokens[this.parseState.position];
7358
+ AlgebraicParser.prototype.parseExport = function (token) {
7359
+ var _a;
7360
+ this.advance();
7361
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7362
+ if (isA_OperatorToken(this.peek(), ';')) {
7363
+ return {
7364
+ t: AstNodeType.SpecialExpression,
7365
+ n: 'def',
7366
+ p: [symbol, symbol],
7367
+ token: getTokenDebugData(token) && token,
7368
+ };
7369
+ }
7370
+ if (!isA_OperatorToken(this.peek(), '=')) {
7371
+ throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7372
+ }
7373
+ this.advance();
7374
+ var value = this.parseExpression();
7375
+ assertA_OperatorToken(this.peek(), ';');
7376
+ return {
7377
+ t: AstNodeType.SpecialExpression,
7378
+ n: 'def',
7379
+ p: [symbol, value],
7380
+ token: getTokenDebugData(token) && token,
7381
+ };
7266
7382
  };
7267
7383
  return AlgebraicParser;
7268
7384
  }());
@@ -7338,33 +7454,6 @@ function parseObjectLitteral(tokenStream, parseState) {
7338
7454
  assertEvenNumberOfParams(node);
7339
7455
  return node;
7340
7456
  }
7341
- function parseRegexpShorthand(tokenStream, parseState) {
7342
- var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
7343
- var endStringPosition = tkn[1].lastIndexOf('"');
7344
- var regexpString = tkn[1].substring(2, endStringPosition);
7345
- var optionsString = tkn[1].substring(endStringPosition + 1);
7346
- var stringNode = {
7347
- t: AstNodeType.String,
7348
- v: regexpString,
7349
- p: [],
7350
- n: undefined,
7351
- token: getTokenDebugData(tkn) && tkn,
7352
- };
7353
- var optionsNode = {
7354
- t: AstNodeType.String,
7355
- v: optionsString,
7356
- p: [],
7357
- n: undefined,
7358
- token: getTokenDebugData(tkn) && tkn,
7359
- };
7360
- var node = {
7361
- t: AstNodeType.NormalExpression,
7362
- n: 'regexp',
7363
- p: [stringNode, optionsNode],
7364
- token: getTokenDebugData(tkn) && tkn,
7365
- };
7366
- return node;
7367
- }
7368
7457
  var placeholderRegexp = /^%([1-9]\d?)?$/;
7369
7458
  function parseFnShorthand(tokenStream, parseState) {
7370
7459
  var _a, _b, _c, _d;
@@ -7534,7 +7623,7 @@ function parsePolishToken(tokenStream, parseState) {
7534
7623
  return parseArrayLitteral(tokenStream, parseState);
7535
7624
  case 'LBrace':
7536
7625
  return parseObjectLitteral(tokenStream, parseState);
7537
- case 'P_RegexpShorthand':
7626
+ case 'RegexpShorthand':
7538
7627
  return parseRegexpShorthand(tokenStream, parseState);
7539
7628
  case 'P_FnShorthand':
7540
7629
  return parseFnShorthand(tokenStream, parseState);
@@ -7697,6 +7786,25 @@ var tokenizeString = function (input, position) {
7697
7786
  value += '"'; // closing quote
7698
7787
  return [length + 1, ['String', value]];
7699
7788
  };
7789
+ var tokenizeRegexpShorthand = function (input, position) {
7790
+ if (input[position] !== '#')
7791
+ return NO_MATCH;
7792
+ var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
7793
+ if (!token)
7794
+ return NO_MATCH;
7795
+ position += stringLength + 1;
7796
+ var length = stringLength + 1;
7797
+ var options = '';
7798
+ while (input[position] === 'g' || input[position] === 'i') {
7799
+ if (options.includes(input[position])) {
7800
+ throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
7801
+ }
7802
+ options += input[position];
7803
+ length += 1;
7804
+ position += 1;
7805
+ }
7806
+ return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
7807
+ };
7700
7808
  function tokenizeSimpleToken(type, value, input, position) {
7701
7809
  if (value === input.slice(position, position + value.length))
7702
7810
  return [value.length, [type]];
@@ -7714,6 +7822,7 @@ var commonTokenizers = [
7714
7822
  tokenizeLBrace,
7715
7823
  tokenizeRBrace,
7716
7824
  tokenizeString,
7825
+ tokenizeRegexpShorthand,
7717
7826
  ];
7718
7827
 
7719
7828
  var validAlgebraicReservedNamesRecord = {
@@ -7727,10 +7836,11 @@ var validAlgebraicReservedNamesRecord = {
7727
7836
  case: { value: null, forbidden: false },
7728
7837
  when: { value: null, forbidden: false },
7729
7838
  while: { value: null, forbidden: false },
7839
+ function: { value: null, forbidden: false },
7840
+ export: { value: null, forbidden: false },
7730
7841
  };
7731
7842
  var forbiddenAlgebraicReservedNamesRecord = {
7732
7843
  fn: { value: null, forbidden: true },
7733
- defns: { value: null, forbidden: true },
7734
7844
  };
7735
7845
  var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
7736
7846
 
@@ -8115,25 +8225,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
8115
8225
  return NO_MATCH;
8116
8226
  return [1, ['P_CollectionAccessor', char]];
8117
8227
  };
8118
- var tokenizeP_RegexpShorthand = function (input, position) {
8119
- if (input[position] !== '#')
8120
- return NO_MATCH;
8121
- var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
8122
- if (!token)
8123
- return NO_MATCH;
8124
- position += stringLength + 1;
8125
- var length = stringLength + 1;
8126
- var options = '';
8127
- while (input[position] === 'g' || input[position] === 'i') {
8128
- if (options.includes(input[position])) {
8129
- throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
8130
- }
8131
- options += input[position];
8132
- length += 1;
8133
- position += 1;
8134
- }
8135
- return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
8136
- };
8137
8228
  // All tokenizers, order matters!
8138
8229
  var polishTokenizers = __spreadArray(__spreadArray([
8139
8230
  tokenizeP_Whitespace,
@@ -8144,7 +8235,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
8144
8235
  tokenizeP_ReservedSymbol,
8145
8236
  tokenizeP_Modifier,
8146
8237
  tokenizeP_Symbol,
8147
- tokenizeP_RegexpShorthand,
8148
8238
  tokenizeP_FnShorthand,
8149
8239
  tokenizeP_CollectionAccessor,
8150
8240
  ], false);