tla-ts 0.0.3-dev.e9d8347 → 0.0.3-dev.eed6eb1
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 +1348 -227
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -21
- package/src/config.ts +254 -181
- package/src/environment.ts +437 -123
- package/src/errors.ts +210 -5
- package/src/evaluate.ts +716 -141
- package/src/exit-codes.ts +5 -4
- package/src/index.ts +1 -0
- package/src/instances.ts +4 -2
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +183 -37
- package/src/lexer.ts +122 -29
- package/src/live-check.ts +204 -146
- package/src/liveness.ts +192 -65
- 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 +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 +1179 -155
- 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 +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 +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 +26 -7
- 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 +162 -114
- 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 +699 -256
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { SourceRange } from "./ast";
|
|
2
|
+
|
|
3
|
+
// Where the modules in TLC's tla2sany/StandardModules define the operators that tla-ts implements
|
|
4
|
+
// natively, which SANY reports when a spec defines one of them again.
|
|
5
|
+
const RANGES: Record<string, Record<string, [number, number, number, number]>> = {
|
|
6
|
+
Naturals: {
|
|
7
|
+
Nat: [14, 1, 14, 16],
|
|
8
|
+
"+": [15, 1, 15, 19],
|
|
9
|
+
"-": [17, 1, 17, 33],
|
|
10
|
+
"*": [18, 1, 18, 17],
|
|
11
|
+
"^": [19, 1, 19, 19],
|
|
12
|
+
"<": [20, 1, 20, 19],
|
|
13
|
+
">": [21, 1, 21, 19],
|
|
14
|
+
"<=": [22, 1, 22, 19],
|
|
15
|
+
">=": [23, 1, 23, 19],
|
|
16
|
+
"%": [33, 1, 33, 20],
|
|
17
|
+
"\\div": [34, 1, 34, 20],
|
|
18
|
+
"..": [35, 1, 35, 20],
|
|
19
|
+
},
|
|
20
|
+
Integers: {
|
|
21
|
+
Int: [18, 1, 18, 12],
|
|
22
|
+
"-.": [22, 1, 22, 13],
|
|
23
|
+
},
|
|
24
|
+
Sequences: {
|
|
25
|
+
Seq: [20, 1, 20, 41],
|
|
26
|
+
Len: [25, 1, 25, 44],
|
|
27
|
+
"\\o": [30, 1, 31, 76],
|
|
28
|
+
Append: [36, 1, 36, 26],
|
|
29
|
+
Head: [41, 1, 41, 15],
|
|
30
|
+
Tail: [42, 1, 42, 61],
|
|
31
|
+
SubSeq: [48, 1, 48, 50],
|
|
32
|
+
SelectSeq: [53, 1, 65, 14],
|
|
33
|
+
},
|
|
34
|
+
FiniteSets: {
|
|
35
|
+
IsFiniteSet: [14, 1, 19, 68],
|
|
36
|
+
Cardinality: [21, 1, 27, 11],
|
|
37
|
+
},
|
|
38
|
+
Bags: {
|
|
39
|
+
IsABag: [20, 1, 24, 41],
|
|
40
|
+
BagToSet: [26, 1, 26, 23],
|
|
41
|
+
SetToBag: [31, 1, 31, 30],
|
|
42
|
+
BagIn: [36, 1, 36, 31],
|
|
43
|
+
EmptyBag: [41, 1, 41, 24],
|
|
44
|
+
"\\oplus": [43, 1, 49, 46],
|
|
45
|
+
"\\ominus": [51, 1, 60, 50],
|
|
46
|
+
BagUnion: [74, 1, 79, 58],
|
|
47
|
+
"\\sqsubseteq": [81, 1, 87, 42],
|
|
48
|
+
SubBag: [89, 1, 110, 11],
|
|
49
|
+
BagOfAll: [122, 1, 130, 66],
|
|
50
|
+
BagCardinality: [132, 1, 138, 8],
|
|
51
|
+
CopiesIn: [140, 1, 145, 33],
|
|
52
|
+
},
|
|
53
|
+
TLC: {
|
|
54
|
+
Print: [17, 1, 17, 22],
|
|
55
|
+
PrintT: [18, 1, 18, 19],
|
|
56
|
+
Assert: [24, 1, 25, 54],
|
|
57
|
+
JavaTime: [26, 1, 26, 32],
|
|
58
|
+
TLCGet: [75, 1, 75, 28],
|
|
59
|
+
TLCSet: [76, 1, 76, 20],
|
|
60
|
+
":>": [78, 1, 78, 27],
|
|
61
|
+
"@@": [79, 1, 80, 50],
|
|
62
|
+
Permutations: [81, 1, 82, 54],
|
|
63
|
+
SortSeq: [88, 1, 92, 40],
|
|
64
|
+
RandomElement: [110, 1, 110, 41],
|
|
65
|
+
Any: [119, 1, 119, 22],
|
|
66
|
+
ToString: [121, 1, 121, 58],
|
|
67
|
+
TLCEval: [145, 1, 145, 15],
|
|
68
|
+
},
|
|
69
|
+
TLCExt: {
|
|
70
|
+
AssertEq: [14, 1, 20, 14],
|
|
71
|
+
AssertError: [23, 1, 26, 72],
|
|
72
|
+
TLCGetOrDefault: [30, 1, 31, 17],
|
|
73
|
+
TLCGetAndSet: [33, 1, 35, 57],
|
|
74
|
+
Trace: [41, 1, 57, 6],
|
|
75
|
+
CounterExample: [61, 1, 75, 8],
|
|
76
|
+
ToTrace: [77, 1, 87, 12],
|
|
77
|
+
TLCModelValue: [91, 1, 120, 29],
|
|
78
|
+
TLCDefer: [122, 1, 134, 6],
|
|
79
|
+
TLCNoOp: [138, 1, 145, 5],
|
|
80
|
+
PickSuccessor: [148, 1, 162, 37],
|
|
81
|
+
TLCCache: [166, 1, 173, 12],
|
|
82
|
+
TLCFP: [175, 1, 181, 24],
|
|
83
|
+
TLCEvalDefinition: [185, 1, 190, 6],
|
|
84
|
+
},
|
|
85
|
+
Randomization: {
|
|
86
|
+
RandomSubset: [30, 1, 30, 64],
|
|
87
|
+
RandomSetOfSubsets: [48, 1, 49, 67],
|
|
88
|
+
TestRandomSetOfSubsets: [61, 1, 62, 71],
|
|
89
|
+
},
|
|
90
|
+
Json: {
|
|
91
|
+
ToJson: [46, 1, 55, 37],
|
|
92
|
+
ToJsonArray: [57, 1, 64, 42],
|
|
93
|
+
ToJsonObject: [66, 1, 73, 43],
|
|
94
|
+
JsonSerialize: [75, 1, 80, 6],
|
|
95
|
+
JsonDeserialize: [82, 1, 87, 19],
|
|
96
|
+
ndJsonSerialize: [89, 1, 95, 6],
|
|
97
|
+
ndJsonDeserialize: [97, 1, 103, 19],
|
|
98
|
+
},
|
|
99
|
+
_Possible: {
|
|
100
|
+
_Track: [10, 1, 17, 38],
|
|
101
|
+
_Counts: [24, 1, 30, 14],
|
|
102
|
+
_CheckName: [32, 1, 35, 35],
|
|
103
|
+
_PrintCounts: [37, 1, 37, 31],
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const getStandardRange = (module: string, name: string): SourceRange | undefined => {
|
|
108
|
+
const range = RANGES[module]?.[name];
|
|
109
|
+
return (
|
|
110
|
+
range && {
|
|
111
|
+
module,
|
|
112
|
+
start: { line: range[0], column: range[1] },
|
|
113
|
+
end: { line: range[2], column: range[3] },
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
};
|
package/src/state-graph.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// A port of TLC's -dump writers, tlc2.util.StateWriter and tlc2.util.DotStateWriter.
|
|
2
2
|
|
|
3
|
+
import type { TlcVersion } from "./tlc-version";
|
|
4
|
+
|
|
3
5
|
export interface StateDump {
|
|
4
6
|
path: string;
|
|
5
7
|
dot?: boolean;
|
|
@@ -29,6 +31,8 @@ export interface StateWriter {
|
|
|
29
31
|
isSeen: boolean,
|
|
30
32
|
action: GraphAction | undefined,
|
|
31
33
|
) => void;
|
|
34
|
+
// The stuttering step of a state that TLC 1.7.4 adds to the behavior graph.
|
|
35
|
+
writeStuttering: (state: GraphState) => void;
|
|
32
36
|
close: () => void;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -77,14 +81,23 @@ const createPlainWriter = (dump: StateDump, writeFile: WriteFile): StateWriter =
|
|
|
77
81
|
writeSuccessor: (_state, successor, isSeen) => {
|
|
78
82
|
if (!isSeen) writeState(successor);
|
|
79
83
|
},
|
|
84
|
+
// TLC 1.7.4 writes the state again, as it takes the stuttering step for one to a new state.
|
|
85
|
+
writeStuttering: writeState,
|
|
80
86
|
close: () => writeFile?.(dump.path, states.join("")),
|
|
81
87
|
};
|
|
82
88
|
};
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
// TLC 1.7.4 draws its nodes as ellipses, gives them no tooltip, and labels an edge with the name
|
|
91
|
+
// of its action alone.
|
|
92
|
+
const createDotWriter = (
|
|
93
|
+
dump: StateDump,
|
|
94
|
+
writeFile: WriteFile,
|
|
95
|
+
version: TlcVersion | undefined,
|
|
96
|
+
): StateWriter => {
|
|
97
|
+
const is174 = version === "1.7.4";
|
|
85
98
|
const lines = [
|
|
86
99
|
"strict digraph DiskGraph {\n",
|
|
87
|
-
"node [shape=box,style=rounded]\n",
|
|
100
|
+
is174 ? "" : "node [shape=box,style=rounded]\n",
|
|
88
101
|
dump.colorize ? `edge [colorscheme="${COLOR_SCHEME}"]\n` : "",
|
|
89
102
|
"nodesep=0.35;\n",
|
|
90
103
|
"subgraph cluster_graph {\n",
|
|
@@ -137,21 +150,31 @@ const createDotWriter = (dump: StateDump, writeFile: WriteFile): StateWriter =>
|
|
|
137
150
|
},
|
|
138
151
|
writeSuccessor: (state, successor, isSeen, action) => {
|
|
139
152
|
const color = dump.colorize ? String(getColor(action)) : "black";
|
|
140
|
-
const label =
|
|
153
|
+
const label =
|
|
154
|
+
dump.actionLabels && action ? escape(is174 ? action.name : action.signature) : "";
|
|
141
155
|
lines.push(
|
|
142
156
|
`${state.fingerprint} -> ${successor.fingerprint} [label="${label}",color="${color}",fontcolor="${color}"];\n`,
|
|
143
157
|
);
|
|
144
158
|
if (!isSeen) {
|
|
159
|
+
const tooltip = is174 ? "" : `,tooltip="${toDot(successor.getText())}"`;
|
|
145
160
|
lines.push(
|
|
146
|
-
`${successor.fingerprint} [label="${toDot(successor.getLabel())}"
|
|
161
|
+
`${successor.fingerprint} [label="${toDot(successor.getLabel())}"${tooltip}];\n`,
|
|
147
162
|
);
|
|
148
163
|
}
|
|
149
164
|
addRank(state);
|
|
150
165
|
writeSnapshot();
|
|
151
166
|
},
|
|
167
|
+
writeStuttering: (state) => {
|
|
168
|
+
lines.push(`${state.fingerprint} -> ${state.fingerprint} [style="dashed"];\n`);
|
|
169
|
+
addRank(state);
|
|
170
|
+
writeSnapshot();
|
|
171
|
+
},
|
|
152
172
|
close: () => writeFile?.(dump.path, lines.join("") + getEnding()),
|
|
153
173
|
};
|
|
154
174
|
};
|
|
155
175
|
|
|
156
|
-
export const createStateWriter = (
|
|
157
|
-
dump
|
|
176
|
+
export const createStateWriter = (
|
|
177
|
+
dump: StateDump,
|
|
178
|
+
writeFile: WriteFile,
|
|
179
|
+
version: TlcVersion | undefined,
|
|
180
|
+
) => (dump.dot ? createDotWriter(dump, writeFile, version) : createPlainWriter(dump, writeFile));
|