tla-ts 0.0.8-dev.d9bffda → 0.0.9-dev.0dd11f695

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.
Files changed (119) hide show
  1. package/README.md +30 -0
  2. package/dist/compile.cjs +23 -0
  3. package/dist/compile.js +23 -0
  4. package/dist/deciders.cjs +15 -15
  5. package/dist/deciders.js +40 -40
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +80 -10
  8. package/dist/index.d.ts +80 -10
  9. package/dist/index.js +1 -1
  10. package/dist/parallel-worker.cjs +1 -1
  11. package/dist/parallel-worker.js +1 -1
  12. package/dist/prove-worker.cjs +1 -1
  13. package/dist/prove-worker.js +1 -1
  14. package/dist/prove.cjs +116 -36
  15. package/dist/prove.js +116 -36
  16. package/dist/run.cjs +143 -31
  17. package/dist/run.js +143 -31
  18. package/dist/tlapm.cjs +2 -2
  19. package/dist/tlapm.js +1 -1
  20. package/dist/transfer.cjs +128 -103
  21. package/dist/transfer.js +128 -103
  22. package/dist/worker.cjs +7 -7
  23. package/dist/worker.js +7 -7
  24. package/package.json +3 -1
  25. package/src/ast.ts +7 -21
  26. package/src/bags.ts +99 -99
  27. package/src/builtins.ts +44 -75
  28. package/src/bundled-modules.ts +1 -8
  29. package/src/check.ts +605 -311
  30. package/src/cli/options.ts +12 -3
  31. package/src/cli/run.ts +2 -2
  32. package/src/cli/runtime-invariants.ts +135 -0
  33. package/src/cli/shared.ts +20 -9
  34. package/src/cli/tlc-arguments.ts +646 -0
  35. package/src/cli/tlc-usage.ts +362 -0
  36. package/src/cli/tlc.ts +571 -185
  37. package/src/cli/typescript.ts +26 -0
  38. package/src/cli/xml-exporter.ts +4 -10
  39. package/src/codegen.ts +190 -46
  40. package/src/config.ts +101 -68
  41. package/src/coverage.ts +855 -0
  42. package/src/dependencies.ts +20 -28
  43. package/src/dfid.ts +636 -0
  44. package/src/environment.ts +266 -98
  45. package/src/errors.ts +142 -45
  46. package/src/evaluate.ts +632 -298
  47. package/src/exit-codes.ts +37 -1
  48. package/src/index.ts +3 -0
  49. package/src/instances.ts +85 -9
  50. package/src/java-overrides.ts +2 -12
  51. package/src/json-reader.ts +456 -0
  52. package/src/json.ts +262 -139
  53. package/src/levels.ts +2 -3
  54. package/src/lexer.ts +17 -26
  55. package/src/liveness-checker.ts +10 -18
  56. package/src/liveness.ts +121 -49
  57. package/src/parallel-worker.ts +14 -10
  58. package/src/parallel.ts +41 -17
  59. package/src/parser.ts +436 -90
  60. package/src/pcal/ast.ts +7 -28
  61. package/src/pcal/parse.ts +11 -39
  62. package/src/pcal/tokenize.ts +4 -20
  63. package/src/pcal/translate.ts +10 -42
  64. package/src/pcal/validate.ts +3 -21
  65. package/src/pretty-print.ts +1 -2
  66. package/src/prover/smt/solver/solver.ts +31 -27
  67. package/src/randomization.ts +84 -35
  68. package/src/resolve.ts +18 -60
  69. package/src/runtime.ts +11 -4
  70. package/src/sany/builtins.ts +3 -4
  71. package/src/sany/generator.ts +128 -176
  72. package/src/sany/levels.ts +6 -30
  73. package/src/sany/lexer.ts +7 -23
  74. package/src/sany/linter.ts +31 -29
  75. package/src/sany/modules.ts +1 -5
  76. package/src/sany/nodes.ts +4 -28
  77. package/src/sany/parse-error.ts +44 -100
  78. package/src/sany/report.ts +25 -40
  79. package/src/sany/selectors.ts +8 -22
  80. package/src/sany/source.ts +8 -15
  81. package/src/sany/xml.ts +11 -42
  82. package/src/search.ts +547 -144
  83. package/src/simulate.ts +694 -0
  84. package/src/spec-description.ts +166 -48
  85. package/src/standard-definitions.ts +2 -3
  86. package/src/standard-modules.ts +264 -68
  87. package/src/state-graph.ts +51 -18
  88. package/src/subexpressions.ts +31 -5
  89. package/src/successors.ts +267 -77
  90. package/src/symmetry.ts +31 -8
  91. package/src/tableau.ts +1 -2
  92. package/src/tlc/fingerprint.ts +183 -61
  93. package/src/tlc/jar-data.ts +113 -6
  94. package/src/tlc/messages.ts +122 -37
  95. package/src/tlc/order.ts +33 -38
  96. package/src/tlc/random.ts +16 -16
  97. package/src/tlc/replay.ts +563 -211
  98. package/src/tlc/summary.ts +2 -4
  99. package/src/tlc/tlc-operators.ts +81 -36
  100. package/src/tlc/tlcext-operators.ts +138 -117
  101. package/src/tlc/trace-spec.ts +273 -0
  102. package/src/tlc/value-stream.ts +143 -0
  103. package/src/tlc/version.ts +2 -4
  104. package/src/typescript/actions.ts +494 -0
  105. package/src/typescript/collections.ts +615 -0
  106. package/src/typescript/compile.ts +70 -0
  107. package/src/typescript/context.ts +106 -0
  108. package/src/typescript/emit.ts +122 -0
  109. package/src/typescript/expressions.ts +508 -0
  110. package/src/typescript/formula.ts +160 -0
  111. package/src/typescript/functions.ts +295 -0
  112. package/src/typescript/model.ts +164 -0
  113. package/src/typescript/names.ts +116 -0
  114. package/src/typescript/program.ts +51 -0
  115. package/src/typescript/properties.ts +148 -0
  116. package/src/typescript/scope.ts +117 -0
  117. package/src/typescript/steps.ts +175 -0
  118. package/src/typescript/types.ts +178 -0
  119. package/src/values.ts +832 -255
