@bablr/helpers 0.20.4 → 0.20.6
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 +12 -0
- package/lib/stream.js +9 -9
- package/package.json +2 -2
package/lib/enhancers.js
CHANGED
|
@@ -59,6 +59,18 @@ export const mapProductions = (fn, Grammar) => {
|
|
|
59
59
|
return MappedGrammar;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
export function* generateProductions(Grammar) {
|
|
63
|
+
let { prototype } = Grammar;
|
|
64
|
+
|
|
65
|
+
while (prototype && prototype !== Object.prototype) {
|
|
66
|
+
for (const key of [...getOwnPropertyNames(prototype), ...getOwnPropertySymbols(prototype)]) {
|
|
67
|
+
let value = prototype[key];
|
|
68
|
+
if (key !== 'constructor') yield [key, value];
|
|
69
|
+
}
|
|
70
|
+
prototype = getPrototypeOf(prototype);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
export const debugEnhancers = {
|
|
63
75
|
// agast: (strategy) => logEmitted(strategy, '<<< '),
|
|
64
76
|
createBablrStrategy: (strategy) => logStrategy(strategy, ' >>> '),
|
package/lib/stream.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Coroutine } from '@bablr/coroutine';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
generatePrettyCSTML as generatePrettyCSTMLStream,
|
|
4
|
+
generateCSTML as generateCSTMLStream,
|
|
5
5
|
stringFromStream,
|
|
6
|
-
generateStandardOutput,
|
|
7
6
|
getStreamIterator,
|
|
8
7
|
StreamIterable,
|
|
9
8
|
} from '@bablr/agast-helpers/stream';
|
|
@@ -67,22 +66,23 @@ export const resolveTags = (ctx, tags) => {
|
|
|
67
66
|
return new StreamIterable(__resolveTags(ctx, tags));
|
|
68
67
|
};
|
|
69
68
|
|
|
70
|
-
export const
|
|
69
|
+
export const generatePrettyCSTML = (tags, options = {}) => {
|
|
71
70
|
const { ctx } = options;
|
|
72
71
|
|
|
73
|
-
return
|
|
72
|
+
return generatePrettyCSTMLStream(ctx ? resolveTags(ctx, tags) : tags, options);
|
|
74
73
|
};
|
|
75
74
|
|
|
76
75
|
export const printPrettyCSTML = (tags, options = {}) => {
|
|
77
|
-
|
|
76
|
+
const { ctx } = options;
|
|
77
|
+
return stringFromStream(generatePrettyCSTMLStream(ctx ? resolveTags(ctx, tags) : tags, options));
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
export const
|
|
80
|
+
export const generateCSTML = (tags, options = {}) => {
|
|
81
81
|
const { ctx } = options;
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return generateCSTMLStream(ctx ? resolveTags(ctx, tags) : tags, options);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
export const printCSTML = (tags, options = {}) => {
|
|
87
|
-
return stringFromStream(
|
|
87
|
+
return stringFromStream(generateCSTMLStream(tags, options));
|
|
88
88
|
};
|
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.20.
|
|
4
|
+
"version": "0.20.6",
|
|
5
5
|
"author": "Conrad Buck<conartist6@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": ["lib"],
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@bablr/language_enhancer-debug-log": "^0.7.0",
|
|
31
31
|
"@bablr/strategy_enhancer-debug-log": "^0.6.0",
|
|
32
|
-
"@bablr/agast-helpers": "^0.5.
|
|
32
|
+
"@bablr/agast-helpers": "^0.5.3",
|
|
33
33
|
"@bablr/agast-vm-helpers": "^0.5.0",
|
|
34
34
|
"@bablr/coroutine": "0.1.0",
|
|
35
35
|
"@iter-tools/imm-stack": "1.1.0",
|