@mojir/lits 2.1.32 → 2.1.33

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/lits.iife.js CHANGED
@@ -11699,165 +11699,13 @@ var Lits = (function (exports) {
11699
11699
  },
11700
11700
  };
11701
11701
 
11702
- var nonNumberReservedSymbolRecord = {
11703
- true: true,
11704
- false: false,
11705
- null: null,
11706
- else: null,
11707
- case: null,
11708
- each: null,
11709
- in: null,
11710
- when: null,
11711
- while: null,
11712
- catch: null,
11713
- function: null,
11714
- export: null,
11715
- as: null,
11716
- _: null,
11717
- };
11718
- var phi = (1 + Math.sqrt(5)) / 2;
11719
- var numberReservedSymbolRecord = {
11720
- 'E': Math.E,
11721
- '-E': -Math.E,
11722
- 'ε': Math.E,
11723
- '-ε': -Math.E,
11724
- 'PI': Math.PI,
11725
- '-PI': -Math.PI,
11726
- 'π': Math.PI,
11727
- '-π': -Math.PI,
11728
- 'PHI': phi,
11729
- '-PHI': -phi,
11730
- 'φ': phi,
11731
- '-φ': -phi,
11732
- 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,
11733
- '∞': Number.POSITIVE_INFINITY,
11734
- 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,
11735
- '-∞': Number.NEGATIVE_INFINITY,
11736
- 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,
11737
- 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,
11738
- 'MAX_VALUE': Number.MAX_VALUE,
11739
- 'MIN_VALUE': Number.MIN_VALUE,
11740
- 'NaN': Number.NaN,
11741
- };
11742
- var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
11743
- function isReservedSymbol(symbol) {
11744
- return symbol in reservedSymbolRecord;
11745
- }
11746
- function isNumberReservedSymbol(symbol) {
11747
- return symbol in numberReservedSymbolRecord;
11748
- }
11749
-
11750
- var specialExpressionTypes = {
11751
- '??': 0,
11752
- '&&': 1,
11753
- '||': 2,
11754
- 'array': 3,
11755
- 'cond': 4,
11756
- '0_def': 5,
11757
- 'defined?': 6,
11758
- '0_defn': 7,
11759
- 'block': 8,
11760
- 'doseq': 9,
11761
- '0_fn': 10,
11762
- 'for': 11,
11763
- 'function': 12,
11764
- 'if': 13,
11765
- 'let': 14,
11766
- 'loop': 15,
11767
- 'object': 16,
11768
- 'recur': 17,
11769
- 'switch': 18,
11770
- 'throw': 19,
11771
- 'try': 20,
11772
- 'unless': 21,
11773
- };
11774
-
11775
- function assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo) {
11776
- if (typeof name !== 'string')
11777
- return;
11778
- // TODO only subset of special expressions are necessary to check (CommonSpecialExpressionType)
11779
- if (specialExpressionTypes[name])
11780
- throw new LitsError("Cannot define variable ".concat(name, ", it's a special expression."), sourceCodeInfo);
11781
- if (builtin.normalExpressions[name])
11782
- throw new LitsError("Cannot define variable ".concat(name, ", it's a builtin function."), sourceCodeInfo);
11783
- if (isReservedSymbol(name))
11784
- throw new LitsError("Cannot define variable ".concat(name, ", it's a reserved name."), sourceCodeInfo);
11785
- if (contextStack.globalContext[name])
11786
- throw new LitsError("Name already defined \"".concat(name, "\"."), sourceCodeInfo);
11787
- }
11788
-
11789
- var functionSpecialExpression = {
11790
- arity: {},
11791
- evaluate: function (node, contextStack, _a) {
11792
- var _b, _c;
11793
- var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11794
- var _d = __read(node[1], 4), functionSymbol = _d[1], fn = _d[2], docString = _d[3];
11795
- assertUserDefinedSymbolNode(functionSymbol, node[2]);
11796
- assertNameNotDefined(functionSymbol[1], contextStack, builtin, node[2]);
11797
- var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11798
- var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11799
- var max = evaluatedFunction[0].some(function (arg) { return arg[0] === bindingTargetTypes.rest; }) ? undefined : evaluatedFunction[0].length;
11800
- var arity = { min: min > 0 ? min : undefined, max: max };
11801
- var litsFunction = (_b = {},
11802
- _b[FUNCTION_SYMBOL] = true,
11803
- _b.sourceCodeInfo = node[2],
11804
- _b.functionType = 'UserDefined',
11805
- _b.name = functionSymbol[1],
11806
- _b.evaluatedfunction = evaluatedFunction,
11807
- _b.arity = arity,
11808
- _b.docString = docString,
11809
- _b);
11810
- contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
11811
- return litsFunction;
11812
- },
11813
- getUndefinedSymbols: function (node, contextStack, _a) {
11814
- var _b, _c;
11815
- var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
11816
- var functionName = node[1][1][1];
11817
- contextStack.addValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
11818
- var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
11819
- return getFunctionUnresolvedSymbols(node[1][2], contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
11820
- },
11821
- };
11822
- var defnSpecialExpression = {
11823
- arity: {},
11824
- evaluate: function (node, contextStack, _a) {
11825
- var _b, _c;
11826
- var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11827
- var _d = __read(node[1], 4), functionSymbol = _d[1], fn = _d[2], docString = _d[3];
11828
- assertUserDefinedSymbolNode(functionSymbol, node[2]);
11829
- assertNameNotDefined(functionSymbol[1], contextStack, builtin, node[2]);
11830
- var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11831
- var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11832
- var arity = { min: min };
11833
- var litsFunction = (_b = {},
11834
- _b[FUNCTION_SYMBOL] = true,
11835
- _b.sourceCodeInfo = node[2],
11836
- _b.functionType = 'UserDefined',
11837
- _b.name = functionSymbol[1],
11838
- _b.evaluatedfunction = evaluatedFunction,
11839
- _b.arity = arity,
11840
- _b.docString = docString,
11841
- _b);
11842
- contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
11843
- return litsFunction;
11844
- },
11845
- getUndefinedSymbols: function (node, contextStack, _a) {
11846
- var _b, _c;
11847
- var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
11848
- var functionName = node[1][1][1];
11849
- var fn = node[1][2];
11850
- contextStack.exportValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
11851
- var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
11852
- return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
11853
- },
11854
- };
11855
- var fnSpecialExpression = {
11702
+ var lambdaSpecialExpression = {
11856
11703
  arity: {},
11857
11704
  evaluate: function (node, contextStack, _a) {
11858
11705
  var _b;
11859
11706
  var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11860
11707
  var fn = node[1][1];
11708
+ var docString = node[1][2];
11861
11709
  var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11862
11710
  var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11863
11711
  var max = evaluatedFunction[0].some(function (arg) { return arg[0] === bindingTargetTypes.rest; }) ? undefined : evaluatedFunction[0].length;
@@ -11869,8 +11717,9 @@ var Lits = (function (exports) {
11869
11717
  _b.name = undefined,
11870
11718
  _b.evaluatedfunction = evaluatedFunction,
11871
11719
  _b.arity = arity,
11872
- _b.docString = '',
11720
+ _b.docString = docString,
11873
11721
  _b);
11722
+ evaluatedFunction[2].self = { value: litsFunction };
11874
11723
  return litsFunction;
11875
11724
  },
11876
11725
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -11901,17 +11750,16 @@ var Lits = (function (exports) {
11901
11750
  ];
11902
11751
  return evaluatedFunction;
11903
11752
  }
11904
- function getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, functionNameContext) {
11753
+ function getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode) {
11905
11754
  var result = new Set();
11906
- var contextStackWithFunctionName = functionNameContext ? contextStack.create(functionNameContext) : contextStack;
11907
- var newContext = {};
11755
+ var newContext = { self: { value: null } };
11908
11756
  fn[0].forEach(function (arg) {
11909
11757
  Object.assign(newContext, getAllBindingTargetNames(arg));
11910
11758
  walkDefaults(arg, function (defaultNode) {
11911
11759
  addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
11912
11760
  });
11913
11761
  });
11914
- var newContextStack = contextStackWithFunctionName.create(newContext);
11762
+ var newContextStack = contextStack.create(newContext);
11915
11763
  var overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode);
11916
11764
  addToSet(result, overloadResult);
11917
11765
  return result;
@@ -11998,22 +11846,9 @@ var Lits = (function (exports) {
11998
11846
  var newContextStack = contextStack.create(bindingContext);
11999
11847
  var body = node[1][2];
12000
11848
  var _loop_1 = function () {
12001
- var e_1, _b;
12002
11849
  var result = null;
12003
11850
  try {
12004
- try {
12005
- for (var body_1 = (e_1 = void 0, __values(body)), body_1_1 = body_1.next(); !body_1_1.done; body_1_1 = body_1.next()) {
12006
- var form = body_1_1.value;
12007
- result = evaluateNode(form, newContextStack);
12008
- }
12009
- }
12010
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
12011
- finally {
12012
- try {
12013
- if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
12014
- }
12015
- finally { if (e_1) throw e_1.error; }
12016
- }
11851
+ result = evaluateNode(body, newContextStack);
12017
11852
  }
12018
11853
  catch (error) {
12019
11854
  if (error instanceof RecurSignal) {
@@ -12022,20 +11857,20 @@ var Lits = (function (exports) {
12022
11857
  throw new LitsError("recur expected ".concat(bindingNodes.length, " parameters, got ").concat(valueToString(params_1.length)), node[2]);
12023
11858
  }
12024
11859
  bindingNodes.forEach(function (bindingNode, index) {
12025
- var e_2, _a;
11860
+ var e_1, _a;
12026
11861
  var valueRecord = evalueateBindingNodeValues(bindingNode[1][0], asAny(params_1[index]), function (Node) { return evaluateNode(Node, contextStack); });
12027
11862
  try {
12028
- for (var _b = (e_2 = void 0, __values(Object.entries(valueRecord))), _c = _b.next(); !_c.done; _c = _b.next()) {
11863
+ for (var _b = (e_1 = void 0, __values(Object.entries(valueRecord))), _c = _b.next(); !_c.done; _c = _b.next()) {
12029
11864
  var _d = __read(_c.value, 2), name_1 = _d[0], value = _d[1];
12030
11865
  bindingContext[name_1].value = value;
12031
11866
  }
12032
11867
  }
12033
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
11868
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
12034
11869
  finally {
12035
11870
  try {
12036
11871
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
12037
11872
  }
12038
- finally { if (e_2) throw e_2.error; }
11873
+ finally { if (e_1) throw e_1.error; }
12039
11874
  }
12040
11875
  });
12041
11876
  return "continue";
@@ -12063,7 +11898,7 @@ var Lits = (function (exports) {
12063
11898
  }, {});
12064
11899
  var bindingValueNodes = bindingNodes.map(function (bindingNode) { return bindingNode[1][1]; });
12065
11900
  var bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode);
12066
- var paramsResult = getUndefinedSymbols(node[1][2], contextStack.create(newContext), builtin, evaluateNode);
11901
+ var paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode);
12067
11902
  return joinSets(bindingsResult, paramsResult);
12068
11903
  },
12069
11904
  };
@@ -12450,6 +12285,31 @@ var Lits = (function (exports) {
12450
12285
  },
12451
12286
  };
12452
12287
 
12288
+ var specialExpressionTypes = {
12289
+ '??': 0,
12290
+ '&&': 1,
12291
+ '||': 2,
12292
+ 'array': 3,
12293
+ 'cond': 4,
12294
+ '0_def': 5,
12295
+ 'defined?': 6,
12296
+ // '0_defn': 7,
12297
+ 'block': 7,
12298
+ 'doseq': 8,
12299
+ '0_lambda': 9,
12300
+ 'for': 10,
12301
+ // 'function': 10,
12302
+ 'if': 11,
12303
+ 'let': 12,
12304
+ 'loop': 13,
12305
+ 'object': 14,
12306
+ 'recur': 15,
12307
+ 'switch': 16,
12308
+ 'throw': 17,
12309
+ 'try': 18,
12310
+ 'unless': 19,
12311
+ };
12312
+
12453
12313
  var specialExpressions = [
12454
12314
  qqSpecialExpression,
12455
12315
  andSpecialExpression,
@@ -12458,12 +12318,12 @@ var Lits = (function (exports) {
12458
12318
  condSpecialExpression,
12459
12319
  defSpecialExpression,
12460
12320
  definedSpecialExpression,
12461
- defnSpecialExpression,
12321
+ // defnSpecialExpression,
12462
12322
  doSpecialExpression,
12463
12323
  doseqSpecialExpression,
12464
- fnSpecialExpression,
12324
+ lambdaSpecialExpression,
12465
12325
  forSpecialExpression,
12466
- functionSpecialExpression,
12326
+ // functionSpecialExpression,
12467
12327
  ifSpecialExpression,
12468
12328
  letSpecialExpression,
12469
12329
  loopSpecialExpression,
@@ -12575,6 +12435,53 @@ var Lits = (function (exports) {
12575
12435
  }
12576
12436
  }
12577
12437
 
12438
+ var nonNumberReservedSymbolRecord = {
12439
+ true: true,
12440
+ false: false,
12441
+ null: null,
12442
+ else: null,
12443
+ case: null,
12444
+ each: null,
12445
+ in: null,
12446
+ when: null,
12447
+ while: null,
12448
+ catch: null,
12449
+ function: null,
12450
+ export: null,
12451
+ as: null,
12452
+ then: null,
12453
+ end: null,
12454
+ _: null,
12455
+ };
12456
+ var phi = (1 + Math.sqrt(5)) / 2;
12457
+ var numberReservedSymbolRecord = {
12458
+ 'E': Math.E,
12459
+ '-E': -Math.E,
12460
+ 'ε': Math.E,
12461
+ '-ε': -Math.E,
12462
+ 'PI': Math.PI,
12463
+ '-PI': -Math.PI,
12464
+ 'π': Math.PI,
12465
+ '-π': -Math.PI,
12466
+ 'PHI': phi,
12467
+ '-PHI': -phi,
12468
+ 'φ': phi,
12469
+ '-φ': -phi,
12470
+ 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,
12471
+ '∞': Number.POSITIVE_INFINITY,
12472
+ 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,
12473
+ '-∞': Number.NEGATIVE_INFINITY,
12474
+ 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,
12475
+ 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,
12476
+ 'MAX_VALUE': Number.MAX_VALUE,
12477
+ 'MIN_VALUE': Number.MIN_VALUE,
12478
+ 'NaN': Number.NaN,
12479
+ };
12480
+ var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
12481
+ function isNumberReservedSymbol(symbol) {
12482
+ return symbol in numberReservedSymbolRecord;
12483
+ }
12484
+
12578
12485
  var functionExecutors = {
12579
12486
  NativeJsFunction: function (fn, params, sourceCodeInfo) {
12580
12487
  var _a;
@@ -13023,6 +12930,9 @@ var Lits = (function (exports) {
13023
12930
  if (normalExpressionKeys.includes(name_1)) {
13024
12931
  throw new LitsError("Cannot shadow builtin function \"".concat(name_1, "\""), sourceCodeInfo);
13025
12932
  }
12933
+ if (name_1 === 'self') {
12934
+ throw new LitsError("Cannot shadow builtin value \"".concat(name_1, "\""), sourceCodeInfo);
12935
+ }
13026
12936
  this.globalContext[name_1] = { value: value };
13027
12937
  }
13028
12938
  }
@@ -13052,6 +12962,9 @@ var Lits = (function (exports) {
13052
12962
  if (normalExpressionKeys.includes(name_2)) {
13053
12963
  throw new LitsError("Cannot shadow builtin function \"".concat(name_2, "\""), sourceCodeInfo);
13054
12964
  }
12965
+ if (name_2 === 'self') {
12966
+ throw new LitsError("Cannot shadow builtin value \"".concat(name_2, "\""), sourceCodeInfo);
12967
+ }
13055
12968
  currentContext[name_2] = { value: toAny(value) };
13056
12969
  }
13057
12970
  }
@@ -14047,9 +13960,6 @@ var Lits = (function (exports) {
14047
13960
  break;
14048
13961
  }
14049
13962
  }
14050
- else if (isReservedSymbolToken(firstToken, 'function')) {
14051
- return this.parseFunction(firstToken);
14052
- }
14053
13963
  else if (isReservedSymbolToken(firstToken, 'export')) {
14054
13964
  if (!moduleScope) {
14055
13965
  throw new LitsError('export is only allowed in module scope', firstToken[2]);
@@ -14342,9 +14252,8 @@ var Lits = (function (exports) {
14342
14252
  var _c = __read(params, 1), param = _c[0];
14343
14253
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param]], symbol[2]);
14344
14254
  }
14345
- case specialExpressionTypes['0_fn']:
14255
+ case specialExpressionTypes['0_lambda']:
14346
14256
  case specialExpressionTypes['0_def']:
14347
- case specialExpressionTypes['0_defn']:
14348
14257
  throw new LitsError("".concat(type, " is not allowed"), symbol[2]);
14349
14258
  /* v8 ignore next 2 */
14350
14259
  default:
@@ -14371,11 +14280,27 @@ var Lits = (function (exports) {
14371
14280
  return null;
14372
14281
  }
14373
14282
  this.advance();
14374
- var body = this.parseExpression();
14375
- return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_fn'], [
14283
+ var nodes = void 0;
14284
+ var docString = '';
14285
+ if (isLBraceToken(this.peek())) {
14286
+ var parsedBlock = this.parseBlock(true);
14287
+ docString = parsedBlock[1];
14288
+ nodes = parsedBlock[0][1][1];
14289
+ }
14290
+ else {
14291
+ nodes = [this.parseExpression()];
14292
+ }
14293
+ return withSourceCodeInfo([
14294
+ NodeTypes.SpecialExpression,
14295
+ [
14296
+ specialExpressionTypes['0_lambda'],
14297
+ [
14376
14298
  functionArguments,
14377
- [body],
14378
- ]]], firstToken[2]);
14299
+ nodes,
14300
+ ],
14301
+ docString,
14302
+ ],
14303
+ ], firstToken[2]);
14379
14304
  }
14380
14305
  catch (_a) {
14381
14306
  return null;
@@ -14424,7 +14349,16 @@ var Lits = (function (exports) {
14424
14349
  var firstToken = this.asToken(this.peek());
14425
14350
  this.advance();
14426
14351
  var startPos = this.parseState.position;
14427
- var exprNode = this.parseExpression();
14352
+ var nodes;
14353
+ var docString = '';
14354
+ if (isLBraceToken(this.peek())) {
14355
+ var parsedBlock = this.parseBlock(true);
14356
+ docString = parsedBlock[1];
14357
+ nodes = parsedBlock[0][1][1];
14358
+ }
14359
+ else {
14360
+ nodes = [this.parseExpression()];
14361
+ }
14428
14362
  var endPos = this.parseState.position - 1;
14429
14363
  var arity = 0;
14430
14364
  var dollar1 = 'NOT_SET'; // referring to argument bindings. $ = NAKED, $1, $2, $3, etc = WITH_1
@@ -14455,10 +14389,10 @@ var Lits = (function (exports) {
14455
14389
  functionArguments.push(withSourceCodeInfo([bindingTargetTypes.symbol, [[NodeTypes.UserDefinedSymbol, "$".concat(i)], undefined]], firstToken[2]));
14456
14390
  }
14457
14391
  }
14458
- var node = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_fn'], [
14392
+ var node = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_lambda'], [
14459
14393
  functionArguments,
14460
- [exprNode],
14461
- ]]], firstToken[2]);
14394
+ nodes,
14395
+ ], docString]], firstToken[2]);
14462
14396
  return node;
14463
14397
  };
14464
14398
  Parser.prototype.parseOptionalDefaulValue = function () {
@@ -14649,21 +14583,10 @@ var Lits = (function (exports) {
14649
14583
  }
14650
14584
  assertRParenToken(token);
14651
14585
  this.advance();
14652
- assertLBraceToken(this.peek());
14653
- this.advance();
14654
- var params = [];
14655
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14656
- params.push(this.parseExpression());
14657
- if (isOperatorToken(this.peek(), ';')) {
14658
- this.advance();
14659
- }
14660
- else if (!isRBraceToken(this.peek())) {
14661
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14662
- }
14663
- }
14664
- assertRBraceToken(this.peek());
14586
+ assertOperatorToken(this.peek(), '->');
14665
14587
  this.advance();
14666
- return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.loop, bindingNodes, params]], firstToken[2]);
14588
+ var expression = this.parseExpression();
14589
+ return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.loop, bindingNodes, expression]], firstToken[2]);
14667
14590
  };
