@mojir/lits 2.1.31 → 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.
@@ -180,21 +180,21 @@ var specialExpressionTypes = {
180
180
  'cond': 4,
181
181
  '0_def': 5,
182
182
  'defined?': 6,
183
- '0_defn': 7,
184
- 'block': 8,
185
- 'doseq': 9,
186
- '0_fn': 10,
187
- 'for': 11,
188
- 'function': 12,
189
- 'if': 13,
190
- 'let': 14,
191
- 'loop': 15,
192
- 'object': 16,
193
- 'recur': 17,
194
- 'switch': 18,
195
- 'throw': 19,
196
- 'try': 20,
197
- 'unless': 21,
183
+ // '0_defn': 7,
184
+ 'block': 7,
185
+ 'doseq': 8,
186
+ '0_lambda': 9,
187
+ 'for': 10,
188
+ // 'function': 10,
189
+ 'if': 11,
190
+ 'let': 12,
191
+ 'loop': 13,
192
+ 'object': 14,
193
+ 'recur': 15,
194
+ 'switch': 16,
195
+ 'throw': 17,
196
+ 'try': 18,
197
+ 'unless': 19,
198
198
  };
199
199
 
200
200
  var NodeTypes = {
@@ -11778,140 +11778,13 @@ var doSpecialExpression = {
11778
11778
  },
11779
11779
  };
11780
11780
 
11781
- var nonNumberReservedSymbolRecord = {
11782
- true: true,
11783
- false: false,
11784
- null: null,
11785
- else: null,
11786
- case: null,
11787
- each: null,
11788
- in: null,
11789
- when: null,
11790
- while: null,
11791
- catch: null,
11792
- function: null,
11793
- export: null,
11794
- as: null,
11795
- _: null,
11796
- };
11797
- var phi = (1 + Math.sqrt(5)) / 2;
11798
- var numberReservedSymbolRecord = {
11799
- 'E': Math.E,
11800
- '-E': -Math.E,
11801
- 'ε': Math.E,
11802
- '-ε': -Math.E,
11803
- 'PI': Math.PI,
11804
- '-PI': -Math.PI,
11805
- 'π': Math.PI,
11806
- '-π': -Math.PI,
11807
- 'PHI': phi,
11808
- '-PHI': -phi,
11809
- 'φ': phi,
11810
- '-φ': -phi,
11811
- 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,
11812
- '∞': Number.POSITIVE_INFINITY,
11813
- 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,
11814
- '-∞': Number.NEGATIVE_INFINITY,
11815
- 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,
11816
- 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,
11817
- 'MAX_VALUE': Number.MAX_VALUE,
11818
- 'MIN_VALUE': Number.MIN_VALUE,
11819
- 'NaN': Number.NaN,
11820
- };
11821
- var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
11822
- function isReservedSymbol(symbol) {
11823
- return symbol in reservedSymbolRecord;
11824
- }
11825
- function isNumberReservedSymbol(symbol) {
11826
- return symbol in numberReservedSymbolRecord;
11827
- }
11828
-
11829
- function assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo) {
11830
- if (typeof name !== 'string')
11831
- return;
11832
- // TODO only subset of special expressions are necessary to check (CommonSpecialExpressionType)
11833
- if (specialExpressionTypes[name])
11834
- throw new LitsError("Cannot define variable ".concat(name, ", it's a special expression."), sourceCodeInfo);
11835
- if (builtin.normalExpressions[name])
11836
- throw new LitsError("Cannot define variable ".concat(name, ", it's a builtin function."), sourceCodeInfo);
11837
- if (isReservedSymbol(name))
11838
- throw new LitsError("Cannot define variable ".concat(name, ", it's a reserved name."), sourceCodeInfo);
11839
- if (contextStack.globalContext[name])
11840
- throw new LitsError("Name already defined \"".concat(name, "\"."), sourceCodeInfo);
11841
- }
11842
-
11843
- var functionSpecialExpression = {
11844
- arity: {},
11845
- evaluate: function (node, contextStack, _a) {
11846
- var _b, _c;
11847
- var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11848
- var _d = __read(node[1], 4), functionSymbol = _d[1], fn = _d[2], docString = _d[3];
11849
- assertUserDefinedSymbolNode(functionSymbol, node[2]);
11850
- assertNameNotDefined(functionSymbol[1], contextStack, builtin, node[2]);
11851
- var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11852
- var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11853
- var max = evaluatedFunction[0].some(function (arg) { return arg[0] === bindingTargetTypes.rest; }) ? undefined : evaluatedFunction[0].length;
11854
- var arity = { min: min > 0 ? min : undefined, max: max };
11855
- var litsFunction = (_b = {},
11856
- _b[FUNCTION_SYMBOL] = true,
11857
- _b.sourceCodeInfo = node[2],
11858
- _b.functionType = 'UserDefined',
11859
- _b.name = functionSymbol[1],
11860
- _b.evaluatedfunction = evaluatedFunction,
11861
- _b.arity = arity,
11862
- _b.docString = docString,
11863
- _b);
11864
- contextStack.addValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
11865
- return litsFunction;
11866
- },
11867
- getUndefinedSymbols: function (node, contextStack, _a) {
11868
- var _b, _c;
11869
- var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
11870
- var functionName = node[1][1][1];
11871
- contextStack.addValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
11872
- var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
11873
- return getFunctionUnresolvedSymbols(node[1][2], contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
11874
- },
11875
- };
11876
- var defnSpecialExpression = {
11877
- arity: {},
11878
- evaluate: function (node, contextStack, _a) {
11879
- var _b, _c;
11880
- var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11881
- var _d = __read(node[1], 4), functionSymbol = _d[1], fn = _d[2], docString = _d[3];
11882
- assertUserDefinedSymbolNode(functionSymbol, node[2]);
11883
- assertNameNotDefined(functionSymbol[1], contextStack, builtin, node[2]);
11884
- var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11885
- var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11886
- var arity = { min: min };
11887
- var litsFunction = (_b = {},
11888
- _b[FUNCTION_SYMBOL] = true,
11889
- _b.sourceCodeInfo = node[2],
11890
- _b.functionType = 'UserDefined',
11891
- _b.name = functionSymbol[1],
11892
- _b.evaluatedfunction = evaluatedFunction,
11893
- _b.arity = arity,
11894
- _b.docString = docString,
11895
- _b);
11896
- contextStack.exportValues((_c = {}, _c[functionSymbol[1]] = litsFunction, _c), functionSymbol[2]);
11897
- return litsFunction;
11898
- },
11899
- getUndefinedSymbols: function (node, contextStack, _a) {
11900
- var _b, _c;
11901
- var getUndefinedSymbols = _a.getUndefinedSymbols, builtin = _a.builtin, evaluateNode = _a.evaluateNode;
11902
- var functionName = node[1][1][1];
11903
- var fn = node[1][2];
11904
- contextStack.exportValues((_b = {}, _b[functionName] = true, _b), node[1][1][2]);
11905
- var newContext = (_c = {}, _c[functionName] = { value: true }, _c);
11906
- return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, newContext);
11907
- },
11908
- };
11909
- var fnSpecialExpression = {
11781
+ var lambdaSpecialExpression = {
11910
11782
  arity: {},
11911
11783
  evaluate: function (node, contextStack, _a) {
11912
11784
  var _b;
11913
11785
  var builtin = _a.builtin, getUndefinedSymbols = _a.getUndefinedSymbols, evaluateNode = _a.evaluateNode;
11914
11786
  var fn = node[1][1];
11787
+ var docString = node[1][2];
11915
11788
  var evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode);
11916
11789
  var min = evaluatedFunction[0].filter(function (arg) { return arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined; }).length;
11917
11790
  var max = evaluatedFunction[0].some(function (arg) { return arg[0] === bindingTargetTypes.rest; }) ? undefined : evaluatedFunction[0].length;
@@ -11923,8 +11796,9 @@ var fnSpecialExpression = {
11923
11796
  _b.name = undefined,
11924
11797
  _b.evaluatedfunction = evaluatedFunction,
11925
11798
  _b.arity = arity,
11926
- _b.docString = '',
11799
+ _b.docString = docString,
11927
11800
  _b);
11801
+ evaluatedFunction[2].self = { value: litsFunction };
11928
11802
  return litsFunction;
11929
11803
  },
11930
11804
  getUndefinedSymbols: function (node, contextStack, _a) {
@@ -11955,17 +11829,16 @@ function evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evalua
11955
11829
  ];
11956
11830
  return evaluatedFunction;
11957
11831
  }
