@bablr/helpers 0.15.4 → 0.16.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/enhancers.js +4 -8
- package/lib/source.js +13 -4
- package/lib/trivia.js +1 -1
- package/package.json +7 -14
- package/lib/.babelrc.json +0 -7
package/lib/enhancers.js
CHANGED
|
@@ -59,16 +59,12 @@ export const mapProductions = (fn, Grammar) => {
|
|
|
59
59
|
return MappedGrammar;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
bablrProduction: createProductionLogger(' ', log),
|
|
67
|
-
};
|
|
62
|
+
export const debugEnhancers = {
|
|
63
|
+
agast: (strategy) => logEmitted(strategy, '<<< '),
|
|
64
|
+
createBablrStrategy: (strategy) => logStrategy(strategy, ' >>> '),
|
|
65
|
+
bablrProduction: createProductionLogger('>>> '),
|
|
68
66
|
};
|
|
69
67
|
|
|
70
|
-
export const debugEnhancers = buildDebugEnhancers();
|
|
71
|
-
|
|
72
68
|
export const stateEnhancer = (hooks, grammar) => {
|
|
73
69
|
let state;
|
|
74
70
|
return mapProductions((production) => {
|
package/lib/source.js
CHANGED
|
@@ -145,7 +145,7 @@ export const sourceFromQuasis = (quasis) => new StreamIterable(__sourceFromQuasi
|
|
|
145
145
|
export function* fillGapsWith(expressions, stream) {
|
|
146
146
|
let exprIdx = 0;
|
|
147
147
|
let iter = getStreamIterator(stream);
|
|
148
|
-
let
|
|
148
|
+
let holding = false;
|
|
149
149
|
|
|
150
150
|
for (;;) {
|
|
151
151
|
let step = iter.next();
|
|
@@ -158,10 +158,19 @@ export function* fillGapsWith(expressions, stream) {
|
|
|
158
158
|
|
|
159
159
|
const token = step.value;
|
|
160
160
|
|
|
161
|
+
if (token.type === 'Shift') {
|
|
162
|
+
holding = true;
|
|
163
|
+
}
|
|
164
|
+
|
|
161
165
|
if (token.type === 'Gap') {
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
if (holding) {
|
|
167
|
+
holding = false;
|
|
168
|
+
yield token;
|
|
169
|
+
} else {
|
|
170
|
+
if (exprIdx >= expressions.length) throw new Error('not enough gaps for expressions');
|
|
171
|
+
yield* slice(2, -1, streamFromTree(expressions[exprIdx]));
|
|
172
|
+
exprIdx++;
|
|
173
|
+
}
|
|
165
174
|
} else {
|
|
166
175
|
yield token;
|
|
167
176
|
}
|
package/lib/trivia.js
CHANGED
|
@@ -6,7 +6,7 @@ const lookbehind = (context, s) => {
|
|
|
6
6
|
let token = s.result;
|
|
7
7
|
while (
|
|
8
8
|
token &&
|
|
9
|
-
['OpenNodeTag', 'CloseNodeTag', '
|
|
9
|
+
['OpenNodeTag', 'CloseNodeTag', 'Reference'].includes(token.type) &&
|
|
10
10
|
(token.type !== 'OpenNodeTag' || !token.value.intrinsicValue)
|
|
11
11
|
) {
|
|
12
12
|
const prevToken = context.getPreviousTerminal(token);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/helpers",
|
|
3
3
|
"description": "Command helpers for use in writing BABLR grammars",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -26,25 +26,18 @@
|
|
|
26
26
|
"clean": "macrome clean"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@bablr/language_enhancer-debug-log": "0.
|
|
30
|
-
"@bablr/strategy_enhancer-debug-log": "0.
|
|
31
|
-
"@bablr/agast-helpers": "0.1.
|
|
32
|
-
"@bablr/agast-vm-helpers": "0.1.
|
|
29
|
+
"@bablr/language_enhancer-debug-log": "0.3.0",
|
|
30
|
+
"@bablr/strategy_enhancer-debug-log": "0.2.0",
|
|
31
|
+
"@bablr/agast-helpers": "0.1.6",
|
|
32
|
+
"@bablr/agast-vm-helpers": "0.1.5",
|
|
33
33
|
"@bablr/coroutine": "0.1.0",
|
|
34
34
|
"iter-tools-es": "^7.5.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@babel/core": "7.22.20",
|
|
39
|
-
"@babel/plugin-proposal-decorators": "7.22.15",
|
|
40
|
-
"@babel/plugin-transform-modules-commonjs": "^7.23.0",
|
|
41
|
-
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
42
|
-
"@babel/runtime": "^7.23.2",
|
|
43
|
-
"@bablr/boot": "0.2.3",
|
|
37
|
+
"@bablr/boot": "0.2.4",
|
|
44
38
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#d834ccc52795d6c3b96ecc6c419960fceed221a6",
|
|
45
39
|
"@bablr/macrome": "0.1.1",
|
|
46
|
-
"@bablr/macrome-generator-bablr": "0.
|
|
47
|
-
"babel-plugin-macros": "3.1.0",
|
|
40
|
+
"@bablr/macrome-generator-bablr": "0.3.1",
|
|
48
41
|
"enhanced-resolve": "^5.12.0",
|
|
49
42
|
"eslint": "^7.32.0",
|
|
50
43
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|