@bablr/helpers 0.15.3 → 0.15.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/lib/enhancers.js +2 -3
- package/lib/productions.js +42 -23
- package/lib/productions.macro.js +8 -1
- package/package.json +4 -4
package/lib/enhancers.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Coroutine } from '@bablr/coroutine';
|
|
2
1
|
import {
|
|
3
2
|
enhanceStrategyBuilderWithDebugLogging as logStrategy,
|
|
4
3
|
enhanceStrategyBuilderWithEmittedLogging as logEmitted,
|
|
@@ -62,8 +61,8 @@ export const mapProductions = (fn, Grammar) => {
|
|
|
62
61
|
|
|
63
62
|
export const buildDebugEnhancers = (log) => {
|
|
64
63
|
return {
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
agast: (strategy) => logEmitted(strategy, '>>> ', log),
|
|
65
|
+
creeateBablrStrategy: (strategy) => logStrategy(strategy, ' ', log),
|
|
67
66
|
bablrProduction: createProductionLogger(' ', log),
|
|
68
67
|
};
|
|
69
68
|
};
|
package/lib/productions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @macrome
|
|
2
2
|
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./productions.macro.js#
|
|
3
|
+
* @generatedfrom ./productions.macro.js#f76280b033fb91e9fb8362cc2c1caa8988b5beb4
|
|
4
4
|
* This file is autogenerated. Please do not edit it directly.
|
|
5
5
|
* When editing run `npx macrome watch` then change the file this is generated from.
|
|
6
6
|
*/
|
|
@@ -19,32 +19,51 @@ export function* List({
|
|
|
19
19
|
allowHoles = false,
|
|
20
20
|
allowTrailingSeparator = true
|
|
21
21
|
} = ctx.unbox(props);
|
|
22
|
-
let sep,
|
|
22
|
+
let sep,
|
|
23
|
+
it,
|
|
24
|
+
anySep = false;
|
|
23
25
|
for (;;) {
|
|
24
26
|
it = yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
25
27
|
verb: _t.s_node(_l.Instruction, "Identifier", "eatMatch"),
|
|
26
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
27
|
-
|
|
28
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(element, _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.ref`closeToken`], {
|
|
29
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
28
30
|
values: [..._interpolateArray(element)],
|
|
29
|
-
|
|
31
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
30
32
|
}, {})
|
|
31
33
|
}, {});
|
|
32
34
|
if (it || allowTrailingSeparator) {
|
|
33
35
|
sep = yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
34
36
|
verb: _t.s_node(_l.Instruction, "Identifier", "eatMatch"),
|
|
35
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
36
|
-
|
|
37
|
-
values: [..._interpolateArray(separator), _t.node(_l.CSTML, "String", [_t.ref`
|
|
38
|
-
|
|
37
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(separator, _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.embedded(_t.s_t_node(_l.Space, "Space", [_t.lit(" ")], {}, {})), _t.ref`values[]`, _t.ref`closeToken`], {
|
|
38
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
39
|
+
values: [..._interpolateArray(separator), _t.node(_l.CSTML, "String", [_t.ref`openToken`, _t.ref`content`, _t.ref`closeToken`], {
|
|
40
|
+
openToken: _t.s_i_node(_l.CSTML, "Punctuator", "'"),
|
|
39
41
|
content: _t.node(_l.CSTML, "Content", [_t.lit("separators[]")], {}, {}),
|
|
40
|
-
|
|
42
|
+
closeToken: _t.s_i_node(_l.CSTML, "Punctuator", "'")
|
|
41
43
|
}, {})],
|
|
42
|
-
|
|
44
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
43
45
|
}, {})
|
|
44
46
|
}, {});
|
|
47
|
+
anySep ||= sep;
|
|
45
48
|
}
|
|
46
49
|
if (!(sep || allowHoles)) break;
|
|
47
50
|
}
|
|
51
|
+
if (!anySep) {
|
|
52
|
+
yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
53
|
+
verb: _t.s_node(_l.Instruction, "Identifier", "eat"),
|
|
54
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, _t.ref`values[]`, _t.embedded(_t.s_t_node(_l.Space, "Space", [_t.lit(" ")], {}, {})), _t.ref`values[]`, _t.ref`closeToken`], {
|
|
55
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
56
|
+
values: [_t.node(_l.Instruction, "Null", [_t.ref`sigilToken`], {
|
|
57
|
+
sigilToken: _t.s_i_node(_l.Instruction, "Keyword", "null")
|
|
58
|
+
}, {}), _t.node(_l.CSTML, "String", [_t.ref`openToken`, _t.ref`content`, _t.ref`closeToken`], {
|
|
59
|
+
openToken: _t.s_i_node(_l.CSTML, "Punctuator", "'"),
|
|
60
|
+
content: _t.node(_l.CSTML, "Content", [_t.lit("separators[]")], {}, {}),
|
|
61
|
+
closeToken: _t.s_i_node(_l.CSTML, "Punctuator", "'")
|
|
62
|
+
}, {})],
|
|
63
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
64
|
+
}, {})
|
|
65
|
+
}, {});
|
|
66
|
+
}
|
|
48
67
|
}
|
|
49
68
|
export function* Any({
|
|
50
69
|
value: matchers,
|
|
@@ -53,10 +72,10 @@ export function* Any({
|
|
|
53
72
|
for (const matcher of ctx.unbox(matchers)) {
|
|
54
73
|
if (yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
55
74
|
verb: _t.s_node(_l.Instruction, "Identifier", "eatMatch"),
|
|
56
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
57
|
-
|
|
75
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(matcher, _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.ref`closeToken`], {
|
|
76
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
58
77
|
values: [..._interpolateArray(matcher)],
|
|
59
|
-
|
|
78
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
60
79
|
}, {})
|
|
61
80
|
}, {})) break;
|
|
62
81
|
}
|
|
@@ -68,10 +87,10 @@ export function* All({
|
|
|
68
87
|
for (const matcher of ctx.unbox(matchers)) {
|
|
69
88
|
yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
70
89
|
verb: _t.s_node(_l.Instruction, "Identifier", "eat"),
|
|
71
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
72
|
-
|
|
90
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(matcher, _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.ref`closeToken`], {
|
|
91
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
73
92
|
values: [..._interpolateArray(matcher)],
|
|
74
|
-
|
|
93
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
75
94
|
}, {})
|
|
76
95
|
}, {});
|
|
77
96
|
}
|
|
@@ -82,10 +101,10 @@ export function* Punctuator({
|
|
|
82
101
|
if (!intrinsicValue) throw new Error('Intrinsic productions must have value');
|
|
83
102
|
yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
84
103
|
verb: _t.s_node(_l.Instruction, "Identifier", "eat"),
|
|
85
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
86
|
-
|
|
104
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(intrinsicValue, _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.ref`closeToken`], {
|
|
105
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
87
106
|
values: [..._interpolateArray(intrinsicValue)],
|
|
88
|
-
|
|
107
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
89
108
|
}, {})
|
|
90
109
|
}, {});
|
|
91
110
|
}
|
|
@@ -100,10 +119,10 @@ export function* Optional({
|
|
|
100
119
|
}
|
|
101
120
|
yield _t.node(_l.Instruction, "Call", [_t.ref`verb`, _t.ref`arguments`], {
|
|
102
121
|
verb: _t.s_node(_l.Instruction, "Identifier", "eatMatch"),
|
|
103
|
-
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`
|
|
104
|
-
|
|
122
|
+
arguments: _t.node(_l.Instruction, "Tuple", [_t.ref`openToken`, ..._interpolateArrayChildren(matchers_[0], _t.ref`values[]`, _t.embedded(_t.t_node(_l.Comment, null, [_t.embedded(_t.t_node('Space', 'Space', [_t.lit(' ')]))]))), _t.ref`closeToken`], {
|
|
123
|
+
openToken: _t.s_i_node(_l.Instruction, "Punctuator", "("),
|
|
105
124
|
values: [..._interpolateArray(matchers_[0])],
|
|
106
|
-
|
|
125
|
+
closeToken: _t.s_i_node(_l.Instruction, "Punctuator", ")")
|
|
107
126
|
}, {})
|
|
108
127
|
}, {});
|
|
109
128
|
}
|
package/lib/productions.macro.js
CHANGED
|
@@ -8,14 +8,21 @@ export function* List({ value: props, ctx }) {
|
|
|
8
8
|
allowTrailingSeparator = true,
|
|
9
9
|
} = ctx.unbox(props);
|
|
10
10
|
|
|
11
|
-
let sep,
|
|
11
|
+
let sep,
|
|
12
|
+
it,
|
|
13
|
+
anySep = false;
|
|
12
14
|
for (;;) {
|
|
13
15
|
it = yield i`eatMatch(${element})`;
|
|
14
16
|
if (it || allowTrailingSeparator) {
|
|
15
17
|
sep = yield i`eatMatch(${separator} 'separators[]')`;
|
|
18
|
+
anySep ||= sep;
|
|
16
19
|
}
|
|
17
20
|
if (!(sep || allowHoles)) break;
|
|
18
21
|
}
|
|
22
|
+
|
|
23
|
+
if (!anySep) {
|
|
24
|
+
yield i`eat(null 'separators[]')`;
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
export function* Any({ value: matchers, ctx }) {
|
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.15.
|
|
4
|
+
"version": "0.15.4",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@bablr/language_enhancer-debug-log": "0.2.1",
|
|
30
30
|
"@bablr/strategy_enhancer-debug-log": "0.1.1",
|
|
31
|
-
"@bablr/agast-helpers": "0.1.
|
|
32
|
-
"@bablr/agast-vm-helpers": "0.1.
|
|
31
|
+
"@bablr/agast-helpers": "0.1.5",
|
|
32
|
+
"@bablr/agast-vm-helpers": "0.1.3",
|
|
33
33
|
"@bablr/coroutine": "0.1.0",
|
|
34
34
|
"iter-tools-es": "^7.5.3"
|
|
35
35
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@babel/plugin-transform-modules-commonjs": "^7.23.0",
|
|
41
41
|
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
42
42
|
"@babel/runtime": "^7.23.2",
|
|
43
|
-
"@bablr/boot": "0.2.
|
|
43
|
+
"@bablr/boot": "0.2.3",
|
|
44
44
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#d834ccc52795d6c3b96ecc6c419960fceed221a6",
|
|
45
45
|
"@bablr/macrome": "0.1.1",
|
|
46
46
|
"@bablr/macrome-generator-bablr": "0.2.0",
|