11958
- function getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode, functionNameContext) {
11832
+ function getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode) {
11959
11833
  var result = new Set();
11960
- var contextStackWithFunctionName = functionNameContext ? contextStack.create(functionNameContext) : contextStack;
11961
- var newContext = {};
11834
+ var newContext = { self: { value: null } };
11962
11835
  fn[0].forEach(function (arg) {
11963
11836
  Object.assign(newContext, getAllBindingTargetNames(arg));
11964
11837
  walkDefaults(arg, function (defaultNode) {
11965
11838
  addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode));
11966
11839
  });
11967
11840
  });
11968
- var newContextStack = contextStackWithFunctionName.create(newContext);
11841
+ var newContextStack = contextStack.create(newContext);
11969
11842
  var overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode);
11970
11843
  addToSet(result, overloadResult);
11971
11844
  return result;
@@ -12052,22 +11925,9 @@ var loopSpecialExpression = {
12052
11925
  var newContextStack = contextStack.create(bindingContext);
12053
11926
  var body = node[1][2];
12054
11927
  var _loop_1 = function () {
12055
- var e_1, _b;
12056
11928
  var result = null;
12057
11929
  try {
12058
- try {
12059
- 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()) {
12060
- var form = body_1_1.value;
12061
- result = evaluateNode(form, newContextStack);
12062
- }
12063
- }
12064
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
12065
- finally {
12066
- try {
12067
- if (body_1_1 && !body_1_1.done && (_b = body_1.return)) _b.call(body_1);
12068
- }
12069
- finally { if (e_1) throw e_1.error; }
12070
- }
11930
+ result = evaluateNode(body, newContextStack);
12071
11931
  }
12072
11932
  catch (error) {
12073
11933
  if (error instanceof RecurSignal) {
@@ -12076,20 +11936,20 @@ var loopSpecialExpression = {
12076
11936
  throw new LitsError("recur expected ".concat(bindingNodes.length, " parameters, got ").concat(valueToString(params_1.length)), node[2]);
12077
11937
  }
12078
11938
  bindingNodes.forEach(function (bindingNode, index) {
12079
- var e_2, _a;
11939
+ var e_1, _a;
12080
11940
  var valueRecord = evalueateBindingNodeValues(bindingNode[1][0], asAny(params_1[index]), function (Node) { return evaluateNode(Node, contextStack); });
12081
11941
  try {
12082
- for (var _b = (e_2 = void 0, __values(Object.entries(valueRecord))), _c = _b.next(); !_c.done; _c = _b.next()) {
11942
+ for (var _b = (e_1 = void 0, __values(Object.entries(valueRecord))), _c = _b.next(); !_c.done; _c = _b.next()) {
12083
11943
  var _d = __read(_c.value, 2), name_1 = _d[0], value = _d[1];
12084
11944
  bindingContext[name_1].value = value;
12085
11945
  }
12086
11946
  }
12087
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
11947
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
12088
11948
  finally {
12089
11949
  try {
12090
11950
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
12091
11951
  }
12092
- finally { if (e_2) throw e_2.error; }
11952
+ finally { if (e_1) throw e_1.error; }
12093
11953
  }
12094
11954
  });
12095
11955
  return "continue";
@@ -12117,7 +11977,7 @@ var loopSpecialExpression = {
12117
11977
  }, {});
12118
11978
  var bindingValueNodes = bindingNodes.map(function (bindingNode) { return bindingNode[1][1]; });
12119
11979
  var bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode);
12120
- var paramsResult = getUndefinedSymbols(node[1][2], contextStack.create(newContext), builtin, evaluateNode);
11980
+ var paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode);
12121
11981
  return joinSets(bindingsResult, paramsResult);
12122
11982
  },
