@mojir/lits 2.1.35 → 2.1.36

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.
@@ -13913,9 +13913,6 @@ var Parser = /** @class */ (function () {
13913
13913
  case 'doseq':
13914
13914
  left = this.parseForOrDoseq(firstToken);
13915
13915
  break;
13916
- // cas:
13917
- // left = this.parseDo(firstToken)
13918
- // break
13919
13916
  case 'loop':
13920
13917
  left = this.parseLoop(firstToken);
13921
13918
  break;
@@ -14117,6 +14114,12 @@ var Parser = /** @class */ (function () {
14117
14114
  params.push(withSourceCodeInfo([NodeTypes.String, value], token[2]));
14118
14115
  this.advance();
14119
14116
  }
14117
+ else if (isLBracketToken(token)) {
14118
+ this.advance();
14119
+ params.push(this.parseExpression());
14120
+ assertRBracketToken(this.peek());
14121
+ this.advance();
14122
+ }
14120
14123
  else {
14121
14124
  throw new LitsError('Expected key to be a symbol or a string', this.peekSourceCodeInfo());
14122
14125
  }
@@ -14247,9 +14250,17 @@ var Parser = /** @class */ (function () {
14247
14250
  var nodes = void 0;
14248
14251
  var docString = '';
14249
14252
  if (isLBraceToken(this.peek())) {
14250
- var parsedBlock = this.parseBlock(true);
14251
- docString = parsedBlock[1];
14252
- nodes = parsedBlock[0][1][1];
14253
+ var positionBefore = this.parseState.position;
14254
+ try {
14255
+ var objectNode = this.parseObject();
14256
+ nodes = [objectNode];
14257
+ }
14258
+ catch (_a) {
14259
+ this.parseState.position = positionBefore;
14260
+ var parsedBlock = this.parseBlock(true);
14261
+ docString = parsedBlock[1];
14262
+ nodes = parsedBlock[0][1][1];
14263
+ }
14253
14264
  }
14254
14265
  else {
14255
14266
  nodes = [this.parseExpression()];
@@ -14266,7 +14277,7 @@ var Parser = /** @class */ (function () {
14266
14277
  ],
14267
14278
  ], firstToken[2]);
14268
14279
  }
14269
- catch (_a) {
14280
+ catch (_b) {
14270
14281
  return null;
14271
14282
  }
14272
14283
  };
@@ -14316,9 +14327,17 @@ var Parser = /** @class */ (function () {
14316
14327
  var nodes;
14317
14328
  var docString = '';
14318
14329
  if (isLBraceToken(this.peek())) {
14319
- var parsedBlock = this.parseBlock(true);
14320
- docString = parsedBlock[1];
14321
- nodes = parsedBlock[0][1][1];
14330
+ var positionBefore = this.parseState.position;
14331
+ try {
14332
+ var objectNode = this.parseObject();
14333
+ nodes = [objectNode];
14334
+ }
14335
+ catch (_b) {
14336
+ this.parseState.position = positionBefore;
14337
+ var parsedBlock = this.parseBlock(true);
14338
+ docString = parsedBlock[1];
14339
+ nodes = parsedBlock[0][1][1];
14340
+ }
14322
14341
  }
14323
14342
  else {
14324
14343
  nodes = [this.parseExpression()];
@@ -14516,9 +14535,6 @@ var Parser = /** @class */ (function () {
14516
14535
  throw new LitsError('Expected }', this.peekSourceCodeInfo());
14517
14536
  }
14518
14537
  }
14519
- if (expressions.length === 0) {
14520
- expressions.push(withSourceCodeInfo([NodeTypes.ReservedSymbol, 'null'], token[2]));
14521
- }
14522
14538
  assertRBraceToken(this.peek());
14523
14539
  this.advance();
14524
14540
  return [
@@ -26631,6 +26647,50 @@ var sequenceReference = {
26631
26647
  };
26632
26648
 
26633
26649
  var specialExpressionsReference = {
26650
+ 'doseq': {
26651
+ title: 'doseq',
26652
+ category: 'Special expression',
26653
+ customVariants: ['doseq (...binding) -> body'],
26654
+ details: [
26655
+ ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A doseq loop binding'],
26656
+ ['loop-var', 'symbol', 'The name of the loop variable.'],
26657
+ ['collection', 'any', 'The collection to iterate over.'],
26658
+ ['let-binding', 'let binding', 'A let binding to create a local variable.'],
26659
+ ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],
26660
+ ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],
26661
+ ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],
26662
+ ],
26663
+ returns: {
26664
+ type: 'null',
26665
+ },
26666
+ description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.',
26667
+ examples: [
26668
+ "\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n ",
26669
+ ],
26670
+ },
26671
+ 'for': {
26672
+ title: 'for',
26673
+ category: 'Special expression',
26674
+ customVariants: ['for (...binding) -> body'],
26675
+ details: [
26676
+ ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A for loop binding'],
26677
+ ['loop-var', 'symbol', 'The name of the loop variable.'],
26678
+ ['collection', 'any', 'The collection to iterate over.'],
26679
+ ['let-binding', 'let binding', 'A let binding to create a local variable.'],
26680
+ ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],
26681
+ ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],
26682
+ ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],
26683
+ ],
26684
+ returns: {
26685
+ type: 'any',
26686
+ array: true,
26687
+ },
26688
+ description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.',
26689
+ examples: [
26690
+ "\nfor (i in [1, 2, 3]) -> i * 2\n ",
26691
+ "\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n ",
26692
+ ],
26693
+ },
26634
26694
  'array': {
26635
26695
  title: 'array',
26636
26696
  category: 'Special expression',