package/src/parser.ts CHANGED
@@ -35,8 +35,6 @@ interface InfixOperator extends Precedence {
35
35
  isAssociative: boolean;
36
36
  }
37
37
 
38
- // TLAplusParser.lastOp, the operator parsed last, and the operator an operand being parsed follows
39
- // in its expression.
40
38
  interface OperatorContext {
41
39
  last?: Precedence;
42
40
  preceding?: Precedence;
@@ -154,9 +152,10 @@ const NEGATION_PRECEDENCE = 12;
154
152
 
155
153
  const POSTFIX_OPERATORS = new Set(["^+", "^*", "^#"]);
156
154
 
155
+ const DEFINABLE_POSTFIX_OPERATORS = new Set([...POSTFIX_OPERATORS, "'"]);
156
+
157
157
  const PREFIX_OPERATOR_REFERENCES = new Set(["-", "~", "-."]);
158
158
 
159
- // The prefix operators SANY reads in a definition's left-hand side, built-in ones included.
160
159
  const DEFINABLE_PREFIX_OPERATORS = new Set([
161
160
  "-.",
162
161
  "~",
@@ -193,8 +192,7 @@ const OPERATOR_ARGUMENTS = new Set([
193
192
  "UNCHANGED",
194
193
  "[]",
195
194
  "<>",
196
- "'",
197
- ...POSTFIX_OPERATORS,
195
+ ...DEFINABLE_POSTFIX_OPERATORS,
198
196
  ]);
199
197
 
200
198
  const SELECTOR_SYMBOLS = new Set(["<<", ">>", ":", "@", "("]);
@@ -259,6 +257,77 @@ const TLAPM_PUNCTUATION = new Set([
259
257
 
260
258
  const UNNAMED_STEP_LABELS = new Set(["", "*", "-"]);
261
259
 
260
+ interface Point {
261
+ line: number;
262
+ column: number;
263
+ }
264
+
265
+ // A location as tlapm's Loc.locus has it, with stop just past the end.
266
+ interface Span {
267
+ start: Point;
268
+ stop: Point;
269
+ }
270
+
271
+ // tlapm reads a proof as leaf proofs and steps without their proofs, then nests them. first is the
272
+ // index of the first token, before any PROOF.
273
+ type Preproof =
274
+ | { kind: "Leaf"; proof: Proof; span: Span; first: number; end: number }
275
+ | {
276
+ kind: "Step";
277
+ token: Token;
278
+ isProof: boolean;
279
+ body: StepBody;
280
+ head: SourceRange;
281
+ statement: SourceRange;
282
+ span: Span;
283
+ first: number;
284
+ start: number;
285
+ end: number;
286
+ };
287
+
288
+ interface NestedProof {
289
+ proof: Proof | undefined;
290
+ span: Span;
291
+ next: number;
292
+ end: number | undefined;
293
+ }
294
+
295
+ interface NestedSteps {
296
+ level: number;
297
+ steps: ProofStep[];
298
+ span: Span;
299
+ next: number;
300
+ end: number;
301
+ }
302
+
303
+ const LEAF_NAMES: Record<string, string> = {
304
+ Obvious: "n OBVIOUS",
305
+ Omitted: "n OMITTED",
306
+ By: " BY",
307
+ };
308
+
309
+ const comparePoints = (left: Point, right: Point) =>
310
+ left.line - right.line || left.column - right.column;
311
+
312
+ const mergeSpans = (left: Span, right: Span): Span => ({
313
+ start: comparePoints(left.start, right.start) <= 0 ? left.start : right.start,
314
+ stop: comparePoints(left.stop, right.stop) >= 0 ? left.stop : right.stop,
315
+ });
316
+
317
+ const getSpan = (range: SourceRange): Span => ({
318
+ start: { line: range.start.line, column: range.start.column },
319
+ stop: { line: range.end.line, column: range.end.column + 1 },
320
+ });
321
+
322
+ const createProofError = (message: string, span: Span, exception = "Proof.Parser") =>
323
+ new TlaSyntaxError(message, undefined, {
324
+ reason: message,
325
+ line: span.start.line,
326
+ column: span.start.column,
327
+ isEnd: false,
328
+ proof: { stop: span.stop, exception },
329
+ });
330
+
262
331
  const FACT_KEYWORDS = new Set([
263
332
  "CASE",
264
333
  "CHOOSE",
@@ -297,7 +366,6 @@ const BUILTIN_CONSTANTS = new Set(["TRUE", "FALSE", "BOOLEAN", "STRING"]);
297
366
 
298
367
  const NO_OFFSIDE = -1;
299
368
 
300
- // A SANY InfixExpr or PostfixExpr.
301
369
  const isOperatorExpression = (expression: Expression) =>
302
370
  expression.kind === "Prime" ||
303
371
  expression.kind === "Product" ||
@@ -307,6 +375,12 @@ const isOperatorExpression = (expression: Expression) =>
307
375
  ? INFIX_OPERATORS.has(expression.operator)
308
376
  : POSTFIX_OPERATORS.has(expression.operator)));
309
377
 
378
+ // SANY's \land and \lor are infix operators only, not bullets.
379
+ const isBullet = (token: Token) =>
380
+ (token.text === "/\\" || token.text === "\\/") &&
381
+ token.spelling !== "\\land" &&
382
+ token.spelling !== "\\lor";
383
+
310
384
  const isOperatorName = (text: string) =>
311
385
  INFIX_OPERATORS.has(text) || POSTFIX_OPERATORS.has(text) || text === "-.";
312
386
 
@@ -335,24 +409,27 @@ const getOperatorApplication = (
335
409
  // root module's file, from its ---- MODULE line to the next ==== line.
336
410
  export const extractModule = (source: string, name: string) => {
337
411
  const header = new RegExp(`^-{4,}\\s*MODULE\\s+${name}\\s*-{3,}$`);
338
- const lines = source.split(/\r?\n/);
412
+ // MonolithSpecExtractor.module writes each line it reads, with its own line terminator.
413
+ const lines = source.replace(/\r?\n$/, "").split(/\r?\n/);
339
414
  const start = lines.findIndex((line) => header.test(line));
340
415
  if (start === -1) return undefined;
341
416
  const end = lines.findIndex((line, index) => index > start && line.startsWith("===="));
342
417
  return `${lines.slice(start, end === -1 ? undefined : end + 1).join("\n")}\n`;
343
418
  };
344
419
 
345
- // The tlapm mode parses as tlapm does for proof obligations, which accepts and rejects some modules
346
- // that SANY does not. The sany mode leaves the checks that SANY makes after parsing to the SANY
347
- // generator.
420
+ // The tlapm mode parses as tlapm does for proof obligations, which accepts and rejects some
421
+ // modules that SANY does not. The sany mode leaves SANY's post-parse checks to the SANY generator.
348
422
  type ParseMode = "tlc" | "tlapm" | "sany";
349
423
 
350
- const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source)): Module => {
424
+ const parse = (
425
+ source: string,
426
+ mode: ParseMode,
427
+ sourceTokens = tokenize(source, mode === "tlapm"),
428
+ ): Module => {
351
429
  const isTlapm = mode === "tlapm";
352
430
  const tokens = isTlapm ? sourceTokens : sourceTokens.map(readAtAsIdentifier);
353
431
  const cursor = { index: 0, offsideColumns: [] as number[] };
354
432
  const operators: OperatorContext = {};
355
- // A RECURSIVE declaration covers the definitions of its own LET or module.
356
433
  const recursiveScopes: Set<string>[] = [];
357
434
  const factNames = new Set<string>();
358
435
  // The NEW, TAKE, and PICK names in scope, which a DEF clause cannot cite.
@@ -436,6 +513,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
436
513
  if (TLAPM_PUNCTUATION.has(token.text) || token.kind === "Number" || token.kind === "Decimal")
437
514
  return token.text;
438
515
  if (token.kind === "String") return JSON.stringify(token.text);
516
+ if (token.kind === "Step") return token.text;
439
517
  if (isTlapmKeyword(token)) return `keyword ${token.text}`;
440
518
  return token.kind === "Identifier" ? `identifier ${token.text}` : `operator ${token.text}`;
441
519
  };
@@ -528,15 +606,13 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
528
606
  ranges: names.map((item) => item.range),
529
607
  });
530
608
 
531
- // TLAplusParser.Substitution: an identifier, or a prefix, infix or postfix operator.
532
609
  const expectSubstitutionTarget = () => {
533
610
  const token = peek();
534
611
  const isOperator =
535
612
  token.kind !== "String" &&
536
613
  (DEFINABLE_PREFIX_OPERATORS.has(token.text) ||
537
614
  INFIX_OPERATORS.has(token.text) ||
538
- POSTFIX_OPERATORS.has(token.text) ||
539
- token.text === "'");
615
+ DEFINABLE_POSTFIX_OPERATORS.has(token.text));
540
616
  if (!isOperator) return expectIdentifier();
541
617
  cursor.index++;
542
618
  return token.text;
@@ -599,7 +675,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
599
675
  const named = expectName();
600
676
  return { kind: "Name", name: named.name, ranges: [named.range] };
601
677
  }
602
- const names = getNames(parseSeparated(expectName));
678
+ const names = getNames(isAt(">>") ? [] : parseSeparated(expectName));
603
679
  expect(">>");
604
680
  return { kind: "Tuple", names: names.names, ranges: names.ranges };
605
681
  };
@@ -612,21 +688,61 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
612
688
  return patterns.map((pattern) => ({ pattern, set }));
613
689
  }).flat();