12123
11983
  };
@@ -12512,12 +12372,12 @@ var specialExpressions = [
12512
12372
  condSpecialExpression,
12513
12373
  defSpecialExpression,
12514
12374
  definedSpecialExpression,
12515
- defnSpecialExpression,
12375
+ // defnSpecialExpression,
12516
12376
  doSpecialExpression,
12517
12377
  doseqSpecialExpression,
12518
- fnSpecialExpression,
12378
+ lambdaSpecialExpression,
12519
12379
  forSpecialExpression,
12520
- functionSpecialExpression,
12380
+ // functionSpecialExpression,
12521
12381
  ifSpecialExpression,
12522
12382
  letSpecialExpression,
12523
12383
  loopSpecialExpression,
@@ -12539,6 +12399,53 @@ new Set(specialExpressionKeys);
12539
12399
  // TODO, remove
12540
12400
  // console.log('builtin', [...specialExpressionKeys, ...normalExpressionKeys].length)
12541
12401
 
12402
+ var nonNumberReservedSymbolRecord = {
12403
+ true: true,
12404
+ false: false,
12405
+ null: null,
12406
+ else: null,
12407
+ case: null,
12408
+ each: null,
12409
+ in: null,
12410
+ when: null,
12411
+ while: null,
12412
+ catch: null,
12413
+ function: null,
12414
+ export: null,
12415
+ as: null,
12416
+ then: null,
12417
+ end: null,
12418
+ _: null,
12419
+ };
12420
+ var phi = (1 + Math.sqrt(5)) / 2;
12421
+ var numberReservedSymbolRecord = {
12422
+ 'E': Math.E,
12423
+ '-E': -Math.E,
12424
+ 'ε': Math.E,
12425
+ '-ε': -Math.E,
12426
+ 'PI': Math.PI,
12427
+ '-PI': -Math.PI,
12428
+ 'π': Math.PI,
12429
+ '-π': -Math.PI,
12430
+ 'PHI': phi,
12431
+ '-PHI': -phi,
12432
+ 'φ': phi,
12433
+ '-φ': -phi,
12434
+ 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,
12435
+ '∞': Number.POSITIVE_INFINITY,
12436
+ 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,
12437
+ '-∞': Number.NEGATIVE_INFINITY,
12438
+ 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,
12439
+ 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,
12440
+ 'MAX_VALUE': Number.MAX_VALUE,
12441
+ 'MIN_VALUE': Number.MIN_VALUE,
12442
+ 'NaN': Number.NaN,
12443
+ };
12444
+ var reservedSymbolRecord = __assign(__assign({}, nonNumberReservedSymbolRecord), numberReservedSymbolRecord);
12445
+ function isNumberReservedSymbol(symbol) {
12446
+ return symbol in numberReservedSymbolRecord;
12447
+ }
12448
+
12542
12449
  var functionExecutors = {
12543
12450
  NativeJsFunction: function (fn, params, sourceCodeInfo) {
12544
12451
  var _a;
@@ -12987,6 +12894,9 @@ var ContextStackImpl = /** @class */ (function () {
12987
12894
  if (normalExpressionKeys.includes(name_1)) {
12988
12895
  throw new LitsError("Cannot shadow builtin function \"".concat(name_1, "\""), sourceCodeInfo);
12989
12896
  }
12897
+ if (name_1 === 'self') {
12898
+ throw new LitsError("Cannot shadow builtin value \"".concat(name_1, "\""), sourceCodeInfo);
12899
+ }
12990
12900
  this.globalContext[name_1] = { value: value };
12991
12901
  }
12992
12902
  }
@@ -13016,6 +12926,9 @@ var ContextStackImpl = /** @class */ (function () {
13016
12926
  if (normalExpressionKeys.includes(name_2)) {
13017
12927
  throw new LitsError("Cannot shadow builtin function \"".concat(name_2, "\""), sourceCodeInfo);
13018
12928
  }
12929
+ if (name_2 === 'self') {
12930
+ throw new LitsError("Cannot shadow builtin value \"".concat(name_2, "\""), sourceCodeInfo);
12931
+ }
13019
12932
  currentContext[name_2] = { value: toAny(value) };
13020
12933
  }
13021
12934
  }
@@ -14011,9 +13924,6 @@ var Parser = /** @class */ (function () {
14011
13924
  break;
14012
13925
  }
14013
13926
  }
14014
- else if (isReservedSymbolToken(firstToken, 'function')) {
14015
- return this.parseFunction(firstToken);
14016
- }
14017
13927
  else if (isReservedSymbolToken(firstToken, 'export')) {
14018
13928
  if (!moduleScope) {
14019
13929
  throw new LitsError('export is only allowed in module scope', firstToken[2]);
@@ -14306,9 +14216,8 @@ var Parser = /** @class */ (function () {
14306
14216
  var _c = __read(params, 1), param = _c[0];
14307
14217
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param]], symbol[2]);
14308
14218
  }
14309
- case specialExpressionTypes['0_fn']:
14219
+ case specialExpressionTypes['0_lambda']:
14310
14220
  case specialExpressionTypes['0_def']:
14311
- case specialExpressionTypes['0_defn']:
14312
14221
  throw new LitsError("".concat(type, " is not allowed"), symbol[2]);
14313
14222
  /* v8 ignore next 2 */
14314
14223
  default:
@@ -14335,11 +14244,27 @@ var Parser = /** @class */ (function () {
14335
14244
  return null;
14336
14245
  }
14337
14246
  this.advance();
14338
- var body = this.parseExpression();
14339
- return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_fn'], [
14247
+ var nodes = void 0;
14248
+ var docString = '';
14249
+ if (isLBraceToken(this.peek())) {
14250
+ var parsedBlock = this.parseBlock(true);
14251
+ docString = parsedBlock[1];
14252
+ nodes = parsedBlock[0][1][1];
14253
+ }
14254
+ else {
14255
+ nodes = [this.parseExpression()];
14256
+ }
14257
+ return withSourceCodeInfo([
14258
+ NodeTypes.SpecialExpression,
14259
+ [
14260
+ specialExpressionTypes['0_lambda'],
14261
+ [
14340
14262
  functionArguments,
14341
- [body],
14342
- ]]], firstToken[2]);
14263
+ nodes,
14264
+ ],
14265
+ docString,
14266
+ ],
14267
+ ], firstToken[2]);
14343
14268
  }
