@bablr/bablr-vm 0.16.2 → 0.16.3
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/strategy.js +2 -1
- package/lib/utils/pattern.js +5 -1
- package/lib/utils/token.js +2 -2
- package/package.json +2 -2
package/lib/strategy.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import size from 'iter-tools-es/methods/size';
|
|
1
2
|
import { Coroutine } from '@bablr/coroutine';
|
|
2
3
|
import {
|
|
3
4
|
buildCall,
|
|
@@ -110,7 +111,7 @@ const __strategy = function* bablrStrategy(ctx, rootSource, agastState, strategy
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
if (result) {
|
|
113
|
-
let sourceStep = s.source.advance(result
|
|
114
|
+
let sourceStep = s.source.advance(size(result));
|
|
114
115
|
|
|
115
116
|
if (sourceStep instanceof Promise) {
|
|
116
117
|
sourceStep = yield sourceStep;
|
package/lib/utils/pattern.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import isString from 'iter-tools-es/methods/is-string';
|
|
2
|
+
import isEmpty from 'iter-tools-es/methods/is-empty';
|
|
2
3
|
import { generateMatches } from '@bablr/regex-vm';
|
|
3
4
|
import { getStreamIterator, maybeWait } from '@bablr/agast-helpers/stream';
|
|
4
5
|
import * as t from '@bablr/agast-helpers/shorthand';
|
|
@@ -37,7 +38,10 @@ export const match = (pattern, source) => {
|
|
|
37
38
|
|
|
38
39
|
const step = iter.next();
|
|
39
40
|
|
|
40
|
-
return maybeWait(step, (step) =>
|
|
41
|
+
return maybeWait(step, (step) => {
|
|
42
|
+
const result = step.done ? null : step.value[0];
|
|
43
|
+
return isEmpty(result) ? null : result;
|
|
44
|
+
});
|
|
41
45
|
};
|
|
42
46
|
|
|
43
47
|
class GuardedIterator {
|
package/lib/utils/token.js
CHANGED
|
@@ -10,9 +10,9 @@ export function* allChildrenFor(range) {
|
|
|
10
10
|
throw new Error('unimplemented');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function* buildTokens(
|
|
13
|
+
export function* buildTokens(chrs) {
|
|
14
14
|
let str = '';
|
|
15
|
-
for (const chr of
|
|
15
|
+
for (const chr of chrs) {
|
|
16
16
|
if (chr == null) {
|
|
17
17
|
if (str) {
|
|
18
18
|
yield buildLiteral(str);
|
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.16.
|
|
4
|
+
"version": "0.16.3",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@bablr/agast-vm-helpers": "0.3.2",
|
|
17
17
|
"@bablr/coroutine": "0.1.0",
|
|
18
18
|
"@bablr/helpers": "0.18.0",
|
|
19
|
-
"@bablr/regex-vm": "0.
|
|
19
|
+
"@bablr/regex-vm": "0.7.0",
|
|
20
20
|
"@bablr/weak-stack": "0.1.0",
|
|
21
21
|
"@iter-tools/imm-stack": "1.1.0",
|
|
22
22
|
"iter-tools-es": "^7.5.3"
|