binary-decision-diagram 3.2.0 → 5.0.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/CHANGELOG.md +6 -0
- package/README.md +211 -31
- package/dist/cjs/src/abstract-node.js +7 -4
- package/dist/cjs/src/abstract-node.js.map +1 -1
- package/dist/cjs/src/branches.d.ts +4 -1
- package/dist/cjs/src/branches.js +10 -9
- package/dist/cjs/src/branches.js.map +1 -1
- package/dist/cjs/src/create-bdd-from-truth-table.js +1 -2
- package/dist/cjs/src/create-bdd-from-truth-table.js.map +1 -1
- package/dist/cjs/src/ensure-correct-bdd.js +2 -3
- package/dist/cjs/src/ensure-correct-bdd.js.map +1 -1
- package/dist/cjs/src/fill-truth-table.js +1 -2
- package/dist/cjs/src/fill-truth-table.js.map +1 -1
- package/dist/cjs/src/find-similar-node.js +1 -2
- package/dist/cjs/src/find-similar-node.js.map +1 -1
- package/dist/cjs/src/index.d.ts +2 -1
- package/dist/cjs/src/index.es5.js +17 -7
- package/dist/cjs/src/index.es5.js.map +1 -1
- package/dist/cjs/src/index.js +2 -1
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/internal-node.js +6 -3
- package/dist/cjs/src/internal-node.js.map +1 -1
- package/dist/cjs/src/optimize-brute-force.js +10 -12
- package/dist/cjs/src/optimize-brute-force.js.map +1 -1
- package/dist/cjs/src/ordering/build-bdd.d.ts +13 -0
- package/dist/cjs/src/ordering/build-bdd.js +64 -0
- package/dist/cjs/src/ordering/build-bdd.js.map +1 -0
- package/dist/cjs/src/ordering/dense-truth-table.d.ts +42 -0
- package/dist/cjs/src/ordering/dense-truth-table.js +125 -0
- package/dist/cjs/src/ordering/dense-truth-table.js.map +1 -0
- package/dist/cjs/src/ordering/exact-cost-ordering.d.ts +91 -0
- package/dist/cjs/src/ordering/exact-cost-ordering.js +351 -0
- package/dist/cjs/src/ordering/exact-cost-ordering.js.map +1 -0
- package/dist/cjs/src/ordering/exact-ordering.d.ts +89 -0
- package/dist/cjs/src/ordering/exact-ordering.js +260 -0
- package/dist/cjs/src/ordering/exact-ordering.js.map +1 -0
- package/dist/cjs/src/ordering/index.d.ts +22 -0
- package/dist/cjs/src/ordering/index.js +38 -0
- package/dist/cjs/src/ordering/index.js.map +1 -0
- package/dist/cjs/src/ordering/int-pair-map.d.ts +20 -0
- package/dist/cjs/src/ordering/int-pair-map.js +85 -0
- package/dist/cjs/src/ordering/int-pair-map.js.map +1 -0
- package/dist/cjs/src/ordering/local-search.d.ts +114 -0
- package/dist/cjs/src/ordering/local-search.js +317 -0
- package/dist/cjs/src/ordering/local-search.js.map +1 -0
- package/dist/cjs/src/ordering/optimize-ordering.d.ts +153 -0
- package/dist/cjs/src/ordering/optimize-ordering.js +406 -0
- package/dist/cjs/src/ordering/optimize-ordering.js.map +1 -0
- package/dist/cjs/src/ordering/ordering-evaluator.d.ts +198 -0
- package/dist/cjs/src/ordering/ordering-evaluator.js +384 -0
- package/dist/cjs/src/ordering/ordering-evaluator.js.map +1 -0
- package/dist/cjs/src/ordering/shared-diagram.d.ts +85 -0
- package/dist/cjs/src/ordering/shared-diagram.js +295 -0
- package/dist/cjs/src/ordering/shared-diagram.js.map +1 -0
- package/dist/cjs/src/packed/index.d.ts +2 -0
- package/dist/cjs/src/{minimal-string → packed}/index.js +2 -5
- package/dist/cjs/src/packed/index.js.map +1 -0
- package/dist/cjs/src/packed/packed-bdd-base64-string.d.ts +3 -0
- package/dist/cjs/src/packed/packed-bdd-base64-string.js +46 -0
- package/dist/cjs/src/packed/packed-bdd-base64-string.js.map +1 -0
- package/dist/cjs/src/packed/packed-bdd.d.ts +13 -0
- package/dist/cjs/src/packed/packed-bdd.js +70 -0
- package/dist/cjs/src/packed/packed-bdd.js.map +1 -0
- package/dist/cjs/src/root-node.d.ts +1 -2
- package/dist/cjs/src/root-node.js +4 -9
- package/dist/cjs/src/root-node.js.map +1 -1
- package/dist/cjs/src/types.d.ts +0 -12
- package/dist/cjs/src/util.js +29 -21
- package/dist/cjs/src/util.js.map +1 -1
- package/dist/esm/src/abstract-node.js +7 -4
- package/dist/esm/src/abstract-node.js.map +1 -1
- package/dist/esm/src/branches.d.ts +4 -1
- package/dist/esm/src/branches.js +8 -7
- package/dist/esm/src/branches.js.map +1 -1
- package/dist/esm/src/create-bdd-from-truth-table.js.map +1 -1
- package/dist/esm/src/index.d.ts +2 -1
- package/dist/esm/src/index.js +2 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/internal-node.js +7 -4
- package/dist/esm/src/internal-node.js.map +1 -1
- package/dist/esm/src/optimize-brute-force.js +5 -7
- package/dist/esm/src/optimize-brute-force.js.map +1 -1
- package/dist/esm/src/ordering/build-bdd.d.ts +13 -0
- package/dist/esm/src/ordering/build-bdd.js +61 -0
- package/dist/esm/src/ordering/build-bdd.js.map +1 -0
- package/dist/esm/src/ordering/dense-truth-table.d.ts +42 -0
- package/dist/esm/src/ordering/dense-truth-table.js +117 -0
- package/dist/esm/src/ordering/dense-truth-table.js.map +1 -0
- package/dist/esm/src/ordering/exact-cost-ordering.d.ts +91 -0
- package/dist/esm/src/ordering/exact-cost-ordering.js +347 -0
- package/dist/esm/src/ordering/exact-cost-ordering.js.map +1 -0
- package/dist/esm/src/ordering/exact-ordering.d.ts +89 -0
- package/dist/esm/src/ordering/exact-ordering.js +256 -0
- package/dist/esm/src/ordering/exact-ordering.js.map +1 -0
- package/dist/esm/src/ordering/index.d.ts +22 -0
- package/dist/esm/src/ordering/index.js +17 -0
- package/dist/esm/src/ordering/index.js.map +1 -0
- package/dist/esm/src/ordering/int-pair-map.d.ts +20 -0
- package/dist/esm/src/ordering/int-pair-map.js +81 -0
- package/dist/esm/src/ordering/int-pair-map.js.map +1 -0
- package/dist/esm/src/ordering/local-search.d.ts +114 -0
- package/dist/esm/src/ordering/local-search.js +308 -0
- package/dist/esm/src/ordering/local-search.js.map +1 -0
- package/dist/esm/src/ordering/optimize-ordering.d.ts +153 -0
- package/dist/esm/src/ordering/optimize-ordering.js +399 -0
- package/dist/esm/src/ordering/optimize-ordering.js.map +1 -0
- package/dist/esm/src/ordering/ordering-evaluator.d.ts +198 -0
- package/dist/esm/src/ordering/ordering-evaluator.js +377 -0
- package/dist/esm/src/ordering/ordering-evaluator.js.map +1 -0
- package/dist/esm/src/ordering/shared-diagram.d.ts +85 -0
- package/dist/esm/src/ordering/shared-diagram.js +289 -0
- package/dist/esm/src/ordering/shared-diagram.js.map +1 -0
- package/dist/esm/src/packed/index.d.ts +2 -0
- package/dist/esm/src/packed/index.js +3 -0
- package/dist/esm/src/packed/index.js.map +1 -0
- package/dist/esm/src/packed/packed-bdd-base64-string.d.ts +3 -0
- package/dist/esm/src/packed/packed-bdd-base64-string.js +42 -0
- package/dist/esm/src/packed/packed-bdd-base64-string.js.map +1 -0
- package/dist/esm/src/packed/packed-bdd.d.ts +13 -0
- package/dist/esm/src/packed/packed-bdd.js +66 -0
- package/dist/esm/src/packed/packed-bdd.js.map +1 -0
- package/dist/esm/src/root-node.d.ts +1 -2
- package/dist/esm/src/root-node.js +5 -10
- package/dist/esm/src/root-node.js.map +1 -1
- package/dist/esm/src/types.d.ts +0 -12
- package/dist/esm/src/util.js +14 -5
- package/dist/esm/src/util.js.map +1 -1
- package/docs/variable-ordering.md +306 -0
- package/package.json +15 -12
- package/src/abstract-node.ts +7 -5
- package/src/branches.ts +9 -7
- package/src/create-bdd-from-truth-table.ts +1 -1
- package/src/index.ts +2 -1
- package/src/internal-node.ts +7 -4
- package/src/optimize-brute-force.ts +5 -7
- package/src/ordering/build-bdd.ts +70 -0
- package/src/ordering/dense-truth-table.ts +161 -0
- package/src/ordering/exact-cost-ordering.ts +425 -0
- package/src/ordering/exact-ordering.ts +317 -0
- package/src/ordering/index.ts +57 -0
- package/src/ordering/int-pair-map.ts +85 -0
- package/src/ordering/local-search.ts +369 -0
- package/src/ordering/optimize-ordering.ts +570 -0
- package/src/ordering/ordering-evaluator.ts +479 -0
- package/src/ordering/shared-diagram.ts +310 -0
- package/src/packed/index.ts +2 -0
- package/src/packed/packed-bdd-base64-string.ts +47 -0
- package/src/packed/packed-bdd.ts +98 -0
- package/src/root-node.ts +8 -17
- package/src/types.ts +0 -18
- package/src/util.ts +15 -6
- package/dist/cjs/src/minimal-string/bdd-to-minimal-string.d.ts +0 -8
- package/dist/cjs/src/minimal-string/bdd-to-minimal-string.js +0 -60
- package/dist/cjs/src/minimal-string/bdd-to-minimal-string.js.map +0 -1
- package/dist/cjs/src/minimal-string/bdd-to-simple-bdd.d.ts +0 -11
- package/dist/cjs/src/minimal-string/bdd-to-simple-bdd.js +0 -24
- package/dist/cjs/src/minimal-string/bdd-to-simple-bdd.js.map +0 -1
- package/dist/cjs/src/minimal-string/index.d.ts +0 -5
- package/dist/cjs/src/minimal-string/index.js.map +0 -1
- package/dist/cjs/src/minimal-string/minimal-string-to-simple-bdd.d.ts +0 -2
- package/dist/cjs/src/minimal-string/minimal-string-to-simple-bdd.js +0 -58
- package/dist/cjs/src/minimal-string/minimal-string-to-simple-bdd.js.map +0 -1
- package/dist/cjs/src/minimal-string/resolve-with-simple-bdd.d.ts +0 -2
- package/dist/cjs/src/minimal-string/resolve-with-simple-bdd.js +0 -21
- package/dist/cjs/src/minimal-string/resolve-with-simple-bdd.js.map +0 -1
- package/dist/cjs/src/minimal-string/string-format.d.ts +0 -9
- package/dist/cjs/src/minimal-string/string-format.js +0 -61
- package/dist/cjs/src/minimal-string/string-format.js.map +0 -1
- package/dist/esm/src/minimal-string/bdd-to-minimal-string.d.ts +0 -8
- package/dist/esm/src/minimal-string/bdd-to-minimal-string.js +0 -55
- package/dist/esm/src/minimal-string/bdd-to-minimal-string.js.map +0 -1
- package/dist/esm/src/minimal-string/bdd-to-simple-bdd.d.ts +0 -11
- package/dist/esm/src/minimal-string/bdd-to-simple-bdd.js +0 -19
- package/dist/esm/src/minimal-string/bdd-to-simple-bdd.js.map +0 -1
- package/dist/esm/src/minimal-string/index.d.ts +0 -5
- package/dist/esm/src/minimal-string/index.js +0 -6
- package/dist/esm/src/minimal-string/index.js.map +0 -1
- package/dist/esm/src/minimal-string/minimal-string-to-simple-bdd.d.ts +0 -2
- package/dist/esm/src/minimal-string/minimal-string-to-simple-bdd.js +0 -54
- package/dist/esm/src/minimal-string/minimal-string-to-simple-bdd.js.map +0 -1
- package/dist/esm/src/minimal-string/resolve-with-simple-bdd.d.ts +0 -2
- package/dist/esm/src/minimal-string/resolve-with-simple-bdd.js +0 -17
- package/dist/esm/src/minimal-string/resolve-with-simple-bdd.js.map +0 -1
- package/dist/esm/src/minimal-string/string-format.d.ts +0 -9
- package/dist/esm/src/minimal-string/string-format.js +0 -54
- package/dist/esm/src/minimal-string/string-format.js.map +0 -1
- package/src/minimal-string/bdd-to-minimal-string.ts +0 -72
- package/src/minimal-string/bdd-to-simple-bdd.ts +0 -31
- package/src/minimal-string/index.ts +0 -5
- package/src/minimal-string/minimal-string-to-simple-bdd.ts +0 -67
- package/src/minimal-string/resolve-with-simple-bdd.ts +0 -25
- package/src/minimal-string/string-format.ts +0 -67
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nodeToSimpleBddNode = exports.bddToSimpleBdd = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @recursive
|
|
6
|
-
*/
|
|
7
|
-
function bddToSimpleBdd(bdd) {
|
|
8
|
-
return nodeToSimpleBddNode(bdd);
|
|
9
|
-
}
|
|
10
|
-
exports.bddToSimpleBdd = bddToSimpleBdd;
|
|
11
|
-
/**
|
|
12
|
-
* @recursive
|
|
13
|
-
*/
|
|
14
|
-
function nodeToSimpleBddNode(node) {
|
|
15
|
-
const branch0 = node.branches.getBranch('0');
|
|
16
|
-
const branch1 = node.branches.getBranch('1');
|
|
17
|
-
return {
|
|
18
|
-
l: node.level,
|
|
19
|
-
0: branch0.isLeafNode() ? branch0.asLeafNode().value : nodeToSimpleBddNode(branch0),
|
|
20
|
-
1: branch1.isLeafNode() ? branch1.asLeafNode().value : nodeToSimpleBddNode(branch1),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.nodeToSimpleBddNode = nodeToSimpleBddNode;
|
|
24
|
-
//# sourceMappingURL=bdd-to-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bdd-to-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/bdd-to-simple-bdd.ts"],"names":[],"mappings":";;;AAOA;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAa;IACxC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAFD,wCAEC;AAGD;;GAEG;AACH,SAAgB,mBAAmB,CAC/B,IAAkB;IAGlB,MAAM,OAAO,GAAkB,IAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAkB,IAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAE7E,OAAO;QACH,CAAC,EAAE,IAAI,CAAC,KAAK;QACb,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;QACnF,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;KACtF,CAAC;AACN,CAAC;AAZD,kDAYC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/minimal-string/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,oEAAkD;AAClD,+DAA6C;AAC7C,qDAAmC;AACnC,yDAAuC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.minimalStringToSimpleBdd = void 0;
|
|
4
|
-
const util_js_1 = require("../util.js");
|
|
5
|
-
const string_format_js_1 = require("./string-format.js");
|
|
6
|
-
function minimalStringToSimpleBdd(str) {
|
|
7
|
-
const nodesById = new Map();
|
|
8
|
-
// parse leaf nodes
|
|
9
|
-
const leafNodeAmount = parseInt(str.charAt(0) + str.charAt(1), 10);
|
|
10
|
-
const lastLeafNodeChar = (2 + leafNodeAmount * 2);
|
|
11
|
-
const leafNodeChars = str.substring(2, lastLeafNodeChar);
|
|
12
|
-
const leafNodeChunks = (0, util_js_1.splitStringToChunks)(leafNodeChars, 2);
|
|
13
|
-
for (let i = 0; i < leafNodeChunks.length; i++) {
|
|
14
|
-
const chunk = leafNodeChunks[i];
|
|
15
|
-
const id = chunk.charAt(0);
|
|
16
|
-
const value = (0, string_format_js_1.getNumberOfChar)(chunk.charAt(1));
|
|
17
|
-
nodesById.set(id, value);
|
|
18
|
-
}
|
|
19
|
-
// parse internal nodes
|
|
20
|
-
const internalNodeChars = str.substring(lastLeafNodeChar, str.length - 3);
|
|
21
|
-
const internalNodeChunks = (0, util_js_1.splitStringToChunks)(internalNodeChars, 4);
|
|
22
|
-
for (let i = 0; i < internalNodeChunks.length; i++) {
|
|
23
|
-
const chunk = internalNodeChunks[i];
|
|
24
|
-
const id = chunk.charAt(0);
|
|
25
|
-
const idOf0Branch = chunk.charAt(1);
|
|
26
|
-
const idOf1Branch = chunk.charAt(2);
|
|
27
|
-
const level = (0, string_format_js_1.getNumberOfChar)(chunk.charAt(3));
|
|
28
|
-
if (!nodesById.has(idOf0Branch)) {
|
|
29
|
-
throw new Error('missing node with id ' + idOf0Branch);
|
|
30
|
-
}
|
|
31
|
-
if (!nodesById.has(idOf1Branch)) {
|
|
32
|
-
throw new Error('missing node with id ' + idOf1Branch);
|
|
33
|
-
}
|
|
34
|
-
const node0 = nodesById.get(idOf0Branch);
|
|
35
|
-
const node1 = nodesById.get(idOf1Branch);
|
|
36
|
-
const node = {
|
|
37
|
-
l: level, // level is first for prettier json output
|
|
38
|
-
0: node0,
|
|
39
|
-
1: node1
|
|
40
|
-
};
|
|
41
|
-
nodesById.set(id, node);
|
|
42
|
-
}
|
|
43
|
-
// parse root node
|
|
44
|
-
const last3 = str.slice(-3);
|
|
45
|
-
const idOf0 = last3.charAt(0);
|
|
46
|
-
const idOf1 = last3.charAt(1);
|
|
47
|
-
const levelOfRoot = (0, string_format_js_1.getNumberOfChar)(last3.charAt(2));
|
|
48
|
-
const nodeOf0 = nodesById.get(idOf0);
|
|
49
|
-
const nodeOf1 = nodesById.get(idOf1);
|
|
50
|
-
const rootNode = {
|
|
51
|
-
l: levelOfRoot,
|
|
52
|
-
0: nodeOf0,
|
|
53
|
-
1: nodeOf1,
|
|
54
|
-
};
|
|
55
|
-
return rootNode;
|
|
56
|
-
}
|
|
57
|
-
exports.minimalStringToSimpleBdd = minimalStringToSimpleBdd;
|
|
58
|
-
//# sourceMappingURL=minimal-string-to-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"minimal-string-to-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/minimal-string-to-simple-bdd.ts"],"names":[],"mappings":";;;AAIA,wCAAiD;AACjD,yDAAqD;AAErD,SAAgB,wBAAwB,CACpC,GAAW;IAEX,MAAM,SAAS,GAA+C,IAAI,GAAG,EAAE,CAAC;IAExE,mBAAmB;IACnB,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB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dd = void 0;
|
|
4
|
-
const util_js_1 = require("../util.js");
|
|
5
|
-
function resolveWithSimpleBdd(simpleBdd, fns, input) {
|
|
6
|
-
let currentNode = simpleBdd;
|
|
7
|
-
let currentLevel = simpleBdd.l;
|
|
8
|
-
while (true) {
|
|
9
|
-
const booleanResult = fns[currentLevel](input);
|
|
10
|
-
const branchKey = (0, util_js_1.booleanToBooleanString)(booleanResult);
|
|
11
|
-
currentNode = currentNode[branchKey];
|
|
12
|
-
if (typeof currentNode === 'number' || typeof currentNode === 'string') {
|
|
13
|
-
return currentNode;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
currentLevel = currentNode.l;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.resolveWithSimpleBdd = resolveWithSimpleBdd;
|
|
21
|
-
//# sourceMappingURL=resolve-with-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-with-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/resolve-with-simple-bdd.ts"],"names":[],"mappings":";;;AAKA,wCAAoD;AAEpD,SAAgB,oBAAoB,CAChC,SAAoB,EACpB,GAAsB,EACtB,KAAU;IAEV,IAAI,WAAW,GAAkC,SAAS,CAAC;IAC3D,IAAI,YAAY,GAAW,SAAS,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,EAAE,CAAC;QACV,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAA,gCAAsB,EAAC,aAAa,CAAC,CAAC;QACxD,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACrE,OAAO,WAAkB,CAAC;QAC9B,CAAC;aAAM,CAAC;YACJ,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC;QACjC,CAAC;IACL,CAAC;AACL,CAAC;AAjBD,oDAiBC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const CHAR_CODE_OFFSET = 40;
|
|
2
|
-
export declare function getCharOfLevel(level: number): string;
|
|
3
|
-
export declare function getNumberOfChar(char: string): number;
|
|
4
|
-
export declare function getCharOfValue(value: number): string;
|
|
5
|
-
export declare const FIRST_CHAR_CODE_FOR_ID = 97;
|
|
6
|
-
export declare function getNextCharId(lastCode: number): {
|
|
7
|
-
char: string;
|
|
8
|
-
nextCode: number;
|
|
9
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
let t = 0;
|
|
4
|
-
while (t < 10000) {
|
|
5
|
-
const char = String.fromCharCode(t);
|
|
6
|
-
console.log(t + ' : ' + char);
|
|
7
|
-
t++;
|
|
8
|
-
}
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.getNextCharId = exports.FIRST_CHAR_CODE_FOR_ID = exports.getCharOfValue = exports.getNumberOfChar = exports.getCharOfLevel = exports.CHAR_CODE_OFFSET = void 0;
|
|
12
|
-
/*
|
|
13
|
-
|
|
14
|
-
To have a really small string representation, we have to hack some stuff
|
|
15
|
-
which makes is complicated but effective.
|
|
16
|
-
|
|
17
|
-
Rules for the string:
|
|
18
|
-
- The string starts with a number like '23' that defines how many leaf-nodes we have
|
|
19
|
-
- leaf nodes consist of two chars like 'ab'
|
|
20
|
-
- the first char is the id
|
|
21
|
-
- the second the value is a number you can get via String.charCodeAt()
|
|
22
|
-
- Internal nodes have four chars like 'abcd'
|
|
23
|
-
- the first char is the id
|
|
24
|
-
- the second char is the id of the 0-branch
|
|
25
|
-
- the third char is the id of the 1-branch
|
|
26
|
-
- the last char is the id of the boolean-function (= level)
|
|
27
|
-
- The last 3 chars of the string is the root node like 'abc'
|
|
28
|
-
- it looks like the internal-node but without the id (first char)
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
// we use this because 39 is the quotes which causes problems
|
|
32
|
-
exports.CHAR_CODE_OFFSET = 40; // String.fromCharCode(33) === ')'
|
|
33
|
-
function getCharOfLevel(level) {
|
|
34
|
-
const charCode = exports.CHAR_CODE_OFFSET + level;
|
|
35
|
-
return String.fromCharCode(charCode);
|
|
36
|
-
}
|
|
37
|
-
exports.getCharOfLevel = getCharOfLevel;
|
|
38
|
-
function getNumberOfChar(char) {
|
|
39
|
-
const charCode = char.charCodeAt(0);
|
|
40
|
-
return charCode - exports.CHAR_CODE_OFFSET;
|
|
41
|
-
}
|
|
42
|
-
exports.getNumberOfChar = getNumberOfChar;
|
|
43
|
-
function getCharOfValue(value) {
|
|
44
|
-
const charCode = exports.CHAR_CODE_OFFSET + value;
|
|
45
|
-
return String.fromCharCode(charCode);
|
|
46
|
-
}
|
|
47
|
-
exports.getCharOfValue = getCharOfValue;
|
|
48
|
-
exports.FIRST_CHAR_CODE_FOR_ID = 97; // String.fromCharCode(97) === 'a'
|
|
49
|
-
function getNextCharId(lastCode) {
|
|
50
|
-
// jump these codes because they look strange
|
|
51
|
-
if (lastCode >= 128 && lastCode <= 160) {
|
|
52
|
-
lastCode = 161;
|
|
53
|
-
}
|
|
54
|
-
const char = String.fromCharCode(lastCode);
|
|
55
|
-
return {
|
|
56
|
-
char,
|
|
57
|
-
nextCode: lastCode + 1
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
exports.getNextCharId = getNextCharId;
|
|
61
|
-
//# sourceMappingURL=string-format.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-format.js","sourceRoot":"","sources":["../../../../src/minimal-string/string-format.ts"],"names":[],"mappings":";AAAA;;;;;;;EAOE;;;AAEF;;;;;;;;;;;;;;;;;;EAkBE;AAEF,6DAA6D;AAChD,QAAA,gBAAgB,GAAG,EAAE,CAAC,CAAC,kCAAkC;AAGtE,SAAgB,cAAc,CAAC,KAAa;IACxC,MAAM,QAAQ,GAAG,wBAAgB,GAAG,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAHD,wCAGC;AAED,SAAgB,eAAe,CAAC,IAAY;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,QAAQ,GAAG,wBAAgB,CAAC;AACvC,CAAC;AAHD,0CAGC;AAED,SAAgB,cAAc,CAAC,KAAa;IACxC,MAAM,QAAQ,GAAG,wBAAgB,GAAG,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAHD,wCAGC;AAGY,QAAA,sBAAsB,GAAG,EAAE,CAAC,CAAC,kCAAkC;AAE5E,SAAgB,aAAa,CAAC,QAAgB;IAK1C,6CAA6C;IAC7C,IAAI,QAAQ,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;QACrC,QAAQ,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO;QACH,IAAI;QACJ,QAAQ,EAAE,QAAQ,GAAG,CAAC;KACzB,CAAC;AACN,CAAC;AAfD,sCAeC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RootNode } from '../root-node.js';
|
|
2
|
-
import { AbstractNode } from '../abstract-node.js';
|
|
3
|
-
export declare function bddToMinimalString(bdd: RootNode): string;
|
|
4
|
-
export declare function nodeToString(node: AbstractNode, idByNode: Map<AbstractNode, string>, lastCode: number): {
|
|
5
|
-
id: string;
|
|
6
|
-
str: string;
|
|
7
|
-
nextCode: number;
|
|
8
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { getCharOfLevel, getCharOfValue, getNextCharId } from './string-format.js';
|
|
2
|
-
import { FIRST_CHAR_CODE_FOR_ID } from './string-format.js';
|
|
3
|
-
export function bddToMinimalString(bdd) {
|
|
4
|
-
let ret = '';
|
|
5
|
-
let currentCharCode = FIRST_CHAR_CODE_FOR_ID;
|
|
6
|
-
// add leaf node count
|
|
7
|
-
const leafNodeAmount = bdd.getLeafNodes().length;
|
|
8
|
-
if (leafNodeAmount > 99) {
|
|
9
|
-
throw new Error('cannot build string with too many leaf nodes');
|
|
10
|
-
}
|
|
11
|
-
ret += leafNodeAmount.toString().padStart(2, '0');
|
|
12
|
-
const levelsHighestFirst = bdd.levels.slice().reverse();
|
|
13
|
-
const idByNode = new Map();
|
|
14
|
-
levelsHighestFirst.forEach(level => {
|
|
15
|
-
const nodes = bdd.getNodesOfLevel(level);
|
|
16
|
-
nodes.forEach(node => {
|
|
17
|
-
const stringRep = nodeToString(node, idByNode, currentCharCode);
|
|
18
|
-
currentCharCode = stringRep.nextCode;
|
|
19
|
-
idByNode.set(node, stringRep.id);
|
|
20
|
-
ret += stringRep.str;
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return ret;
|
|
24
|
-
}
|
|
25
|
-
export function nodeToString(node, idByNode, lastCode) {
|
|
26
|
-
const nextId = getNextCharId(lastCode);
|
|
27
|
-
switch (node.type) {
|
|
28
|
-
case 'LeafNode':
|
|
29
|
-
const valueChar = getCharOfValue(node.asLeafNode().value);
|
|
30
|
-
return {
|
|
31
|
-
id: nextId.char,
|
|
32
|
-
nextCode: nextId.nextCode,
|
|
33
|
-
str: nextId.char + valueChar
|
|
34
|
-
};
|
|
35
|
-
case 'InternalNode':
|
|
36
|
-
const branch0Id = idByNode.get(node.asInternalNode().branches.getBranch('0'));
|
|
37
|
-
const branch1Id = idByNode.get(node.asInternalNode().branches.getBranch('1'));
|
|
38
|
-
return {
|
|
39
|
-
id: nextId.char,
|
|
40
|
-
nextCode: nextId.nextCode,
|
|
41
|
-
str: nextId.char + branch0Id + branch1Id + getCharOfLevel(node.level)
|
|
42
|
-
};
|
|
43
|
-
case 'RootNode':
|
|
44
|
-
const branch0IdRoot = idByNode.get(node.asRootNode().branches.getBranch('0'));
|
|
45
|
-
const branch1IdRoot = idByNode.get(node.asRootNode().branches.getBranch('1'));
|
|
46
|
-
return {
|
|
47
|
-
id: nextId.char,
|
|
48
|
-
nextCode: nextId.nextCode,
|
|
49
|
-
str: '' + branch0IdRoot + branch1IdRoot + getCharOfLevel(node.level)
|
|
50
|
-
};
|
|
51
|
-
default:
|
|
52
|
-
throw new Error('unknown node type');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=bdd-to-minimal-string.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bdd-to-minimal-string.js","sourceRoot":"","sources":["../../../../src/minimal-string/bdd-to-minimal-string.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EACH,sBAAsB,EACzB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,UAAU,kBAAkB,CAAC,GAAa;IAC5C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,eAAe,GAAG,sBAAsB,CAAC;IAE7C,sBAAsB;IACtB,MAAM,cAAc,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC;IACjD,IAAI,cAAc,GAAG,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACpE,CAAC;IAED,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAElD,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC;IACxD,MAAM,QAAQ,GAA8B,IAAI,GAAG,EAAE,CAAC;IACtD,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,KAAK,GAAG,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S,GAAG,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;aACxE,CAAC;QACN,KAAK,UAAU;YACX,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9E,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9E,OAAO;gBACH,EAAE,EAAE,MAAM,CAAC,IAAI;gBACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,GAAG,EAAE,EAAE,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;aACvE,CAAC;QACN;YACI,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RootNode } from '../root-node.js';
|
|
2
|
-
import { SimpleBdd } from '../types.js';
|
|
3
|
-
import { AbstractNode } from '../abstract-node.js';
|
|
4
|
-
/**
|
|
5
|
-
* @recursive
|
|
6
|
-
*/
|
|
7
|
-
export declare function bddToSimpleBdd(bdd: RootNode): SimpleBdd;
|
|
8
|
-
/**
|
|
9
|
-
* @recursive
|
|
10
|
-
*/
|
|
11
|
-
export declare function nodeToSimpleBddNode(node: AbstractNode): SimpleBdd;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @recursive
|
|
3
|
-
*/
|
|
4
|
-
export function bddToSimpleBdd(bdd) {
|
|
5
|
-
return nodeToSimpleBddNode(bdd);
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* @recursive
|
|
9
|
-
*/
|
|
10
|
-
export function nodeToSimpleBddNode(node) {
|
|
11
|
-
const branch0 = node.branches.getBranch('0');
|
|
12
|
-
const branch1 = node.branches.getBranch('1');
|
|
13
|
-
return {
|
|
14
|
-
l: node.level,
|
|
15
|
-
0: branch0.isLeafNode() ? branch0.asLeafNode().value : nodeToSimpleBddNode(branch0),
|
|
16
|
-
1: branch1.isLeafNode() ? branch1.asLeafNode().value : nodeToSimpleBddNode(branch1),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=bdd-to-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bdd-to-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/bdd-to-simple-bdd.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAa;IACxC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAGD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAAkB;IAGlB,MAAM,OAAO,GAAkB,IAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAkB,IAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAE7E,OAAO;QACH,CAAC,EAAE,IAAI,CAAC,KAAK;QACb,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;QACnF,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;KACtF,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/minimal-string/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { splitStringToChunks } from '../util.js';
|
|
2
|
-
import { getNumberOfChar } from './string-format.js';
|
|
3
|
-
export function minimalStringToSimpleBdd(str) {
|
|
4
|
-
const nodesById = new Map();
|
|
5
|
-
// parse leaf nodes
|
|
6
|
-
const leafNodeAmount = parseInt(str.charAt(0) + str.charAt(1), 10);
|
|
7
|
-
const lastLeafNodeChar = (2 + leafNodeAmount * 2);
|
|
8
|
-
const leafNodeChars = str.substring(2, lastLeafNodeChar);
|
|
9
|
-
const leafNodeChunks = splitStringToChunks(leafNodeChars, 2);
|
|
10
|
-
for (let i = 0; i < leafNodeChunks.length; i++) {
|
|
11
|
-
const chunk = leafNodeChunks[i];
|
|
12
|
-
const id = chunk.charAt(0);
|
|
13
|
-
const value = getNumberOfChar(chunk.charAt(1));
|
|
14
|
-
nodesById.set(id, value);
|
|
15
|
-
}
|
|
16
|
-
// parse internal nodes
|
|
17
|
-
const internalNodeChars = str.substring(lastLeafNodeChar, str.length - 3);
|
|
18
|
-
const internalNodeChunks = splitStringToChunks(internalNodeChars, 4);
|
|
19
|
-
for (let i = 0; i < internalNodeChunks.length; i++) {
|
|
20
|
-
const chunk = internalNodeChunks[i];
|
|
21
|
-
const id = chunk.charAt(0);
|
|
22
|
-
const idOf0Branch = chunk.charAt(1);
|
|
23
|
-
const idOf1Branch = chunk.charAt(2);
|
|
24
|
-
const level = getNumberOfChar(chunk.charAt(3));
|
|
25
|
-
if (!nodesById.has(idOf0Branch)) {
|
|
26
|
-
throw new Error('missing node with id ' + idOf0Branch);
|
|
27
|
-
}
|
|
28
|
-
if (!nodesById.has(idOf1Branch)) {
|
|
29
|
-
throw new Error('missing node with id ' + idOf1Branch);
|
|
30
|
-
}
|
|
31
|
-
const node0 = nodesById.get(idOf0Branch);
|
|
32
|
-
const node1 = nodesById.get(idOf1Branch);
|
|
33
|
-
const node = {
|
|
34
|
-
l: level, // level is first for prettier json output
|
|
35
|
-
0: node0,
|
|
36
|
-
1: node1
|
|
37
|
-
};
|
|
38
|
-
nodesById.set(id, node);
|
|
39
|
-
}
|
|
40
|
-
// parse root node
|
|
41
|
-
const last3 = str.slice(-3);
|
|
42
|
-
const idOf0 = last3.charAt(0);
|
|
43
|
-
const idOf1 = last3.charAt(1);
|
|
44
|
-
const levelOfRoot = getNumberOfChar(last3.charAt(2));
|
|
45
|
-
const nodeOf0 = nodesById.get(idOf0);
|
|
46
|
-
const nodeOf1 = nodesById.get(idOf1);
|
|
47
|
-
const rootNode = {
|
|
48
|
-
l: levelOfRoot,
|
|
49
|
-
0: nodeOf0,
|
|
50
|
-
1: nodeOf1,
|
|
51
|
-
};
|
|
52
|
-
return rootNode;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=minimal-string-to-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"minimal-string-to-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/minimal-string-to-simple-bdd.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,UAAU,wBAAwB,CACpC,GAAW;IAEX,MAAM,SAAS,GAA+C,IAAI,GAAG,EAAE,CAAC;IAExE,mBAAmB;IACnB,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;I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AAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,WAAW,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,CAAc,CAAC;QACtD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,CAAc,CAAC;QACtD,MAAM,IAAI,GAAc;YACpB,CAAC,EAAE,KAAK,EAAE,0CAA0C;YACpD,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;SACX,CAAC;QACF,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,kBAAkB;IAClB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAc,CAAC;IAClD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAc,CAAC;IAClD,MAAM,QAAQ,GAAc;QACxB,CAAC,EAAE,WAAW;QACd,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,OAAO;KACb,CAAC;IAEF,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { booleanToBooleanString } from '../util.js';
|
|
2
|
-
export function resolveWithSimpleBdd(simpleBdd, fns, input) {
|
|
3
|
-
let currentNode = simpleBdd;
|
|
4
|
-
let currentLevel = simpleBdd.l;
|
|
5
|
-
while (true) {
|
|
6
|
-
const booleanResult = fns[currentLevel](input);
|
|
7
|
-
const branchKey = booleanToBooleanString(booleanResult);
|
|
8
|
-
currentNode = currentNode[branchKey];
|
|
9
|
-
if (typeof currentNode === 'number' || typeof currentNode === 'string') {
|
|
10
|
-
return currentNode;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
currentLevel = currentNode.l;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=resolve-with-simple-bdd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-with-simple-bdd.js","sourceRoot":"","sources":["../../../../src/minimal-string/resolve-with-simple-bdd.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,UAAU,oBAAoB,CAChC,SAAoB,EACpB,GAAsB,EACtB,KAAU;IAEV,IAAI,WAAW,GAAkC,SAAS,CAAC;IAC3D,IAAI,YAAY,GAAW,SAAS,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,EAAE,CAAC;QACV,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;QACxD,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACrE,OAAO,WAAkB,CAAC;QAC9B,CAAC;aAAM,CAAC;YACJ,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC;QACjC,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const CHAR_CODE_OFFSET = 40;
|
|
2
|
-
export declare function getCharOfLevel(level: number): string;
|
|
3
|
-
export declare function getNumberOfChar(char: string): number;
|
|
4
|
-
export declare function getCharOfValue(value: number): string;
|
|
5
|
-
export declare const FIRST_CHAR_CODE_FOR_ID = 97;
|
|
6
|
-
export declare function getNextCharId(lastCode: number): {
|
|
7
|
-
char: string;
|
|
8
|
-
nextCode: number;
|
|
9
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
let t = 0;
|
|
3
|
-
while (t < 10000) {
|
|
4
|
-
const char = String.fromCharCode(t);
|
|
5
|
-
console.log(t + ' : ' + char);
|
|
6
|
-
t++;
|
|
7
|
-
}
|
|
8
|
-
*/
|
|
9
|
-
/*
|
|
10
|
-
|
|
11
|
-
To have a really small string representation, we have to hack some stuff
|
|
12
|
-
which makes is complicated but effective.
|
|
13
|
-
|
|
14
|
-
Rules for the string:
|
|
15
|
-
- The string starts with a number like '23' that defines how many leaf-nodes we have
|
|
16
|
-
- leaf nodes consist of two chars like 'ab'
|
|
17
|
-
- the first char is the id
|
|
18
|
-
- the second the value is a number you can get via String.charCodeAt()
|
|
19
|
-
- Internal nodes have four chars like 'abcd'
|
|
20
|
-
- the first char is the id
|
|
21
|
-
- the second char is the id of the 0-branch
|
|
22
|
-
- the third char is the id of the 1-branch
|
|
23
|
-
- the last char is the id of the boolean-function (= level)
|
|
24
|
-
- The last 3 chars of the string is the root node like 'abc'
|
|
25
|
-
- it looks like the internal-node but without the id (first char)
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
// we use this because 39 is the quotes which causes problems
|
|
29
|
-
export const CHAR_CODE_OFFSET = 40; // String.fromCharCode(33) === ')'
|
|
30
|
-
export function getCharOfLevel(level) {
|
|
31
|
-
const charCode = CHAR_CODE_OFFSET + level;
|
|
32
|
-
return String.fromCharCode(charCode);
|
|
33
|
-
}
|
|
34
|
-
export function getNumberOfChar(char) {
|
|
35
|
-
const charCode = char.charCodeAt(0);
|
|
36
|
-
return charCode - CHAR_CODE_OFFSET;
|
|
37
|
-
}
|
|
38
|
-
export function getCharOfValue(value) {
|
|
39
|
-
const charCode = CHAR_CODE_OFFSET + value;
|
|
40
|
-
return String.fromCharCode(charCode);
|
|
41
|
-
}
|
|
42
|
-
export const FIRST_CHAR_CODE_FOR_ID = 97; // String.fromCharCode(97) === 'a'
|
|
43
|
-
export function getNextCharId(lastCode) {
|
|
44
|
-
// jump these codes because they look strange
|
|
45
|
-
if (lastCode >= 128 && lastCode <= 160) {
|
|
46
|
-
lastCode = 161;
|
|
47
|
-
}
|
|
48
|
-
const char = String.fromCharCode(lastCode);
|
|
49
|
-
return {
|
|
50
|
-
char,
|
|
51
|
-
nextCode: lastCode + 1
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=string-format.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string-format.js","sourceRoot":"","sources":["../../../../src/minimal-string/string-format.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;;;;;;;;;;;EAkBE;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC,CAAC,kCAAkC;AAGtE,MAAM,UAAU,cAAc,CAAC,KAAa;IACxC,MAAM,QAAQ,GAAG,gBAAgB,GAAG,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,QAAQ,GAAG,gBAAgB,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IACxC,MAAM,QAAQ,GAAG,gBAAgB,GAAG,KAAK,CAAC;IAC1C,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAGD,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC,CAAC,kCAAkC;AAE5E,MAAM,UAAU,aAAa,CAAC,QAAgB;IAK1C,6CAA6C;IAC7C,IAAI,QAAQ,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;QACrC,QAAQ,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO;QACH,IAAI;QACJ,QAAQ,EAAE,QAAQ,GAAG,CAAC;KACzB,CAAC;AACN,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { RootNode } from '../root-node.js';
|
|
2
|
-
import { AbstractNode } from '../abstract-node.js';
|
|
3
|
-
import { getCharOfLevel, getCharOfValue, getNextCharId } from './string-format.js';
|
|
4
|
-
import {
|
|
5
|
-
FIRST_CHAR_CODE_FOR_ID
|
|
6
|
-
} from './string-format.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function bddToMinimalString(bdd: RootNode): string {
|
|
10
|
-
let ret = '';
|
|
11
|
-
let currentCharCode = FIRST_CHAR_CODE_FOR_ID;
|
|
12
|
-
|
|
13
|
-
// add leaf node count
|
|
14
|
-
const leafNodeAmount = bdd.getLeafNodes().length;
|
|
15
|
-
if (leafNodeAmount > 99) {
|
|
16
|
-
throw new Error('cannot build string with too many leaf nodes');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
ret += leafNodeAmount.toString().padStart(2, '0');
|
|
20
|
-
|
|
21
|
-
const levelsHighestFirst = bdd.levels.slice().reverse();
|
|
22
|
-
const idByNode: Map<AbstractNode, string> = new Map();
|
|
23
|
-
levelsHighestFirst.forEach(level => {
|
|
24
|
-
const nodes = bdd.getNodesOfLevel(level);
|
|
25
|
-
nodes.forEach(node => {
|
|
26
|
-
const stringRep = nodeToString(node, idByNode, currentCharCode);
|
|
27
|
-
currentCharCode = stringRep.nextCode;
|
|
28
|
-
idByNode.set(node, stringRep.id);
|
|
29
|
-
ret += stringRep.str;
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
return ret;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function nodeToString(
|
|
36
|
-
node: AbstractNode,
|
|
37
|
-
idByNode: Map<AbstractNode, string>,
|
|
38
|
-
lastCode: number
|
|
39
|
-
): {
|
|
40
|
-
id: string,
|
|
41
|
-
str: string,
|
|
42
|
-
nextCode: number
|
|
43
|
-
} {
|
|
44
|
-
const nextId = getNextCharId(lastCode);
|
|
45
|
-
switch (node.type) {
|
|
46
|
-
case 'LeafNode':
|
|
47
|
-
const valueChar = getCharOfValue(node.asLeafNode().value);
|
|
48
|
-
return {
|
|
49
|
-
id: nextId.char,
|
|
50
|
-
nextCode: nextId.nextCode,
|
|
51
|
-
str: nextId.char + valueChar
|
|
52
|
-
};
|
|
53
|
-
case 'InternalNode':
|
|
54
|
-
const branch0Id = idByNode.get(node.asInternalNode().branches.getBranch('0'));
|
|
55
|
-
const branch1Id = idByNode.get(node.asInternalNode().branches.getBranch('1'));
|
|
56
|
-
return {
|
|
57
|
-
id: nextId.char,
|
|
58
|
-
nextCode: nextId.nextCode,
|
|
59
|
-
str: nextId.char + branch0Id + branch1Id + getCharOfLevel(node.level)
|
|
60
|
-
};
|
|
61
|
-
case 'RootNode':
|
|
62
|
-
const branch0IdRoot = idByNode.get(node.asRootNode().branches.getBranch('0'));
|
|
63
|
-
const branch1IdRoot = idByNode.get(node.asRootNode().branches.getBranch('1'));
|
|
64
|
-
return {
|
|
65
|
-
id: nextId.char,
|
|
66
|
-
nextCode: nextId.nextCode,
|
|
67
|
-
str: '' + branch0IdRoot + branch1IdRoot + getCharOfLevel(node.level)
|
|
68
|
-
};
|
|
69
|
-
default:
|
|
70
|
-
throw new Error('unknown node type');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { RootNode } from '../root-node.js';
|
|
2
|
-
import {
|
|
3
|
-
SimpleBdd
|
|
4
|
-
} from '../types.js';
|
|
5
|
-
import { AbstractNode } from '../abstract-node.js';
|
|
6
|
-
import { InternalNode } from '../internal-node.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @recursive
|
|
10
|
-
*/
|
|
11
|
-
export function bddToSimpleBdd(bdd: RootNode): SimpleBdd {
|
|
12
|
-
return nodeToSimpleBddNode(bdd);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @recursive
|
|
18
|
-
*/
|
|
19
|
-
export function nodeToSimpleBddNode(
|
|
20
|
-
node: AbstractNode
|
|
21
|
-
): SimpleBdd {
|
|
22
|
-
|
|
23
|
-
const branch0: AbstractNode = (node as InternalNode).branches.getBranch('0');
|
|
24
|
-
const branch1: AbstractNode = (node as InternalNode).branches.getBranch('1');
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
l: node.level,
|
|
28
|
-
0: branch0.isLeafNode() ? branch0.asLeafNode().value : nodeToSimpleBddNode(branch0),
|
|
29
|
-
1: branch1.isLeafNode() ? branch1.asLeafNode().value : nodeToSimpleBddNode(branch1),
|
|
30
|
-
};
|
|
31
|
-
}
|