14344
14269
  catch (_a) {
14345
14270
  return null;
@@ -14388,7 +14313,16 @@ var Parser = /** @class */ (function () {
14388
14313
  var firstToken = this.asToken(this.peek());
14389
14314
  this.advance();
14390
14315
  var startPos = this.parseState.position;
14391
- var exprNode = this.parseExpression();
14316
+ var nodes;
14317
+ var docString = '';
14318
+ if (isLBraceToken(this.peek())) {
14319
+ var parsedBlock = this.parseBlock(true);
14320
+ docString = parsedBlock[1];
14321
+ nodes = parsedBlock[0][1][1];
14322
+ }
14323
+ else {
14324
+ nodes = [this.parseExpression()];
14325
+ }
14392
14326
  var endPos = this.parseState.position - 1;
14393
14327
  var arity = 0;
14394
14328
  var dollar1 = 'NOT_SET'; // referring to argument bindings. $ = NAKED, $1, $2, $3, etc = WITH_1
@@ -14419,10 +14353,10 @@ var Parser = /** @class */ (function () {
14419
14353
  functionArguments.push(withSourceCodeInfo([bindingTargetTypes.symbol, [[NodeTypes.UserDefinedSymbol, "$".concat(i)], undefined]], firstToken[2]));
14420
14354
  }
14421
14355
  }
14422
- var node = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_fn'], [
14356
+ var node = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_lambda'], [
14423
14357
  functionArguments,
14424
- [exprNode],
14425
- ]]], firstToken[2]);
14358
+ nodes,
14359
+ ], docString]], firstToken[2]);
14426
14360
  return node;
14427
14361
  };
14428
14362
  Parser.prototype.parseOptionalDefaulValue = function () {
@@ -14613,21 +14547,10 @@ var Parser = /** @class */ (function () {
14613
14547
  }
14614
14548
  assertRParenToken(token);
14615
14549
  this.advance();
14616
- assertLBraceToken(this.peek());
14550
+ assertOperatorToken(this.peek(), '->');
14617
14551
  this.advance();
14618
- var params = [];
14619
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14620
- params.push(this.parseExpression());
14621
- if (isOperatorToken(this.peek(), ';')) {
14622
- this.advance();
14623
- }
14624
- else if (!isRBraceToken(this.peek())) {
14625
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14626
- }
14627
- }
14628
- assertRBraceToken(this.peek());
14629
- this.advance();
14630
- return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.loop, bindingNodes, params]], firstToken[2]);
14552
+ var expression = this.parseExpression();
14553
+ return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.loop, bindingNodes, expression]], firstToken[2]);
14631
14554
  };
14632
14555
  Parser.prototype.parseTry = function (token) {
14633
14556
  this.advance();
@@ -14658,7 +14581,7 @@ var Parser = /** @class */ (function () {
14658
14581
  throw new LitsError('Duplicate binding', loopBinding[0][2]);
14659
14582
  }
14660
14583
  forLoopBindings.push(loopBinding);
14661
- if (isOperatorToken(this_1.peek(), ';')) {
14584
+ if (isOperatorToken(this_1.peek(), ',')) {
14662
14585
  this_1.advance();
14663
14586
  }
14664
14587
  };
@@ -14668,6 +14591,8 @@ var Parser = /** @class */ (function () {
14668
14591
  }
14669
14592
  assertRParenToken(this.peek());
14670
14593
  this.advance();
14594
+ assertOperatorToken(this.peek(), '->');
14595
+ this.advance();
14671
14596
  var expression = this.parseExpression();
14672
14597
  return isDoseq
14673
14598
  ? withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.doseq, forLoopBindings, expression]], firstToken[2])