614
690
 
615
- const parseSubscript = (): Expression => {
691
+ // TLAplusParser.NoOpExtension, which leaves the arguments of the subscript's last name for a
692
+ // fairness expression to take as its action.
693
+ const parseSubscript = (): { subscript: Expression; lastArgs: Expression[] } => {
616
694
  const token = peek();
695
+ if (isTlapm && BUILTIN_CONSTANTS.has(token.text)) {
696
+ const start = cursor.index;
697
+ advance();
698
+ const constant: Expression = {
699
+ kind: "Identifier",
700
+ name: token.text,
701
+ location: getLocation(token),
702
+ };
703
+ return { subscript: withRange(constant, start), lastArgs: [] };
704
+ }
705
+ const isTlapmAtom =
706
+ isTlapm && (token.kind === "Number" || token.kind === "String" || isAt("@"));
617
707
  if (token.kind === "Identifier") {
618
708
  const start = cursor.index;
619
- const names = [advance().text];
709
+ const names: string[] = [];
710
+ const selectorRanges: SourceRange[] = [];
711
+ const parseElement = (isApplicable: boolean) => {
712
+ selectorRanges.push(getRange(cursor.index, cursor.index));
713
+ names.push(expectIdentifier());
714
+ return isApplicable && isAt("(") ? parseArguments() : [];
715
+ };
716
+ const elementArgs = [parseElement(!isTlapm)];
620
717
  while (isAt("!") && peek(1).kind === "Identifier") {
621
718
  advance();
622
- names.push(expectIdentifier());
719
+ elementArgs.push(parseElement(true));
623
720
  }
624
- return withRange(
625
- { kind: "Identifier", name: names.join("!"), location: getLocation(token) },
626
- start,
627
- );
721
+ const prefixArgs = elementArgs.slice(0, -1);
722
+ const location = getLocation(token);
723
+ location.range = { ...getRange(start), end: selectorRanges[selectorRanges.length - 1].end };
724
+ const name = names.join("!");
725
+ const subscript: Expression = prefixArgs.every((args) => args.length === 0)
726
+ ? { kind: "Identifier", name, location }
727
+ : {
728
+ kind: "Apply",
729
+ operator: name,
730
+ args: prefixArgs.flat(),
731
+ argumentCounts: [...prefixArgs.map((args) => args.length), 0],
732
+ argumentsRange: location.range,
733
+ selectorRanges,
734
+ location,
735
+ };
736
+ return { subscript, lastArgs: elementArgs[elementArgs.length - 1] };
737
+ }
738
+ if (isAt("<<") || isAt("(") || isAt("{") || isAt("[") || isTlapmAtom) {
739
+ const start = cursor.index;
740
+ const subscript = parsePrimary();
741
+ return {
742
+ subscript: subscript.location.range ? subscript : withRange(subscript, start),
743
+ lastArgs: [],
744
+ };
628
745
  }
629
- if (isAt("<<") || isAt("(")) return parsePrimary();
630
746
  throw createUnexpected(`Expected a subscript but found ${describeToken(token)}`);
631
747
  };
632
748
 
@@ -640,7 +756,8 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
640
756
  token.kind === "Identifier" &&
641
757
  (next.text === "(" ||
642
758
  next.text === "[" ||
643
- (next.kind === "Operator" && isAt("==", POSTFIX_OPERATORS.has(next.text) ? 3 : 4)))
759
+ (next.kind === "Operator" &&
760
+ isAt("==", DEFINABLE_POSTFIX_OPERATORS.has(next.text) ? 3 : 4)))
644
761
  );
