tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.b4a856304
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/index.cjs +1 -1
- package/dist/index.d.cts +0 -34
- package/dist/index.d.ts +0 -34
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +1 -1
- package/dist/prove.cjs +43 -43
- package/dist/prove.js +47 -47
- package/dist/run.cjs +30 -30
- package/dist/run.js +33 -33
- package/dist/transfer.cjs +38 -38
- package/dist/transfer.js +39 -39
- package/package.json +1 -1
- package/src/ast.ts +5 -0
- package/src/bags.ts +5 -2
- package/src/builtins.ts +8 -1
- package/src/check.ts +193 -128
- package/src/cli/run.ts +2 -0
- package/src/cli/runtime-invariants.ts +7 -8
- package/src/cli/shared.ts +4 -0
- package/src/cli/tlc-arguments.ts +30 -24
- package/src/cli/tlc-usage.ts +3 -2
- package/src/evaluate.ts +102 -26
- package/src/java-overrides.ts +9 -4
- package/src/json-reader.ts +2 -1
- package/src/json.ts +11 -4
- package/src/levels.ts +15 -7
- package/src/lexer.ts +83 -72
- package/src/liveness-checker.ts +106 -77
- package/src/liveness.ts +34 -10
- package/src/parallel.ts +33 -26
- package/src/parser.ts +226 -163
- package/src/pcal/ast.ts +65 -53
- package/src/pcal/parse.ts +191 -144
- package/src/pcal/tokenize.ts +115 -91
- package/src/pcal/translate.ts +98 -83
- package/src/pcal/validate.ts +50 -48
- package/src/pretty-print.ts +6 -6
- package/src/randomization.ts +4 -1
- package/src/resolve.ts +70 -12
- package/src/runtime.ts +18 -11
- package/src/sany/builtins.ts +3 -1
- package/src/sany/generator.ts +127 -74
- package/src/sany/levels.ts +9 -5
- package/src/sany/lexer.ts +44 -40
- package/src/sany/linter.ts +1 -0
- package/src/search.ts +1 -1
- package/src/simulate.ts +59 -50
- package/src/spec-description.ts +34 -23
- package/src/standard-definitions.ts +3 -0
- package/src/standard-modules.ts +12 -1
- package/src/state-graph.ts +8 -1
- package/src/subexpressions.ts +47 -38
- package/src/successors.ts +35 -14
- package/src/symmetry.ts +19 -4
- package/src/tlc/fingerprint.ts +21 -15
- package/src/tlc/jar-data.ts +1 -0
- package/src/tlc/messages.ts +21 -2
- package/src/tlc/order.ts +38 -20
- package/src/tlc/random.ts +30 -18
- package/src/tlc/replay.ts +33 -13
- package/src/tlc/summary.ts +45 -36
- package/src/tlc/tlc-operators.ts +14 -4
- package/src/tlc/tlcext-operators.ts +15 -11
- package/src/tlc/trace-spec.ts +4 -0
- package/src/tlc/value-stream.ts +13 -9
- package/src/tlc/version.ts +1 -0
- package/src/values.ts +181 -74
package/src/pcal/tokenize.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PcalError, PcalBugError } from "../errors";
|
|
2
2
|
import { createNormalizedPcalExpr, createPcalToken, PCAL_TOKEN, type PcalToken } from "./ast";
|
|
3
3
|
|
|
4
|
+
// Returns "\n" at the end of each line and "\t" at the end of the input. Columns count code
|
|
5
|
+
// points, and the lines come without tabs, as trans.removeTabs replaced them.
|
|
4
6
|
export interface PcalCharReader {
|
|
5
7
|
lines: string[];
|
|
6
8
|
currentLine: string[] | undefined;
|
|
@@ -88,6 +90,7 @@ const BUILT_IN_SYMBOLS = new Set([
|
|
|
88
90
|
),
|
|
89
91
|
]);
|
|
90
92
|
|
|
93
|
+
// tla2tex.Misc.IsLetter, IsDigit and IsSpace, which only accept ASCII.
|
|
91
94
|
const isLetter = (char: string) => /^[A-Za-z_]$/.test(char);
|
|
92
95
|
const isDigit = (char: string) => /^[0-9]$/.test(char);
|
|
93
96
|
const isSpace = (char: string) => char === " " || char === "\f" || char === "\r";
|
|
@@ -95,9 +98,7 @@ const isSpace = (char: string) => char === " " || char === "\f" || char === "\r"
|
|
|
95
98
|
const BUILT_IN_PREFIXES = new Set(
|
|
96
99
|
[...BUILT_IN_SYMBOLS]
|
|
97
100
|
.filter((symbol) => !isLetter(symbol[0]) && !(symbol[0] === "\\" && isLetter(symbol[1] ?? "")))
|
|
98
|
-
.flatMap((symbol) =>
|
|
99
|
-
Array.from(symbol, (_char, index) => symbol.slice(0, symbol.length - index)),
|
|
100
|
-
),
|
|
101
|
+
.flatMap((symbol) => Array.from(symbol, (_, index) => symbol.slice(0, symbol.length - index))),
|
|
101
102
|
);
|
|
102
103
|
|
|
103
104
|
const STRING_CHARS = new Set(
|
|
@@ -112,6 +113,7 @@ const DELIMITERS = new Set(
|
|
|
112
113
|
|
|
113
114
|
const TOKEN_TYPE = { ...PCAL_TOKEN, dashes: 6, endModule: 7 };
|
|
114
115
|
|
|
116
|
+
// An error in a comment leaves the comment depth set for the next call.
|
|
115
117
|
export interface PcalTokenizerState {
|
|
116
118
|
delimiter: string;
|
|
117
119
|
delimiterLine: number;
|
|
@@ -126,108 +128,126 @@ export const createPcalTokenizerState = (): PcalTokenizerState => ({
|
|
|
126
128
|
commentDepth: 0,
|
|
127
129
|
});
|
|
128
130
|
|
|
131
|
+
interface PcalScan {
|
|
132
|
+
lines: PcalToken[][];
|
|
133
|
+
line: PcalToken[];
|
|
134
|
+
token: string;
|
|
135
|
+
state: string;
|
|
136
|
+
column: number;
|
|
137
|
+
nextColumn: number;
|
|
138
|
+
nextChar: string;
|
|
139
|
+
parenDepth: number;
|
|
140
|
+
isInQuantifier: boolean;
|
|
141
|
+
isExprEnd: boolean;
|
|
142
|
+
previousToken: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// A define block's commas at the top level don't end its expression.
|
|
129
146
|
const tokenize = (
|
|
130
147
|
state: PcalTokenizerState,
|
|
131
148
|
reader: PcalCharReader,
|
|
132
149
|
isExpr: boolean,
|
|
133
150
|
isInDefineBlock: boolean,
|
|
134
151
|
) => {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
const scan: PcalScan = {
|
|
153
|
+
lines: [],
|
|
154
|
+
line: [],
|
|
155
|
+
token: "",
|
|
156
|
+
state: "start",
|
|
157
|
+
column: reader.vcolumn,
|
|
158
|
+
nextColumn: reader.vcolumn,
|
|
159
|
+
nextChar: getNextPcalChar(reader),
|
|
160
|
+
parenDepth: 0,
|
|
161
|
+
isInQuantifier: false,
|
|
162
|
+
isExprEnd: false,
|
|
163
|
+
previousToken: " ",
|
|
164
|
+
};
|
|
146
165
|
const skipNextChar = () => {
|
|
147
|
-
nextColumn = reader.vcolumn;
|
|
148
|
-
nextChar = getNextPcalChar(reader);
|
|
166
|
+
scan.nextColumn = reader.vcolumn;
|
|
167
|
+
scan.nextChar = getNextPcalChar(reader);
|
|
149
168
|
};
|
|
150
169
|
const addNextChar = () => {
|
|
151
|
-
token += nextChar;
|
|
170
|
+
scan.token += scan.nextChar;
|
|
152
171
|
skipNextChar();
|
|
153
172
|
};
|
|
154
173
|
const gotoStart = () => {
|
|
155
|
-
|
|
156
|
-
column = nextColumn;
|
|
174
|
+
scan.state = "start";
|
|
175
|
+
scan.column = scan.nextColumn;
|
|
157
176
|
};
|
|
158
177
|
const startNewLine = () => {
|
|
159
|
-
lines.push(line);
|
|
160
|
-
line = [];
|
|
161
|
-
column = 0;
|
|
178
|
+
scan.lines.push(scan.line);
|
|
179
|
+
scan.line = [];
|
|
180
|
+
scan.column = 0;
|
|
162
181
|
};
|
|
163
182
|
const throwTokenizingError = (message: string): never => {
|
|
164
183
|
throw new PcalError(
|
|
165
|
-
`${message} \`${token}' found at\n line ${reader.line + 1}, column ${column + 1}`,
|
|
184
|
+
`${message} \`${scan.token}' found at\n line ${reader.line + 1}, column ${scan.column + 1}`,
|
|
166
185
|
);
|
|
167
186
|
};
|
|
168
187
|
const endExpression = () => {
|
|
169
|
-
isExprEnd = true;
|
|
170
|
-
state.delimiter = token;
|
|
171
|
-
state.delimiterCol = column;
|
|
172
|
-
state.delimiterLine = reader.line - (nextChar === "\n" ? 1 : 0);
|
|
188
|
+
scan.isExprEnd = true;
|
|
189
|
+
state.delimiter = scan.token;
|
|
190
|
+
state.delimiterCol = scan.column;
|
|
191
|
+
state.delimiterLine = reader.line - (scan.nextChar === "\n" ? 1 : 0);
|
|
173
192
|
};
|
|
174
|
-
const
|
|
193
|
+
const tokenOut = (type: number) => {
|
|
175
194
|
if (!isExpr) {
|
|
176
195
|
endExpression();
|
|
177
|
-
token = "";
|
|
196
|
+
scan.token = "";
|
|
178
197
|
return;
|
|
179
198
|
}
|
|
180
199
|
if (type > TOKEN_TYPE.ident) throwTokenizingError("Illegal token in an expression");
|
|
200
|
+
const token = scan.token;
|
|
181
201
|
const isDelimiter =
|
|
182
202
|
type !== TOKEN_TYPE.string &&
|
|
183
203
|
((DELIMITERS.has(token) &&
|
|
184
|
-
!(type === TOKEN_TYPE.ident && [".", "[", ","].includes(previousToken))) ||
|
|
185
|
-
(((token === "," && !isInQuantifier && !isInDefineBlock) ||
|
|
204
|
+
!(type === TOKEN_TYPE.ident && [".", "[", ","].includes(scan.previousToken))) ||
|
|
205
|
+
(((token === "," && !scan.isInQuantifier && !isInDefineBlock) ||
|
|
186
206
|
token === ")" ||
|
|
187
207
|
token === "}") &&
|
|
188
|
-
parenDepth === 0));
|
|
208
|
+
scan.parenDepth === 0));
|
|
189
209
|
if (isDelimiter) {
|
|
190
|
-
if (parenDepth !== 0) {
|
|
210
|
+
if (scan.parenDepth !== 0) {
|
|
191
211
|
throwTokenizingError("Expression with an unmatched (, [, {, or << followed by");
|
|
192
212
|
}
|
|
193
|
-
if (isInQuantifier) {
|
|
213
|
+
if (scan.isInQuantifier) {
|
|
194
214
|
throwTokenizingError("Expression with \\A or \\E but no following `:` followed by");
|
|
195
215
|
}
|
|
196
216
|
endExpression();
|
|
197
|
-
if (line.length > 0) startNewLine();
|
|
217
|
+
if (scan.line.length > 0) startNewLine();
|
|
198
218
|
return;
|
|
199
219
|
}
|
|
200
|
-
if (type === TOKEN_TYPE.builtin && LEFT_PARENS.has(token)) parenDepth += 1;
|
|
220
|
+
if (type === TOKEN_TYPE.builtin && LEFT_PARENS.has(token)) scan.parenDepth += 1;
|
|
201
221
|
if (type === TOKEN_TYPE.builtin && RIGHT_PARENS.has(token)) {
|
|
202
|
-
parenDepth -= 1;
|
|
203
|
-
if (parenDepth < 0) throwTokenizingError("Extra (unmatching)");
|
|
222
|
+
scan.parenDepth -= 1;
|
|
223
|
+
if (scan.parenDepth < 0) throwTokenizingError("Extra (unmatching)");
|
|
204
224
|
}
|
|
205
|
-
previousToken = type === TOKEN_TYPE.string ? " " : token;
|
|
206
|
-
if (["\\A", "∀", "\\E", "∃"].includes(token) && parenDepth === 0) {
|
|
207
|
-
isInQuantifier = true;
|
|
225
|
+
scan.previousToken = type === TOKEN_TYPE.string ? " " : token;
|
|
226
|
+
if (["\\A", "∀", "\\E", "∃"].includes(token) && scan.parenDepth === 0) {
|
|
227
|
+
scan.isInQuantifier = true;
|
|
208
228
|
}
|
|
209
|
-
if (isInQuantifier && token === ":" && parenDepth === 0) {
|
|
210
|
-
isInQuantifier = false;
|
|
229
|
+
if (scan.isInQuantifier && token === ":" && scan.parenDepth === 0) {
|
|
230
|
+
scan.isInQuantifier = false;
|
|
211
231
|
}
|
|
212
232
|
if (token !== "" || type === TOKEN_TYPE.string) {
|
|
213
|
-
line.push(createPcalToken(token, column, type));
|
|
233
|
+
scan.line.push(createPcalToken(token, scan.column, type));
|
|
214
234
|
}
|
|
215
|
-
token = "";
|
|
235
|
+
scan.token = "";
|
|
216
236
|
};
|
|
217
237
|
const outputToken = (type: number) => {
|
|
218
|
-
|
|
238
|
+
tokenOut(type);
|
|
219
239
|
gotoStart();
|
|
220
240
|
};
|
|
221
241
|
const addAndGoto = (nextState: string) => {
|
|
222
242
|
addNextChar();
|
|
223
|
-
|
|
243
|
+
scan.state = nextState;
|
|
224
244
|
};
|
|
225
245
|
const skipAndGoto = (nextState: string) => {
|
|
226
246
|
skipNextChar();
|
|
227
|
-
|
|
247
|
+
scan.state = nextState;
|
|
228
248
|
};
|
|
229
249
|
const step = (next: string) => {
|
|
230
|
-
switch (
|
|
250
|
+
switch (scan.state) {
|
|
231
251
|
case "start":
|
|
232
252
|
if (isSpace(next)) {
|
|
233
253
|
skipNextChar();
|
|
@@ -251,15 +271,17 @@ const tokenize = (
|
|
|
251
271
|
}
|
|
252
272
|
if (BUILT_IN_PREFIXES.has(next)) return addAndGoto("builtIn");
|
|
253
273
|
if (next === "\t") {
|
|
254
|
-
|
|
274
|
+
scan.state = "done";
|
|
255
275
|
return;
|
|
256
276
|
}
|
|
257
277
|
addNextChar();
|
|
258
278
|
return throwTokenizingError("Illegal lexeme");
|
|
259
279
|
case "id":
|
|
260
|
-
if (token === "WF_" || token === "SF_") return outputToken(TOKEN_TYPE.builtin);
|
|
280
|
+
if (scan.token === "WF_" || scan.token === "SF_") return outputToken(TOKEN_TYPE.builtin);
|
|
261
281
|
if (isLetter(next) || isDigit(next)) return addNextChar();
|
|
262
|
-
return outputToken(
|
|
282
|
+
return outputToken(
|
|
283
|
+
BUILT_IN_SYMBOLS.has(scan.token) ? TOKEN_TYPE.builtin : TOKEN_TYPE.ident,
|
|
284
|
+
);
|
|
263
285
|
case "numOrId":
|
|
264
286
|
if (isDigit(next)) return addNextChar();
|
|
265
287
|
if (isLetter(next)) return addAndGoto("id");
|
|
@@ -267,47 +289,48 @@ const tokenize = (
|
|
|
267
289
|
case "bs":
|
|
268
290
|
if (["b", "B", "o", "O", "h", "H"].includes(next)) return addAndGoto("numOrBi");
|
|
269
291
|
if (isLetter(next)) {
|
|
270
|
-
|
|
292
|
+
scan.state = "bsBuiltIn";
|
|
271
293
|
return;
|
|
272
294
|
}
|
|
273
295
|
if (next === "*") {
|
|
274
296
|
skipNextChar();
|
|
275
|
-
token = "";
|
|
276
|
-
|
|
297
|
+
scan.token = "";
|
|
298
|
+
scan.state = "lineComment";
|
|
277
299
|
return;
|
|
278
300
|
}
|
|
279
|
-
|
|
301
|
+
scan.state = "builtIn";
|
|
280
302
|
return;
|
|
281
303
|
case "numOrBi":
|
|
282
|
-
|
|
304
|
+
scan.state = isDigit(next) ? "num" : "bsBuiltIn";
|
|
283
305
|
return;
|
|
284
306
|
case "num":
|
|
285
307
|
if (isDigit(next)) return addNextChar();
|
|
286
308
|
if (!isLetter(next)) return outputToken(TOKEN_TYPE.number);
|
|
287
309
|
addNextChar();
|
|
288
|
-
if (token.startsWith("\\")) throwTokenizingError("Illegal lexeme");
|
|
289
|
-
|
|
310
|
+
if (scan.token.startsWith("\\")) throwTokenizingError("Illegal lexeme");
|
|
311
|
+
scan.state = "id";
|
|
290
312
|
return;
|
|
291
313
|
case "bsBuiltIn":
|
|
292
314
|
if (isLetter(next) && next !== "_") return addNextChar();
|
|
293
|
-
if (BUILT_IN_SYMBOLS.has(token)) return outputToken(TOKEN_TYPE.builtin);
|
|
315
|
+
if (BUILT_IN_SYMBOLS.has(scan.token)) return outputToken(TOKEN_TYPE.builtin);
|
|
294
316
|
return throwTokenizingError("Illegal lexeme ");
|
|
295
317
|
case "builtIn":
|
|
296
|
-
if (BUILT_IN_PREFIXES.has(token + next)) return addNextChar();
|
|
297
|
-
|
|
318
|
+
if (BUILT_IN_PREFIXES.has(scan.token + next)) return addNextChar();
|
|
319
|
+
// A prefix that is no symbol backs up to its longest symbol.
|
|
320
|
+
if (!BUILT_IN_SYMBOLS.has(scan.token)) {
|
|
298
321
|
backspacePcalReader(reader);
|
|
299
|
-
while (!BUILT_IN_SYMBOLS.has(token)) {
|
|
322
|
+
while (!BUILT_IN_SYMBOLS.has(scan.token)) {
|
|
300
323
|
backspacePcalReader(reader);
|
|
301
|
-
if (token.length === 0) throwTokenizingError("Illegal lexeme");
|
|
302
|
-
token = Array.from(token).slice(0, -1).join("");
|
|
324
|
+
if (scan.token.length === 0) throwTokenizingError("Illegal lexeme");
|
|
325
|
+
scan.token = Array.from(scan.token).slice(0, -1).join("");
|
|
303
326
|
}
|
|
304
327
|
skipNextChar();
|
|
305
328
|
}
|
|
306
329
|
return outputToken(TOKEN_TYPE.builtin);
|
|
307
330
|
case "dash1":
|
|
308
331
|
case "dash2":
|
|
309
|
-
if (next === "-") return addAndGoto(
|
|
310
|
-
|
|
332
|
+
if (next === "-") return addAndGoto(scan.state === "dash1" ? "dash2" : "dash3");
|
|
333
|
+
scan.state = "builtIn";
|
|
311
334
|
return;
|
|
312
335
|
case "dash3":
|
|
313
336
|
if (next !== "-") throwTokenizingError("Illegal lexeme");
|
|
@@ -316,8 +339,8 @@ const tokenize = (
|
|
|
316
339
|
return next === "-" ? addNextChar() : outputToken(TOKEN_TYPE.dashes);
|
|
317
340
|
case "eq1":
|
|
318
341
|
case "eq2":
|
|
319
|
-
if (next === "=") return addAndGoto(
|
|
320
|
-
|
|
342
|
+
if (next === "=") return addAndGoto(scan.state === "eq1" ? "eq2" : "eq3");
|
|
343
|
+
scan.state = "builtIn";
|
|
321
344
|
return;
|
|
322
345
|
case "eq3":
|
|
323
346
|
if (next !== "=") throwTokenizingError("Illegal lexeme");
|
|
@@ -329,8 +352,8 @@ const tokenize = (
|
|
|
329
352
|
state.commentDepth = 1;
|
|
330
353
|
return skipAndGoto("comment");
|
|
331
354
|
}
|
|
332
|
-
token = "(";
|
|
333
|
-
|
|
355
|
+
scan.token = "(";
|
|
356
|
+
scan.state = "builtIn";
|
|
334
357
|
return;
|
|
335
358
|
case "string":
|
|
336
359
|
if (next === "\\") return addAndGoto("escString");
|
|
@@ -346,13 +369,13 @@ const tokenize = (
|
|
|
346
369
|
if (!['"', "\\", "t", "n", "f", "r"].includes(next)) {
|
|
347
370
|
throwTokenizingError("Illegal character following \\ in string");
|
|
348
371
|
}
|
|
349
|
-
|
|
372
|
+
scan.state = "string";
|
|
350
373
|
return;
|
|
351
374
|
case "lineComment":
|
|
352
375
|
if (next === "(") return skipAndGoto("lineComParen");
|
|
353
376
|
if (next === "*" && state.commentDepth > 0) return skipAndGoto("lineComStar");
|
|
354
377
|
if (next === "\n" || next === "\t") {
|
|
355
|
-
token = "";
|
|
378
|
+
scan.token = "";
|
|
356
379
|
state.commentDepth = 0;
|
|
357
380
|
return gotoStart();
|
|
358
381
|
}
|
|
@@ -362,8 +385,8 @@ const tokenize = (
|
|
|
362
385
|
state.commentDepth += 1;
|
|
363
386
|
return skipAndGoto("lineComment");
|
|
364
387
|
}
|
|
365
|
-
if (state.commentDepth === 0) token += "(";
|
|
366
|
-
|
|
388
|
+
if (state.commentDepth === 0) scan.token += "(";
|
|
389
|
+
scan.state = "lineComment";
|
|
367
390
|
return;
|
|
368
391
|
case "lineComStar":
|
|
369
392
|
if (next === ")") {
|
|
@@ -373,19 +396,20 @@ const tokenize = (
|
|
|
373
396
|
}
|
|
374
397
|
return skipAndGoto("lineComment");
|
|
375
398
|
}
|
|
376
|
-
if (state.commentDepth === 0) token += "*";
|
|
377
|
-
|
|
399
|
+
if (state.commentDepth === 0) scan.token += "*";
|
|
400
|
+
scan.state = "lineComment";
|
|
378
401
|
return;
|
|
402
|
+
// A comment that continues past its first line is an "or comment".
|
|
379
403
|
case "comment":
|
|
380
404
|
case "orComment": {
|
|
381
|
-
const isFirstLine =
|
|
405
|
+
const isFirstLine = scan.state === "comment";
|
|
382
406
|
if (next === "*") return skipAndGoto(isFirstLine ? "commentStar" : "orCommentStar");
|
|
383
407
|
if (next === "(") return skipAndGoto(isFirstLine ? "commentParen" : "orCommentParen");
|
|
384
408
|
if (next === "\n") {
|
|
385
|
-
token = "";
|
|
409
|
+
scan.token = "";
|
|
386
410
|
skipNextChar();
|
|
387
411
|
startNewLine();
|
|
388
|
-
|
|
412
|
+
scan.state = "orComment";
|
|
389
413
|
return;
|
|
390
414
|
}
|
|
391
415
|
if (next === "\t") {
|
|
@@ -399,10 +423,10 @@ const tokenize = (
|
|
|
399
423
|
}
|
|
400
424
|
case "commentStar":
|
|
401
425
|
case "orCommentStar": {
|
|
402
|
-
const commentState =
|
|
426
|
+
const commentState = scan.state === "commentStar" ? "comment" : "orComment";
|
|
403
427
|
if (next !== ")") {
|
|
404
|
-
if (state.commentDepth === 1) token += "*";
|
|
405
|
-
|
|
428
|
+
if (state.commentDepth === 1) scan.token += "*";
|
|
429
|
+
scan.state = commentState;
|
|
406
430
|
return;
|
|
407
431
|
}
|
|
408
432
|
skipNextChar();
|
|
@@ -411,28 +435,28 @@ const tokenize = (
|
|
|
411
435
|
throw new PcalBugError("Assertion failure");
|
|
412
436
|
}
|
|
413
437
|
if (state.commentDepth !== 0) {
|
|
414
|
-
|
|
438
|
+
scan.state = commentState;
|
|
415
439
|
return;
|
|
416
440
|
}
|
|
417
|
-
token = "";
|
|
441
|
+
scan.token = "";
|
|
418
442
|
return gotoStart();
|
|
419
443
|
}
|
|
420
444
|
case "commentParen":
|
|
421
445
|
case "orCommentParen": {
|
|
422
|
-
const commentState =
|
|
446
|
+
const commentState = scan.state === "commentParen" ? "comment" : "orComment";
|
|
423
447
|
if (next === "*") {
|
|
424
448
|
state.commentDepth += 1;
|
|
425
449
|
return skipAndGoto(commentState);
|
|
426
450
|
}
|
|
427
|
-
if (state.commentDepth === 1) token += "(";
|
|
428
|
-
|
|
451
|
+
if (state.commentDepth === 1) scan.token += "(";
|
|
452
|
+
scan.state = commentState;
|
|
429
453
|
return;
|
|
430
454
|
}
|
|
431
455
|
}
|
|
432
456
|
};
|
|
433
|
-
while (
|
|
434
|
-
if (nextChar !== "\n") backspacePcalReader(reader);
|
|
435
|
-
return createNormalizedPcalExpr(lines);
|
|
457
|
+
while (scan.state !== "done" && !scan.isExprEnd) step(scan.nextChar);
|
|
458
|
+
if (scan.nextChar !== "\n") backspacePcalReader(reader);
|
|
459
|
+
return createNormalizedPcalExpr(scan.lines);
|
|
436
460
|
};
|
|
437
461
|
|
|
438
462
|
export const tokenizePcalExpr = (
|