lemmascript 0.5.18 → 0.5.19
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/README.md +1 -1
- package/package.json +1 -1
- package/tools/dist/autohavoc.js +2 -0
- package/tools/dist/builtins.js +124 -0
- package/tools/dist/condition-facts.js +364 -0
- package/tools/dist/dafny-emit.js +162 -35
- package/tools/dist/extract.js +108 -21
- package/tools/dist/info-command.js +68 -0
- package/tools/dist/ir.js +27 -7
- package/tools/dist/lean-emit.js +27 -16
- package/tools/dist/lsc.js +53 -5
- package/tools/dist/names.js +10 -6
- package/tools/dist/narrow.js +296 -677
- package/tools/dist/peephole.js +12 -94
- package/tools/dist/rawir.js +15 -1
- package/tools/dist/resolve.js +182 -203
- package/tools/dist/specparser.js +21 -17
- package/tools/dist/transform.js +298 -108
- package/tools/dist/typedecls.js +59 -0
package/tools/dist/specparser.js
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
* Spec expression parser.
|
|
3
3
|
* Parses //@ annotation expressions into RawExpr AST nodes.
|
|
4
4
|
*/
|
|
5
|
+
import { normalizeBigIntLiteral } from "./rawir.js";
|
|
5
6
|
const MULTI_OPS = ["<==>", "==>", "===", "!==", "==", "!=", ">=", "<=", "&&", "||"];
|
|
7
|
+
/** Hex / binary / octal / decimal integer, with optional numeric separators and
|
|
8
|
+
* an optional `n` (BigInt) suffix in capture group 1. Deliberately integer-only:
|
|
9
|
+
* a trailing `.` is left for the tokenizer to emit as punctuation, exactly as
|
|
10
|
+
* the previous digit-scanning loop did. */
|
|
11
|
+
const INTEGER_LITERAL = /^(?:(?:0[xX][0-9a-fA-F](?:_?[0-9a-fA-F])*)|(?:0[bB][01](?:_?[01])*)|(?:0[oO][0-7](?:_?[0-7])*)|(?:[0-9](?:_?[0-9])*))(n)?/;
|
|
6
12
|
function tokenize(input) {
|
|
7
13
|
const tokens = [];
|
|
8
14
|
let i = 0;
|
|
@@ -42,23 +48,17 @@ function tokenize(input) {
|
|
|
42
48
|
continue;
|
|
43
49
|
}
|
|
44
50
|
if (/[0-9]/.test(input[i])) {
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
i
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
dec += input[i++];
|
|
57
|
-
value = parseInt(dec, 10);
|
|
58
|
-
}
|
|
59
|
-
if (i < input.length && input[i] === "n")
|
|
60
|
-
i++;
|
|
61
|
-
tokens.push({ type: "num", value });
|
|
51
|
+
const match = input.slice(i).match(INTEGER_LITERAL);
|
|
52
|
+
if (!match)
|
|
53
|
+
throw new Error(`Invalid numeric literal at ${i} in: ${input}`);
|
|
54
|
+
const text = match[0];
|
|
55
|
+
i += text.length;
|
|
56
|
+
// The `n` suffix is meaningful, not noise: a BigInt keeps its exact value
|
|
57
|
+
// as a decimal string instead of being rounded into a double.
|
|
58
|
+
if (match[1] === "n")
|
|
59
|
+
tokens.push({ type: "bigint", value: normalizeBigIntLiteral(text) });
|
|
60
|
+
else
|
|
61
|
+
tokens.push({ type: "num", value: Number(text.replace(/_/g, "")) });
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
64
|
if (/[a-zA-Z_]/.test(input[i])) {
|
|
@@ -240,6 +240,10 @@ class Parser {
|
|
|
240
240
|
this.advance();
|
|
241
241
|
return { kind: "num", value: t.value };
|
|
242
242
|
}
|
|
243
|
+
if (t.type === "bigint") {
|
|
244
|
+
this.advance();
|
|
245
|
+
return { kind: "bigint", value: t.value };
|
|
246
|
+
}
|
|
243
247
|
if (t.type === "str") {
|
|
244
248
|
this.advance();
|
|
245
249
|
return { kind: "str", value: t.value };
|