@bablr/bablr-vm 0.14.0 → 0.15.0
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/lib/source.js +4 -0
- package/lib/state.js +8 -0
- package/lib/strategy.js +9 -5
- package/package.json +4 -4
package/lib/source.js
CHANGED
package/lib/state.js
CHANGED
|
@@ -33,6 +33,10 @@ export const StateFacade = class BABLRStateFacade {
|
|
|
33
33
|
return actuals.get(this).node;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
get parentNode() {
|
|
37
|
+
return actuals.get(this).parentNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
get source() {
|
|
37
41
|
return facades.get(actuals.get(this).source);
|
|
38
42
|
}
|
|
@@ -85,6 +89,10 @@ export const State = class BABLRState extends WeakStackFrame {
|
|
|
85
89
|
return this.agast.node;
|
|
86
90
|
}
|
|
87
91
|
|
|
92
|
+
get parentNode() {
|
|
93
|
+
return this.agast.parentNode;
|
|
94
|
+
}
|
|
95
|
+
|
|
88
96
|
get holding() {
|
|
89
97
|
return this.agast.holding;
|
|
90
98
|
}
|
package/lib/strategy.js
CHANGED
|
@@ -71,7 +71,7 @@ const __strategy = function* bablrStrategy(ctx, rootSource, agastState, strategy
|
|
|
71
71
|
intrinsicResult = yield intrinsicResult;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
updateSpans(ctx, s,
|
|
74
|
+
updateSpans(ctx, s, ctx.nodeForTag(openTag), 'open');
|
|
75
75
|
|
|
76
76
|
if (intrinsicValue) {
|
|
77
77
|
if (!intrinsicResult) {
|
|
@@ -192,7 +192,9 @@ const __strategy = function* bablrStrategy(ctx, rootSource, agastState, strategy
|
|
|
192
192
|
|
|
193
193
|
s = s.push(source.branch(), agast, balanced, spans);
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
if (node) {
|
|
196
|
+
resolvedLanguages.set(s.node, resolvedLanguages.get(node));
|
|
197
|
+
}
|
|
196
198
|
|
|
197
199
|
returnValue = facades.get(s);
|
|
198
200
|
break;
|
|
@@ -231,15 +233,17 @@ const __strategy = function* bablrStrategy(ctx, rootSource, agastState, strategy
|
|
|
231
233
|
s = s.parent;
|
|
232
234
|
|
|
233
235
|
if (s.path.depth && rejectedState.path.depth > s.path.depth) {
|
|
234
|
-
const didShift = rejectedState.node.at(
|
|
236
|
+
// const didShift = rejectedState.node.at(sNodeDepth) === s.node;
|
|
237
|
+
const didShift =
|
|
238
|
+
ctx.nodeForPath(s.path) && !ctx.nodeForPath(rejectedState.path.at(s.path.depth));
|
|
235
239
|
const lowPath = rejectedState.path.at(
|
|
236
240
|
Math.min(s.path.depth + (didShift ? 0 : 1), rejectedState.path.depth),
|
|
237
241
|
);
|
|
238
|
-
const lowNode = s.node;
|
|
242
|
+
const lowNode = s.node || s.parentNode;
|
|
239
243
|
|
|
240
244
|
const { name, isArray } = lowPath.reference?.value || {};
|
|
241
245
|
|
|
242
|
-
if (
|
|
246
|
+
if (!didShift && !lowNode.resolver.counters.has(name)) {
|
|
243
247
|
if (!lowNode.openTag?.value.flags.trivia && !lowNode.openTag?.value.flags.escape) {
|
|
244
248
|
yield buildCall('advance', buildReference(name, isArray));
|
|
245
249
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/bablr-vm",
|
|
3
3
|
"description": "A VM for parsing using BABLR languages",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@bablr/agast-helpers": "0.
|
|
16
|
-
"@bablr/agast-vm-helpers": "0.
|
|
15
|
+
"@bablr/agast-helpers": "0.2.0",
|
|
16
|
+
"@bablr/agast-vm-helpers": "0.2.0",
|
|
17
17
|
"@bablr/coroutine": "0.1.0",
|
|
18
|
-
"@bablr/helpers": "0.
|
|
18
|
+
"@bablr/helpers": "0.17.0",
|
|
19
19
|
"@bablr/regex-vm": "0.5.1",
|
|
20
20
|
"@bablr/weak-stack": "0.1.0",
|
|
21
21
|
"@iter-tools/imm-stack": "1.1.0",
|