@mojir/lits 2.0.8 → 2.0.10

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.
@@ -3126,7 +3126,7 @@ var mathNormalExpression = {
3126
3126
  },
3127
3127
  };
3128
3128
 
3129
- var version = "2.0.8";
3129
+ var version = "2.0.10";
3130
3130
 
3131
3131
  var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
3132
3132
  var xyRegexp = /[xy]/g;
@@ -4341,6 +4341,7 @@ var andSpecialExpression = {
4341
4341
  };
4342
4342
  return node;
4343
4343
  },
4344
+ validateParameterCount: function () { return undefined; },
4344
4345
  evaluate: function (node, contextStack, _a) {
4345
4346
  var e_1, _b;
4346
4347
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4368,42 +4369,30 @@ var andSpecialExpression = {
4368
4369
  },
4369
4370
  };
4370
4371
 
4371
- var commentSpecialExpression = {
4372
- parse: function (tokenStream, parseState, firstToken, _a) {
4373
- var parseToken = _a.parseToken;
4374
- var node = {
4375
- t: AstNodeType.SpecialExpression,
4376
- n: 'comment',
4377
- p: [],
4378
- token: undefined,
4379
- };
4380
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4381
- while (!isRParenToken(tkn)) {
4382
- node.p.push(parseToken(tokenStream, parseState));
4383
- tkn = asToken(tokenStream.tokens[parseState.position]);
4384
- }
4385
- parseState.position += 1;
4386
- node.token = getTokenDebugData(firstToken) && firstToken;
4387
- return node;
4388
- },
4389
- evaluate: function () { return null; },
4390
- findUnresolvedIdentifiers: function () { return new Set(); },
4391
- };
4392
-
4393
- var condSpecialExpression = {
4394
- parse: function (tokenStream, parseState, firstToken, _a) {
4372
+ function getCommonParser(name) {
4373
+ return function (tokenStream, parseState, firstToken, _a) {
4395
4374
  var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4396
4375
  var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4397
4376
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4398
- var node = {
4377
+ return {
4399
4378
  t: AstNodeType.SpecialExpression,
4400
- n: 'cond',
4379
+ n: name,
4401
4380
  p: params,
4402
4381
  token: getTokenDebugData(firstToken) && firstToken,
4403
4382
  };
4404
- assertEvenNumberOfParams(node);
4405
- return node;
4406
- },
4383
+ };
4384
+ }
4385
+
4386
+ var commentSpecialExpression = {
4387
+ parse: getCommonParser('comment'),
4388
+ validateParameterCount: function () { return undefined; },
4389
+ evaluate: function () { return null; },
4390
+ findUnresolvedIdentifiers: function () { return new Set(); },
4391
+ };
4392
+
4393
+ var condSpecialExpression = {
4394
+ parse: getCommonParser('cond'),
4395
+ validateParameterCount: function (node) { return assertEvenNumberOfParams(node); },
4407
4396
  evaluate: function (node, contextStack, _a) {
4408
4397
  var e_1, _b;
4409
4398
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4432,19 +4421,8 @@ var condSpecialExpression = {
4432
4421
  };
4433
4422
 
4434
4423
  var declaredSpecialExpression = {
4435
- parse: function (tokenStream, parseState, firstToken, _a) {
4436
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4437
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4438
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4439
- var node = {
4440
- t: AstNodeType.SpecialExpression,
4441
- n: 'declared?',
4442
- p: params,
4443
- token: getTokenDebugData(firstToken) && firstToken,
4444
- };
4445
- assertNumberOfParams(1, node);
4446
- return node;
4447
- },
4424
+ parse: getCommonParser('declared?'),
4425
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
4448
4426
  evaluate: function (node, contextStack) {
4449
4427
  var lookUpResult = contextStack.lookUp(node.p[0]);
4450
4428
  return lookUpResult !== null;
@@ -4489,9 +4467,9 @@ var defSpecialExpression = {
4489
4467
  token: getTokenDebugData(firstToken) && firstToken,
4490
4468
  };
4491
4469
  assertSymbolNode(node.p[0], (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
4492
- assertNumberOfParams(2, node);
4493
4470
  return node;
4494
4471
  },
4472
+ validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4495
4473
  evaluate: function (node, contextStack, _a) {
4496
4474
  var _b;
4497
4475
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4527,9 +4505,9 @@ var defsSpecialExpression = {
4527
4505
  p: params,
4528
4506
  token: getTokenDebugData(firstToken) && firstToken,
4529
4507
  };
4530
- assertNumberOfParams(2, node);
4531
4508
  return node;
4532
4509
  },
4510
+ validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4533
4511
  evaluate: function (node, contextStack, _a) {
4534
4512
  var _b, _c;
4535
4513
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4557,23 +4535,8 @@ var defsSpecialExpression = {
4557
4535
  };
4558
4536
 
4559
4537
  var doSpecialExpression = {
4560
- parse: function (tokenStream, parseState, firstToken, _a) {
4561
- var parseToken = _a.parseToken;
4562
- var node = {
4563
- t: AstNodeType.SpecialExpression,
4564
- n: 'do',
4565
- p: [],
4566
- token: undefined,
4567
- };
4568
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4569
- while (!isRParenToken(tkn)) {
4570
- node.p.push(parseToken(tokenStream, parseState));
4571
- tkn = asToken(tokenStream.tokens[parseState.position]);
4572
- }
4573
- parseState.position += 1;
4574
- node.token = getTokenDebugData(firstToken) && firstToken;
4575
- return node;
4576
- },
4538
+ parse: getCommonParser('do'),
4539
+ validateParameterCount: function () { return undefined; },
4577
4540
  evaluate: function (node, contextStack, _a) {
4578
4541
  var e_1, _b;
4579
4542
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4650,6 +4613,7 @@ var defnSpecialExpression = {
4650
4613
  };
4651
4614
  return node;
4652
4615
  },
4616
+ validateParameterCount: function () { return undefined; },
4653
4617
  evaluate: function (node, contextStack, _a) {
4654
4618
  var _b;
4655
4619
  var _c, _d;
@@ -4691,6 +4655,7 @@ var defnsSpecialExpression = {
4691
4655
  };
4692
4656
  return node;
4693
4657
  },
4658
+ validateParameterCount: function () { return undefined; },
4694
4659
  evaluate: function (node, contextStack, _a) {
4695
4660
  var _b;
4696
4661
  var _c, _d;
@@ -4734,6 +4699,7 @@ var fnSpecialExpression = {
4734
4699
  };
4735
4700
  return node;
4736
4701
  },
4702
+ validateParameterCount: function () { return undefined; },
4737
4703
  evaluate: function (node, contextStack, _a) {
4738
4704
  var _b;
4739
4705
  var _c;
@@ -4965,19 +4931,8 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
4965
4931
  }
4966
4932
 
4967
4933
  var ifSpecialExpression = {
4968
- parse: function (tokenStream, parseState, firstToken, _a) {
4969
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4970
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4971
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4972
- var node = {
4973
- t: AstNodeType.SpecialExpression,
4974
- n: 'if',
4975
- p: params,
4976
- token: getTokenDebugData(firstToken) && firstToken,
4977
- };
4978
- assertNumberOfParams({ min: 2, max: 3 }, node);
4979
- return node;
4980
- },
4934
+ parse: getCommonParser('if'),
4935
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4981
4936
  evaluate: function (node, contextStack, _a) {
4982
4937
  var _b;
4983
4938
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5016,9 +4971,9 @@ var ifLetSpecialExpression = {
5016
4971
  p: params,
5017
4972
  token: getTokenDebugData(firstToken) && firstToken,
5018
4973
  };
5019
- assertNumberOfParams({ min: 1, max: 2 }, node);
5020
4974
  return node;
5021
4975
  },
4976
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5022
4977
  evaluate: function (node, contextStack, _a) {
5023
4978
  var _b;
5024
4979
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5048,19 +5003,8 @@ var ifLetSpecialExpression = {
5048
5003
  };
5049
5004
 
5050
5005
  var ifNotSpecialExpression = {
5051
- parse: function (tokenStream, parseState, firstToken, _a) {
5052
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5053
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5054
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5055
- var node = {
5056
- t: AstNodeType.SpecialExpression,
5057
- n: 'if-not',
5058
- p: params,
5059
- token: getTokenDebugData(firstToken) && firstToken,
5060
- };
5061
- assertNumberOfParams({ min: 2, max: 3 }, node);
5062
- return node;
5063
- },
5006
+ parse: getCommonParser('if-not'),
5007
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
5064
5008
  evaluate: function (node, contextStack, _a) {
5065
5009
  var _b;
5066
5010
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5097,6 +5041,7 @@ var letSpecialExpression = {
5097
5041
  };
5098
5042
  return node;
5099
5043
  },
5044
+ validateParameterCount: function () { return undefined; },
5100
5045
  evaluate: function (node, contextStack, _a) {
5101
5046
  var e_1, _b, e_2, _c;
5102
5047
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5168,6 +5113,7 @@ var loopSpecialExpression = {
5168
5113
  };
5169
5114
  return node;
5170
5115
  },
5116
+ validateParameterCount: function () { return undefined; },
5171
5117
  evaluate: function (node, contextStack, _a) {
5172
5118
  var _b;
5173
5119
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5431,9 +5377,9 @@ var forSpecialExpression = {
5431
5377
  p: params,
5432
5378
  token: getTokenDebugData(firstToken) && firstToken,
5433
5379
  };
5434
- assertNumberOfParams(1, node);
5435
5380
  return node;
5436
5381
  },
5382
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5437
5383
  evaluate: function (node, contextStack, helpers) { return evaluateLoop(true, node, contextStack, helpers.evaluateAstNode); },
5438
5384
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
5439
5385
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
@@ -5453,9 +5399,9 @@ var doseqSpecialExpression = {
5453
5399
  p: params,
5454
5400
  token: getTokenDebugData(firstToken) && firstToken,
5455
5401
  };
5456
- assertNumberOfParams(1, node);
5457
5402
  return node;
5458
5403
  },
5404
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5459
5405
  evaluate: function (node, contextStack, helpers) {
5460
5406
  evaluateLoop(false, node, contextStack, helpers.evaluateAstNode);
5461
5407
  return null;
@@ -5467,18 +5413,8 @@ var doseqSpecialExpression = {
5467
5413
  };
5468
5414
 
5469
5415
  var orSpecialExpression = {
5470
- parse: function (tokenStream, parseState, firstToken, _a) {
5471
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5472
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5473
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5474
- var node = {
5475
- t: AstNodeType.SpecialExpression,
5476
- n: 'or',
5477
- p: params,
5478
- token: getTokenDebugData(firstToken) && firstToken,
5479
- };
5480
- return node;
5481
- },
5416
+ parse: getCommonParser('or'),
5417
+ validateParameterCount: function () { return undefined; },
5482
5418
  evaluate: function (node, contextStack, _a) {
5483
5419
  var e_1, _b;
5484
5420
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5507,19 +5443,8 @@ var orSpecialExpression = {
5507
5443
  };
5508
5444
 
5509
5445
  var qqSpecialExpression = {
5510
- parse: function (tokenStream, parseState, firstToken, _a) {
5511
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5512
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5513
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5514
- var node = {
5515
- t: AstNodeType.SpecialExpression,
5516
- n: '??',
5517
- p: params,
5518
- token: getTokenDebugData(firstToken) && firstToken,
5519
- };
5520
- assertNumberOfParams({ min: 1, max: 2 }, node);
5521
- return node;
5522
- },
5446
+ parse: getCommonParser('??'),
5447
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5523
5448
  evaluate: function (node, contextStack, _a) {
5524
5449
  var _b;
5525
5450
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5551,6 +5476,7 @@ var recurSpecialExpression = {
5551
5476
  };
5552
5477
  return node;
5553
5478
  },
5479
+ validateParameterCount: function () { return undefined; },
5554
5480
  evaluate: function (node, contextStack, _a) {
5555
5481
  var evaluateAstNode = _a.evaluateAstNode;
5556
5482
  var params = node.p.map(function (paramNode) { return evaluateAstNode(paramNode, contextStack); });
@@ -5563,19 +5489,8 @@ var recurSpecialExpression = {
5563
5489
  };
5564
5490
 
5565
5491
  var throwSpecialExpression = {
5566
- parse: function (tokenStream, parseState, firstToken, _a) {
5567
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5568
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5569
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5570
- var node = {
5571
- t: AstNodeType.SpecialExpression,
5572
- n: 'throw',
5573
- p: params,
5574
- token: getTokenDebugData(firstToken) && firstToken,
5575
- };
5576
- assertNumberOfParams(1, node);
5577
- return node;
5578
- },
5492
+ parse: getCommonParser('throw'),
5493
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5579
5494
  evaluate: function (node, contextStack, _a) {
5580
5495
  var _b, _c;
5581
5496
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5591,19 +5506,8 @@ var throwSpecialExpression = {
5591
5506
  };
5592
5507
 
5593
5508
  var timeSpecialExpression = {
5594
- parse: function (tokenStream, parseState, firstToken, _a) {
5595
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5596
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5597
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5598
- var node = {
5599
- t: AstNodeType.SpecialExpression,
5600
- n: 'time!',
5601
- p: params,
5602
- token: getTokenDebugData(firstToken) && firstToken,
5603
- };
5604
- assertNumberOfParams(1, node);
5605
- return node;
5606
- },
5509
+ parse: getCommonParser('time!'),
5510
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5607
5511
  evaluate: function (node, contextStack, _a) {
5608
5512
  var evaluateAstNode = _a.evaluateAstNode;
5609
5513
  var param = node.p[0];
@@ -5644,9 +5548,9 @@ var trySpecialExpression = {
5644
5548
  e: error,
5645
5549
  token: getTokenDebugData(firstToken) && firstToken,
5646
5550
  };
5647
- assertNumberOfParams(1, node);
5648
5551
  return node;
5649
5552
  },
5553
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5650
5554
  evaluate: function (node, contextStack, _a) {
5651
5555
  var _b;
5652
5556
  var _c;
@@ -5676,19 +5580,8 @@ var trySpecialExpression = {
5676
5580
  };
5677
5581
 
5678
5582
  var whenSpecialExpression = {
5679
- parse: function (tokenStream, parseState, firstToken, _a) {
5680
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5681
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5682
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5683
- var node = {
5684
- t: AstNodeType.SpecialExpression,
5685
- n: 'when',
5686
- p: params,
5687
- token: getTokenDebugData(firstToken) && firstToken,
5688
- };
5689
- assertNumberOfParams({ min: 1 }, node);
5690
- return node;
5691
- },
5583
+ parse: getCommonParser('when'),
5584
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5692
5585
  evaluate: function (node, contextStack, _a) {
5693
5586
  var e_1, _b;
5694
5587
  var _c;
@@ -5738,6 +5631,7 @@ var whenFirstSpecialExpression = {
5738
5631
  };
5739
5632
  return node;
5740
5633
  },
5634
+ validateParameterCount: function () { return undefined; },
5741
5635
  evaluate: function (node, contextStack, _a) {
5742
5636
  var e_1, _b;
5743
5637
  var _c;
@@ -5799,6 +5693,7 @@ var whenLetSpecialExpression = {
5799
5693
  };
5800
5694
  return node;
5801
5695
  },
5696
+ validateParameterCount: function () { return undefined; },
5802
5697
  evaluate: function (node, contextStack, _a) {
5803
5698
  var e_1, _b;
5804
5699
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5837,19 +5732,8 @@ var whenLetSpecialExpression = {
5837
5732
  };
5838
5733
 
5839
5734
  var whenNotSpecialExpression = {
5840
- parse: function (tokenStream, parseState, firstToken, _a) {
5841
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5842
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5843
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5844
- var node = {
5845
- t: AstNodeType.SpecialExpression,
5846
- n: 'when-not',
5847
- p: params,
5848
- token: getTokenDebugData(firstToken) && firstToken,
5849
- };
5850
- assertNumberOfParams({ min: 1 }, node);
5851
- return node;
5852
- },
5735
+ parse: getCommonParser('when-not'),
5736
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5853
5737
  evaluate: function (node, contextStack, _a) {
5854
5738
  var e_1, _b;
5855
5739
  var _c;
@@ -7077,6 +6961,7 @@ function parseString(tokenStream, parseState) {
7077
6961
  }
7078
6962
 
7079
6963
  var exponentiationPrecedence = 9;
6964
+ var placeholderRegexp$1 = /^\$([1-9]\d?)?$/;
7080
6965
  function getPrecedence(operator) {
7081
6966
  var operatorSign = operator[1];
7082
6967
  switch (operatorSign) {
@@ -7309,7 +7194,7 @@ var AlgebraicParser = /** @class */ (function () {
7309
7194
  // Parentheses
7310
7195
  if (isLParenToken(token)) {
7311
7196
  var positionBefore = this.parseState.position;
7312
- var lamdaFunction = this.parseLamdaFunction();
7197
+ var lamdaFunction = this.parseLambdaFunction();
7313
7198
  if (lamdaFunction) {
7314
7199
  return lamdaFunction;
7315
7200
  }
@@ -7330,6 +7215,9 @@ var AlgebraicParser = /** @class */ (function () {
7330
7215
  var operand = this.parseOperand();
7331
7216
  return fromUnaryAlgebraicToAstNode(token, operand);
7332
7217
  }
7218
+ else if (operatorName === '=>') {
7219
+ return this.parseShorthandLamdaFunction();
7220
+ }
7333
7221
  else {
7334
7222
  throw new Error("Unknown unary operator: ".concat(operatorName));
7335
7223
  }
@@ -7445,7 +7333,7 @@ var AlgebraicParser = /** @class */ (function () {
7445
7333
  };
7446
7334
  };
7447
7335
  AlgebraicParser.prototype.parseFunctionCall = function (symbol) {
7448
- var _a, _b;
7336
+ var _a, _b, _c;
7449
7337
  var params = [];
7450
7338
  this.advance();
7451
7339
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
@@ -7477,13 +7365,17 @@ var AlgebraicParser = /** @class */ (function () {
7477
7365
  case 'when':
7478
7366
  case 'when-not':
7479
7367
  case 'do':
7480
- case 'throw':
7481
- return {
7368
+ case 'time!':
7369
+ case 'throw': {
7370
+ var node_1 = {
7482
7371
  t: AstNodeType.SpecialExpression,
7483
7372
  n: name_1,
7484
7373
  p: params,
7485
7374
  token: getTokenDebugData(symbol.token) && symbol.token,
7486
7375
  };
7376
+ builtin.specialExpressions[node_1.n].validateParameterCount(node_1);
7377
+ return node_1;
7378
+ }
7487
7379
  case 'def':
7488
7380
  case 'defs':
7489
7381
  case 'let':
@@ -7496,7 +7388,6 @@ var AlgebraicParser = /** @class */ (function () {
7496
7388
  case 'try':
7497
7389
  case 'recur':
7498
7390
  case 'loop':
7499
- case 'time!':
7500
7391
  case 'doseq':
7501
7392
  case 'for':
7502
7393
  throw new Error("Special expression ".concat(name_1, " is not available in algebraic notation"));
@@ -7504,7 +7395,12 @@ var AlgebraicParser = /** @class */ (function () {
7504
7395
  throw new Error("Unknown special expression: ".concat(name_1));
7505
7396
  }
7506
7397
  }
7507
- return createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7398
+ var node = createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7399
+ var builtinExpression = builtin.normalExpressions[node.n];
7400
+ if (builtinExpression) {
7401
+ (_c = builtinExpression.validate) === null || _c === void 0 ? void 0 : _c.call(builtinExpression, __assign(__assign({}, node), { p: withoutCommentNodes(node.p) }));
7402
+ }
7403
+ return node;
7508
7404
  }
7509
7405
  else {
7510
7406
  return {
@@ -7515,7 +7411,7 @@ var AlgebraicParser = /** @class */ (function () {
7515
7411
  };
7516
7412
  }
7517
7413
  };
7518
- AlgebraicParser.prototype.parseLamdaFunction = function () {
7414
+ AlgebraicParser.prototype.parseLambdaFunction = function () {
7519
7415
  var _a;
7520
7416
  var firstToken = this.peek();
7521
7417
  this.advance();
@@ -7574,6 +7470,62 @@ var AlgebraicParser = /** @class */ (function () {
7574
7470
  token: getTokenDebugData(firstToken) && firstToken,
7575
7471
  };
7576
7472
  };
7473
+ AlgebraicParser.prototype.parseShorthandLamdaFunction = function () {
7474
+ var _a, _b, _c, _d;
7475
+ var firstToken = this.peek();
7476
+ this.advance();
7477
+ var startPos = this.parseState.position;
7478
+ var exprNode = this.parseExpression();
7479
+ var endPos = this.parseState.position - 1;
7480
+ var arity = 0;
7481
+ var percent1 = 'NOT_SET'; // referring to argument bindings. % = NAKED, %1, %2, %3, etc = WITH_1
7482
+ for (var pos = startPos; pos <= endPos; pos += 1) {
7483
+ var tkn = this.tokenStream.tokens[pos];
7484
+ if (isA_SymbolToken(tkn)) {
7485
+ var match = placeholderRegexp$1.exec(tkn[1]);
7486
+ if (match) {
7487
+ var number = (_a = match[1]) !== null && _a !== void 0 ? _a : '1';
7488
+ if (number === '1') {
7489
+ var mixedPercent1 = (!match[1] && percent1 === 'WITH_1') || (match[1] && percent1 === 'NAKED');
7490
+ if (mixedPercent1)
7491
+ throw new LitsError('Please make up your mind, either use $ or $1', (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
7492
+ percent1 = match[1] ? 'WITH_1' : 'NAKED';
7493
+ }
7494
+ arity = Math.max(arity, Number(number));
7495
+ if (arity > 20)
7496
+ throw new LitsError('Can\'t specify more than 20 arguments', (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
7497
+ }
7498
+ }
7499
+ if (isA_OperatorToken(tkn, '=>')) {
7500
+ throw new LitsError('Nested shortcut functions are not allowed', (_d = getTokenDebugData(firstToken)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo);
7501
+ }
7502
+ }
7503
+ var mandatoryArguments = [];
7504
+ for (var i = 1; i <= arity; i += 1) {
7505
+ if (i === 1 && percent1 === 'NAKED')
7506
+ mandatoryArguments.push('$');
7507
+ else
7508
+ mandatoryArguments.push("$".concat(i));
7509
+ }
7510
+ var args = {
7511
+ b: [],
7512
+ m: mandatoryArguments,
7513
+ };
7514
+ var node = {
7515
+ t: AstNodeType.SpecialExpression,
7516
+ n: 'fn',
7517
+ p: [],
7518
+ o: [
7519
+ {
7520
+ as: args,
7521
+ b: [exprNode],
7522
+ a: args.m.length,
7523
+ },
7524
+ ],
7525
+ token: getTokenDebugData(firstToken) && firstToken,
7526
+ };
7527
+ return node;
7528
+ };
7577
7529
  AlgebraicParser.prototype.isAtEnd = function () {
7578
7530
  return this.parseState.position >= this.tokenStream.tokens.length;
7579
7531
  };
@@ -7817,7 +7769,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7817
7769
  var firstToken = asLParenToken(tokenStream.tokens[parseState.position++]);
7818
7770
  var nameToken = asP_SymbolToken(tokenStream.tokens[parseState.position++]);
7819
7771
  var expressionName = nameToken[1];
7820
- var parse = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo).parse;
7772
+ var _b = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo), parse = _b.parse, validateParameterCount = _b.validateParameterCount;
7821
7773
  var node = parse(tokenStream, parseState, firstToken, {
7822
7774
  parseExpression: parseExpression,
7823
7775
  parseTokensUntilClosingBracket: parseTokensUntilClosingBracket,
@@ -7826,6 +7778,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7826
7778
  parseBindings: parseBindings,
7827
7779
  parseArgument: parseArgument,
7828
7780
  });
7781
+ validateParameterCount(node);
7829
7782
  return node;
7830
7783
  }
7831
7784
  function parsePolishToken(tokenStream, parseState) {