645
762
  };
646
763
 
@@ -682,6 +799,9 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
682
799
  peek(1).line === token.line &&
683
800
  peek(1).column === token.endColumn + 1));
684
801
  if (isTlapmIncomplete && isStandalone(token)) throw createError("incomplete expression", token);
802
+ if (isOperatorAlone && !isTlapm && token.text === "\\X" && token.spelling !== "×") {
803
+ throw createError("\\X may not be used as an infix operator", token);
804
+ }
685
805
  if (isOperatorAlone) {
686
806
  cursor.index++;
687
807
  return withRange(
@@ -753,7 +873,11 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
753
873
  const bullet = advance();
754
874
  cursor.offsideColumns.push(bullet.column);
755
875
  const operands = [parseExpression()];
756
- while (peekRaw().text === bullet.text && peekRaw().column === bullet.column) {
876
+ while (
877
+ isBullet(peekRaw()) &&
878
+ peekRaw().text === bullet.text &&
879
+ peekRaw().column === bullet.column
880
+ ) {
757
881
  cursor.index++;
758
882
  operands.push(parseExpression());
759
883
  }
@@ -790,11 +914,15 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
790
914
  return { kind, fields, location };
791
915
  }
792
916
  if (isBoundAhead()) {
917
+ const checkpoint = cursor.index;
793
918
  const bounds = parseBounds();
794
- expect("|->");
795
- const body = parseExpression();
796
- expect("]");
797
- return { kind: "FunctionConstruction", bounds, body, location };
919
+ if (!isTlapm || isAt("|->")) {
920
+ expect("|->");
921
+ const body = parseExpression();
922
+ expect("]");
923
+ return { kind: "FunctionConstruction", bounds, body, location };
924
+ }
925
+ cursor.index = checkpoint;
798
926
  }
799
927
  const expression = parseExpression();
800
928
  if (accept("->")) {
@@ -810,6 +938,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
810
938
  if (accept(".")) {
811
939
  if (!isFieldName(peek()))
812
940
  throw createUnexpected(`Expected a field name but found ${describeToken(peek())}`);
941
+ if (!isTlapm && isAt("@")) throw createUnexpected("@ used in !.@");
813
942
  path.push({ kind: "Field", name: advance().text });
814
943
  continue;
815
944
  }
@@ -830,7 +959,12 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
830
959
  return { kind: "Bracket", args, location };
831
960
  }
832
961
  expect("]_");
833
- return { kind: "BoxAction", action: expression, subscript: parseSubscript(), location };
962
+ return {
963
+ kind: "BoxAction",
964
+ action: expression,
965
+ subscript: parseSubscript().subscript,
966
+ location,
967
+ };
834
968
  });
835
969
 
836
970
  // SANY reads the set after the \in of {x \in S} as a whole expression, whatever operators it has.
@@ -881,7 +1015,12 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
881
1015
  if (accept(">>_")) {
882
1016
  if (elements.length !== 1)
883
1017
  throw createError("Expected a single action inside <<A>>_v", start);
884
- return { kind: "AngleAction", action: elements[0], subscript: parseSubscript(), location };
1018
+ return {
1019
+ kind: "AngleAction",
1020
+ action: elements[0],
1021
+ subscript: parseSubscript().subscript,
1022
+ location,
1023
+ };
885
1024
  }
886
1025
  expect(">>");
887
1026
  return { kind: "Tuple", elements, location };
@@ -912,9 +1051,17 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
912
1051
  const parseCase = (start: Token): Expression => {
913
1052
  const arms: CaseArm[] = [];
914
1053
  do {
1054
+ const otherStart = cursor.index;
915
1055
  if (accept("OTHER")) {
916
1056
  expect("->");
917
- return { kind: "Case", arms, other: parseExpression(), location: getLocation(start) };
1057
+ const other = parseExpression();
1058
+ return {
1059
+ kind: "Case",
1060
+ arms,
1061
+ other,
1062
+ otherRange: getRange(otherStart),
1063
+ location: getLocation(start),
1064
+ };
918
1065
  }
919
1066
  const condition = parseExpression();
920
1067
  expect("->");
@@ -931,9 +1078,9 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
931
1078
  next.kind === "Number" ||
932
1079
  SELECTOR_SYMBOLS.has(next.text) ||
933
1080
  (next.kind === "Operator" &&
934
- (INFIX_OPERATORS.has(next.text) ||
935
- POSTFIX_OPERATORS.has(next.text) ||
936
- PREFIX_OPERATOR_REFERENCES.has(next.text))))
1081
+ (INFIX_OPERATORS.has(next.text) || DEFINABLE_POSTFIX_OPERATORS.has(next.text))) ||
1082
+ ((next.kind === "Operator" || next.kind === "Keyword") &&
1083
+ DEFINABLE_PREFIX_OPERATORS.has(next.text)))
937
1084
  );
