@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.
package/dist/index.js CHANGED
@@ -3163,7 +3163,7 @@ var mathNormalExpression = {
3163
3163
  },
3164
3164
  };
3165
3165
 
3166
- var version = "2.0.8";
3166
+ var version = "2.0.10";
3167
3167
 
3168
3168
  var uuidTemplate = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
3169
3169
  var xyRegexp = /[xy]/g;
@@ -4378,6 +4378,7 @@ var andSpecialExpression = {
4378
4378
  };
4379
4379
  return node;
4380
4380
  },
4381
+ validateParameterCount: function () { return undefined; },
4381
4382
  evaluate: function (node, contextStack, _a) {
4382
4383
  var e_1, _b;
4383
4384
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4405,42 +4406,30 @@ var andSpecialExpression = {
4405
4406
  },
4406
4407
  };
4407
4408
 
4408
- var commentSpecialExpression = {
4409
- parse: function (tokenStream, parseState, firstToken, _a) {
4410
- var parseToken = _a.parseToken;
4411
- var node = {
4412
- t: exports.AstNodeType.SpecialExpression,
4413
- n: 'comment',
4414
- p: [],
4415
- token: undefined,
4416
- };
4417
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4418
- while (!isRParenToken(tkn)) {
4419
- node.p.push(parseToken(tokenStream, parseState));
4420
- tkn = asToken(tokenStream.tokens[parseState.position]);
4421
- }
4422
- parseState.position += 1;
4423
- node.token = getTokenDebugData(firstToken) && firstToken;
4424
- return node;
4425
- },
4426
- evaluate: function () { return null; },
4427
- findUnresolvedIdentifiers: function () { return new Set(); },
4428
- };
4429
-
4430
- var condSpecialExpression = {
4431
- parse: function (tokenStream, parseState, firstToken, _a) {
4409
+ function getCommonParser(name) {
4410
+ return function (tokenStream, parseState, firstToken, _a) {
4432
4411
  var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4433
4412
  var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4434
4413
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4435
- var node = {
4414
+ return {
4436
4415
  t: exports.AstNodeType.SpecialExpression,
4437
- n: 'cond',
4416
+ n: name,
4438
4417
  p: params,
4439
4418
  token: getTokenDebugData(firstToken) && firstToken,
4440
4419
  };
4441
- assertEvenNumberOfParams(node);
4442
- return node;
4443
- },
4420
+ };
4421
+ }
4422
+
4423
+ var commentSpecialExpression = {
4424
+ parse: getCommonParser('comment'),
4425
+ validateParameterCount: function () { return undefined; },
4426
+ evaluate: function () { return null; },
4427
+ findUnresolvedIdentifiers: function () { return new Set(); },
4428
+ };
4429
+
4430
+ var condSpecialExpression = {
4431
+ parse: getCommonParser('cond'),
4432
+ validateParameterCount: function (node) { return assertEvenNumberOfParams(node); },
4444
4433
  evaluate: function (node, contextStack, _a) {
4445
4434
  var e_1, _b;
4446
4435
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4469,19 +4458,8 @@ var condSpecialExpression = {
4469
4458
  };
4470
4459
 
4471
4460
  var declaredSpecialExpression = {
4472
- parse: function (tokenStream, parseState, firstToken, _a) {
4473
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4474
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4475
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4476
- var node = {
4477
- t: exports.AstNodeType.SpecialExpression,
4478
- n: 'declared?',
4479
- p: params,
4480
- token: getTokenDebugData(firstToken) && firstToken,
4481
- };
4482
- assertNumberOfParams(1, node);
4483
- return node;
4484
- },
4461
+ parse: getCommonParser('declared?'),
4462
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
4485
4463
  evaluate: function (node, contextStack) {
4486
4464
  var lookUpResult = contextStack.lookUp(node.p[0]);
4487
4465
  return lookUpResult !== null;
@@ -4527,9 +4505,9 @@ var defSpecialExpression = {
4527
4505
  token: getTokenDebugData(firstToken) && firstToken,
4528
4506
  };
4529
4507
  assertSymbolNode(node.p[0], (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
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;
4535
4513
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4565,9 +4543,9 @@ var defsSpecialExpression = {
4565
4543
  p: params,
4566
4544
  token: getTokenDebugData(firstToken) && firstToken,
4567
4545
  };
4568
- assertNumberOfParams(2, node);
4569
4546
  return node;
4570
4547
  },
4548
+ validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4571
4549
  evaluate: function (node, contextStack, _a) {
4572
4550
  var _b, _c;
4573
4551
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4595,23 +4573,8 @@ var defsSpecialExpression = {
4595
4573
  };
4596
4574
 
4597
4575
  var doSpecialExpression = {
4598
- parse: function (tokenStream, parseState, firstToken, _a) {
4599
- var parseToken = _a.parseToken;
4600
- var node = {
4601
- t: exports.AstNodeType.SpecialExpression,
4602
- n: 'do',
4603
- p: [],
4604
- token: undefined,
4605
- };
4606
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4607
- while (!isRParenToken(tkn)) {
4608
- node.p.push(parseToken(tokenStream, parseState));
4609
- tkn = asToken(tokenStream.tokens[parseState.position]);
4610
- }
4611
- parseState.position += 1;
4612
- node.token = getTokenDebugData(firstToken) && firstToken;
4613
- return node;
4614
- },
4576
+ parse: getCommonParser('do'),
4577
+ validateParameterCount: function () { return undefined; },
4615
4578
  evaluate: function (node, contextStack, _a) {
4616
4579
  var e_1, _b;
4617
4580
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4688,6 +4651,7 @@ var defnSpecialExpression = {
4688
4651
  };
4689
4652
  return node;
4690
4653
  },
4654
+ validateParameterCount: function () { return undefined; },
4691
4655
  evaluate: function (node, contextStack, _a) {
4692
4656
  var _b;
4693
4657
  var _c, _d;
@@ -4729,6 +4693,7 @@ var defnsSpecialExpression = {
4729
4693
  };
4730
4694
  return node;
4731
4695
  },
4696
+ validateParameterCount: function () { return undefined; },
4732
4697
  evaluate: function (node, contextStack, _a) {
4733
4698
  var _b;
4734
4699
  var _c, _d;
@@ -4772,6 +4737,7 @@ var fnSpecialExpression = {
4772
4737
  };
4773
4738
  return node;
4774
4739
  },
4740
+ validateParameterCount: function () { return undefined; },
4775
4741
  evaluate: function (node, contextStack, _a) {
4776
4742
  var _b;
4777
4743
  var _c;
@@ -5003,19 +4969,8 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
5003
4969
  }
5004
4970
 
5005
4971
  var ifSpecialExpression = {
5006
- parse: function (tokenStream, parseState, firstToken, _a) {
5007
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5008
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5009
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5010
- var node = {
5011
- t: exports.AstNodeType.SpecialExpression,
5012
- n: 'if',
5013
- p: params,
5014
- token: getTokenDebugData(firstToken) && firstToken,
5015
- };
5016
- assertNumberOfParams({ min: 2, max: 3 }, node);
5017
- return node;
5018
- },
4972
+ parse: getCommonParser('if'),
4973
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
5019
4974
  evaluate: function (node, contextStack, _a) {
5020
4975
  var _b;
5021
4976
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5054,9 +5009,9 @@ var ifLetSpecialExpression = {
5054
5009
  p: params,
5055
5010
  token: getTokenDebugData(firstToken) && firstToken,
5056
5011
  };
5057
- assertNumberOfParams({ min: 1, max: 2 }, node);
5058
5012
  return node;
5059
5013
  },
5014
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5060
5015
  evaluate: function (node, contextStack, _a) {
5061
5016
  var _b;
5062
5017
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5086,19 +5041,8 @@ var ifLetSpecialExpression = {
5086
5041
  };
5087
5042
 
5088
5043
  var ifNotSpecialExpression = {
5089
- parse: function (tokenStream, parseState, firstToken, _a) {
5090
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5091
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5092
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5093
- var node = {
5094
- t: exports.AstNodeType.SpecialExpression,
5095
- n: 'if-not',
5096
- p: params,
5097
- token: getTokenDebugData(firstToken) && firstToken,
5098
- };
5099
- assertNumberOfParams({ min: 2, max: 3 }, node);
5100
- return node;
5101
- },
5044
+ parse: getCommonParser('if-not'),
5045
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
5102
5046
  evaluate: function (node, contextStack, _a) {
5103
5047
  var _b;
5104
5048
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5135,6 +5079,7 @@ var letSpecialExpression = {
5135
5079
  };
5136
5080
  return node;
5137
5081
  },
5082
+ validateParameterCount: function () { return undefined; },
5138
5083
  evaluate: function (node, contextStack, _a) {
5139
5084
  var e_1, _b, e_2, _c;
5140
5085
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5206,6 +5151,7 @@ var loopSpecialExpression = {
5206
5151
  };
5207
5152
  return node;
5208
5153
  },
5154
+ validateParameterCount: function () { return undefined; },
5209
5155
  evaluate: function (node, contextStack, _a) {
5210
5156
  var _b;
5211
5157
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5469,9 +5415,9 @@ var forSpecialExpression = {
5469
5415
  p: params,
5470
5416
  token: getTokenDebugData(firstToken) && firstToken,
5471
5417
  };
5472
- assertNumberOfParams(1, node);
5473
5418
  return node;
5474
5419
  },
5420
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5475
5421
  evaluate: function (node, contextStack, helpers) { return evaluateLoop(true, node, contextStack, helpers.evaluateAstNode); },
5476
5422
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
5477
5423
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
@@ -5491,9 +5437,9 @@ var doseqSpecialExpression = {
5491
5437
  p: params,
5492
5438
  token: getTokenDebugData(firstToken) && firstToken,
5493
5439
  };
5494
- assertNumberOfParams(1, node);
5495
5440
  return node;
5496
5441
  },
5442
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5497
5443
  evaluate: function (node, contextStack, helpers) {
5498
5444
  evaluateLoop(false, node, contextStack, helpers.evaluateAstNode);
5499
5445
  return null;
@@ -5505,18 +5451,8 @@ var doseqSpecialExpression = {
5505
5451
  };
5506
5452
 
5507
5453
  var orSpecialExpression = {
5508
- parse: function (tokenStream, parseState, firstToken, _a) {
5509
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5510
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5511
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5512
- var node = {
5513
- t: exports.AstNodeType.SpecialExpression,
5514
- n: 'or',
5515
- p: params,
5516
- token: getTokenDebugData(firstToken) && firstToken,
5517
- };
5518
- return node;
5519
- },
5454
+ parse: getCommonParser('or'),
5455
+ validateParameterCount: function () { return undefined; },
5520
5456
  evaluate: function (node, contextStack, _a) {
5521
5457
  var e_1, _b;
5522
5458
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5545,19 +5481,8 @@ var orSpecialExpression = {
5545
5481
  };
5546
5482
 
5547
5483
  var qqSpecialExpression = {
5548
- parse: function (tokenStream, parseState, firstToken, _a) {
5549
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5550
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5551
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5552
- var node = {
5553
- t: exports.AstNodeType.SpecialExpression,
5554
- n: '??',
5555
- p: params,
5556
- token: getTokenDebugData(firstToken) && firstToken,
5557
- };
5558
- assertNumberOfParams({ min: 1, max: 2 }, node);
5559
- return node;
5560
- },
5484
+ parse: getCommonParser('??'),
5485
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5561
5486
  evaluate: function (node, contextStack, _a) {
5562
5487
  var _b;
5563
5488
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5589,6 +5514,7 @@ var recurSpecialExpression = {
5589
5514
  };
5590
5515
  return node;
5591
5516
  },
5517
+ validateParameterCount: function () { return undefined; },
5592
5518
  evaluate: function (node, contextStack, _a) {
5593
5519
  var evaluateAstNode = _a.evaluateAstNode;
5594
5520
  var params = node.p.map(function (paramNode) { return evaluateAstNode(paramNode, contextStack); });
@@ -5601,19 +5527,8 @@ var recurSpecialExpression = {
5601
5527
  };
5602
5528
 
5603
5529
  var throwSpecialExpression = {
5604
- parse: function (tokenStream, parseState, firstToken, _a) {
5605
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5606
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5607
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5608
- var node = {
5609
- t: exports.AstNodeType.SpecialExpression,
5610
- n: 'throw',
5611
- p: params,
5612
- token: getTokenDebugData(firstToken) && firstToken,
5613
- };
5614
- assertNumberOfParams(1, node);
5615
- return node;
5616
- },
5530
+ parse: getCommonParser('throw'),
5531
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5617
5532
  evaluate: function (node, contextStack, _a) {
5618
5533
  var _b, _c;
5619
5534
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5629,19 +5544,8 @@ var throwSpecialExpression = {
5629
5544
  };
5630
5545
 
5631
5546
  var timeSpecialExpression = {
5632
- parse: function (tokenStream, parseState, firstToken, _a) {
5633
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5634
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5635
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5636
- var node = {
5637
- t: exports.AstNodeType.SpecialExpression,
5638
- n: 'time!',
5639
- p: params,
5640
- token: getTokenDebugData(firstToken) && firstToken,
5641
- };
5642
- assertNumberOfParams(1, node);
5643
- return node;
5644
- },
5547
+ parse: getCommonParser('time!'),
5548
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5645
5549
  evaluate: function (node, contextStack, _a) {
5646
5550
  var evaluateAstNode = _a.evaluateAstNode;
5647
5551
  var param = node.p[0];
@@ -5682,9 +5586,9 @@ var trySpecialExpression = {
5682
5586
  e: error,
5683
5587
  token: getTokenDebugData(firstToken) && firstToken,
5684
5588
  };
5685
- assertNumberOfParams(1, node);
5686
5589
  return node;
5687
5590
  },
5591
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5688
5592
  evaluate: function (node, contextStack, _a) {
5689
5593
  var _b;
5690
5594
  var _c;
@@ -5714,19 +5618,8 @@ var trySpecialExpression = {
5714
5618
  };
5715
5619
 
5716
5620
  var whenSpecialExpression = {
5717
- parse: function (tokenStream, parseState, firstToken, _a) {
5718
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5719
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5720
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5721
- var node = {
5722
- t: exports.AstNodeType.SpecialExpression,
5723
- n: 'when',
5724
- p: params,
5725
- token: getTokenDebugData(firstToken) && firstToken,
5726
- };
5727
- assertNumberOfParams({ min: 1 }, node);
5728
- return node;
5729
- },
5621
+ parse: getCommonParser('when'),
5622
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5730
5623
  evaluate: function (node, contextStack, _a) {
5731
5624
  var e_1, _b;
5732
5625
  var _c;
@@ -5776,6 +5669,7 @@ var whenFirstSpecialExpression = {
5776
5669
  };
5777
5670
  return node;
5778
5671
  },
5672
+ validateParameterCount: function () { return undefined; },
5779
5673
  evaluate: function (node, contextStack, _a) {
5780
5674
  var e_1, _b;
5781
5675
  var _c;
@@ -5837,6 +5731,7 @@ var whenLetSpecialExpression = {
5837
5731
  };
5838
5732
  return node;
5839
5733
  },
5734
+ validateParameterCount: function () { return undefined; },
5840
5735
  evaluate: function (node, contextStack, _a) {
5841
5736
  var e_1, _b;
5842
5737
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5875,19 +5770,8 @@ var whenLetSpecialExpression = {
5875
5770
  };
5876
5771
 
5877
5772
  var whenNotSpecialExpression = {
5878
- parse: function (tokenStream, parseState, firstToken, _a) {
5879
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5880
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5881
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5882
- var node = {
5883
- t: exports.AstNodeType.SpecialExpression,
5884
- n: 'when-not',
5885
- p: params,
5886
- token: getTokenDebugData(firstToken) && firstToken,
5887
- };
5888
- assertNumberOfParams({ min: 1 }, node);
5889
- return node;
5890
- },
5773
+ parse: getCommonParser('when-not'),
5774
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5891
5775
  evaluate: function (node, contextStack, _a) {
5892
5776
  var e_1, _b;
5893
5777
  var _c;
@@ -7115,6 +6999,7 @@ function parseString(tokenStream, parseState) {
7115
6999
  }
7116
7000
 
7117
7001
  var exponentiationPrecedence = 9;
7002
+ var placeholderRegexp$1 = /^\$([1-9]\d?)?$/;
7118
7003
  function getPrecedence(operator) {
7119
7004
  var operatorSign = operator[1];
7120
7005
  switch (operatorSign) {
@@ -7347,7 +7232,7 @@ var AlgebraicParser = /** @class */ (function () {
7347
7232
  // Parentheses
7348
7233
  if (isLParenToken(token)) {
7349
7234
  var positionBefore = this.parseState.position;
7350
- var lamdaFunction = this.parseLamdaFunction();
7235
+ var lamdaFunction = this.parseLambdaFunction();
7351
7236
  if (lamdaFunction) {
7352
7237
  return lamdaFunction;
7353
7238
  }
@@ -7368,6 +7253,9 @@ var AlgebraicParser = /** @class */ (function () {
7368
7253
  var operand = this.parseOperand();
7369
7254
  return fromUnaryAlgebraicToAstNode(token, operand);
7370
7255
  }
7256
+ else if (operatorName === '=>') {
7257
+ return this.parseShorthandLamdaFunction();
7258
+ }
7371
7259
  else {
7372
7260
  throw new Error("Unknown unary operator: ".concat(operatorName));
7373
7261
  }
@@ -7483,7 +7371,7 @@ var AlgebraicParser = /** @class */ (function () {
7483
7371
  };
7484
7372
  };
7485
7373
  AlgebraicParser.prototype.parseFunctionCall = function (symbol) {
7486
- var _a, _b;
7374
+ var _a, _b, _c;
7487
7375
  var params = [];
7488
7376
  this.advance();
7489
7377
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
@@ -7515,13 +7403,17 @@ var AlgebraicParser = /** @class */ (function () {
7515
7403
  case 'when':
7516
7404
  case 'when-not':
7517
7405
  case 'do':
7518
- case 'throw':
7519
- return {
7406
+ case 'time!':
7407
+ case 'throw': {
7408
+ var node_1 = {
7520
7409
  t: exports.AstNodeType.SpecialExpression,
7521
7410
  n: name_1,
7522
7411
  p: params,
7523
7412
  token: getTokenDebugData(symbol.token) && symbol.token,
7524
7413
  };
7414
+ builtin.specialExpressions[node_1.n].validateParameterCount(node_1);
7415
+ return node_1;
7416
+ }
7525
7417
  case 'def':
7526
7418
  case 'defs':
7527
7419
  case 'let':
@@ -7534,7 +7426,6 @@ var AlgebraicParser = /** @class */ (function () {
7534
7426
  case 'try':
7535
7427
  case 'recur':
7536
7428
  case 'loop':
7537
- case 'time!':
7538
7429
  case 'doseq':
7539
7430
  case 'for':
7540
7431
  throw new Error("Special expression ".concat(name_1, " is not available in algebraic notation"));
@@ -7542,7 +7433,12 @@ var AlgebraicParser = /** @class */ (function () {
7542
7433
  throw new Error("Unknown special expression: ".concat(name_1));
7543
7434
  }
7544
7435
  }
7545
- return createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7436
+ var node = createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7437
+ var builtinExpression = builtin.normalExpressions[node.n];
7438
+ if (builtinExpression) {
7439
+ (_c = builtinExpression.validate) === null || _c === void 0 ? void 0 : _c.call(builtinExpression, __assign(__assign({}, node), { p: withoutCommentNodes(node.p) }));
7440
+ }
7441
+ return node;
7546
7442
  }
7547
7443
  else {
7548
7444
  return {
@@ -7553,7 +7449,7 @@ var AlgebraicParser = /** @class */ (function () {
7553
7449
  };
7554
7450
  }
7555
7451
  };
7556
- AlgebraicParser.prototype.parseLamdaFunction = function () {
7452
+ AlgebraicParser.prototype.parseLambdaFunction = function () {
7557
7453
  var _a;
7558
7454
  var firstToken = this.peek();
7559
7455
  this.advance();
@@ -7612,6 +7508,62 @@ var AlgebraicParser = /** @class */ (function () {
7612
7508
  token: getTokenDebugData(firstToken) && firstToken,
7613
7509
  };
7614
7510
  };
7511
+ AlgebraicParser.prototype.parseShorthandLamdaFunction = function () {
7512
+ var _a, _b, _c, _d;
7513
+ var firstToken = this.peek();
7514
+ this.advance();
7515
+ var startPos = this.parseState.position;
7516
+ var exprNode = this.parseExpression();
7517
+ var endPos = this.parseState.position - 1;
7518
+ var arity = 0;
7519
+ var percent1 = 'NOT_SET'; // referring to argument bindings. % = NAKED, %1, %2, %3, etc = WITH_1
7520
+ for (var pos = startPos; pos <= endPos; pos += 1) {
7521
+ var tkn = this.tokenStream.tokens[pos];
7522
+ if (isA_SymbolToken(tkn)) {
7523
+ var match = placeholderRegexp$1.exec(tkn[1]);
7524
+ if (match) {
7525
+ var number = (_a = match[1]) !== null && _a !== void 0 ? _a : '1';
7526
+ if (number === '1') {
7527
+ var mixedPercent1 = (!match[1] && percent1 === 'WITH_1') || (match[1] && percent1 === 'NAKED');
7528
+ if (mixedPercent1)
7529
+ throw new LitsError('Please make up your mind, either use $ or $1', (_b = getTokenDebugData(firstToken)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
7530
+ percent1 = match[1] ? 'WITH_1' : 'NAKED';
7531
+ }
7532
+ arity = Math.max(arity, Number(number));
7533
+ if (arity > 20)
7534
+ throw new LitsError('Can\'t specify more than 20 arguments', (_c = getTokenDebugData(firstToken)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
7535
+ }
7536
+ }
7537
+ if (isA_OperatorToken(tkn, '=>')) {
7538
+ throw new LitsError('Nested shortcut functions are not allowed', (_d = getTokenDebugData(firstToken)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo);
7539
+ }
7540
+ }
7541
+ var mandatoryArguments = [];
7542
+ for (var i = 1; i <= arity; i += 1) {
7543
+ if (i === 1 && percent1 === 'NAKED')
7544
+ mandatoryArguments.push('$');
7545
+ else
7546
+ mandatoryArguments.push("$".concat(i));
7547
+ }
7548
+ var args = {
7549
+ b: [],
7550
+ m: mandatoryArguments,
7551
+ };
7552
+ var node = {
7553
+ t: exports.AstNodeType.SpecialExpression,
7554
+ n: 'fn',
7555
+ p: [],
7556
+ o: [
7557
+ {
7558
+ as: args,
7559
+ b: [exprNode],
7560
+ a: args.m.length,
7561
+ },
7562
+ ],
7563
+ token: getTokenDebugData(firstToken) && firstToken,
7564
+ };
7565
+ return node;
7566
+ };
7615
7567
  AlgebraicParser.prototype.isAtEnd = function () {
7616
7568
  return this.parseState.position >= this.tokenStream.tokens.length;
7617
7569
  };
@@ -7855,7 +7807,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7855
7807
  var firstToken = asLParenToken(tokenStream.tokens[parseState.position++]);
7856
7808
  var nameToken = asP_SymbolToken(tokenStream.tokens[parseState.position++]);
7857
7809
  var expressionName = nameToken[1];
7858
- var parse = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo).parse;
7810
+ var _b = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo), parse = _b.parse, validateParameterCount = _b.validateParameterCount;
7859
7811
  var node = parse(tokenStream, parseState, firstToken, {
7860
7812
  parseExpression: parseExpression,
7861
7813
  parseTokensUntilClosingBracket: parseTokensUntilClosingBracket,
@@ -7864,6 +7816,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7864
7816
  parseBindings: parseBindings,
7865
7817
  parseArgument: parseArgument,
7866
7818
  });
7819
+ validateParameterCount(node);
7867
7820
  return node;
7868
7821
  }
7869
7822
  function parsePolishToken(tokenStream, parseState) {