@mojir/lits 2.0.9 → 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/cli/cli.js CHANGED
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
92
92
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
93
93
  };
94
94
 
95
- var version = "2.0.9";
95
+ var version = "2.0.10";
96
96
 
97
97
  var AstNodeType;
98
98
  (function (AstNodeType) {
@@ -4344,6 +4344,7 @@ var andSpecialExpression = {
4344
4344
  };
4345
4345
  return node;
4346
4346
  },
4347
+ validateParameterCount: function () { return undefined; },
4347
4348
  evaluate: function (node, contextStack, _a) {
4348
4349
  var e_1, _b;
4349
4350
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4371,42 +4372,30 @@ var andSpecialExpression = {
4371
4372
  },
4372
4373
  };
4373
4374
 
4374
- var commentSpecialExpression = {
4375
- parse: function (tokenStream, parseState, firstToken, _a) {
4376
- var parseToken = _a.parseToken;
4377
- var node = {
4378
- t: AstNodeType.SpecialExpression,
4379
- n: 'comment',
4380
- p: [],
4381
- token: undefined,
4382
- };
4383
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4384
- while (!isRParenToken(tkn)) {
4385
- node.p.push(parseToken(tokenStream, parseState));
4386
- tkn = asToken(tokenStream.tokens[parseState.position]);
4387
- }
4388
- parseState.position += 1;
4389
- node.token = getTokenDebugData(firstToken) && firstToken;
4390
- return node;
4391
- },
4392
- evaluate: function () { return null; },
4393
- findUnresolvedIdentifiers: function () { return new Set(); },
4394
- };
4395
-
4396
- var condSpecialExpression = {
4397
- parse: function (tokenStream, parseState, firstToken, _a) {
4375
+ function getCommonParser(name) {
4376
+ return function (tokenStream, parseState, firstToken, _a) {
4398
4377
  var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4399
4378
  var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4400
4379
  assertRParenToken(tokenStream.tokens[parseState.position++]);
4401
- var node = {
4380
+ return {
4402
4381
  t: AstNodeType.SpecialExpression,
4403
- n: 'cond',
4382
+ n: name,
4404
4383
  p: params,
4405
4384
  token: getTokenDebugData(firstToken) && firstToken,
4406
4385
  };
4407
- assertEvenNumberOfParams(node);
4408
- return node;
4409
- },
4386
+ };
4387
+ }
4388
+
4389
+ var commentSpecialExpression = {
4390
+ parse: getCommonParser('comment'),
4391
+ validateParameterCount: function () { return undefined; },
4392
+ evaluate: function () { return null; },
4393
+ findUnresolvedIdentifiers: function () { return new Set(); },
4394
+ };
4395
+
4396
+ var condSpecialExpression = {
4397
+ parse: getCommonParser('cond'),
4398
+ validateParameterCount: function (node) { return assertEvenNumberOfParams(node); },
4410
4399
  evaluate: function (node, contextStack, _a) {
4411
4400
  var e_1, _b;
4412
4401
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4435,19 +4424,8 @@ var condSpecialExpression = {
4435
4424
  };
4436
4425
 
4437
4426
  var declaredSpecialExpression = {
4438
- parse: function (tokenStream, parseState, firstToken, _a) {
4439
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4440
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4441
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4442
- var node = {
4443
- t: AstNodeType.SpecialExpression,
4444
- n: 'declared?',
4445
- p: params,
4446
- token: getTokenDebugData(firstToken) && firstToken,
4447
- };
4448
- assertNumberOfParams(1, node);
4449
- return node;
4450
- },
4427
+ parse: getCommonParser('declared?'),
4428
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
4451
4429
  evaluate: function (node, contextStack) {
4452
4430
  var lookUpResult = contextStack.lookUp(node.p[0]);
4453
4431
  return lookUpResult !== null;
@@ -4493,9 +4471,9 @@ var defSpecialExpression = {
4493
4471
  token: getTokenDebugData(firstToken) && firstToken,
4494
4472
  };
4495
4473
  assertSymbolNode(node.p[0], (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo);
4496
- assertNumberOfParams(2, node);
4497
4474
  return node;
4498
4475
  },
4476
+ validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4499
4477
  evaluate: function (node, contextStack, _a) {
4500
4478
  var _b;
4501
4479
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4531,9 +4509,9 @@ var defsSpecialExpression = {
4531
4509
  p: params,
4532
4510
  token: getTokenDebugData(firstToken) && firstToken,
4533
4511
  };
4534
- assertNumberOfParams(2, node);
4535
4512
  return node;
4536
4513
  },
4514
+ validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4537
4515
  evaluate: function (node, contextStack, _a) {
4538
4516
  var _b, _c;
4539
4517
  var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
@@ -4561,23 +4539,8 @@ var defsSpecialExpression = {
4561
4539
  };
4562
4540
 
4563
4541
  var doSpecialExpression = {
4564
- parse: function (tokenStream, parseState, firstToken, _a) {
4565
- var parseToken = _a.parseToken;
4566
- var node = {
4567
- t: AstNodeType.SpecialExpression,
4568
- n: 'do',
4569
- p: [],
4570
- token: undefined,
4571
- };
4572
- var tkn = asToken(tokenStream.tokens[parseState.position]);
4573
- while (!isRParenToken(tkn)) {
4574
- node.p.push(parseToken(tokenStream, parseState));
4575
- tkn = asToken(tokenStream.tokens[parseState.position]);
4576
- }
4577
- parseState.position += 1;
4578
- node.token = getTokenDebugData(firstToken) && firstToken;
4579
- return node;
4580
- },
4542
+ parse: getCommonParser('do'),
4543
+ validateParameterCount: function () { return undefined; },
4581
4544
  evaluate: function (node, contextStack, _a) {
4582
4545
  var e_1, _b;
4583
4546
  var evaluateAstNode = _a.evaluateAstNode;
@@ -4654,6 +4617,7 @@ var defnSpecialExpression = {
4654
4617
  };
4655
4618
  return node;
4656
4619
  },
4620
+ validateParameterCount: function () { return undefined; },
4657
4621
  evaluate: function (node, contextStack, _a) {
4658
4622
  var _b;
4659
4623
  var _c, _d;
@@ -4695,6 +4659,7 @@ var defnsSpecialExpression = {
4695
4659
  };
4696
4660
  return node;
4697
4661
  },
4662
+ validateParameterCount: function () { return undefined; },
4698
4663
  evaluate: function (node, contextStack, _a) {
4699
4664
  var _b;
4700
4665
  var _c, _d;
@@ -4738,6 +4703,7 @@ var fnSpecialExpression = {
4738
4703
  };
4739
4704
  return node;
4740
4705
  },
4706
+ validateParameterCount: function () { return undefined; },
4741
4707
  evaluate: function (node, contextStack, _a) {
4742
4708
  var _b;
4743
4709
  var _c;
@@ -4969,19 +4935,8 @@ function parseFunctionArguments(tokenStream, parseState, parsers) {
4969
4935
  }
4970
4936
 
4971
4937
  var ifSpecialExpression = {
4972
- parse: function (tokenStream, parseState, firstToken, _a) {
4973
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4974
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4975
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4976
- var node = {
4977
- t: AstNodeType.SpecialExpression,
4978
- n: 'if',
4979
- p: params,
4980
- token: getTokenDebugData(firstToken) && firstToken,
4981
- };
4982
- assertNumberOfParams({ min: 2, max: 3 }, node);
4983
- return node;
4984
- },
4938
+ parse: getCommonParser('if'),
4939
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4985
4940
  evaluate: function (node, contextStack, _a) {
4986
4941
  var _b;
4987
4942
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5020,9 +4975,9 @@ var ifLetSpecialExpression = {
5020
4975
  p: params,
5021
4976
  token: getTokenDebugData(firstToken) && firstToken,
5022
4977
  };
5023
- assertNumberOfParams({ min: 1, max: 2 }, node);
5024
4978
  return node;
5025
4979
  },
4980
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5026
4981
  evaluate: function (node, contextStack, _a) {
5027
4982
  var _b;
5028
4983
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5052,19 +5007,8 @@ var ifLetSpecialExpression = {
5052
5007
  };
5053
5008
 
5054
5009
  var ifNotSpecialExpression = {
5055
- parse: function (tokenStream, parseState, firstToken, _a) {
5056
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5057
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5058
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5059
- var node = {
5060
- t: AstNodeType.SpecialExpression,
5061
- n: 'if-not',
5062
- p: params,
5063
- token: getTokenDebugData(firstToken) && firstToken,
5064
- };
5065
- assertNumberOfParams({ min: 2, max: 3 }, node);
5066
- return node;
5067
- },
5010
+ parse: getCommonParser('if-not'),
5011
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
5068
5012
  evaluate: function (node, contextStack, _a) {
5069
5013
  var _b;
5070
5014
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5101,6 +5045,7 @@ var letSpecialExpression = {
5101
5045
  };
5102
5046
  return node;
5103
5047
  },
5048
+ validateParameterCount: function () { return undefined; },
5104
5049
  evaluate: function (node, contextStack, _a) {
5105
5050
  var e_1, _b, e_2, _c;
5106
5051
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5172,6 +5117,7 @@ var loopSpecialExpression = {
5172
5117
  };
5173
5118
  return node;
5174
5119
  },
5120
+ validateParameterCount: function () { return undefined; },
5175
5121
  evaluate: function (node, contextStack, _a) {
5176
5122
  var _b;
5177
5123
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5435,9 +5381,9 @@ var forSpecialExpression = {
5435
5381
  p: params,
5436
5382
  token: getTokenDebugData(firstToken) && firstToken,
5437
5383
  };
5438
- assertNumberOfParams(1, node);
5439
5384
  return node;
5440
5385
  },
5386
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5441
5387
  evaluate: function (node, contextStack, helpers) { return evaluateLoop(true, node, contextStack, helpers.evaluateAstNode); },
5442
5388
  findUnresolvedIdentifiers: function (node, contextStack, _a) {
5443
5389
  var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin;
@@ -5457,9 +5403,9 @@ var doseqSpecialExpression = {
5457
5403
  p: params,
5458
5404
  token: getTokenDebugData(firstToken) && firstToken,
5459
5405
  };
5460
- assertNumberOfParams(1, node);
5461
5406
  return node;
5462
5407
  },
5408
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5463
5409
  evaluate: function (node, contextStack, helpers) {
5464
5410
  evaluateLoop(false, node, contextStack, helpers.evaluateAstNode);
5465
5411
  return null;
@@ -5471,18 +5417,8 @@ var doseqSpecialExpression = {
5471
5417
  };
5472
5418
 
5473
5419
  var orSpecialExpression = {
5474
- parse: function (tokenStream, parseState, firstToken, _a) {
5475
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5476
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5477
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5478
- var node = {
5479
- t: AstNodeType.SpecialExpression,
5480
- n: 'or',
5481
- p: params,
5482
- token: getTokenDebugData(firstToken) && firstToken,
5483
- };
5484
- return node;
5485
- },
5420
+ parse: getCommonParser('or'),
5421
+ validateParameterCount: function () { return undefined; },
5486
5422
  evaluate: function (node, contextStack, _a) {
5487
5423
  var e_1, _b;
5488
5424
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5511,19 +5447,8 @@ var orSpecialExpression = {
5511
5447
  };
5512
5448
 
5513
5449
  var qqSpecialExpression = {
5514
- parse: function (tokenStream, parseState, firstToken, _a) {
5515
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5516
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5517
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5518
- var node = {
5519
- t: AstNodeType.SpecialExpression,
5520
- n: '??',
5521
- p: params,
5522
- token: getTokenDebugData(firstToken) && firstToken,
5523
- };
5524
- assertNumberOfParams({ min: 1, max: 2 }, node);
5525
- return node;
5526
- },
5450
+ parse: getCommonParser('??'),
5451
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
5527
5452
  evaluate: function (node, contextStack, _a) {
5528
5453
  var _b;
5529
5454
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5555,6 +5480,7 @@ var recurSpecialExpression = {
5555
5480
  };
5556
5481
  return node;
5557
5482
  },
5483
+ validateParameterCount: function () { return undefined; },
5558
5484
  evaluate: function (node, contextStack, _a) {
5559
5485
  var evaluateAstNode = _a.evaluateAstNode;
5560
5486
  var params = node.p.map(function (paramNode) { return evaluateAstNode(paramNode, contextStack); });
@@ -5567,19 +5493,8 @@ var recurSpecialExpression = {
5567
5493
  };
5568
5494
 
5569
5495
  var throwSpecialExpression = {
5570
- parse: function (tokenStream, parseState, firstToken, _a) {
5571
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5572
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5573
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5574
- var node = {
5575
- t: AstNodeType.SpecialExpression,
5576
- n: 'throw',
5577
- p: params,
5578
- token: getTokenDebugData(firstToken) && firstToken,
5579
- };
5580
- assertNumberOfParams(1, node);
5581
- return node;
5582
- },
5496
+ parse: getCommonParser('throw'),
5497
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5583
5498
  evaluate: function (node, contextStack, _a) {
5584
5499
  var _b, _c;
5585
5500
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5595,19 +5510,8 @@ var throwSpecialExpression = {
5595
5510
  };
5596
5511
 
5597
5512
  var timeSpecialExpression = {
5598
- parse: function (tokenStream, parseState, firstToken, _a) {
5599
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5600
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5601
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5602
- var node = {
5603
- t: AstNodeType.SpecialExpression,
5604
- n: 'time!',
5605
- p: params,
5606
- token: getTokenDebugData(firstToken) && firstToken,
5607
- };
5608
- assertNumberOfParams(1, node);
5609
- return node;
5610
- },
5513
+ parse: getCommonParser('time!'),
5514
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5611
5515
  evaluate: function (node, contextStack, _a) {
5612
5516
  var evaluateAstNode = _a.evaluateAstNode;
5613
5517
  var param = node.p[0];
@@ -5648,9 +5552,9 @@ var trySpecialExpression = {
5648
5552
  e: error,
5649
5553
  token: getTokenDebugData(firstToken) && firstToken,
5650
5554
  };
5651
- assertNumberOfParams(1, node);
5652
5555
  return node;
5653
5556
  },
5557
+ validateParameterCount: function (node) { return assertNumberOfParams(1, node); },
5654
5558
  evaluate: function (node, contextStack, _a) {
5655
5559
  var _b;
5656
5560
  var _c;
@@ -5680,19 +5584,8 @@ var trySpecialExpression = {
5680
5584
  };
5681
5585
 
5682
5586
  var whenSpecialExpression = {
5683
- parse: function (tokenStream, parseState, firstToken, _a) {
5684
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5685
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5686
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5687
- var node = {
5688
- t: AstNodeType.SpecialExpression,
5689
- n: 'when',
5690
- p: params,
5691
- token: getTokenDebugData(firstToken) && firstToken,
5692
- };
5693
- assertNumberOfParams({ min: 1 }, node);
5694
- return node;
5695
- },
5587
+ parse: getCommonParser('when'),
5588
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5696
5589
  evaluate: function (node, contextStack, _a) {
5697
5590
  var e_1, _b;
5698
5591
  var _c;
@@ -5742,6 +5635,7 @@ var whenFirstSpecialExpression = {
5742
5635
  };
5743
5636
  return node;
5744
5637
  },
5638
+ validateParameterCount: function () { return undefined; },
5745
5639
  evaluate: function (node, contextStack, _a) {
5746
5640
  var e_1, _b;
5747
5641
  var _c;
@@ -5803,6 +5697,7 @@ var whenLetSpecialExpression = {
5803
5697
  };
5804
5698
  return node;
5805
5699
  },
5700
+ validateParameterCount: function () { return undefined; },
5806
5701
  evaluate: function (node, contextStack, _a) {
5807
5702
  var e_1, _b;
5808
5703
  var evaluateAstNode = _a.evaluateAstNode;
@@ -5841,19 +5736,8 @@ var whenLetSpecialExpression = {
5841
5736
  };
5842
5737
 
5843
5738
  var whenNotSpecialExpression = {
5844
- parse: function (tokenStream, parseState, firstToken, _a) {
5845
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
5846
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
5847
- assertRParenToken(tokenStream.tokens[parseState.position++]);
5848
- var node = {
5849
- t: AstNodeType.SpecialExpression,
5850
- n: 'when-not',
5851
- p: params,
5852
- token: getTokenDebugData(firstToken) && firstToken,
5853
- };
5854
- assertNumberOfParams({ min: 1 }, node);
5855
- return node;
5856
- },
5739
+ parse: getCommonParser('when-not'),
5740
+ validateParameterCount: function (node) { return assertNumberOfParams({ min: 1 }, node); },
5857
5741
  evaluate: function (node, contextStack, _a) {
5858
5742
  var e_1, _b;
5859
5743
  var _c;
@@ -7453,7 +7337,7 @@ var AlgebraicParser = /** @class */ (function () {
7453
7337
  };
7454
7338
  };
7455
7339
  AlgebraicParser.prototype.parseFunctionCall = function (symbol) {
7456
- var _a, _b;
7340
+ var _a, _b, _c;
7457
7341
  var params = [];
7458
7342
  this.advance();
7459
7343
  while (!this.isAtEnd() && !isRParenToken(this.peek())) {
@@ -7485,13 +7369,17 @@ var AlgebraicParser = /** @class */ (function () {
7485
7369
  case 'when':
7486
7370
  case 'when-not':
7487
7371
  case 'do':
7488
- case 'throw':
7489
- return {
7372
+ case 'time!':
7373
+ case 'throw': {
7374
+ var node_1 = {
7490
7375
  t: AstNodeType.SpecialExpression,
7491
7376
  n: name_1,
7492
7377
  p: params,
7493
7378
  token: getTokenDebugData(symbol.token) && symbol.token,
7494
7379
  };
7380
+ builtin.specialExpressions[node_1.n].validateParameterCount(node_1);
7381
+ return node_1;
7382
+ }
7495
7383
  case 'def':
7496
7384
  case 'defs':
7497
7385
  case 'let':
@@ -7504,7 +7392,6 @@ var AlgebraicParser = /** @class */ (function () {
7504
7392
  case 'try':
7505
7393
  case 'recur':
7506
7394
  case 'loop':
7507
- case 'time!':
7508
7395
  case 'doseq':
7509
7396
  case 'for':
7510
7397
  throw new Error("Special expression ".concat(name_1, " is not available in algebraic notation"));
@@ -7512,7 +7399,12 @@ var AlgebraicParser = /** @class */ (function () {
7512
7399
  throw new Error("Unknown special expression: ".concat(name_1));
7513
7400
  }
7514
7401
  }
7515
- return createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7402
+ var node = createNamedNormalExpressionNode(symbol.v, params, symbol.token);
7403
+ var builtinExpression = builtin.normalExpressions[node.n];
7404
+ if (builtinExpression) {
7405
+ (_c = builtinExpression.validate) === null || _c === void 0 ? void 0 : _c.call(builtinExpression, __assign(__assign({}, node), { p: withoutCommentNodes(node.p) }));
7406
+ }
7407
+ return node;
7516
7408
  }
7517
7409
  else {
7518
7410
  return {
@@ -7881,7 +7773,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7881
7773
  var firstToken = asLParenToken(tokenStream.tokens[parseState.position++]);
7882
7774
  var nameToken = asP_SymbolToken(tokenStream.tokens[parseState.position++]);
7883
7775
  var expressionName = nameToken[1];
7884
- var parse = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo).parse;
7776
+ var _b = asNonUndefined(builtin.specialExpressions[expressionName], (_a = getTokenDebugData(nameToken)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo), parse = _b.parse, validateParameterCount = _b.validateParameterCount;
7885
7777
  var node = parse(tokenStream, parseState, firstToken, {
7886
7778
  parseExpression: parseExpression,
7887
7779
  parseTokensUntilClosingBracket: parseTokensUntilClosingBracket,
@@ -7890,6 +7782,7 @@ function parseSpecialExpression(tokenStream, parseState) {
7890
7782
  parseBindings: parseBindings,
7891
7783
  parseArgument: parseArgument,
7892
7784
  });
7785
+ validateParameterCount(node);
7893
7786
  return node;
7894
7787
  }
7895
7788
  function parsePolishToken(tokenStream, parseState) {
@@ -29,8 +29,11 @@ declare const specialExpressions: {
29
29
  readonly '??': import("./interface").BuiltinSpecialExpression<import("../interface").Any, import("./specialExpressions/qq").QqNode>;
30
30
  };
31
31
  export type SpecialExpressionName = keyof typeof specialExpressions;
32
+ export type CommonSpecialExpressionName = keyof Pick<typeof specialExpressions, '??' | '??' | 'and' | 'comment' | 'cond' | 'declared?' | 'do' | 'if' | 'if-not' | 'or' | 'time!' | 'when' | 'when-not' | 'throw'>;
32
33
  export type BuiltinSpecialExpressions = typeof specialExpressions;
33
34
  export type BuiltinSpecialExpression = typeof specialExpressions[SpecialExpressionName];
35
+ export type BuiltinCommonSpecialExpression = typeof specialExpressions[CommonSpecialExpressionName];
36
+ export type GenericCommonSpecialExpressionNode<T extends CommonSpecialExpressionName> = ReturnType<typeof specialExpressions[T]['parse']>;
34
37
  export type SpecialExpressionNode = ReturnType<typeof specialExpressions[SpecialExpressionName]['parse']>;
35
38
  export declare const builtin: Builtin;
36
39
  export declare const normalExpressionKeys: string[];
@@ -9,10 +9,11 @@ import type { BuiltinSpecialExpressions, SpecialExpressionNode } from '.';
9
9
  export type NormalExpressionEvaluator<T> = (params: Arr, sourceCodeInfo: SourceCodeInfo | undefined, contextStack: ContextStack, { executeFunction }: {
10
10
  executeFunction: ExecuteFunction;
11
11
  }) => T;
12
- type ValidateNode = (node: NormalExpressionNode) => void;
12
+ type ValidateNormalExpressionNode = (node: NormalExpressionNode) => void;
13
+ type ValidateSpecialExpressionNode = (node: SpecialExpressionNode) => void;
13
14
  interface BuiltinNormalExpression<T> {
14
15
  evaluate: NormalExpressionEvaluator<T>;
15
- validate?: ValidateNode;
16
+ validate?: ValidateNormalExpressionNode;
16
17
  }
17
18
  export interface ParserHelpers {
18
19
  parseExpression: ParseExpression;
@@ -30,6 +31,7 @@ interface EvaluateHelpers {
30
31
  export interface BuiltinSpecialExpression<T, N extends SpecialExpressionNode> {
31
32
  parse: (tokenStream: TokenStream, parseState: ParseState, firstToken: Token, parsers: ParserHelpers) => N;
32
33
  evaluate: (node: N, contextStack: ContextStack, helpers: EvaluateHelpers) => T;
34
+ validateParameterCount: ValidateSpecialExpressionNode;
33
35
  findUnresolvedIdentifiers: (node: N, contextStack: ContextStack, params: {
34
36
  findUnresolvedIdentifiers: FindUnresolvedIdentifiers;
35
37
  builtin: Builtin;
@@ -0,0 +1,4 @@
1
+ import type { CommonSpecialExpressionName, GenericCommonSpecialExpressionNode } from '..';
2
+ import type { Any } from '../../interface';
3
+ import type { BuiltinSpecialExpression } from '../interface';
4
+ export declare function getCommonParser<T extends CommonSpecialExpressionName>(name: T): BuiltinSpecialExpression<Any, GenericCommonSpecialExpressionNode<T>>['parse'];