@@ -14677,20 +14602,7 @@ var Parser = /** @class */ (function () {
14677
14602
  var bindingNode = this.parseBinding();
14678
14603
  var modifiers = [];
14679
14604
  var token = this.asToken(this.peek());
14680
- if (!isRParenToken(token) && !isOperatorToken(this.peek(), ';') && !isOperatorToken(token, ',')) {
14681
- throw new LitsError('Expected ")", ";" or ","', token[2]);
14682
- }
14683
- if (isOperatorToken(token, ',')) {
14684
- this.advance();
14685
- token = this.asToken(this.peek());
14686
- }
14687
- if (!isSymbolToken(token, 'let')
14688
- && !isReservedSymbolToken(token, 'when')
14689
- && !isReservedSymbolToken(token, 'while')
14690
- && !isRParenToken(token)
14691
- && !isOperatorToken(token, ';')) {
14692
- throw new LitsError('Expected symbol ";", ")", let, when or while', token[2]);
14693
- }
14605
+ this.assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while']);
14694
14606
  var letBindings = [];
14695
14607
  if (token[1] === 'let') {
14696
14608
  modifiers.push('&let');
@@ -14703,12 +14615,7 @@ var Parser = /** @class */ (function () {
14703
14615
  }
14704
14616
  letBindings.push(letNode[1][1]);
14705
14617
  token = this_2.asToken(this_2.peek());
14706
- if (!isRParenToken(token) && !isOperatorToken(token, ';') && !isOperatorToken(token, ',')) {
14707
- throw new LitsError('Expected ")", ";" or ","', token[2]);
14708
- }
14709
- if (isOperatorToken(token, ',')) {
14710
- this_2.advance();
14711
- }
14618
+ this_2.assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while']);
14712
14619
  token = this_2.asToken(this_2.peek());
14713
14620
  };
14714
14621
  var this_2 = this;
@@ -14722,33 +14629,57 @@ var Parser = /** @class */ (function () {
14722
14629
  || isReservedSymbolToken(token, 'while')) {
14723
14630
  this.advance();
14724
14631
  if (token[1] === 'when') {
14725
- if (modifiers.includes('&when')) {
14726
- throw new LitsError('Multiple when modifiers in for loop', token[2]);
14727
- }
14728
14632
  modifiers.push('&when');
14729
14633
  whenNode = this.parseExpression();
14730
14634
  }
14731
14635
  else {
14732
- if (modifiers.includes('&while')) {
14733
- throw new LitsError('Multiple while modifiers in for loop', token[2]);
14734
- }
14735
14636
  modifiers.push('&while');
14736
14637
  whileNode = this.parseExpression();
14737
14638
  }
14738
14639
  token = this.asToken(this.peek());
14739
- if (!isRParenToken(token) && !isOperatorToken(token, ';') && !isOperatorToken(token, ',')) {
14740
- throw new LitsError('Expected do or comma', token[2]);
14741
- }
14742
- if (isOperatorToken(token, ',')) {
14743
- this.advance();
14744
- }
14640
+ var symbols = modifiers.includes('&when') && modifiers.includes('&while')
14641
+ ? []
14642
+ : modifiers.includes('&when')
14643
+ ? ['while']
14644
+ : ['when'];
14645
+ this.assertInternalLoopBindingDelimiter(token, symbols);
14745
14646
  token = this.asToken(this.peek());
14746
14647
  }
14747
- if (!isRParenToken(token) && !isOperatorToken(token, ';')) {
14748
- throw new LitsError('Expected "{" or ";"', token[2]);
14749
- }
14648
+ this.assertInternalLoopBindingDelimiter(token, []);
14750
14649
  return [bindingNode, letBindings, whenNode, whileNode];
14751
14650
  };
14651
+ Parser.prototype.assertInternalLoopBindingDelimiter = function (token, symbols) {
14652
+ if (!this.isInternalLoopBindingDelimiter(token, symbols)) {
14653
+ var symbolsString = "".concat(__spreadArray(__spreadArray([], __read(symbols), false), [','], false).map(function (symbol) { return "\"".concat(symbol, "\""); }).join(', '), " or \")\"");
14654
+ throw new LitsError("Expected symbol ".concat(symbolsString), token[2]);
14655
+ }
14656
+ };
14657
+ Parser.prototype.isInternalLoopBindingDelimiter = function (token, symbols) {
14658
+ var e_1, _a;
14659
+ // end of loop binding
14660
+ if (isOperatorToken(token, ',') || isRParenToken(token)) {
14661
+ return true;
14662
+ }
14663
+ try {
14664
+ for (var symbols_1 = __values(symbols), symbols_1_1 = symbols_1.next(); !symbols_1_1.done; symbols_1_1 = symbols_1.next()) {
14665
+ var symbol = symbols_1_1.value;
14666
+ if (symbol === 'let' && isSymbolToken(token, 'let')) {
14667
+ return true;
14668
+ }
14669
+ if (['when', 'while'].includes(symbol) && isReservedSymbolToken(token, symbol)) {
14670
+ return true;
14671
+ }
14672
+ }
14673
+ }
14674
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
14675
+ finally {
14676
+ try {
14677
+ if (symbols_1_1 && !symbols_1_1.done && (_a = symbols_1.return)) _a.call(symbols_1);
14678
+ }
14679
+ finally { if (e_1) throw e_1.error; }
14680
+ }
14681
+ return false;
14682
+ };
14752
14683
  Parser.prototype.parseBinding = function () {
14753
14684
  var firstToken = asSymbolToken(this.peek());
14754
14685
  var name = asUserDefinedSymbolNode(this.parseSymbol());
@@ -14767,10 +14698,8 @@ var Parser = /** @class */ (function () {
14767
14698
  Parser.prototype.parseIfOrUnless = function (token) {
14768
14699
  var isUnless = token[1] === 'unless';
14769
14700
  this.advance();
14770
- assertLParenToken(this.peek());
14771
- this.advance();
14772
14701
  var condition = this.parseExpression();
14773
- assertRParenToken(this.peek());
14702
+ assertReservedSymbolToken(this.peek(), 'then');
14774
14703
  this.advance();
14775
14704
  var thenExpression = this.parseExpression();
14776
14705
  var elseExpression;
@@ -14783,100 +14712,74 @@ var Parser = /** @class */ (function () {
14783
14712
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [condition, thenExpression, elseExpression]]], token[2]);
14784
14713
  };
14785
14714
  Parser.prototype.parseCond = function (token) {
14786
- this.advance();
14787
- assertLBraceToken(this.peek());
14788
14715
  this.advance();
14789
14716
  var params = [];
14790
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14717
+ while (!this.isAtEnd() && !isReservedSymbolToken(this.peek(), 'end')) {
14791
14718
  assertReservedSymbolToken(this.peek(), 'case');
14792
14719
  this.advance();
14793
14720
  var caseExpression = this.parseExpression();
14794
- assertOperatorToken(this.peek(), ':');
14721
+ assertReservedSymbolToken(this.peek(), 'then');
14795
14722
  this.advance();
14796
14723
  var expressions = [];
14797
14724
  while (!this.isAtEnd()
14798
14725
  && !isReservedSymbolToken(this.peek(), 'case')
14799
- && !isRBraceToken(this.peek())) {
14726
+ && !isReservedSymbolToken(this.peek(), 'end')) {
14800
14727
  expressions.push(this.parseExpression());
14801
14728
  if (isOperatorToken(this.peek(), ';')) {
14802
14729
  this.advance();
14803
14730
  }
14804
- else if (!isReservedSymbolToken(this.peek(), 'case') && !isRBraceToken(this.peek())) {
14805
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14731
+ else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14732
+ throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
14806
14733
  }
14807
14734
  }
14808
14735
  var thenExpression = expressions.length === 1
14809
14736
  ? expressions[0]
14810
14737
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
14811
14738
  params.push([caseExpression, thenExpression]);
14812
- if (isRBraceToken(this.peek())) {
14739
+ if (isReservedSymbolToken(this.peek(), 'end')) {
14813
14740
  break;
14814
14741
  }
14815
14742
  assertReservedSymbolToken(this.peek(), 'case');
14816
14743
  }
14817
- assertRBraceToken(this.peek());
14744
+ assertReservedSymbolToken(this.peek());
14818
14745
  this.advance();
14819
14746
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.cond, params]], token[2]);
14820
14747
  };
14821
14748
  Parser.prototype.parseSwitch = function (token) {
14822
- this.advance();
14823
- assertLParenToken(this.peek());
14824
14749
  this.advance();
14825
14750
  var valueExpression = this.parseExpression();
14826
- assertRParenToken(this.peek());
14827
- this.advance();
14828
- assertLBraceToken(this.peek());
14829
- this.advance();
14830
14751
  var params = [];
14831
- while (!this.isAtEnd() && !isRBraceToken(this.peek())) {
14752
+ while (!this.isAtEnd() && !isReservedSymbolToken(this.peek(), 'end')) {
14832
14753
  assertReservedSymbolToken(this.peek(), 'case');
14833
14754
  this.advance();
14834
14755
  var caseExpression = this.parseExpression();
14835
- assertOperatorToken(this.peek(), ':');
14756
+ assertReservedSymbolToken(this.peek(), 'then');
14836
14757
  this.advance();
14837
14758
  var expressions = [];
14838
14759
  while (!this.isAtEnd()
14839
14760
  && !isReservedSymbolToken(this.peek(), 'case')
14840
- && !isRBraceToken(this.peek())) {
14761
+ && !isReservedSymbolToken(this.peek(), 'end')) {
14841
14762
  expressions.push(this.parseExpression());
14842
14763
  if (isOperatorToken(this.peek(), ';')) {
14843
14764
  this.advance();
14844
14765
  }
14845
- else if (!isReservedSymbolToken(this.peek(), 'case') && !isRBraceToken(this.peek())) {
14846
- throw new LitsError('Expected ;', this.peekSourceCodeInfo());
14766
+ else if (!isReservedSymbolToken(this.peek(), 'case') && !isReservedSymbolToken(this.peek(), 'end')) {
14767
+ throw new LitsError('Expected case or end', this.peekSourceCodeInfo());
14847
14768
  }
14848
14769
  }
14849
14770
  var thenExpression = expressions.length === 1
14850
14771
  ? expressions[0]
14851
14772
  : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]);
14852
14773
  params.push([caseExpression, thenExpression]);
14853
- if (isRBraceToken(this.peek())) {
14774
+ if (isReservedSymbolToken(this.peek(), 'end')) {
14854
14775
  break;
14855
14776
  }
14856
14777
  assertReservedSymbolToken(this.peek(), 'case');
14857
14778
  }
14858
- assertRBraceToken(this.peek());
14779
+ assertReservedSymbolToken(this.peek(), 'end');
14859
14780
  this.advance();
14860
14781
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.switch, valueExpression, params]], token[2]);
14861
14782
  };
14862
- Parser.prototype.parseFunction = function (token) {
14863
- this.advance();
14864
- var symbol = this.parseSymbol();
14865
- var functionArguments = this.parseFunctionArguments();
14866
- var _a = __read(this.parseBlock(true), 2), block = _a[0], docString = _a[1];
14867
- return withSourceCodeInfo([
14868
- NodeTypes.SpecialExpression,
14869
- [
14870
- specialExpressionTypes.function,
14871
- symbol,
14872
- [
14873
- functionArguments,
14874
- block[1][1],
14875
- ],
14876
- docString,
14877
- ],
14878
- ], token[2]);
14879
- };
14880
14783
  Parser.prototype.isAtEnd = function () {
14881
14784
  return this.parseState.position >= this.tokenStream.tokens.length;
14882
14785
  };
@@ -14889,7 +14792,7 @@ var Parser = /** @class */ (function () {
14889
14792
  return [';', ',', ':'].includes(token[1]);
14890
14793
  }
14891
14794
  if (isReservedSymbolToken(token)) {
14892
- return ['else', 'when', 'while', 'case', 'catch'].includes(token[1]);
14795
+ return ['else', 'when', 'while', 'case', 'catch', 'let', 'then'].includes(token[1]);
14893
14796
  }
14894
14797
  return false;
14895
14798
  };
@@ -14900,13 +14803,8 @@ var Parser = /** @class */ (function () {
14900
14803
  var letNode = this.parseLet(asSymbolToken(token));
14901
14804
  return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_def'], letNode[1][1]]], exportToken[2]);
14902
14805
  }
14903
- else if (isReservedSymbolToken(token, 'function')) {
14904
- var functionNode = this.parseFunction(token);
14905
- functionNode[1][0] = specialExpressionTypes['0_defn'];
14906
- return functionNode;
14907
- }
14908
14806
  else {
14909
- throw new LitsError('Expected let or function', this.peekSourceCodeInfo());
14807
+ throw new LitsError('Expected let', this.peekSourceCodeInfo());
14910
14808
  }
14911
14809
  };
14912
14810
  Parser.prototype.stringToSymbolNode = function (value, sourceCodeInfo) {
@@ -15096,7 +14994,7 @@ var AutoCompleter = /** @class */ (function () {
15096
14994
  };
15097
14995
  AutoCompleter.prototype.generateSuggestions = function (params) {
15098
14996
  var _this = this;
15099
- var blacklist = new Set(['0_def', '0_defn', '0_fn']);
14997
+ var blacklist = new Set(['0_def', '0_defn', '0_lambda']);
15100
14998
  var startsWithCaseSensitive = this.generateWithPredicate(params, function (suggestion) {
15101
14999
  return !blacklist.has(suggestion) && suggestion.startsWith(_this.searchString);
15102
15000
  });
@@ -15722,7 +15620,7 @@ var arrayReference = {
15722
15620
  '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',
15723
15621
  'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',
15724
15622
  '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',
15725
- "\nfunction foo(n) {\n [n - 1, n, n + 1]\n};\n[1, 2, 3] mapcat foo",
15623
+ "\nlet foo = (n) -> {\n [n - 1, n, n + 1]\n};\n[1, 2, 3] mapcat foo",
15726
15624
  "\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
15727
15625
  ],
15728
15626
  },
@@ -20453,7 +20351,7 @@ var metaReference = {
20453
20351
  description: 'Returns documentation string of the $fun.',
20454
20352
  examples: [
20455
20353
  'doc(+)',
20456
- "\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)",
20354
+ "\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)",
20457
20355
  ],
20458
20356
  },
20459
20357
  arity: {
@@ -20474,8 +20372,8 @@ var metaReference = {
20474
20372
  examples: [
20475
20373
  'arity(+)',
20476
20374
  'arity(defined?)',
20477
- "\nfunction add(x, y = 0) {\n x + y;\n};\n\narity(add)",
20478
- "\nfunction foo(k, ...x) {\n k + x;\n};\n arity(foo)",
20375
+ "\nlet add = (x, y = 0) -> {\n x + y;\n};\n\narity(add)",
20376
+ "\nlet foo = (k, ...x) -> {\n k + x;\n};\n arity(foo)",
20479
20377
  ],
20480
20378
  },
20481
20379
  };
@@ -26355,8 +26253,8 @@ var sequenceReference = {
26355
26253
  examples: [
26356
26254
  '[3, 1, 2] sort (a, b) -> b - a',
26357
26255
  'sort([3, 1, 2])',
26358
- "\nsort(\n [3, 1, 2],\n (a, b) -> cond { case a < b: -1 case a > b: 1 case true: -1 }\n)",
26359
- "\nsort(\n [3, 1, 2],\n (a, b) -> cond { case a > b: -1 case a < b: 1 case true: -1 }\n)",
26256
+ "\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)",
26257
+ "\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)",
26360
26258
  ],
26361
26259
  },
26362
26260
  'sort-by': {
@@ -26833,26 +26731,6 @@ var specialExpressionsReference = {
26833
26731
  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.",
26834
26732
  examples: ["\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)"],
26835
26733
  },
26836
- 'function': {
26837
- title: 'function',
26838
- category: 'Special expression',
26839
- customVariants: ['function name(...arg) { body }'],
26840
- details: [
26841
- ['name', 'symbol', 'The name of the function.'],
26842
- ['arg', '[...]arg-name [= value]', 'Arguments of the function.'],
26843
- ['...', 'rest-symbol', 'Optional. The rest argument of the function.'],
26844
- ['arg-name', 'symbol', 'The name of the argument.'],
26845
- ['value', 'any', 'Optional. The default value of the argument.'],
26846
- ['let-binding', 'symbol', 'Optional. The let bindings of the function.'],
26847
- ['body', 'one or more expressions', 'The body of the function.'],
26848
- ],
26849
- description: 'Creates a named function. When called, evaluation of the last expression in the body is returned.',
26850
- examples: [
26851
- "\nfunction hyp (a, b) {\n sqrt(a * a + b * b)\n};\n\nhyp(3, 4)",
26852
- "\nfunction sumOfSquares(...s) {\n apply(\n +,\n map(s, -> $ ^ 2)\n )\n};\n\nsumOfSquares(1, 2, 3, 4, 5)",
26853
- "\nfunction withOptional(a, b = 42) {\n a + b\n};\n\nwrite!(withOptional(1), withOptional(1, 2))",
26854
- ],
26855
- },
26856
26734
  'try': {
26857
26735
  title: 'try',
26858
26736
  category: 'Special expression',
@@ -26892,7 +26770,7 @@ var specialExpressionsReference = {
26892
26770
  'if': {
26893
26771
  title: 'if',
26894
26772
  category: 'Special expression',
26895
- customVariants: ['if (test) true-expr else false-expr', 'if (test) true-expr'],
26773
+ customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],
26896
26774
  details: [
26897
26775
  ['test', 'expression', 'The condition to test.'],
26898
26776
  ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],
@@ -26900,16 +26778,16 @@ var specialExpressionsReference = {
26900
26778
  ],
26901
26779
  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.',
26902
26780
  examples: [
26903
- "\nif (true) {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26904
- 'if (false) write!("TRUE") else write!("FALSE")',
26905
- 'if (true) write!("TRUE")',
26906
- 'if (false) write!("TRUE")',
26781
+ "\nif true then {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26782
+ 'if false then write!("TRUE") else write!("FALSE")',
26783
+ 'if true then write!("TRUE")',
26784
+ 'if false then write!("TRUE")',
26907
26785
  ],
26908
26786
  },
26909
26787
  'unless': {
26910
26788
  title: 'unless',
26911
26789
  category: 'Special expression',
26912
- customVariants: ['unless (test) true-expr else false-expr end', 'unless test true-expr end'],
26790
+ customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],
26913
26791
  details: [
26914
26792
  ['test', 'expression', 'The condition to test.'],
26915
26793
  ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],
@@ -26917,16 +26795,16 @@ var specialExpressionsReference = {
26917
26795
  ],
26918
26796
  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.',
26919
26797
  examples: [
26920
- "\nunless (true) {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26921
- 'unless (false) write!("TRUE") else write!("FALSE")',
26922
- 'unless (true) write!("TRUE")',
26923
- 'unless (false) write!("TRUE")',
26798
+ "\nunless true then {\n write!(\"TRUE\")\n} else {\n write!(\"FALSE\")\n}",
26799
+ 'unless false then write!("TRUE") else write!("FALSE")',
26800
+ 'unless true then write!("TRUE")',
26801
+ 'unless false then write!("TRUE")',
26924
26802
  ],
26925
26803
  },
26926
26804
  'cond': {
26927
26805
  title: 'cond',
26928
26806
  category: 'Special expression',
26929
- customVariants: ['cond { cond-branch cond-branch ... }'],
26807
+ customVariants: ['cond cond-branch cond-branch ... end'],
26930
26808
  details: [
26931
26809
  ['cond-branch', 'case test then body', 'A branch of the cond expression.'],
26932
26810
  ['test', 'expression', 'The condition to test.'],
@@ -26934,15 +26812,15 @@ var specialExpressionsReference = {
26934
26812
  ],
26935
26813
  description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',
26936
26814
  examples: [
26937
- "\ncond {\n case false: write!(\"FALSE\")\n case true: write!(\"TRUE\")\n}",
26938
- "\ncond {\n case false: write!(\"FALSE\")\n case null: write!(\"null\")\n} ?? write!(\"TRUE\")",
26939
- "\ncond {\n case false: write!(\"FALSE\")\n case null: write!(\"null\")\n} ?? write!(\"TRUE\")",
26815
+ "\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend",
26816
+ "\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")",
26817
+ "\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")",
26940
26818
  ],
26941
26819
  },
26942
26820
  'switch': {
26943
26821
  title: 'switch',
26944
26822
  category: 'Special expression',
26945
- customVariants: ['switch (value) { switch-branch switch-branch ... }'],
26823
+ customVariants: ['switch value switch-branch switch-branch ... end'],
26946
26824
  details: [
26947
26825
  ['value', 'any', 'The value to test.'],
26948
26826
  ['switch-branch', 'case test then body', 'A branch of the switch expression.'],
@@ -26951,9 +26829,9 @@ var specialExpressionsReference = {
26951
26829
  ],
26952
26830
  description: 'Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.',
26953
26831
  examples: [
26954
- "\nswitch (1) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
26955
- "\nswitch (2) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
26956
- "\nswitch (3) {\n case 1: write!(\"One\")\n case 2: write!(\"Two\")\n}",
26832
+ "\nswitch 1\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
26833
+ "\nswitch 2\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
26834
+ "\nswitch 3\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend",
26957
26835
  ],
26958
26836
  },
26959
26837
  'block': {
@@ -26974,9 +26852,9 @@ var specialExpressionsReference = {
26974
26852
  customVariants: ['recur(...recur-args)'],
26975
26853
  description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',
26976
26854
  examples: [
26977
- "\nfunction foo(n) {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n};\nfoo(3)",
26978
- "\n(n -> {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n})(3)",
26979
- "\nloop (n = 3) {\n write!(n);\n if (!(zero?(n))) {\n recur(n - 1)\n }\n}",
26855
+ "\nlet foo = (n) -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n};\nfoo(3)",
26856
+ "\n(n -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n})(3)",
26857
+ "\nloop (n = 3) -> {\n write!(n);\n if !(zero?(n)) then {\n recur(n - 1)\n }\n}",
26980
26858
  ],
26981
26859
  },
26982
26860
  };