@astrale-os/kernel-dsl 0.2.0-beta.24 → 0.2.0-beta.26
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.
|
@@ -38,10 +38,16 @@ class Builder {
|
|
|
38
38
|
}
|
|
39
39
|
if (piece.maximum === undefined)
|
|
40
40
|
return this.concat(output, this.star(piece.atom));
|
|
41
|
+
if (piece.maximum === piece.minimum)
|
|
42
|
+
return output;
|
|
43
|
+
const end = this.state();
|
|
41
44
|
for (let index = piece.minimum; index < piece.maximum; index++) {
|
|
42
|
-
|
|
45
|
+
// A shorter repetition exits the whole suffix, rather than skipping arbitrary copies.
|
|
46
|
+
this.epsilon(output.end, end);
|
|
47
|
+
output = this.concat(output, this.atom(piece.atom));
|
|
43
48
|
}
|
|
44
|
-
|
|
49
|
+
this.epsilon(output.end, end);
|
|
50
|
+
return { start: output.start, end };
|
|
45
51
|
}
|
|
46
52
|
atom(atom) {
|
|
47
53
|
if (atom.kind === 'expression')
|
|
@@ -51,15 +57,6 @@ class Builder {
|
|
|
51
57
|
this.states[start].transitions.push({ to: end, ranges: atom.ranges });
|
|
52
58
|
return { start, end };
|
|
53
59
|
}
|
|
54
|
-
optional(atom) {
|
|
55
|
-
const start = this.state();
|
|
56
|
-
const end = this.state();
|
|
57
|
-
const child = this.atom(atom);
|
|
58
|
-
this.epsilon(start, end);
|
|
59
|
-
this.epsilon(start, child.start);
|
|
60
|
-
this.epsilon(child.end, end);
|
|
61
|
-
return { start, end };
|
|
62
|
-
}
|
|
63
60
|
star(atom) {
|
|
64
61
|
const start = this.state();
|
|
65
62
|
const end = this.state();
|
|
@@ -2,6 +2,8 @@ import { json } from '@astrale-os/kernel-dsl/value';
|
|
|
2
2
|
import { asDomainSchema } from '../model/schema.js';
|
|
3
3
|
import { digestDomainSchemaBytes } from './domain.digest.js';
|
|
4
4
|
import { canonicalizeDomainSchema } from './domain.js';
|
|
5
|
+
// Only canonical schemas created here own a retained revision, never caller-owned input.
|
|
6
|
+
const revisions = new WeakMap();
|
|
5
7
|
export function canonicalDomainSchema(value) {
|
|
6
8
|
return canonicalDomainSchemaAfterValidation(value);
|
|
7
9
|
}
|
|
@@ -10,8 +12,9 @@ export function canonicalDomainSchemaAfterValidation(value) {
|
|
|
10
12
|
const schema = asDomainSchema(canonicalizeDomainSchema(value));
|
|
11
13
|
const bytes = json.encode(schema);
|
|
12
14
|
const revision = digestDomainSchemaBytes(bytes);
|
|
15
|
+
revisions.set(schema, revision);
|
|
13
16
|
return Object.freeze({ schema, bytes, revision });
|
|
14
17
|
}
|
|
15
18
|
export function revisionOfDomainSchema(schema) {
|
|
16
|
-
return canonicalDomainSchema(schema).revision;
|
|
19
|
+
return revisions.get(schema) ?? canonicalDomainSchema(schema).revision;
|
|
17
20
|
}
|