tla-ts 0.0.3-dev.e5b05b9 → 0.0.3-dev.e8bef80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +150 -48
- package/dist/index.d.ts +150 -48
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +1351 -22
- package/dist/run-cli.js +1352 -23
- package/dist/transfer.cjs +83 -43
- package/dist/transfer.js +83 -43
- package/package.json +5 -1
- package/src/ast.ts +28 -4
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -17
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1317 -428
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -21
- package/src/config.ts +226 -207
- package/src/environment.ts +221 -75
- package/src/errors.ts +130 -15
- package/src/evaluate.ts +713 -259
- package/src/exit-codes.ts +6 -24
- package/src/fingerprints.ts +1 -2
- package/src/index.ts +1 -0
- package/src/instances.ts +3 -1
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +6 -1
- package/src/lexer.ts +122 -29
- package/src/live-check.ts +204 -148
- package/src/liveness.ts +191 -122
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +6 -1
- package/src/parallel.ts +57 -6
- package/src/parser.ts +327 -147
- package/src/pcal-ast.ts +770 -0
- package/src/pcal-parse.ts +1523 -0
- package/src/pcal-tokenize.ts +516 -0
- package/src/pcal-translate.ts +1230 -0
- package/src/pcal-validate.ts +454 -0
- package/src/randomization.ts +24 -7
- package/src/resolve.ts +252 -87
- package/src/run-cli.ts +1162 -200
- package/src/runtime.ts +16 -0
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3128 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +410 -480
- package/src/sany-linter.ts +122 -0
- package/src/sany-modules.ts +1398 -0
- package/src/sany-nodes.ts +463 -0
- package/src/sany-parse-error.ts +2033 -3015
- package/src/sany-report.ts +356 -0
- package/src/sany-selectors.ts +738 -0
- package/src/sany-source.ts +248 -0
- package/src/sany-xml.ts +1017 -0
- package/src/spec-description.ts +25 -5
- package/src/standard-modules.ts +172 -129
- package/src/state-graph.ts +29 -6
- package/src/subexpressions.ts +121 -26
- package/src/successors.ts +141 -173
- package/src/symmetry.ts +168 -50
- package/src/tableau.ts +3 -1
- package/src/tlc-ext.ts +13 -17
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +49 -21
- package/src/tlc-modules.ts +0 -4
- package/src/tlc-order.ts +55 -9
- package/src/tlc-random.ts +28 -3
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/values.ts +664 -317
package/src/errors.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { SourceRange } from "./ast";
|
|
2
2
|
import { EXIT_STATUS, getExitCode } from "./exit-codes";
|
|
3
|
+
import type { PcalNode } from "./pcal-ast";
|
|
3
4
|
import type { Value } from "./values";
|
|
4
5
|
|
|
6
|
+
// The start of TLC's message for an exception of a Java class it didn't expect.
|
|
7
|
+
export const getUnexpectedException = (exceptionClass: string) =>
|
|
8
|
+
`TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a ${exceptionClass}\n: `;
|
|
9
|
+
|
|
5
10
|
// How TLC reports a RuntimeException it did not expect, such as one raised while computing next
|
|
6
11
|
// states.
|
|
7
|
-
export const UNEXPECTED_EXCEPTION =
|
|
8
|
-
"TLC threw an unexpected exception.\nThis was probably caused by an error in the spec or model.\nSee the User Output or TLC Console for clues to what happened.\nThe exception was a java.lang.RuntimeException\n: ";
|
|
9
|
-
|
|
10
|
-
// How TLC reports a Java StackOverflowError, which V8 raises as this RangeError.
|
|
11
|
-
export const STACK_OVERFLOW =
|
|
12
|
-
"This was a Java StackOverflowError. It was probably the result\nof an incorrect recursive function definition that caused TLC to enter\nan infinite loop when trying to compute the function or its application\nto an element in its putative domain.";
|
|
12
|
+
export const UNEXPECTED_EXCEPTION = getUnexpectedException("java.lang.RuntimeException");
|
|
13
13
|
|
|
14
|
+
// Whether an error is V8's RangeError for a stack overflow, which TLC raises as a Java
|
|
15
|
+
// StackOverflowError.
|
|
14
16
|
export const isStackOverflow = (error: unknown) =>
|
|
15
17
|
error instanceof RangeError && error.message === "Maximum call stack size exceeded";
|
|
16
18
|
|
|
@@ -56,6 +58,32 @@ export class TlaSyntaxError extends TlaError {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
// A fatal error of SANY's parsing phase: a module SANY can't find or parse, a file whose name
|
|
62
|
+
// doesn't match its module's, or a circular dependency. SANY reports it in the module that imports
|
|
63
|
+
// or holds the failed one, or without a location, after its JavaCC parser's report of a module it
|
|
64
|
+
// failed to parse. It keeps the name TlaSyntaxError, and index.ts doesn't export it.
|
|
65
|
+
export class TlaSanyFatalError extends TlaSyntaxError {
|
|
66
|
+
location: string | undefined;
|
|
67
|
+
parseError: string | undefined;
|
|
68
|
+
|
|
69
|
+
constructor(message: string, location: string | undefined, parseError?: string) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.location = location;
|
|
72
|
+
this.parseError = parseError;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// A module that another imports and SANY can't find, which SANY reports in the importer, except
|
|
77
|
+
// TLC 1.7.4's SANY, which gives it no location.
|
|
78
|
+
export class TlaMissingModuleError extends TlaSanyFatalError {
|
|
79
|
+
constructor(name: string, importer: string | undefined, isLocated = true) {
|
|
80
|
+
super(
|
|
81
|
+
`Cannot find source file for module ${name} imported in module ${importer}.`,
|
|
82
|
+
isLocated ? importer : undefined,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
59
87
|
export const createSanyError = (
|
|
60
88
|
errors: SanyError[],
|
|
61
89
|
isFatal = false,
|
|
@@ -69,6 +97,18 @@ export const createSanyError = (
|
|
|
69
97
|
{ errors, warnings, isFatal, parseError },
|
|
70
98
|
);
|
|
71
99
|
|
|
100
|
+
// SANY reports a module it can't find in the module that imports it.
|
|
101
|
+
export const createMissingModuleError = (name: string, importer: string | undefined) =>
|
|
102
|
+
createSanyError(
|
|
103
|
+
[
|
|
104
|
+
{
|
|
105
|
+
location: `In module ${importer}`,
|
|
106
|
+
message: `Cannot find source file for module ${name} imported in module ${importer}.`,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
true,
|
|
110
|
+
);
|
|
111
|
+
|
|
72
112
|
// How SANY prints the warnings it reports, which do not stop TLC.
|
|
73
113
|
export const formatSanyWarnings = (warnings: SanyError[]) =>
|
|
74
114
|
`*** Warnings: ${warnings.length}\n\n${warnings.map((warning) => `${warning.location}\n\n${warning.message}\n\n\n`).join("\n")}`;
|
|
@@ -102,29 +142,60 @@ export class TlaEvaluationError extends TlaError {
|
|
|
102
142
|
}
|
|
103
143
|
}
|
|
104
144
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
exitCode: number;
|
|
145
|
+
// How TLC reports a Java StackOverflowError.
|
|
146
|
+
export const STACK_OVERFLOW_MESSAGE =
|
|
147
|
+
"This was a Java StackOverflowError. It was probably the result\nof an incorrect recursive function definition that caused TLC to enter\nan infinite loop when trying to compute the function or its application\nto an element in its putative domain.";
|
|
109
148
|
|
|
110
|
-
|
|
149
|
+
// A Java StackOverflowError, which TLC catches only at the top, unlike the exceptions of evaluation.
|
|
150
|
+
export class TlaStackOverflowError extends TlaEvaluationError {
|
|
151
|
+
constructor() {
|
|
152
|
+
super(STACK_OVERFLOW_MESSAGE);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// A next-state action left variables of a successor state unassigned. TLC reports the partial
|
|
157
|
+
// state, with null for each unassigned variable.
|
|
158
|
+
export class TlaIncompleteSuccessorError extends TlaEvaluationError {
|
|
159
|
+
state: (Value | undefined)[];
|
|
160
|
+
action: string | undefined;
|
|
161
|
+
variables: string[];
|
|
162
|
+
|
|
163
|
+
constructor(
|
|
164
|
+
message: string,
|
|
165
|
+
state: (Value | undefined)[],
|
|
166
|
+
action: string | undefined,
|
|
167
|
+
variables: string[],
|
|
168
|
+
) {
|
|
111
169
|
super(message);
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
170
|
+
this.state = state;
|
|
171
|
+
this.action = action;
|
|
172
|
+
this.variables = variables;
|
|
114
173
|
}
|
|
115
174
|
}
|
|
116
175
|
|
|
117
|
-
//
|
|
176
|
+
// An expression read a variable that its state doesn't assign. It keeps the name
|
|
177
|
+
// TlaEvaluationError, and index.ts doesn't export it.
|
|
118
178
|
export class TlaUnassignedError extends TlaEvaluationError {
|
|
119
179
|
variable: string;
|
|
120
180
|
|
|
121
181
|
constructor(message: string, variable: string) {
|
|
122
182
|
super(message);
|
|
123
|
-
this.name = "TlaEvaluationError";
|
|
124
183
|
this.variable = variable;
|
|
125
184
|
}
|
|
126
185
|
}
|
|
127
186
|
|
|
187
|
+
// An evaluation error that TLC raises as an EvalException from a standard module's Java code. It
|
|
188
|
+
// keeps the name TlaEvaluationError, and index.ts doesn't export it.
|
|
189
|
+
export class TlaModuleError extends TlaEvaluationError {
|
|
190
|
+
exitCode: number;
|
|
191
|
+
|
|
192
|
+
constructor(message: string, exitCode: number = EXIT_STATUS.error) {
|
|
193
|
+
super(message);
|
|
194
|
+
this.name = "TlaEvaluationError";
|
|
195
|
+
this.exitCode = exitCode;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
128
199
|
// TLC reports a successor state that the next-state relation leaves incomplete as an error of its
|
|
129
200
|
// own, not as an exception. It keeps the name TlaEvaluationError, and index.ts doesn't export it.
|
|
130
201
|
export class TlaIncompleteStateError extends TlaEvaluationError {
|
|
@@ -187,6 +258,18 @@ export class TlaUnsupportedError extends TlaError {
|
|
|
187
258
|
}
|
|
188
259
|
}
|
|
189
260
|
|
|
261
|
+
// An exception that TLC's Java code throws and nothing catches, with the stack trace it prints, after
|
|
262
|
+
// what the frames that the exception unwinds print about it.
|
|
263
|
+
export class TlaJavaException extends TlaUnsupportedError {
|
|
264
|
+
unwound: string;
|
|
265
|
+
|
|
266
|
+
constructor(message: string, unwound: string) {
|
|
267
|
+
super(message);
|
|
268
|
+
this.name = "TlaJavaException";
|
|
269
|
+
this.unwound = unwound;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
190
273
|
export const getErrorExitCode = (error: TlaError) =>
|
|
191
274
|
getExitCode(error) ??
|
|
192
275
|
(error instanceof TlaSyntaxError
|
|
@@ -196,3 +279,35 @@ export const getErrorExitCode = (error: TlaError) =>
|
|
|
196
279
|
: error instanceof TlaEvaluationError
|
|
197
280
|
? EXIT_STATUS.specEvaluationFailure
|
|
198
281
|
: EXIT_STATUS.error);
|
|
282
|
+
|
|
283
|
+
// pcal.UnrecoverableException and its subclasses: an error the PlusCal translator reports as
|
|
284
|
+
// "Unrecoverable error". UnrecoverablePositionedException adds the statement the error is at.
|
|
285
|
+
export class PcalError extends TlaError {
|
|
286
|
+
node: PcalNode | undefined;
|
|
287
|
+
|
|
288
|
+
constructor(message: string, node?: PcalNode) {
|
|
289
|
+
super(message);
|
|
290
|
+
this.name = "PcalError";
|
|
291
|
+
this.node = node;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// A RuntimeException the translator's Java code throws, such as an index out of bounds, which
|
|
296
|
+
// ParseAlgorithm.getAlgorithm turns into a parsing error.
|
|
297
|
+
export class PcalRuntimeError extends TlaError {
|
|
298
|
+
constructor(message: string) {
|
|
299
|
+
super(message);
|
|
300
|
+
this.name = "PcalRuntimeError";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// PcalDebug.ReportBug: the translator found itself in a state it considers a bug, and throws a
|
|
305
|
+
// java.lang.Error that nothing in SANY catches.
|
|
306
|
+
export class PcalBugError extends TlaError {
|
|
307
|
+
constructor(message: string) {
|
|
308
|
+
super(
|
|
309
|
+
`You have discovered a bug in pcal.trans.\nSend the following information and the\ninput file to the current maintainer(s).\n\n -- ${message}.`,
|
|
310
|
+
);
|
|
311
|
+
this.name = "PcalBugError";
|
|
312
|
+
}
|
|
313
|
+
}
|