parseman 0.50.3 → 0.50.4
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/analysis/diagnostics.js +24 -10
- package/dist/analysis/diagnostics.js.map +2 -2
- package/dist/cli/index.js +24 -10
- package/dist/cli/index.js.map +2 -2
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +22 -8
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/index.js +25 -11
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +25 -11
- package/dist/plugin/index.js.map +1 -1
- package/dist/spec/index.js +22 -8
- package/dist/spec/index.js.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/index.js +24 -10
- package/dist/table/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/combinators/first-set.ts +33 -7
- package/src/table/encode.ts +14 -2
- package/src/version.ts +1 -1
package/dist/spec/index.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
// src/combinators/first-set.ts
|
|
2
|
-
function
|
|
2
|
+
function winnerForRef(p, resolve) {
|
|
3
3
|
if (resolve === void 0) return void 0;
|
|
4
4
|
const name = p._ruleName;
|
|
5
|
-
|
|
5
|
+
const w = name === void 0 ? void 0 : resolve(name);
|
|
6
|
+
if (w === void 0 || w === p) return void 0;
|
|
7
|
+
let cur = w;
|
|
8
|
+
for (const seen = /* @__PURE__ */ new Set(); !seen.has(cur); ) {
|
|
9
|
+
if (cur === p) return void 0;
|
|
10
|
+
seen.add(cur);
|
|
11
|
+
const cd = cur._def;
|
|
12
|
+
if (cd.tag !== "grammar" && cd.tag !== "trivia") return w;
|
|
13
|
+
cur = cd.parser;
|
|
14
|
+
}
|
|
15
|
+
return w;
|
|
6
16
|
}
|
|
7
17
|
function union(a, b) {
|
|
8
18
|
if (a.kind === "any" || b.kind === "any") return { kind: "any" };
|
|
@@ -100,13 +110,15 @@ function matchesEmptyBody(p, seen, resolve) {
|
|
|
100
110
|
case "grammar":
|
|
101
111
|
case "recover":
|
|
102
112
|
return me(d.parser);
|
|
103
|
-
case "lazy":
|
|
113
|
+
case "lazy": {
|
|
114
|
+
const w = winnerForRef(p, resolve);
|
|
115
|
+
if (w !== void 0) return me(w);
|
|
104
116
|
try {
|
|
105
117
|
return me(d.thunk());
|
|
106
118
|
} catch {
|
|
107
|
-
|
|
108
|
-
return t ? me(t) : true;
|
|
119
|
+
return true;
|
|
109
120
|
}
|
|
121
|
+
}
|
|
110
122
|
default:
|
|
111
123
|
return true;
|
|
112
124
|
}
|
|
@@ -170,13 +182,15 @@ function firstSetBody(p, seen, resolve) {
|
|
|
170
182
|
// terminals: no refs, cached set is exact
|
|
171
183
|
case "dispatch":
|
|
172
184
|
return fs(d.selector);
|
|
173
|
-
case "lazy":
|
|
185
|
+
case "lazy": {
|
|
186
|
+
const w = winnerForRef(p, resolve);
|
|
187
|
+
if (w !== void 0) return fs(w);
|
|
174
188
|
try {
|
|
175
189
|
return fs(d.thunk());
|
|
176
190
|
} catch {
|
|
177
|
-
|
|
178
|
-
return t ? fs(t) : any();
|
|
191
|
+
return any();
|
|
179
192
|
}
|
|
193
|
+
}
|
|
180
194
|
case "choice": {
|
|
181
195
|
let out = empty();
|
|
182
196
|
for (const arm of d.parsers) out = union(out, fs(arm));
|