tla-ts 0.0.3-dev.b1578d0 → 0.0.3-dev.b4e335d
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 -8
- package/dist/index.d.ts +150 -8
- 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 -20
- package/dist/run-cli.js +1351 -20
- package/dist/transfer.cjs +86 -28
- package/dist/transfer.js +86 -28
- package/package.json +5 -1
- package/src/ast.ts +57 -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 +1396 -227
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -18
- package/src/config.ts +252 -179
- package/src/environment.ts +514 -130
- package/src/errors.ts +217 -3
- package/src/evaluate.ts +722 -112
- package/src/exit-codes.ts +5 -4
- package/src/index.ts +1 -0
- package/src/instances.ts +7 -5
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +183 -37
- package/src/lexer.ts +112 -29
- package/src/live-check.ts +220 -102
- package/src/liveness.ts +216 -52
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +8 -3
- package/src/parallel.ts +56 -5
- package/src/parser.ts +445 -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 +1465 -411
- package/src/run-cli.ts +1167 -155
- package/src/runtime.ts +18 -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 +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 +26 -7
- package/src/standard-modules.ts +200 -148
- 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 +207 -103
- package/src/symmetry.ts +180 -52
- package/src/tableau.ts +54 -25
- package/src/tlc-ext.ts +13 -17
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +49 -15
- package/src/tlc-order.ts +56 -6
- package/src/tlc-random.ts +37 -9
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-summary.ts +20 -5
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/value-sources.ts +29 -0
- package/src/values.ts +697 -180
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import type { Module } from "./ast";
|
|
4
|
+
import { TlaSyntaxError, PcalRuntimeError, TlaSanyFatalError } from "./errors";
|
|
5
|
+
import { extractModule, parseSanyModule } from "./parser";
|
|
6
|
+
import { createPcalParams } from "./pcal-ast";
|
|
7
|
+
import { createPcalSession } from "./pcal-parse";
|
|
8
|
+
import { validatePcalModule } from "./pcal-validate";
|
|
9
|
+
import { generateSanySpecification, type SanySpecification } from "./sany-generator";
|
|
10
|
+
import { checkModuleLevels } from "./sany-levels";
|
|
11
|
+
import { getSany174LexicalError } from "./sany-lexer";
|
|
12
|
+
import { lintSanyModule } from "./sany-linter";
|
|
13
|
+
import { getSanyStandardModules } from "./sany-modules";
|
|
14
|
+
import { formatSanyLocation, type SanyMessage } from "./sany-nodes";
|
|
15
|
+
import { getUnboxedSource } from "./sany-source";
|
|
16
|
+
import type { TlcVersion } from "./tlc-version";
|
|
17
|
+
|
|
18
|
+
export interface SanyReport {
|
|
19
|
+
text: string;
|
|
20
|
+
isFailed: boolean;
|
|
21
|
+
// The specification SANY analyzes, which has errors when SANY rejects it.
|
|
22
|
+
specification?: SanySpecification;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Where SANY reads a module from: a file of its own, the file of the root module, which holds the
|
|
26
|
+
// root module's inner modules too, or the files of its standard modules.
|
|
27
|
+
export type SanyModuleOrigin = "file" | "root file" | "standard";
|
|
28
|
+
|
|
29
|
+
export interface SanyReportOptions {
|
|
30
|
+
// The file name SANY's caller gives it, which it prints in its messages about the specification.
|
|
31
|
+
fileName?: string;
|
|
32
|
+
// TLC runs SANY to print the file it parses each module from, as describeFile names it, and each
|
|
33
|
+
// module it analyzes and lints.
|
|
34
|
+
describeFile?: (moduleName: string, origin: SanyModuleOrigin) => string;
|
|
35
|
+
// tla2sany.xml.XMLExporter runs SANY with its validAstSettings, which neither lint the modules
|
|
36
|
+
// nor validate their PlusCal, and prints only SANY's errors.
|
|
37
|
+
isXmlExport?: boolean;
|
|
38
|
+
// The TLC whose SANY to reproduce.
|
|
39
|
+
version?: TlcVersion;
|
|
40
|
+
// The modules TLC adds to the root module's EXTENDS for its post conditions.
|
|
41
|
+
rootExtendees?: string[];
|
|
42
|
+
// Prints what SANY prints as it goes, before the report holds all of it.
|
|
43
|
+
onPrint?: (text: string) => void;
|
|
44
|
+
// Prints what TLC 1.7.4's SANY prints to its error stream as it goes.
|
|
45
|
+
onPrintError?: (text: string) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface LoadedModule {
|
|
49
|
+
text: string;
|
|
50
|
+
module: Module;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Validation {
|
|
54
|
+
text: string;
|
|
55
|
+
isError: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ErrorDetails.toString.
|
|
59
|
+
const formatMessage = (message: SanyMessage) =>
|
|
60
|
+
`${formatSanyLocation(message.location)}\n\n${message.text}`;
|
|
61
|
+
|
|
62
|
+
// Errors.toString: the errors and then the warnings of a phase of SANY.
|
|
63
|
+
const formatErrors = (messages: SanyMessage[]) => {
|
|
64
|
+
const errors = messages.filter((message) => !message.isWarning);
|
|
65
|
+
const warnings = messages.filter((message) => message.isWarning);
|
|
66
|
+
return [
|
|
67
|
+
errors.length > 0 ? `*** Errors: ${errors.length}\n\n` : "",
|
|
68
|
+
...errors.map((error) => `${formatMessage(error)}\n\n\n`),
|
|
69
|
+
warnings.length > 0 ? `*** Warnings: ${warnings.length}\n\n` : "",
|
|
70
|
+
...warnings.map((warning) => `${formatMessage(warning)}\n\n\n`),
|
|
71
|
+
].join("");
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// tla2sany.semantic.StandardModules: SANY lints the modules other than these.
|
|
75
|
+
const UNLINTED_MODULES = new Set([
|
|
76
|
+
"FiniteSets",
|
|
77
|
+
"Sequences",
|
|
78
|
+
"Bags",
|
|
79
|
+
"Naturals",
|
|
80
|
+
"Integers",
|
|
81
|
+
"Reals",
|
|
82
|
+
"RealTime",
|
|
83
|
+
"Randomization",
|
|
84
|
+
"TLC",
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
// The modules a module and its inner modules extend, other than its inner modules.
|
|
88
|
+
const getExtendees = (module: Module) => {
|
|
89
|
+
const innerNames = new Set<string>();
|
|
90
|
+
const extendees: string[] = [];
|
|
91
|
+
const visit = (current: Module) => {
|
|
92
|
+
innerNames.add(current.name);
|
|
93
|
+
extendees.push(...current.extends);
|
|
94
|
+
current.modules.forEach(visit);
|
|
95
|
+
};
|
|
96
|
+
visit(module);
|
|
97
|
+
return extendees.filter((extendee) => !innerNames.has(extendee));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// HACK: the report parses a module to find the lines SANY's validation of its PlusCal reads, and
|
|
101
|
+
// a module that doesn't parse is one SANY stops at before validating it.
|
|
102
|
+
const parseValidatedModule = (text: string) => {
|
|
103
|
+
try {
|
|
104
|
+
return parseSanyModule(getUnboxedSource(text));
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error instanceof TlaSyntaxError) return undefined;
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// ParseUnit.parseFile: SANY names the specification by the root module once it parses it.
|
|
112
|
+
export const getSanyModuleName = (text: string, version?: TlcVersion) =>
|
|
113
|
+
version === "1.7.4" && getSany174LexicalError(text) !== undefined
|
|
114
|
+
? undefined
|
|
115
|
+
: parseValidatedModule(text)?.name;
|
|
116
|
+
|
|
117
|
+
// What SANY prints while TLC runs it on the specification in rootPath, and whether SANY rejects the
|
|
118
|
+
// specification. loadModule finds the source of the other modules, and SANY's standard modules fill
|
|
119
|
+
// in the rest.
|
|
120
|
+
export const getSanyReport = (
|
|
121
|
+
rootPath: string,
|
|
122
|
+
loadModule: (name: string) => string | undefined = () => undefined,
|
|
123
|
+
options: SanyReportOptions = {},
|
|
124
|
+
): SanyReport => {
|
|
125
|
+
const rootName = basename(rootPath, ".tla");
|
|
126
|
+
const standardModules = getSanyStandardModules(options.version);
|
|
127
|
+
const name = options.fileName ?? rootName;
|
|
128
|
+
// SANY looks for the root module where it looks for the others, its standard modules among them.
|
|
129
|
+
const source = existsSync(rootPath)
|
|
130
|
+
? readFileSync(rootPath, "utf8")
|
|
131
|
+
: standardModules.get(rootName);
|
|
132
|
+
const lines: string[] = [];
|
|
133
|
+
const write = (text: string) => {
|
|
134
|
+
lines.push(text);
|
|
135
|
+
options.onPrint?.(text);
|
|
136
|
+
};
|
|
137
|
+
const log = (text: string) => write(`${text}\n`);
|
|
138
|
+
const isTlc174 = options.version === "1.7.4";
|
|
139
|
+
// TLC 1.7.4's XMLExporter discards what SANY prints to ToolIO.out rather than its error stream.
|
|
140
|
+
const isToolOutputDiscarded = isTlc174 && options.isXmlExport;
|
|
141
|
+
const warn = (text: string) => {
|
|
142
|
+
if (!options.isXmlExport) log(text);
|
|
143
|
+
};
|
|
144
|
+
const describeFile = options.describeFile;
|
|
145
|
+
const origins = new Map<string, SanyModuleOrigin>([
|
|
146
|
+
[rootName, existsSync(rootPath) ? "file" : "standard"],
|
|
147
|
+
]);
|
|
148
|
+
const isFailed = { value: false };
|
|
149
|
+
// The messages of SANY's parsing phase, which come from its validation of PlusCal, and whether
|
|
150
|
+
// SANY has printed them and whether one is an error that ends its run before semantic analysis.
|
|
151
|
+
const parseMessages: SanyMessage[] = [];
|
|
152
|
+
const parsePhase = { isReported: false, isAborted: false };
|
|
153
|
+
const session = createPcalSession(createPcalParams(), log);
|
|
154
|
+
const loadedModules = new Map<string, LoadedModule>();
|
|
155
|
+
// TLC 1.7.4's SpecObj.validateParseUnit prints what it finds, which follows the file SANY parses
|
|
156
|
+
// next, as SANY validates a module once it parses the module or one that extends it.
|
|
157
|
+
const validations: Validation[] = [];
|
|
158
|
+
const printValidations = () =>
|
|
159
|
+
validations
|
|
160
|
+
.splice(0)
|
|
161
|
+
.forEach((validation) =>
|
|
162
|
+
validation.isError ? options.onPrintError?.(`${validation.text}\n`) : log(validation.text),
|
|
163
|
+
);
|
|
164
|
+
// SpecObj.validateParseUnit: Errors.addMessage drops a message it already has.
|
|
165
|
+
const validate = (moduleName: string) => {
|
|
166
|
+
const loaded = loadedModules.get(moduleName);
|
|
167
|
+
const range = loaded?.module.location.range;
|
|
168
|
+
if (loaded === undefined || range === undefined) return;
|
|
169
|
+
const fileLines = loaded.text.split(/\r\n|\r|\n/);
|
|
170
|
+
const results = validatePcalModule(
|
|
171
|
+
session,
|
|
172
|
+
fileLines.slice(range.start.line - 1, range.end.line),
|
|
173
|
+
options.version,
|
|
174
|
+
);
|
|
175
|
+
const isTlaChanged = results.has("TLA_DIVERGENCE_EXISTS");
|
|
176
|
+
const isPcalChanged = results.has("PCAL_DIVERGENCE_EXISTS");
|
|
177
|
+
// Both versions word a change to just one of the algorithm and its translation alike.
|
|
178
|
+
const oneChange =
|
|
179
|
+
isTlaChanged === isPcalChanged
|
|
180
|
+
? undefined
|
|
181
|
+
: `The ${isTlaChanged ? "TLA+ translation" : "PlusCal algorithm"} in module ${moduleName} has changed since its last translation.`;
|
|
182
|
+
if (isTlc174) {
|
|
183
|
+
const warning =
|
|
184
|
+
isTlaChanged && isPcalChanged
|
|
185
|
+
? `The PlusCal algorithm and its TLA+ translation in module ${moduleName} filename since the last translation.`
|
|
186
|
+
: oneChange;
|
|
187
|
+
if (warning !== undefined)
|
|
188
|
+
validations.push({ text: `!! WARNING: ${warning}`, isError: false });
|
|
189
|
+
else if (results.has("ERROR_ENCOUNTERED")) {
|
|
190
|
+
validations.push({
|
|
191
|
+
text: `A unexpected problem was encountered attempting to validate the specification for ${moduleName}`,
|
|
192
|
+
isError: true,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const text =
|
|
198
|
+
isTlaChanged && isPcalChanged
|
|
199
|
+
? `Both the PlusCal algorithm and its TLA+ translation in module ${moduleName} have changed since the last translation.`
|
|
200
|
+
: (oneChange ??
|
|
201
|
+
(results.has("ERROR_ENCOUNTERED")
|
|
202
|
+
? `An unexpected problem was encountered attempting to validate the specification for ${moduleName}`
|
|
203
|
+
: undefined));
|
|
204
|
+
if (text === undefined) return;
|
|
205
|
+
const isWarning = !results.has("ERROR_ENCOUNTERED") || isTlaChanged || isPcalChanged;
|
|
206
|
+
if (parseMessages.some((message) => message.text === text)) return;
|
|
207
|
+
parseMessages.push({ location: moduleName, text, isWarning });
|
|
208
|
+
};
|
|
209
|
+
// SpecObj.loadSpec validates the root module once it parses, and a module each time SANY
|
|
210
|
+
// resolves another module's EXTENDS of it, which the report does when the generator loads it,
|
|
211
|
+
// and for a module loaded earlier, when the generator loads a module that extends it.
|
|
212
|
+
const loadValidatedModule = (moduleName: string, text: string) => {
|
|
213
|
+
if (options.isXmlExport || loadedModules.has(moduleName)) return;
|
|
214
|
+
const module = parseValidatedModule(text);
|
|
215
|
+
if (module === undefined || module.name !== moduleName) return;
|
|
216
|
+
const extenders = [...loadedModules.values()].filter((loaded) =>
|
|
217
|
+
getExtendees(loaded.module).includes(moduleName),
|
|
218
|
+
);
|
|
219
|
+
loadedModules.set(moduleName, { text, module });
|
|
220
|
+
extenders.forEach(() => validate(moduleName));
|
|
221
|
+
getExtendees(module)
|
|
222
|
+
.filter((extendee) => extendee !== moduleName && loadedModules.has(extendee))
|
|
223
|
+
.forEach(validate);
|
|
224
|
+
};
|
|
225
|
+
// SANY.frontEndParse: once SANY has loaded the specification, it prints the warnings of its
|
|
226
|
+
// parsing phase, and when there are errors, every message, and stops.
|
|
227
|
+
const reportParseMessages = () => {
|
|
228
|
+
printValidations();
|
|
229
|
+
if (parsePhase.isReported) return;
|
|
230
|
+
parsePhase.isReported = true;
|
|
231
|
+
const warnings = parseMessages.filter((message) => message.isWarning);
|
|
232
|
+
if (warnings.length > 0) {
|
|
233
|
+
warn(`Warnings (${warnings.length}) during syntax parsing of ${name}:\n\n`);
|
|
234
|
+
warnings.forEach((warning) => warn(`${formatMessage(warning)}\n\n\n`));
|
|
235
|
+
}
|
|
236
|
+
if (warnings.length === parseMessages.length) return;
|
|
237
|
+
log(formatErrors(parseMessages));
|
|
238
|
+
isFailed.value = true;
|
|
239
|
+
parsePhase.isAborted = true;
|
|
240
|
+
};
|
|
241
|
+
const loadSource = (moduleName: string) => {
|
|
242
|
+
const standard = standardModules.get(moduleName);
|
|
243
|
+
const file = loadModule(moduleName);
|
|
244
|
+
// TLC 1.7.4's SANY reads a module only from a file of its own.
|
|
245
|
+
const extracted =
|
|
246
|
+
file === undefined && standard === undefined && source !== undefined && !isTlc174
|
|
247
|
+
? extractModule(source, moduleName)
|
|
248
|
+
: undefined;
|
|
249
|
+
const text = file ?? extracted;
|
|
250
|
+
origins.set(
|
|
251
|
+
moduleName,
|
|
252
|
+
file !== undefined ? "file" : extracted !== undefined ? "root file" : "standard",
|
|
253
|
+
);
|
|
254
|
+
// The standard modules have no PlusCal, and SANY validates an extracted module's own text.
|
|
255
|
+
if (text !== undefined) loadValidatedModule(moduleName, text);
|
|
256
|
+
return text ?? standard;
|
|
257
|
+
};
|
|
258
|
+
const generate = () => {
|
|
259
|
+
// HACK: SANY reports a fatal error of its parsing phase by the exception it throws, so the
|
|
260
|
+
// report catches the TlaSyntaxError the generator throws for one.
|
|
261
|
+
try {
|
|
262
|
+
if (source === undefined) {
|
|
263
|
+
throw new TlaSanyFatalError(`Cannot find source file for module ${name}`, undefined);
|
|
264
|
+
}
|
|
265
|
+
loadValidatedModule(rootName, source);
|
|
266
|
+
return generateSanySpecification(source, loadSource, {
|
|
267
|
+
rootFileName: rootName,
|
|
268
|
+
version: options.version,
|
|
269
|
+
rootExtendees: options.rootExtendees,
|
|
270
|
+
onParse: (moduleName) => {
|
|
271
|
+
if (describeFile) {
|
|
272
|
+
log(`Parsing file ${describeFile(moduleName, origins.get(moduleName) ?? "file")}`);
|
|
273
|
+
}
|
|
274
|
+
if (moduleName === rootName) validate(rootName);
|
|
275
|
+
printValidations();
|
|
276
|
+
},
|
|
277
|
+
onAnalyze: (moduleName) => {
|
|
278
|
+
reportParseMessages();
|
|
279
|
+
// TLC 1.7.4's XMLExporter prints what SANY prints as it analyzes the modules.
|
|
280
|
+
if ((describeFile || isToolOutputDiscarded) && !parsePhase.isAborted) {
|
|
281
|
+
log(`Semantic processing of module ${moduleName}`);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
// SANY.frontEndSemanticAnalysis: after each module, SANY level-checks it if there are no
|
|
285
|
+
// errors yet, then prints every message so far.
|
|
286
|
+
onModule: (module, messages) => {
|
|
287
|
+
if (parsePhase.isAborted) return;
|
|
288
|
+
if (messages.every((message) => message.isWarning))
|
|
289
|
+
checkModuleLevels(module, { messages, isTlc174 });
|
|
290
|
+
if (messages.length === 0) return;
|
|
291
|
+
if (messages.some((message) => !message.isWarning)) isFailed.value = true;
|
|
292
|
+
// TLC 1.7.4's SANY prints the errors and warnings together.
|
|
293
|
+
if (isTlc174) return log(`Semantic errors:\n\n${formatErrors(messages)}`);
|
|
294
|
+
const warnings = messages.filter((message) => message.isWarning);
|
|
295
|
+
if (warnings.length > 0) {
|
|
296
|
+
warn(`*** Warnings: ${warnings.length}\n`);
|
|
297
|
+
warnings.forEach((warning) => warn(`${formatMessage(warning)}\n\n\n`));
|
|
298
|
+
}
|
|
299
|
+
const errors = messages.filter((message) => !message.isWarning);
|
|
300
|
+
if (errors.length === 0) return;
|
|
301
|
+
log(`Semantic errors:\n\n*** Errors: ${errors.length}\n`);
|
|
302
|
+
errors.forEach((error) => log(`${formatMessage(error)}\n\n`));
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
} catch (error) {
|
|
306
|
+
isFailed.value = true;
|
|
307
|
+
// SANY.frontEndParse turns a Java exception of its validation of PlusCal into a fatal
|
|
308
|
+
// error, printing the exception and its messages so far.
|
|
309
|
+
if (error instanceof PcalRuntimeError) {
|
|
310
|
+
log(`\nFatal errors while parsing TLA+ spec in file ${name}\n`);
|
|
311
|
+
log(error.message);
|
|
312
|
+
log(formatErrors(parseMessages));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!(error instanceof TlaSanyFatalError)) throw error;
|
|
316
|
+
const fatal = { location: error.location, text: error.message, isWarning: false };
|
|
317
|
+
// TLC 1.7.4's ParseException.getShortMessage fails on an error at the first token, which has
|
|
318
|
+
// no image.
|
|
319
|
+
const isImageless = isTlc174 && error.parseError?.includes(' and token "" ');
|
|
320
|
+
if (error.parseError !== undefined && !isImageless && !isToolOutputDiscarded) {
|
|
321
|
+
log(error.parseError);
|
|
322
|
+
}
|
|
323
|
+
log(`\nFatal errors while parsing TLA+ spec in file ${name}\n`);
|
|
324
|
+
if (isImageless) {
|
|
325
|
+
log(
|
|
326
|
+
'java.lang.NullPointerException: Cannot invoke "String.length()" because "str" is null',
|
|
327
|
+
);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
// TLC 1.7.4's SANY aborts with an AbortException, and keeps the message as an abort.
|
|
331
|
+
if (isTlc174) {
|
|
332
|
+
log("tla2sany.semantic.AbortException");
|
|
333
|
+
write(`*** Abort messages: 1\n\n${formatMessage(fatal)}\n\n\n`);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
log(formatMessage(fatal));
|
|
337
|
+
log(formatErrors(parsePhase.isReported ? [fatal] : [...parseMessages, fatal]));
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
const specification = generate();
|
|
341
|
+
if (specification !== undefined) reportParseMessages();
|
|
342
|
+
// SANY.frontEndLinting: when SANY accepts the specification, it lints the modules that are not
|
|
343
|
+
// its standard modules, then prints the warnings. TLC 1.7.4's SANY has no linter.
|
|
344
|
+
if (specification !== undefined && !isFailed.value && !options.isXmlExport && !isTlc174) {
|
|
345
|
+
const linted = specification.modules.filter((module) => !UNLINTED_MODULES.has(module.name));
|
|
346
|
+
if (describeFile) linted.forEach((module) => log(`Linting of module ${module.name}`));
|
|
347
|
+
linted.flatMap(lintSanyModule).forEach((warning) => log(`${formatMessage(warning)}\n\n\n`));
|
|
348
|
+
}
|
|
349
|
+
return {
|
|
350
|
+
text: lines.join(""),
|
|
351
|
+
isFailed: isFailed.value,
|
|
352
|
+
specification: parsePhase.isAborted ? undefined : specification,
|
|
353
|
+
};
|
|
354
|
+
};
|