938
1085
  };
939
1086
 
@@ -972,7 +1119,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
972
1119
  if (token.kind === "Decimal") return { kind: "Decimal", text: token.text, location };
973
1120
  if (token.kind === "String") return { kind: "String", value: token.text, location };
974
1121
  const isStep = token.kind === "Step" && isStepReference(token);
975
- if (isStep && getProofLevel() < 0 && proofLevels.length <= 1) {
1122
+ if (!isTlapm && isStep && getProofLevel() < 0 && proofLevels.length <= 1) {
976
1123
  throw createError("Step number used outside proof", token);
977
1124
  }
978
1125
  if (isStep && token.text[1] === "+") {
@@ -984,8 +1131,8 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
984
1131
  const params = getNames(accept("(") ? parseSeparated(expectName) : []);
985
1132
  if (params.names.length > 0) expect(")");
986
1133
  expect("::");
1134
+ const head = getRange(start);
987
1135
  const body = parseExpression();
988
- // TLAplusParser.labelDoesNotChangeParse.
989
1136
  if (
990
1137
  !isTlapm &&
991
1138
  preceding !== undefined &&
@@ -1000,6 +1147,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1000
1147
  name,
1001
1148
  params: params.names,
1002
1149
  paramRanges: params.ranges,
1150
+ head,
1003
1151
  body,
1004
1152
  location,
1005
1153
  };
@@ -1051,13 +1199,11 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1051
1199
  }
1052
1200
  // SANY reads an infix or postfix operator as a primary expression, with or without arguments.
1053
1201
  if (token.kind === "Operator" && isOperatorName(token.text) && isAt("(")) {
1054
- return {
1055
- kind: "Apply",
1056
- operator: token.text,
1057
- spelling: token.spelling,
1058
- args: parseArguments(),
1059
- location,
1060
- };
1202
+ const args = parseArguments();
1203
+ // SANY's built-in \X has no definition for TLC to evaluate, a TLC bug.
1204
+ return mode === "tlc" && token.text === "\\X" && args.length === 2
1205
+ ? { kind: "Product", factors: args, location }
1206
+ : { kind: "Apply", operator: token.text, spelling: token.spelling, args, location };
1061
1207
  }
1062
1208
  if (token.kind === "Operator" && isOperatorName(token.text) && !isTlapm) {
1063
1209
  return { kind: "Identifier", name: token.text, spelling: token.spelling, location };
@@ -1101,7 +1247,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1101
1247
  declareRecursive();
1102
1248
  continue;
1103
1249
  }
1104
- const unit = parseDefinition(false);
1250
+ const unit = parseDefinition(!isTlapm && accept("LOCAL"));
1105
1251
  if (unit.kind === "Instance") instances.push(unit);
1106
1252
  else definitions.push(unit);
1107
1253
  }
@@ -1120,15 +1266,18 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1120
1266
  case "WF_":