14668
14591
  Parser.prototype.parseTry = function (token) {
14669
14592
  this.advance();
@@ -14694,7 +14617,7 @@ var Lits = (function (exports) {
14694
14617
  throw new LitsError('Duplicate binding', loopBinding[0][2]);
14695
14618
  }
14696
14619
  forLoopBindings.push(loopBinding);
14697
- if (isOperatorToken(this_1.peek(), ';')) {
14620
+ if (isOperatorToken(this_1.peek(), ',')) {
14698
14621
  this_1.advance();
14699
14622
  }
14700
14623
  };
@@ -14704,6 +14627,8 @@ var Lits = (function (exports) {
14704
14627
  }
14705
14628
  assertRParenToken(this.peek());
14706
14629
  this.advance();
14630
+ assertOperatorToken(this.peek(), '->');
14631
+ this.advance();
14707
14632
  var expression = this.parseExpression();
14708
14633
  return isDoseq
14709
14634
  ? withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.doseq, forLoopBindings, expression]], firstToken[2])
@@ -14713,20 +14638,7 @@ var Lits = (function (exports) {
14713
14638
  var bindingNode = this.parseBinding();
14714
14639
  var modifiers = [];
14715
14640
  var token = this.asToken(this.peek());
14716
- if (!isRParenToken(token) && !isOperatorToken(this.peek(), ';') && !isOperatorToken(token, ',')) {
14717
- throw new LitsError('Expected ")", ";" or ","', token[2]);
14718
- }
14719
- if (isOperatorToken(token, ',')) {
14720
- this.advance();
14721
- token = this.asToken(this.peek());
14722
- }
14723
- if (!isSymbolToken(token, 'let')
14724
- && !isReservedSymbolToken(token, 'when')
14725
- && !isReservedSymbolToken(token, 'while')
14726
- && !isRParenToken(token)
14727
- && !isOperatorToken(token, ';')) {
14728
- throw new LitsError('Expected symbol ";", ")", let, when or while', token[2]);
14729
- }
14641
+ this.assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while']);
14730
14642
  var letBindings = [];
14731
14643
  if (token[1] === 'let') {
14732
14644
  modifiers.push('&let');
@@ -14739,12 +14651,7 @@ var Lits = (function (exports) {
14739
14651
  }
14740
14652
  letBindings.push(letNode[1][1]);
14741
14653
  token = this_2.asToken(this_2.peek());
14742
- if (!isRParenToken(token) && !isOperatorToken(token, ';') && !isOperatorToken(token, ',')) {
14743
- throw new LitsError('Expected ")", ";" or ","', token[2]);
14744
- }
14745
- if (isOperatorToken(token, ',')) {
14746
- this_2.advance();
14747
- }
14654
+ this_2.assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while']);
14748
14655
  token = this_2.asToken(this_2.peek());
14749
14656
  };
14750
14657
  var this_2 = this;
@@ -14758,33 +14665,57 @@ var Lits = (function (exports) {
14758
14665
  || isReservedSymbolToken(token, 'while')) {
14759
14666
  this.advance();
14760
14667
  if (token[1] === 'when') {
14761
- if (modifiers.includes('&when')) {
14762
- throw new LitsError('Multiple when modifiers in for loop', token[2]);
14763
- }
14764
14668
  modifiers.push('&when');
14765
14669
  whenNode = this.parseExpression();
14766
14670
  }
14767
14671
  else {
14768
- if (modifiers.includes('&while')) {
14769
- throw new LitsError('Multiple while modifiers in for loop', token[2]);
14770
- }
14771
14672
  modifiers.push('&while');
14772
14673
  whileNode = this.parseExpression();
14773
14674
  }
14774
14675
  token = this.asToken(this.peek());
14775
- if (!isRParenToken(token) && !isOperatorToken(token, ';') && !isOperatorToken(token, ',')) {
14776
- throw new LitsError('Expected do or comma', token[2]);
14777
- }
14778
- if (isOperatorToken(token, ',')) {
14779
- this.advance();
14780
- }
14676
+ var symbols = modifiers.includes('&when') && modifiers.includes('&while')
14677
+ ? []
14678
+ : modifiers.includes('&when')
14679
+ ? ['while']
14680
+ : ['when'];
14681
+ this.assertInternalLoopBindingDelimiter(token, symbols);
14781
14682
  token = this.asToken(this.peek());
14782
14683
  }
14783
- if (!isRParenToken(token) && !isOperatorToken(token, ';')) {
14784
- throw new LitsError('Expected "{" or ";"', token[2]);
14785
- }
14684
+ this.assertInternalLoopBindingDelimiter(token, []);
14786
14685
  return [bindingNode, letBindings, whenNode, whileNode];
14787
14686
  };
14687
+ Parser.prototype.assertInternalLoopBindingDelimiter = function (token, symbols) {
14688
+ if (!this.isInternalLoopBindingDelimiter(token, symbols)) {
14689
+ var symbolsString = "".concat(__spreadArray(__spreadArray([], __read(symbols), false), [','], false).map(function (symbol) { return "\"".concat(symbol, "\""); }).join(', '), " or \")\"");
14690
+ throw new LitsError("Expected symbol ".concat(symbolsString), token[2]);
14691
+ }
14692
+ };
14693
+ Parser.prototype.isInternalLoopBindingDelimiter = function (token, symbols) {
14694
+ var e_1, _a;
14695
+ // end of loop binding
14696
+ if (isOperatorToken(token, ',') || isRParenToken(token)) {
14697
+ return true;
14698
+ }
14699
+ try {
14700
+ for (var symbols_1 = __values(symbols), symbols_1_1 = symbols_1.next(); !symbols_1_1.done; symbols_1_1 = symbols_1.next()) {
14701
+ var symbol = symbols_1_1.value;
14702
+ if (symbol === 'let' && isSymbolToken(token, 'let')) {
14703
+ return true;
14704
+ }
14705
+ if (['when', 'while'].includes(symbol) && isReservedSymbolToken(token, symbol)) {
14706
+ return true;
14707
+ }
14708
+ }
14709
+ }
14710
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14711
+ finally {
14712
+ try {
14713
+ if (symbols_1_1 && !symbols_1_1.done && (_a = symbols_1.return)) _a.call(symbols_1);
14714
+ }
14715
+ finally { if (e_1) throw e_1.error; }
14716
+ }
14717
+ return false;
14718
+ };
14788
14719
  Parser.prototype.parseBinding = function () {
14789
14720
  var firstToken = asSymbolToken(this.peek());
14790
14721
  var name = asUserDefinedSymbolNode(this.parseSymbol());
@@ -14803,10 +14734,8 @@ var Lits = (function (exports) {
14803
14734
  Parser.prototype.parseIfOrUnless = function (token) {
14804
14735
  var isUnless = token[1] === 'unless';
14805
14736
  this.advance();
14806
- assertLParenToken(this.peek());
14807
- this.advance();
14808
14737
  var condition = this.parseExpression();
14809
- assertRParenToken(this.peek());
14738
+ assertReservedSymbolToken(this.peek(), 'then');
14810
14739
  this.advance();
14811
14740
  var thenExpression = this.parseExpression();
14812
14741
  var elseExpression;
@@ -14819,100 +14748,74 @@ var Lits = (function (exports) {
14819
14748
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [condition, thenExpression, elseExpression]]], token[2]);
14820
14749
  };
14821
14750
  Parser.prototype.parseCond = function (token) {
14822
- this.advance();
14823
- assertLBraceToken(this.peek());
14824
14751
  this.advance();
14825
14752
  var params = [];
14826
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14753
+ while (!this.isAtEnd() && !isReservedSymbolToken(this.peek(), 'end')) {
14827
14754
  assertReservedSymbolToken(this.peek(), 'case');
14828
14755
  this.advance();
14829
14756
  var caseExpression = this.parseExpression();
14830
- assertOperatorToken(this.peek(), ':');
14757
+ assertReservedSymbolToken(this.peek(), 'then');
14831
14758
  this.advance();
14832
14759
  var expressions = [];
14833
14760
  while (!this.isAtEnd()
14834
14761
  && !isReservedSymbolToken(this.peek(), 'case')
14835
- && !isRBraceToken(this.peek())) {
14762
+ && !isReservedSymbolToken(this.peek(), 'end')) {
14836
14763
  expressions.push(this.parseExpression());
14837
14764
  if (isOperatorToken(this.peek(), ';')) {
14838
14765
  this.advance();
14839
14766
  }
14840
- else if (!isReservedSymbolToken(this.peek(), 'case') && !isRBraceToken(this.peek())) {
14841
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14767
+ else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14768
+ throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
14842
14769
  }
14843
14770
  }
14844
14771
  var thenExpression = expressions.length === 1
14845
14772
  ? expressions[0]
14846
14773
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
14847
14774
  params.push([caseExpression, thenExpression]);
14848
- if (isRBraceToken(this.peek())) {
14775
+ if (isReservedSymbolToken(this.peek(), 'end')) {
14849
14776
  break;
14850
14777
  }
14851
14778
  assertReservedSymbolToken(this.peek(), 'case');
14852
14779
  }
14853
- assertRBraceToken(this.peek());
14780
+ assertReservedSymbolToken(this.peek());
14854
14781
  this.advance();
14855
14782
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.cond, params]], token[2]);
14856
14783
  };
14857
14784
  Parser.prototype.parseSwitch = function (token) {
14858
- this.advance();
14859
- assertLParenToken(this.peek());
14860
14785
  this.advance();
14861
14786
  var valueExpression = this.parseExpression();
14862
- assertRParenToken(this.peek());
14863
- this.advance();
14864
- assertLBraceToken(this.peek());
14865
- this.advance();
14866
14787
  var params = [];
14867
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14788
+ while (!this.isAtEnd() && !isReservedSymbolToken(this.peek(), 'end')) {
14868
14789
  assertReservedSymbolToken(this.peek(), 'case');
14869
14790
  this.advance();
14870
14791
  var caseExpression = this.parseExpression();
14871
- assertOperatorToken(this.peek(), ':');
14792
+ assertReservedSymbolToken(this.peek(), 'then');
14872
14793
  this.advance();
14873
14794
  var expressions = [];
14874
14795
  while (!this.isAtEnd()
14875
14796
  && !isReservedSymbolToken(this.peek(), 'case')
14876
- && !isRBraceToken(this.peek())) {
14797
+ && !isReservedSymbolToken(this.peek(), 'end')) {
14877
14798
  expressions.push(this.parseExpression());
14878
14799
  if (isOperatorToken(this.peek(), ';')) {
14879
14800
  this.advance();
14880
14801
  }
14881
- else if (!isReservedSymbolToken(this.peek(), 'case') && !isRBraceToken(this.peek())) {
14882
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14802
+ else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14803
+ throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
14883
14804
  }
14884
14805
  }
14885
14806
  var thenExpression = expressions.length === 1
14886
14807
  ? expressions[0]
14887
14808
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
14888
14809
  params.push([caseExpression, thenExpression]);
14889
- if (isRBraceToken(this.peek())) {
14810
+ if (isReservedSymbolToken(this.peek(), 'end')) {
14890
14811
  break;
14891
14812
  }
14892
14813
  assertReservedSymbolToken(this.peek(), 'case');
14893
14814
  }
14894
- assertRBraceToken(this.peek());
14815
+ assertReservedSymbolToken(this.peek(), 'end');
14895
14816
  this.advance();
14896
14817
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.switch, valueExpression, params]], token[2]);
14897
14818
  };
14898
- Parser.prototype.parseFunction = function (token) {
14899
- this.advance();
14900
- var symbol = this.parseSymbol();
14901
- var functionArguments = this.parseFunctionArguments();
14902
- var _a = __read(this.parseBlock(true), 2), block = _a[0], docString = _a[1];
14903
- return withSourceCodeInfo([
14904
- NodeTypes.SpecialExpression,
14905
- [
14906
- specialExpressionTypes.function,
14907
- symbol,
14908
- [
14909
- functionArguments,
14910
- block[1][1],
14911
- ],
14912
- docString,
14913
- ],
14914
- ], token[2]);
14915
- };
14916
14819
  Parser.prototype.isAtEnd = function () {
14917
14820
  return this.parseState.position >= this.tokenStream.tokens.length;
14918
14821
  };
@@ -14925,7 +14828,7 @@ var Lits = (function (exports) {
14925
14828
  return [';', ',', ':'].includes(token[1]);
14926
14829
  }
14927
14830
  if (isReservedSymbolToken(token)) {
14928
- return ['else', 'when', 'while', 'case', 'catch'].includes(token[1]);
14831
+ return ['else', 'when', 'while', 'case', 'catch', 'let', 'then'].includes(token[1]);
14929
14832
  }
14930
14833
  return false;
14931
14834
  };
@@ -14936,13 +14839,8 @@ var Lits = (function (exports) {
14936
14839
  var letNode = this.parseLet(asSymbolToken(token));
14937
14840
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_def'], letNode[1][1]]], exportToken[2]);
14938
14841
  }
14939
- else if (isReservedSymbolToken(token, 'function')) {
14940
- var functionNode = this.parseFunction(token);
14941
- functionNode[1][0] = specialExpressionTypes['0_defn'];
14942
- return functionNode;
14943
- }
14944
14842
  else {
14945
- throw new LitsError('Expected let or function', this.peekSourceCodeInfo());
14843
+ throw new LitsError('Expected let', this.peekSourceCodeInfo());
14946
14844
  }
14947
14845
  };
14948
14846
  Parser.prototype.stringToSymbolNode = function (value, sourceCodeInfo) {
@@ -15132,7 +15030,7 @@ var Lits = (function (exports) {
15132
15030
  };
15133
15031
  AutoCompleter.prototype.generateSuggestions = function (params) {
15134
15032
  var _this = this;
15135
- var blacklist = new Set(['0_def', '0_defn', '0_fn']);
15033
+ var blacklist = new Set(['0_def', '0_defn', '0_lambda']);
15136
15034
  var startsWithCaseSensitive = this.generateWithPredicate(params, function (suggestion) {
15137
15035
  return !blacklist.has(suggestion) && suggestion.startsWith(_this.searchString);
15138
15036
  });
@@ -15782,7 +15680,7 @@ var Lits = (function (exports) {
15782
15680
  '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',
15783
15681
  'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',
15784
15682
  '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',
15785
- "\nfunction foo(n) {\n [n - 1, n, n + 1]\n};\n[1, 2, 3] mapcat foo",
15683
+ "\nlet foo = (n) -> {\n [n - 1, n, n + 1]\n};\n[1, 2, 3] mapcat foo",
15786
15684
  "\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
15787
15685
  ],
15788
15686
  },
@@ -20513,7 +20411,7 @@ var Lits = (function (exports) {
20513
20411
  description: 'Returns documentation string of the $fun.',
20514
20412
  examples: [
20515
20413
  'doc(+)',
20516
- "\nfunction add(x, y) {\n \"\"\"\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n \"\"\"\n x + y;\n};\n\ndoc(add)",
20414
+ "\nlet add = (x, y) -> {\n \"\"\"\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n \"\"\"\n x + y;\n};\n\ndoc(add)",
20517
20415
  ],
20518
20416
  },
20519
20417
  arity: {
@@ -20534,8 +20432,8 @@ var Lits = (function (exports) {
20534
20432
  examples: [
20535
20433
  'arity(+)',
20536
20434
  'arity(defined?)',
20537
- "\nfunction add(x, y = 0) {\n x + y;\n};\n\narity(add)",
20538
- "\nfunction foo(k, ...x) {\n k + x;\n};\n arity(foo)",
20435
+ "\nlet add = (x, y = 0) -> {\n x + y;\n};\n\narity(add)",
20436
+ "\nlet foo = (k, ...x) -> {\n k + x;\n};\n arity(foo)",
20539
20437
  ],
20540
20438
  },
20541
20439
  };
@@ -26415,8 +26313,8 @@ var Lits = (function (exports) {
26415
26313
  examples: [
26416
26314
  '[3, 1, 2] sort (a, b) -> b - a',
26417
26315
  'sort([3, 1, 2])',
26418
- "\nsort(\n [3, 1, 2],\n (a, b) -> cond { case a < b: -1 case a > b: 1 case true: -1 }\n)",
26419
- "\nsort(\n [3, 1, 2],\n (a, b) -> cond { case a > b: -1 case a < b: 1 case true: -1 }\n)",
26316
+ "\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)",
26317
+ "\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)",
26420
26318
  ],
26421
26319
  },
26422
26320
  'sort-by': {
@@ -26893,26 +26791,6 @@ var Lits = (function (exports) {
26893
26791
  description: "\n Binds local variables s to `value`. `value` can be any expression. The scope of the variables is the body of the let expression.",
26894
26792
  examples: ["\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)"],
26895
26793
  },
26896
- 'function': {
26897
- title: 'function',
26898
- category: 'Special expression',
26899
- customVariants: ['function name(...arg) { body }'],
26900
- details: [
26901
- ['name', 'symbol', 'The name of the function.'],
26902
- ['arg', '[...]arg-name [= value]', 'Arguments of the function.'],
26903
- ['...', 'rest-symbol', 'Optional. The rest argument of the function.'],
26904
- ['arg-name', 'symbol', 'The name of the argument.'],
26905
- ['value', 'any', 'Optional. The default value of the argument.'],
26906
- ['let-binding', 'symbol', 'Optional. The let bindings of the function.'],
26907
- ['body', 'one or more expressions', 'The body of the function.'],
26908
- ],
26909
- description: 'Creates a named function. When called, evaluation of the last expression in the body is returned.',
26910
- examples: [
26911
- "\nfunction hyp (a, b) {\n sqrt(a * a + b * b)\n};\n\nhyp(3, 4)",
26912
- "\nfunction sumOfSquares(...s) {\n apply(\n +,\n map(s, -> $ ^ 2)\n )\n};\n\nsumOfSquares(1, 2, 3, 4, 5)",
26913
- "\nfunction withOptional(a, b = 42) {\n a + b\n};\n\nwrite!(withOptional(1), withOptional(1, 2))",
26914
- ],
26915
- },
26916
26794
  'try': {
26917
26795
  title: 'try',
26918
26796
  category: 'Special expression',
@@ -26952,7 +26830,7 @@ var Lits = (function (exports) {
26952
26830
  'if': {
26953
26831
  title: 'if',
26954
26832
  category: 'Special expression',
26955
- customVariants: ['if (test) true-expr else false-expr', 'if (test) true-expr'],
26833
+ customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],
26956
26834
  details: [
26957
26835
  ['test', 'expression', 'The condition to test.'],
26958
26836
  ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],
@@ -26960,16 +26838,16 @@ var Lits = (function (exports) {
26960
26838
  ],
26961
26839
  description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',
26962
26840
  examples: [
26963
- "\nif (true) {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26964
- 'if (false) write!("TRUE") else write!("FALSE")',
26965
- 'if (true) write!("TRUE")',
26966
- 'if (false) write!("TRUE")',
26841
+ "\nif true then {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26842
+ 'if false then write!("TRUE") else write!("FALSE")',
26843
+ 'if true then write!("TRUE")',
26844
+ 'if false then write!("TRUE")',
26967
26845
  ],
26968
26846
  },
26969
26847
  'unless': {
26970
26848
  title: 'unless',
26971
26849
  category: 'Special expression',
26972
- customVariants: ['unless (test) true-expr else false-expr end', 'unless test true-expr end'],
26850
+ customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],
26973
26851
  details: [
26974
26852
  ['test', 'expression', 'The condition to test.'],
26975
26853
  ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],
@@ -26977,16 +26855,16 @@ var Lits = (function (exports) {
26977
26855
  ],
26978
26856
  description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',
26979
26857
  examples: [
26980
- "\nunless (true) {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26981
- 'unless (false) write!("TRUE") else write!("FALSE")',
26982
- 'unless (true) write!("TRUE")',
26983
- 'unless (false) write!("TRUE")',
26858
+ "\nunless true then {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26859
+ 'unless false then write!("TRUE") else write!("FALSE")',
26860
+ 'unless true then write!("TRUE")',
26861
+ 'unless false then write!("TRUE")',
26984
26862
  ],
26985
26863
  },
26986
26864
  'cond': {
26987
26865
  title: 'cond',
26988
26866
  category: 'Special expression',
26989
- customVariants: ['cond { cond-branch cond-branch ... }'],
26867
+ customVariants: ['cond cond-branch cond-branch ... end'],
26990
26868
  details: [
26991
26869
  ['cond-branch', 'case test then body', 'A branch of the cond expression.'],
26992
26870
  ['test', 'expression', 'The condition to test.'],
@@ -26994,15 +26872,15 @@ var Lits = (function (exports) {
26994
26872
  ],
26995
26873
  description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',
26996
26874
  examples: [
26997
- "\ncond {\n case false: write!(\"FALSE\")\n case true: write!(\"TRUE\")\n}",
26998
- "\ncond {\n case false: write!(\"FALSE\")\n case null: write!(\"null\")\n} ?? write!(\"TRUE\")",
26999
- "\ncond {\n case false: write!(\"FALSE\")\n case null: write!(\"null\")\n} ?? write!(\"TRUE\")",
26875
+ "\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend",
26876
+ "\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")",
26877
+ "\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")",
27000
26878
  ],
27001
26879
  },
27002
26880
  'switch': {
27003
26881
  title: 'switch',
27004
26882
  category: 'Special expression',
27005
- customVariants: ['switch (value) { switch-branch switch-branch ... }'],
26883
+ customVariants: ['switch value switch-branch switch-branch ... end'],
27006
26884
  details: [
27007
26885
  ['value', 'any', 'The value to test.'],
27008
26886
  ['switch-branch', 'case test then body', 'A branch of the switch expression.'],
@@ -27011,9 +26889,9 @@ var Lits = (function (exports) {
27011
26889
  ],
27012
26890
  description: 'Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.',
27013
26891
  examples: [
27014
- "\nswitch (1) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
27015
- "\nswitch (2) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
27016
- "\nswitch (3) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
26892
+ "\nswitch 1\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
26893
+ "\nswitch 2\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
26894
+ "\nswitch 3\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
27017
26895
  ],
27018
26896
  },
27019
26897
  'block': {
@@ -27034,9 +26912,9 @@ var Lits = (function (exports) {
27034
26912
  customVariants: ['recur(...recur-args)'],
27035
26913
  description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',
27036
26914
  examples: [
27037
- "\nfunction foo(n) {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n};\nfoo(3)",
27038
- "\n(n -> {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n})(3)",
27039
- "\nloop (n = 3) {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n}",
26915
+ "\nlet foo = (n) -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n};\nfoo(3)",
26916
+ "\n(n -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n})(3)",
26917
+ "\nloop (n = 3) -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n}",
27040
26918
  ],
27041
26919
  },
27042
26920
  };