tla-ts 0.0.3-dev.4cf9a33 → 0.0.3-dev.4fdd845
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 +164 -40
- package/dist/index.d.ts +164 -40
- 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 +1351 -22
- package/dist/transfer.cjs +83 -34
- package/dist/transfer.js +83 -34
- package/package.json +5 -1
- package/src/ast.ts +49 -6
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -11
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1331 -367
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -21
- package/src/config.ts +225 -206
- package/src/environment.ts +417 -124
- package/src/errors.ts +168 -9
- package/src/evaluate.ts +720 -177
- package/src/exit-codes.ts +6 -24
- package/src/index.ts +1 -0
- package/src/instances.ts +3 -1
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +149 -31
- package/src/lexer.ts +32 -4
- 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 +419 -122
- 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 +1334 -452
- package/src/run-cli.ts +1166 -181
- package/src/runtime.ts +16 -0
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3112 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +545 -0
- 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 +2161 -0
- package/src/sany-report.ts +354 -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 +203 -146
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +29 -6
- package/src/subexpressions.ts +221 -161
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +161 -167
- 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/value-sources.ts +29 -0
- package/src/values.ts +683 -256
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
|
|
|
@@ -34,10 +36,14 @@ export interface SanyError {
|
|
|
34
36
|
message: string;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
// The errors SANY reports for a spec. A fatal error stops it
|
|
39
|
+
// The errors SANY reports for a spec, and the warnings it prints before them. A fatal error stops it
|
|
40
|
+
// before semantic analysis. SANY's parser prints its message for a module it rejects before the
|
|
41
|
+
// report.
|
|
38
42
|
export interface SanyReport {
|
|
39
43
|
errors: SanyError[];
|
|
44
|
+
warnings: SanyError[];
|
|
40
45
|
isFatal: boolean;
|
|
46
|
+
parseError?: string;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export class TlaSyntaxError extends TlaError {
|
|
@@ -52,14 +58,70 @@ export class TlaSyntaxError extends TlaError {
|
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
|
|
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
|
+
|
|
87
|
+
export const createSanyError = (
|
|
88
|
+
errors: SanyError[],
|
|
89
|
+
isFatal = false,
|
|
90
|
+
parseError?: string,
|
|
91
|
+
warnings: SanyError[] = [],
|
|
92
|
+
) =>
|
|
56
93
|
new TlaSyntaxError(
|
|
57
94
|
errors.map((error) => `${error.location}\n\n${error.message}`).join("\n\n"),
|
|
58
95
|
undefined,
|
|
59
96
|
undefined,
|
|
60
|
-
{ errors, isFatal },
|
|
97
|
+
{ errors, warnings, isFatal, parseError },
|
|
61
98
|
);
|
|
62
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
|
+
|
|
112
|
+
// How SANY prints the warnings it reports, which do not stop TLC.
|
|
113
|
+
export const formatSanyWarnings = (warnings: SanyError[]) =>
|
|
114
|
+
`*** Warnings: ${warnings.length}\n\n${warnings.map((warning) => `${warning.location}\n\n${warning.message}\n\n\n`).join("\n")}`;
|
|
115
|
+
|
|
116
|
+
// SANY's message for a module its parser rejects, such as a "***Parse Error***" with the
|
|
117
|
+
// productions it was in.
|
|
118
|
+
export class TlaParseError extends TlaError {
|
|
119
|
+
constructor(message: string) {
|
|
120
|
+
super(message);
|
|
121
|
+
this.name = "TlaParseError";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
63
125
|
export const formatRange = (range: SourceRange) =>
|
|
64
126
|
`line ${range.start.line}, col ${range.start.column} to line ${range.end.line}, col ${range.end.column} of module ${range.module}`;
|
|
65
127
|
|
|
@@ -80,6 +142,48 @@ export class TlaEvaluationError extends TlaError {
|
|
|
80
142
|
}
|
|
81
143
|
}
|
|
82
144
|
|
|
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.";
|
|
148
|
+
|
|
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
|
+
) {
|
|
169
|
+
super(message);
|
|
170
|
+
this.state = state;
|
|
171
|
+
this.action = action;
|
|
172
|
+
this.variables = variables;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
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.
|
|
178
|
+
export class TlaUnassignedError extends TlaEvaluationError {
|
|
179
|
+
variable: string;
|
|
180
|
+
|
|
181
|
+
constructor(message: string, variable: string) {
|
|
182
|
+
super(message);
|
|
183
|
+
this.variable = variable;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
83
187
|
// An evaluation error that TLC raises as an EvalException from a standard module's Java code. It
|
|
84
188
|
// keeps the name TlaEvaluationError, and index.ts doesn't export it.
|
|
85
189
|
export class TlaModuleError extends TlaEvaluationError {
|
|
@@ -110,6 +214,17 @@ export class TlaIncompleteStateError extends TlaEvaluationError {
|
|
|
110
214
|
}
|
|
111
215
|
}
|
|
112
216
|
|
|
217
|
+
// TLC reports an initial state that the initial predicate leaves incomplete as an illegal state.
|
|
218
|
+
export class TlaIllegalStateError extends TlaEvaluationError {
|
|
219
|
+
state: (Value | undefined)[];
|
|
220
|
+
|
|
221
|
+
constructor(state: (Value | undefined)[]) {
|
|
222
|
+
super("current state is not a legal state");
|
|
223
|
+
this.name = "TlaEvaluationError";
|
|
224
|
+
this.state = state;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
113
228
|
export interface TlapmReport {
|
|
114
229
|
failure?: string;
|
|
115
230
|
exception?: string;
|
|
@@ -143,6 +258,18 @@ export class TlaUnsupportedError extends TlaError {
|
|
|
143
258
|
}
|
|
144
259
|
}
|
|
145
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
|
+
|
|
146
273
|
export const getErrorExitCode = (error: TlaError) =>
|
|
147
274
|
getExitCode(error) ??
|
|
148
275
|
(error instanceof TlaSyntaxError
|
|
@@ -152,3 +279,35 @@ export const getErrorExitCode = (error: TlaError) =>
|
|
|
152
279
|
: error instanceof TlaEvaluationError
|
|
153
280
|
? EXIT_STATUS.specEvaluationFailure
|
|
154
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
|
+
}
|