@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 CHANGED
@@ -168,6 +168,10 @@ export const SourceFacade = class BABLRSourceFacade {
168
168
  return actuals.get(this).done;
169
169
  }
170
170
 
171
+ get value() {
172
+ return actuals.get(this).value;
173
+ }
174
+
171
175
  get index() {
172
176
  return actuals.get(this).index;
173
177
  }
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, intrinsicValue ? ctx.nodeForTag(openTag) : s.node, 'open');
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
- resolvedLanguages.set(s.node, resolvedLanguages.get(node));
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(s.node.depth) === s.node;
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 (lowPath.depth === lowNode.depth + 1 && !lowNode.resolver.counters.has(name)) {
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.14.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.1.6",
16
- "@bablr/agast-vm-helpers": "0.1.5",
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.16.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",