1121
1267
  case "SF_": {
1122
1268
  const subscript = parseSubscript();
1123
- const action = withBracketLayout(() => {
1124
- expect("(");
1125
- const expression = parseExpression();
1126
- expect(")");
1127
- return expression;
1128
- });
1269
+ const action =
1270
+ !isAt("(") && subscript.lastArgs.length === 1
1271
+ ? subscript.lastArgs[0]
1272
+ : withBracketLayout(() => {
1273
+ expect("(");
1274
+ const expression = parseExpression();
1275
+ expect(")");
1276
+ return expression;
1277
+ });
1129
1278
  return {
1130
1279
  kind: token.text === "WF_" ? "WeakFairness" : "StrongFairness",
1131
- subscript,
1280
+ subscript: subscript.subscript,
1132
1281
  action,
1133
1282
  location,
1134
1283
  };
@@ -1141,12 +1290,14 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1141
1290
  // prefix operator.
1142
1291
  const parsePrefixOperand = (operator: Token, low: number, high: number) => {
1143
1292
  operators.last = operators.preceding = { low, high };
1144
- const operand = parseExpression(high + 1);
1293
+ // tlapm applies a postfix operator to the operand, as no prefix operator binds above it.
1294
+ const operand = parseExpression(
1295
+ isTlapm ? Math.min(high + 1, POSTFIX_PRECEDENCE.low) : high + 1,
1296
+ );
1145
1297
  const next = peek();
1146
- const nextHigh =
1147
- next.text === "'" || POSTFIX_OPERATORS.has(next.text)
1148
- ? POSTFIX_PRECEDENCE.high
1149
- : INFIX_OPERATORS.get(next.text)?.high;
1298
+ const nextHigh = DEFINABLE_POSTFIX_OPERATORS.has(next.text)
1299
+ ? POSTFIX_PRECEDENCE.high
1300
+ : INFIX_OPERATORS.get(next.text)?.high;
1150
1301
  if (!isTlapm && next.kind === "Operator" && nextHigh !== undefined && nextHigh >= low) {
1151
1302
  throw createError(`Precedence conflict between ${operator.text} and ${next.text}`, next);
1152
1303
  }
@@ -1158,9 +1309,29 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1158
1309
  operators.preceding = undefined;
1159
1310
  const token = peek();
1160
1311
  const location = getLocation(token);
1161
- if (token.kind === "Operator" && (token.text === "/\\" || token.text === "\\/")) {
1312
+ if (token.kind === "Operator" && isBullet(token)) {
1162
1313
  return parseJunctionList();
1163
1314
  }
1315
+ if (isTlapm && INFIX_OPERATORS.has(token.text) && isAt("(", 1)) {
1316
+ const start = cursor.index;
1317
+ const nonfix = withBracketLayout(() => {
1318
+ advance();
1319
+ advance();
1320
+ const left = parseExpression();
1321
+ if (!accept(",")) return undefined;
1322
+ const right = parseExpression();
1323
+ expect(")");
1324
+ const apply: Expression = {
1325
+ kind: "Apply",
1326
+ operator: token.text,
1327
+ args: [left, right],
1328
+ location,
1329
+ };
1330
+ return withRange(apply, start);
1331
+ });
1332
+ if (nonfix !== undefined) return nonfix;
1333
+ cursor.index = start;
1334
+ }
1164
1335
  if (token.kind === "Operator" || token.kind === "Keyword") {
1165
1336
  switch (token.text) {
1166
1337
  case "~":
@@ -1172,6 +1343,8 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1172
1343
  location,
1173
1344
  };
1174
1345
  case "-":
1346
+ case "-.":
1347
+ if (token.text === "-." && !isTlapm) break;
1175
1348
  advance();
1176
1349
  return {
1177
1350
  kind: "Apply",
@@ -1271,7 +1444,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1271
1444
  }
1272
1445
  advance();
1273
1446
  // SANY reads - after an infix operator as prefix -, and rejects it after one that binds tighter.
1274
- if (infix.low > NEGATION_PRECEDENCE && isAt("-")) {
1447
+ if (!isTlapm && infix.low > NEGATION_PRECEDENCE && isAt("-")) {
1275
1448
  throw createError(`Precedence conflict between ${token.text} and -`, peek());
1276
1449
  }
1277
1450
  operators.last = operators.preceding = infix;
@@ -1340,11 +1513,13 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1340
1513
 
1341
1514
  const parseDefinitionUnit = (isLocal: boolean): Definition | Instance => {
1342
1515
  const token = peek();
1516
+ const start = cursor.index;
1343
1517
  const location = getLocation(token);
1344
1518
  const parseOperator = (name: string, params: OperatorParam[]): Definition => ({
1345
1519
  kind: "Operator",
1346
1520
  name,
1347
1521
  params,
1522
+ head: getRange(start, cursor.index - 2),
1348
1523
  ...parseBody(),
1349
1524
  isLocal,
1350
1525
  isRecursive: isRecursiveName(name),
@@ -1366,7 +1541,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1366
1541
  const isPrefixDefinition =
1367
1542
  token.kind !== "String" && DEFINABLE_PREFIX_OPERATORS.has(token.text);
1368
1543
  const isPostfixDefinition =
1369
- token.kind === "Identifier" && POSTFIX_OPERATORS.has(peek(1).text) && isAt("==", 2);
1544
+ token.kind === "Identifier" && DEFINABLE_POSTFIX_OPERATORS.has(peek(1).text) && isAt("==", 2);
1370
1545
  if (isPrefixDefinition || isPostfixDefinition) {
1371
1546
  const operator = isPrefixDefinition ? token.text : peek(1).text;
1372
1547
  if (isPrefixDefinition) advance();
@@ -1442,7 +1617,10 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1442
1617
  const name = advance().text;
1443
1618
  return { name, arity: accept("_") ? 2 : 1, location };
1444
1619
  }
1445
- if (peek().kind === "Operator" && isAt("_", 1)) {
1620
+ const isPrefixOperator =
1621
+ peek().kind !== "String" &&
1622
+ (DEFINABLE_PREFIX_OPERATORS.has(peek().text) || (isTlapm && peek().kind === "Operator"));
1623
+ if (isPrefixOperator && isAt("_", 1)) {
1446
1624
  const operator = advance().text;
1447
1625
  advance();
1448
1626
  return { name: operator === "-" ? "-." : operator, arity: 1, location };
@@ -1489,7 +1667,8 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1489
1667
  );
1490
1668
  }
1491
1669
  if (isAt("(", 1) || isAt("[", 1)) return isAt("==", getClosingOffset(1));
1492
- if (next.kind === "Operator" && POSTFIX_OPERATORS.has(next.text)) return isAt("==", 2);
1670
+ if (next.kind === "Operator" && DEFINABLE_POSTFIX_OPERATORS.has(next.text))
1671
+ return isAt("==", 2);
1493
1672
  if (next.kind === "Operator" && INFIX_OPERATORS.has(next.text)) {
1494
1673
  return peek(2).kind === "Identifier" && isAt("==", 3);
1495
1674
  }
@@ -1619,7 +1798,6 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1619
1798
  module.variables.some((variable) => variable.name === name),
1620
1799
  );
1621
1800
 
1622
- // tlapm's definable: names and operators joined by !.
1623
1801
  const parseDefinable = (): Fact => {
1624
1802
  const start = cursor.index;
1625
1803
  const token = peek();
@@ -1654,10 +1832,12 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1654
1832
  return defs;
1655
1833
  };
1656
1834
 
1657
- const parseFacts = () => ({
1658
- facts: isFactAhead() ? parseSeparated(parseFact) : [],
1659
- defs: accept("DEF") || accept("DEFS") ? parseDefs() : [],
1660
- });
1835
+ const parseFacts = () => {
1836
+ const facts = isFactAhead() ? parseSeparated(parseFact) : [];
1837
+ const isDef = accept("DEF") || accept("DEFS");
1838
+ if (isTlapm && facts.length === 0 && !isDef) throw createUnexpected("Expected a fact");
1839
+ return { facts, defs: isDef ? parseDefs() : [] };
1840
+ };
1661
1841
 
1662
1842
  const parseUseOrHide = (): UseOrHide => {
1663
1843
  const start = cursor.index;
@@ -1686,9 +1866,12 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1686
1866
  };
1687
1867
 
1688
1868
  const parseNewSymbol = (): NewSymbol => {
1689
- const start = cursor.index;
1690
- const location = getLocation(peek());
1869
+ const newStart = cursor.index;
1870
+ const newLocation = getLocation(peek());
1691
1871
  const isNew = accept("NEW");
1872
+ // tlapm locates a declaration without its NEW.
1873
+ const start = isTlapm ? cursor.index : newStart;
1874
+ const location = isTlapm ? getLocation(peek()) : newLocation;
1692
1875
  const level = peek().kind === "Keyword" ? NEW_SYMBOL_LEVELS.get(peek().text) : undefined;
1693
1876
  if (!isNew && level === undefined) {
1694
1877
  throw createUnexpected(`Expected a declaration but found ${describeToken(peek())}`);
@@ -1735,6 +1918,10 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1735
1918
  const start = cursor.index;
1736
1919
  const location = getLocation(expect("ASSUME"));
1737
1920
  const assumptions = parseSeparated(() => {
1921
+ if (peek().kind === "Identifier" && isAt("::", 1) && isAt("ASSUME", 2)) {
1922
+ advance();
1923
+ advance();
1924
+ }
1738
1925
  if (isAt("ASSUME")) return withProofScope(parseAssumeProve);
1739
1926
  if (peek().kind === "Keyword" && NEW_SYMBOL_STARTS.has(peek().text)) return parseNewSymbol();
1740
1927
  return parseExpression();
@@ -1819,7 +2006,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1819
2006
  if (!isCorrectLevel(step)) {
1820
2007
  throw createError(`${isQed ? "QED step" : "step"}'s number has bad level`, step);
1821
2008
  }
1822
- if (getStepLevel(step) < 0 && getStepName(step) !== undefined) {
2009
+ if (mode !== "sany" && getStepLevel(step) < 0 && getStepName(step) !== undefined) {
1823
2010
  throw createError("<*> and <+> cannot be used for a named step", step);
1824
2011
  }
1825
2012
  cursor.index++;
@@ -1847,25 +2034,26 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1847
2034
  return withRange({ ...step, body, head, statement, proof }, start);
1848
2035
  };
1849
2036
 
1850
- const parseProofBody = (): Proof => {
1851
- const location = getLocation(peek());
1852
- if (isAt("BY") || (isAt("PROOF") && isAt("BY", 1))) {
1853
- accept("PROOF");
1854
- advance();
2037
+ const parseLeafProof = (
2038
+ location: SourceLocation,
2039
+ ): Exclude<Proof, { kind: "Steps" }> | undefined => {
2040
+ if (accept("BY")) {
1855
2041
  const keyword = getRange(cursor.index - 1);
1856
2042
  return { kind: "By", isOnly: accept("ONLY"), ...parseFacts(), keyword, location };
1857
2043
  }
1858
- const terminal = peek(isAt("PROOF") ? 1 : 0);
1859
- if (
1860
- terminal.kind === "Keyword" &&
1861
- (terminal.text === "OBVIOUS" || terminal.text === "OMITTED")
1862
- ) {
1863
- accept("PROOF");
1864
- advance();
1865
- const keyword = getRange(cursor.index - 1);
1866
- return { kind: terminal.text === "OBVIOUS" ? "Obvious" : "Omitted", keyword, location };
1867
- }
2044
+ const terminal = peek();
2045
+ if (terminal.kind !== "Keyword" || (terminal.text !== "OBVIOUS" && terminal.text !== "OMITTED"))
2046
+ return undefined;
2047
+ advance();
2048
+ const keyword = getRange(cursor.index - 1);
2049
+ return { kind: terminal.text === "OBVIOUS" ? "Obvious" : "Omitted", keyword, location };
2050
+ };
2051
+
2052
+ const parseProofBody = (): Proof => {
2053
+ const location = getLocation(peek());
1868
2054
  accept("PROOF");
2055
+ const leaf = parseLeafProof(location);
2056
+ if (leaf) return leaf;
1869
2057
  const steps = [parseStep()];
1870
2058
  while (steps[steps.length - 1].body.kind !== "Qed") steps.push(parseStep());
1871
2059
  return { kind: "Steps", level: getProofLevel(), steps, location };
@@ -1879,6 +2067,161 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1879
2067
  return withRange(proof, start);
1880
2068
  };
1881
2069
 
2070
+ const isPreproofStart = () =>
2071
+ peek().kind === "Step" || (peek().kind === "Keyword" && PROOF_STARTS.has(peek().text));
2072
+
2073
+ // tlapm locates a USE or HIDE step by its keywords and DEF clause.
2074
+ const getStepSpan = (head: SourceRange, body: StepBody) => {
2075
+ if (body.kind !== "Use" && body.kind !== "Hide") return getSpan(head);
2076
+ const lastDef = body.defs[body.defs.length - 1]?.location.range;
2077
+ return mergeSpans(getSpan({ ...head, end: head.start }), getSpan(lastDef ?? body.keyword));
2078
+ };
2079
+
2080
+ const parsePreproof = (): Preproof => {
2081
+ const first = cursor.index;
2082
+ const location = getLocation(peek());
2083
+ const isProof = accept("PROOF");
2084
+ const leaf = parseLeafProof(location);
2085
+ if (leaf) {
2086
+ const proof = withRange(leaf, first);
2087
+ return { kind: "Leaf", proof, span: getSpan(proof.keyword), first, end: cursor.index - 1 };
2088
+ }
2089
+ const token = peek();
2090
+ if (token.kind !== "Step") {
2091
+ throw createUnexpected(`Expected a step number but found ${describeToken(token)}`);
2092
+ }
2093
+ const start = cursor.index;
2094
+ advance();
2095
+ const statementStart = cursor.index;
2096
+ const body: StepBody = accept("QED") ? { kind: "Qed" } : parseStepBody();
2097
+ const head = getRange(start);
2098
+ return {
2099
+ kind: "Step",
2100
+ token,
2101
+ isProof,
2102
+ body,
2103
+ head,
2104
+ statement: getRange(statementStart),
2105
+ span: getStepSpan(head, body),
2106
+ first,
2107
+ start,
2108
+ end: cursor.index - 1,
2109
+ };
2110
+ };
2111
+
2112
+ // A backtrack leaves the proof implicitly omitted.
2113
+ const nestProof = (
2114
+ items: Preproof[],
2115
+ index: number,
2116
+ level: number,
2117
+ levelSpan: Span,
2118
+ ): NestedProof => {
2119
+ const item = items[index];
2120
+ if (!item) return { proof: undefined, span: levelSpan, next: index, end: undefined };
2121
+ if (item.kind === "Leaf")
2122
+ return { proof: item.proof, span: item.span, next: index + 1, end: item.end };
2123
+ const nested = nestSteps(items, index, level, levelSpan, true);
2124
+ if (!nested) return { proof: undefined, span: levelSpan, next: index, end: undefined };
2125
+ const location = {
2126
+ ...getLocation(tokens[item.first]),
2127
+ range: getRange(item.first, nested.end),
2128
+ };
2129
+ return {
2130
+ proof: { kind: "Steps", level: nested.level, steps: nested.steps, location },
2131
+ span: nested.span,
2132
+ next: nested.next,
2133
+ end: nested.end,
2134
+ };
2135
+ };
2136
+
2137
+ const nestSteps = (
2138
+ items: Preproof[],
2139
+ index: number,
2140
+ level: number,
2141
+ levelSpan: Span,
2142
+ isFirst: boolean,
2143
+ ): NestedSteps | undefined => {
2144
+ const item = items[index];
2145
+ if (!item) {
2146
+ throw createProofError(
2147
+ `Unexpected end of (sub)proof at level ${level} before QED step`,
2148
+ levelSpan,
2149
+ );
2150
+ }
2151
+ if (item.kind === "Leaf") {
2152
+ throw createProofError(
2153
+ `Expecting a proof step but found a${LEAF_NAMES[item.proof.kind]} leaf proof`,
2154
+ item.span,
2155
+ );
2156
+ }
2157
+ if (!isFirst && item.isProof) {
2158
+ throw createProofError("PROOF keyword found in step that does not begin subproof", item.span);
2159
+ }
2160
+ const implicit = item.token.text[1];
2161
+ if (implicit === "+" && !isFirst) {
2162
+ throw createProofError("<+> used but no subproof expected", item.span);
2163
+ }
2164
+ const stepLevel =
2165
+ implicit === "*"
2166
+ ? level - (isFirst && !item.isProof ? 1 : 0)
2167
+ : implicit === "+"
2168
+ ? level
2169
+ : getStepLevel(item.token);
2170
+ if (stepLevel < level || (!isFirst && stepLevel > level)) return undefined;
2171
+ const proof = PROVABLE_STEPS.has(item.body.kind)
2172
+ ? nestProof(items, index + 1, stepLevel + 1, item.span)
2173
+ : { proof: undefined, span: item.span, next: index + 1, end: undefined };
2174
+ const end = proof.end ?? item.end;
2175
+ const step: ProofStep = {
2176
+ name: getStepName(item.token),
2177
+ token: item.token.text,
2178
+ body: item.body,
2179
+ head: item.head,
2180
+ statement: item.statement,
2181
+ proof: proof.proof,
2182
+ location: { ...getLocation(item.token), range: getRange(item.start, end) },
2183
+ };
2184
+ const span = mergeSpans(item.span, proof.span);
2185
+ if (item.body.kind === "Qed") {
2186
+ return { level: stepLevel, steps: [step], span, next: proof.next, end };
2187
+ }
2188
+ const rest = nestSteps(
2189
+ items,
2190
+ proof.next,
2191
+ stepLevel,
2192
+ { start: span.stop, stop: span.stop },
2193
+ false,
2194
+ );
2195
+ return (
2196
+ rest && {
2197
+ ...rest,
2198
+ level: stepLevel,
2199
+ steps: [step, ...rest.steps],
2200
+ span: mergeSpans(span, rest.span),
2201
+ }
2202
+ );
2203
+ };
2204
+
2205
+ // tlapm reads every step and leaf proof that follows, then nests them by level, where the first
2206
+ // step counts as having PROOF.
2207
+ const parseTlapmProof = () => {
2208
+ if (!isPreproofStart()) return undefined;
2209
+ const items: Preproof[] = [];
2210
+ while (isPreproofStart()) items.push(parsePreproof());
2211
+ const first = items[0];
2212
+ if (first.kind === "Step") items[0] = { ...first, isProof: true };
2213
+ const nested = nestProof(items, 0, 0, first.span);
2214
+ const extra = items[nested.next];
2215
+ if (extra) {
2216
+ throw createProofError(
2217
+ "extra step(s) after finished proof",
2218
+ extra.span,
2219
+ "Proof.Parser.toplevel",
2220
+ );
2221
+ }
2222
+ return nested.proof;
2223
+ };
2224
+
1882
2225
  // SANY binds the name of a theorem or assumption that a module already defines to the first
1883
2226
  // definition, warning of the second.
1884
2227
  const addFactDefinition = (module: Module, definition: Definition) => {
@@ -1897,6 +2240,7 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
1897
2240
  }
1898
2241
  const parsed = withProofScope(() => {
1899
2242
  const statement = isAt("ASSUME") ? parseAssumeProve() : parseExpression();
2243
+ if (isTlapm) return { statement, proof: parseTlapmProof() };
1900
2244
  return { statement, proof: isProofStart(peek()) ? parseProof() : undefined };
1901
2245
  });
1902
2246
  const statement = parsed.statement;
@@ -2051,10 +2395,13 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
2051
2395
  module.units.push({ kind: "Use", use });
2052
2396
  continue;
2053
2397
  }
2054
- case "RECURSIVE":
2055
- advance();
2056
- module.units.push({ kind: "Recursive", declarations: declareRecursive() });
2398
+ case "RECURSIVE": {
2399
+ const unitLocation = getLocation(advance());
2400
+ const declarations = declareRecursive();
2401
+ unitLocation.range = getRange(tokenIndex);
2402
+ module.units.push({ kind: "Recursive", declarations, location: unitLocation });
2057
2403
  continue;
2404
+ }
2058
2405
  case "INSTANCE":
2059
2406
  addDefinitionUnit(
2060
2407
  module,
@@ -2102,7 +2449,6 @@ const parse = (source: string, mode: ParseMode, sourceTokens = tokenize(source))
2102
2449
 
2103
2450
  export const parseModule = (source: string) => parse(source, "tlc");
2104
2451
 
2105
- // Parses a module the caller has tokenized already.
2106
2452
  export const parseModuleTokens = (source: string, tokens: Token[]) => parse(source, "tlc", tokens);
2107
2453
 
2108
2454
  export const parseTlapmModule = (source: string) => parse(source, "tlapm");