@inventarch/language 0.0.0-stage → 1.1.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/LANGUAGE.md +56 -0
- package/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +33 -2
- package/SPEC.md +225 -0
- package/dist/ast.d.ts +114 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +2 -0
- package/dist/ast.js.map +1 -0
- package/dist/compile/compile.d.ts +82 -0
- package/dist/compile/compile.d.ts.map +1 -0
- package/dist/compile/compile.js +249 -0
- package/dist/compile/compile.js.map +1 -0
- package/dist/compile/index.d.ts +6 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +4 -0
- package/dist/compile/index.js.map +1 -0
- package/dist/compile/spellings.d.ts +7 -0
- package/dist/compile/spellings.d.ts.map +1 -0
- package/dist/compile/spellings.js +47 -0
- package/dist/compile/spellings.js.map +1 -0
- package/dist/compile/values.d.ts +32 -0
- package/dist/compile/values.d.ts.map +1 -0
- package/dist/compile/values.js +48 -0
- package/dist/compile/values.js.map +1 -0
- package/dist/diagnostics.d.ts +22 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +71 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/editor/index.d.ts +49 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +155 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/fold.d.ts +8 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/fold.js +26 -0
- package/dist/fold.js.map +1 -0
- package/dist/formatter.d.ts +10 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +108 -0
- package/dist/formatter.js.map +1 -0
- package/dist/identity.d.ts +31 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +64 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.generated.d.ts +99 -0
- package/dist/kernel.generated.d.ts.map +1 -0
- package/dist/kernel.generated.js +422 -0
- package/dist/kernel.generated.js.map +1 -0
- package/dist/parser/index.d.ts +5 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +3 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/parser.d.ts +11 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +297 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/values.d.ts +24 -0
- package/dist/parser/values.d.ts.map +1 -0
- package/dist/parser/values.js +284 -0
- package/dist/parser/values.js.map +1 -0
- package/dist/paths.d.ts +6 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +21 -0
- package/dist/paths.js.map +1 -0
- package/dist/references.d.ts +15 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +40 -0
- package/dist/references.js.map +1 -0
- package/dist/registry/consent.d.ts +11 -0
- package/dist/registry/consent.d.ts.map +1 -0
- package/dist/registry/consent.js +31 -0
- package/dist/registry/consent.js.map +1 -0
- package/dist/registry/extract.d.ts +11 -0
- package/dist/registry/extract.d.ts.map +1 -0
- package/dist/registry/extract.js +275 -0
- package/dist/registry/extract.js.map +1 -0
- package/dist/registry/fields.d.ts +14 -0
- package/dist/registry/fields.d.ts.map +1 -0
- package/dist/registry/fields.js +30 -0
- package/dist/registry/fields.js.map +1 -0
- package/dist/registry/floor.d.ts +17 -0
- package/dist/registry/floor.d.ts.map +1 -0
- package/dist/registry/floor.js +42 -0
- package/dist/registry/floor.js.map +1 -0
- package/dist/registry/index.d.ts +19 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +80 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/merge.d.ts +32 -0
- package/dist/registry/merge.d.ts.map +1 -0
- package/dist/registry/merge.js +84 -0
- package/dist/registry/merge.js.map +1 -0
- package/dist/registry/order.d.ts +12 -0
- package/dist/registry/order.d.ts.map +1 -0
- package/dist/registry/order.js +134 -0
- package/dist/registry/order.js.map +1 -0
- package/dist/registry/records.d.ts +14 -0
- package/dist/registry/records.d.ts.map +1 -0
- package/dist/registry/records.js +64 -0
- package/dist/registry/records.js.map +1 -0
- package/dist/registry/schemas.d.ts +20 -0
- package/dist/registry/schemas.d.ts.map +1 -0
- package/dist/registry/schemas.js +282 -0
- package/dist/registry/schemas.js.map +1 -0
- package/dist/registry/types.d.ts +130 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +2 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/scanner/index.d.ts +16 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +78 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/lines.d.ts +46 -0
- package/dist/scanner/lines.d.ts.map +1 -0
- package/dist/scanner/lines.js +210 -0
- package/dist/scanner/lines.js.map +1 -0
- package/dist/scanner/tokenize.d.ts +9 -0
- package/dist/scanner/tokenize.d.ts.map +1 -0
- package/dist/scanner/tokenize.js +125 -0
- package/dist/scanner/tokenize.js.map +1 -0
- package/dist/scanner/tokens.d.ts +52 -0
- package/dist/scanner/tokens.d.ts.map +1 -0
- package/dist/scanner/tokens.js +2 -0
- package/dist/scanner/tokens.js.map +1 -0
- package/dist/semantic/cases.d.ts +12 -0
- package/dist/semantic/cases.d.ts.map +1 -0
- package/dist/semantic/cases.js +81 -0
- package/dist/semantic/cases.js.map +1 -0
- package/dist/semantic/cells.d.ts +9 -0
- package/dist/semantic/cells.d.ts.map +1 -0
- package/dist/semantic/cells.js +120 -0
- package/dist/semantic/cells.js.map +1 -0
- package/dist/semantic/conditions.d.ts +22 -0
- package/dist/semantic/conditions.d.ts.map +1 -0
- package/dist/semantic/conditions.js +54 -0
- package/dist/semantic/conditions.js.map +1 -0
- package/dist/semantic/contracts.d.ts +11 -0
- package/dist/semantic/contracts.d.ts.map +1 -0
- package/dist/semantic/contracts.js +75 -0
- package/dist/semantic/contracts.js.map +1 -0
- package/dist/semantic/edges.d.ts +19 -0
- package/dist/semantic/edges.d.ts.map +1 -0
- package/dist/semantic/edges.js +129 -0
- package/dist/semantic/edges.js.map +1 -0
- package/dist/semantic/placement.d.ts +6 -0
- package/dist/semantic/placement.d.ts.map +1 -0
- package/dist/semantic/placement.js +47 -0
- package/dist/semantic/placement.js.map +1 -0
- package/dist/semantic/requirements.d.ts +14 -0
- package/dist/semantic/requirements.d.ts.map +1 -0
- package/dist/semantic/requirements.js +32 -0
- package/dist/semantic/requirements.js.map +1 -0
- package/dist/semantic/resolve.d.ts +23 -0
- package/dist/semantic/resolve.d.ts.map +1 -0
- package/dist/semantic/resolve.js +62 -0
- package/dist/semantic/resolve.js.map +1 -0
- package/dist/semantic/selectors.d.ts +10 -0
- package/dist/semantic/selectors.d.ts.map +1 -0
- package/dist/semantic/selectors.js +33 -0
- package/dist/semantic/selectors.js.map +1 -0
- package/dist/semantic/types.d.ts +56 -0
- package/dist/semantic/types.d.ts.map +1 -0
- package/dist/semantic/types.js +11 -0
- package/dist/semantic/types.js.map +1 -0
- package/dist/semantic/variants.d.ts +10 -0
- package/dist/semantic/variants.d.ts.map +1 -0
- package/dist/semantic/variants.js +63 -0
- package/dist/semantic/variants.js.map +1 -0
- package/dist/semantic/vocabulary.d.ts +12 -0
- package/dist/semantic/vocabulary.d.ts.map +1 -0
- package/dist/semantic/vocabulary.js +33 -0
- package/dist/semantic/vocabulary.js.map +1 -0
- package/dist/taxonomy.d.ts +51 -0
- package/dist/taxonomy.d.ts.map +1 -0
- package/dist/taxonomy.js +42 -0
- package/dist/taxonomy.js.map +1 -0
- package/package.json +221 -3
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Diagnostic } from './diagnostics.js';
|
|
2
|
+
/** 1-based, inclusive source line range. */
|
|
3
|
+
export interface Span {
|
|
4
|
+
readonly line: number;
|
|
5
|
+
readonly endLine: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A field's value. `scalar` is an unquoted run of words; `string` a `"..."` literal; `prose` a
|
|
9
|
+
* `"""..."""` value after folding; `ref` a `@discriminator name[#fragment]` target; `list` a
|
|
10
|
+
* `[...]`; `block` a bare key that opens an indented block (derived: a `none` value whose field
|
|
11
|
+
* has children and whose line produced no diagnostic); `none` a bare key with nothing under it.
|
|
12
|
+
*/
|
|
13
|
+
export type Value = {
|
|
14
|
+
readonly kind: 'scalar';
|
|
15
|
+
readonly text: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'string';
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly raw: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'prose';
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly raw: string;
|
|
24
|
+
}
|
|
25
|
+
/** `raw` is the canonical rendering `@discriminator name[#fragment]`, not the authored bytes. */
|
|
26
|
+
| {
|
|
27
|
+
readonly kind: 'ref';
|
|
28
|
+
readonly discriminator: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly fragment?: string;
|
|
31
|
+
readonly raw: string;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'list';
|
|
34
|
+
readonly items: readonly ListItem[];
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'block';
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'none';
|
|
39
|
+
};
|
|
40
|
+
/** A list item is a scalar, a string or a ref; derived from `Value` so the shapes cannot drift. */
|
|
41
|
+
export type ListItem = Extract<Value, {
|
|
42
|
+
kind: 'scalar' | 'string' | 'ref';
|
|
43
|
+
}>;
|
|
44
|
+
/** A `key value` line. `words` is every unquoted word before any string, prose, list or ref, in order. */
|
|
45
|
+
export interface FieldNode {
|
|
46
|
+
readonly kind: 'field';
|
|
47
|
+
readonly key: string;
|
|
48
|
+
readonly words: readonly string[];
|
|
49
|
+
readonly value: Value;
|
|
50
|
+
/** Words after a trailing ` when `, when present: the condition, uninterpreted here. A quoted string keeps its quotes; a reference is its `@discriminator` and name words. */
|
|
51
|
+
readonly when?: readonly string[];
|
|
52
|
+
/** Set when the whole line was words in the form `<key> is <value>`. */
|
|
53
|
+
readonly assertive?: boolean;
|
|
54
|
+
readonly span: Span;
|
|
55
|
+
readonly children: readonly ChildNode[];
|
|
56
|
+
}
|
|
57
|
+
/** What a `- value` line may hold: one list item, or `none` when its value was refused. */
|
|
58
|
+
export type ItemValue = ListItem | Extract<Value, {
|
|
59
|
+
kind: 'none';
|
|
60
|
+
}>;
|
|
61
|
+
/** A `- value` line under a field or a section. */
|
|
62
|
+
export interface ItemNode {
|
|
63
|
+
readonly kind: 'item';
|
|
64
|
+
readonly value: ItemValue;
|
|
65
|
+
readonly span: Span;
|
|
66
|
+
}
|
|
67
|
+
export interface RecordNode {
|
|
68
|
+
readonly kind: 'record';
|
|
69
|
+
readonly discriminator: string;
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly head: readonly FieldNode[];
|
|
72
|
+
readonly sections: readonly SectionNode[];
|
|
73
|
+
/**
|
|
74
|
+
* Every record whose nearest enclosing record is this one. Each is also present at its structural
|
|
75
|
+
* position under a section or a field's `children` (a header directly under a header is refused);
|
|
76
|
+
* a record nested inside one of these appears in that record's own `nested`, not here.
|
|
77
|
+
*/
|
|
78
|
+
readonly nested: readonly RecordNode[];
|
|
79
|
+
readonly span: Span;
|
|
80
|
+
}
|
|
81
|
+
export interface SectionNode {
|
|
82
|
+
readonly kind: 'section';
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly span: Span;
|
|
85
|
+
readonly children: readonly ChildNode[];
|
|
86
|
+
}
|
|
87
|
+
export type ChildNode = FieldNode | ItemNode | RecordNode;
|
|
88
|
+
interface TriviaBase {
|
|
89
|
+
readonly line: number;
|
|
90
|
+
/** Index into `FileNode.records` of the top-level record this trivia precedes or lies within, or 'file' when none follows. Position inside that record, including before a nested record, is by `line`. */
|
|
91
|
+
readonly attachedTo: number | 'file';
|
|
92
|
+
/** True for a comment that followed content on a single-line value's line. A comment on any line of a multi-line list or prose value is trivia at its own line and is never trailing. */
|
|
93
|
+
readonly trailing: boolean;
|
|
94
|
+
}
|
|
95
|
+
export type TriviaNode = (TriviaBase & {
|
|
96
|
+
readonly kind: 'comment';
|
|
97
|
+
readonly text: string;
|
|
98
|
+
}) | (TriviaBase & {
|
|
99
|
+
readonly kind: 'blank';
|
|
100
|
+
});
|
|
101
|
+
export interface FileNode {
|
|
102
|
+
readonly kind: 'file';
|
|
103
|
+
readonly path: string;
|
|
104
|
+
/** The pragma's version; the empty string only for a refused file with no pragma. */
|
|
105
|
+
readonly version: string;
|
|
106
|
+
readonly records: readonly RecordNode[];
|
|
107
|
+
readonly trivia: readonly TriviaNode[];
|
|
108
|
+
/** Parser-owned errors, including omitted lines. Absent for a clean parse; consumers must not re-emit them. */
|
|
109
|
+
readonly syntaxDiagnostics?: readonly Diagnostic[];
|
|
110
|
+
/** Structural extents of attempted records, including refused headers; present with parse-error ownership metadata. */
|
|
111
|
+
readonly syntaxRecordSpans?: readonly Span[];
|
|
112
|
+
}
|
|
113
|
+
export {};
|
|
114
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,4CAA4C;AAC5C,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;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ACzL,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,MAAM,UAAU,GAClB,CAAC,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAClE,CAAC,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE9C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,+GAA+G;IAC/G,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACnD,uHAAuH;IACvH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;CAC9C"}
|
package/dist/ast.js
ADDED
package/dist/ast.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { FileNode, Span } from '../ast.js';
|
|
2
|
+
import type { Diagnostic } from '../diagnostics.js';
|
|
3
|
+
import type { FrozenRegistry, Location, Placement } from '../registry/types.js';
|
|
4
|
+
import type { Kind, Provenance } from '../taxonomy.js';
|
|
5
|
+
import type { CompiledValue } from './values.js';
|
|
6
|
+
import type { Cell, CompiledEdge, Requirement, Selector, Variant } from '../semantic/types.js';
|
|
7
|
+
export type { CompiledEdge } from '../semantic/types.js';
|
|
8
|
+
export interface CompiledField {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly value: CompiledValue;
|
|
11
|
+
/** Authored words retained for tools; admitted semantic carriers also expose canonical terms. */
|
|
12
|
+
readonly when?: readonly string[];
|
|
13
|
+
readonly span: Span;
|
|
14
|
+
readonly fields?: readonly CompiledChild[];
|
|
15
|
+
}
|
|
16
|
+
/** A `- value` line beside the fields of its section or block. */
|
|
17
|
+
export interface CompiledItem {
|
|
18
|
+
readonly item: CompiledValue;
|
|
19
|
+
readonly span: Span;
|
|
20
|
+
}
|
|
21
|
+
export type CompiledChild = CompiledField | CompiledItem;
|
|
22
|
+
export interface CompiledSection {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly span: Span;
|
|
25
|
+
readonly fields: readonly CompiledChild[];
|
|
26
|
+
}
|
|
27
|
+
/** The structured record and semantic products of spec 10.2. Errors leave only a preview, not loadable data. */
|
|
28
|
+
export interface CompiledRecord {
|
|
29
|
+
readonly identity: string;
|
|
30
|
+
readonly system: string;
|
|
31
|
+
readonly kind: Kind;
|
|
32
|
+
readonly facet: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly displayName: string;
|
|
35
|
+
readonly discriminator: string;
|
|
36
|
+
readonly parent?: string;
|
|
37
|
+
readonly source: {
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly line: number;
|
|
40
|
+
readonly endLine: number;
|
|
41
|
+
};
|
|
42
|
+
readonly head: readonly CompiledField[];
|
|
43
|
+
readonly sections: readonly CompiledSection[];
|
|
44
|
+
readonly edges: readonly CompiledEdge[];
|
|
45
|
+
readonly cells: readonly Cell[];
|
|
46
|
+
readonly selectors: readonly Selector[];
|
|
47
|
+
readonly variants: readonly Variant[];
|
|
48
|
+
readonly requirements: readonly Requirement[];
|
|
49
|
+
readonly schema: string;
|
|
50
|
+
readonly provenance: Provenance;
|
|
51
|
+
readonly placement: Placement;
|
|
52
|
+
}
|
|
53
|
+
/** Spec 10.4: authored spans plus arrays parallel to every emitted semantic product. */
|
|
54
|
+
export interface SourceMapEntry {
|
|
55
|
+
readonly identity: string;
|
|
56
|
+
readonly header: Span;
|
|
57
|
+
readonly sections: readonly {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly span: Span;
|
|
60
|
+
}[];
|
|
61
|
+
readonly fields: readonly {
|
|
62
|
+
readonly path: string;
|
|
63
|
+
readonly span: Span;
|
|
64
|
+
}[];
|
|
65
|
+
/** Parallel to the record's emitted edges. */
|
|
66
|
+
readonly edges: readonly Span[];
|
|
67
|
+
readonly cells: readonly Span[];
|
|
68
|
+
readonly selectors: readonly Span[];
|
|
69
|
+
readonly variants: readonly Span[];
|
|
70
|
+
readonly requirements: readonly Span[];
|
|
71
|
+
}
|
|
72
|
+
export interface CompileResult {
|
|
73
|
+
readonly records: readonly CompiledRecord[];
|
|
74
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
75
|
+
readonly sourceMap: readonly SourceMapEntry[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Lower one parsed file at a location (spec 10.1). Pure: no I/O, no clock, no default vocabulary.
|
|
79
|
+
* pool contains external admitted occurrences and must exclude this canonical source path.
|
|
80
|
+
*/
|
|
81
|
+
export declare function compile(ast: FileNode, registry: FrozenRegistry, location: Location, pool: readonly CompiledRecord[]): CompileResult;
|
|
82
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,QAAQ,EAAc,IAAI,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,aAAa,EAA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S,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,SAAS,IAAI,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;CAC/C;AAmBD;;;GAGG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,QAAQ,EACb,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,cAAc,EAAE,GAC9B,aAAa,CAwDf"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { diag } from '../diagnostics.js';
|
|
2
|
+
import { collisions, identityOf, renderIdentity } from '../identity.js';
|
|
3
|
+
import { canonicalPath } from '../paths.js';
|
|
4
|
+
import { spelledAs } from '../registry/fields.js';
|
|
5
|
+
import { FLOOR_SYSTEM } from '../registry/floor.js';
|
|
6
|
+
import { conditionsIn, recordsIn } from '../registry/records.js';
|
|
7
|
+
import { sortDiagnostics } from '../registry/index.js';
|
|
8
|
+
import { spellingsFor } from './spellings.js';
|
|
9
|
+
import { compiledValue, resolveKey } from './values.js';
|
|
10
|
+
import { readCells } from '../semantic/cells.js';
|
|
11
|
+
import { readSelectors } from '../semantic/selectors.js';
|
|
12
|
+
import { readVariants } from '../semantic/variants.js';
|
|
13
|
+
import { readEdges } from '../semantic/edges.js';
|
|
14
|
+
import { readContract } from '../semantic/contracts.js';
|
|
15
|
+
import { validateCase } from '../semantic/cases.js';
|
|
16
|
+
import { misplacedConditions } from '../semantic/placement.js';
|
|
17
|
+
import { requirementCollisions } from '../semantic/requirements.js';
|
|
18
|
+
import { indexedResolver, validatePool } from '../semantic/resolve.js';
|
|
19
|
+
/**
|
|
20
|
+
* Lower one parsed file at a location (spec 10.1). Pure: no I/O, no clock, no default vocabulary.
|
|
21
|
+
* pool contains external admitted occurrences and must exclude this canonical source path.
|
|
22
|
+
*/
|
|
23
|
+
export function compile(ast, registry, location, pool) {
|
|
24
|
+
validatePool(registry, pool, ast.path);
|
|
25
|
+
const syntaxRefused = new Set(recordsIn(ast, ast.syntaxDiagnostics ?? [])
|
|
26
|
+
.filter((source) => source.errors.length > 0)
|
|
27
|
+
.map((source) => source.record));
|
|
28
|
+
const ctx = {
|
|
29
|
+
registry,
|
|
30
|
+
location,
|
|
31
|
+
path: canonicalPath(ast.path),
|
|
32
|
+
diagnostics: [],
|
|
33
|
+
drafts: [],
|
|
34
|
+
syntaxRefused,
|
|
35
|
+
};
|
|
36
|
+
for (const record of ast.records)
|
|
37
|
+
compileRecord(record, undefined, ctx);
|
|
38
|
+
// One identity twice in this file is a collision on both (spec 3.2); across files the caller and the graph decide.
|
|
39
|
+
const found = collisions(ctx.drafts.map((draft) => draft.occurrence));
|
|
40
|
+
ctx.diagnostics.push(...found.diagnostics);
|
|
41
|
+
// Parents precede their descendants in source order. Follow actual occurrences, not names:
|
|
42
|
+
// a refused enclosing record cannot leave compiled children with a dangling parent.
|
|
43
|
+
const refused = new Set(found.refused);
|
|
44
|
+
const kept = [];
|
|
45
|
+
for (const draft of ctx.drafts.sort((a, b) => a.record.source.line - b.record.source.line)) {
|
|
46
|
+
if (draft.parent !== undefined && refused.has(draft.parent))
|
|
47
|
+
refused.add(draft.occurrence);
|
|
48
|
+
if (!refused.has(draft.occurrence))
|
|
49
|
+
kept.push(draft);
|
|
50
|
+
}
|
|
51
|
+
const local = kept.map((draft) => lowerProducts(draft, ctx));
|
|
52
|
+
const candidates = [...local.map((draft) => draft.record), ...pool];
|
|
53
|
+
const resolver = indexedResolver(registry, candidates);
|
|
54
|
+
const related = local.map((draft) => lowerRelationships(draft, resolver, ctx));
|
|
55
|
+
const occurrences = related.flatMap(({ record }) => record.requirements.map((requirement) => ({
|
|
56
|
+
id: requirement.id,
|
|
57
|
+
identity: record.identity,
|
|
58
|
+
path: record.source.path,
|
|
59
|
+
line: requirement.span.line,
|
|
60
|
+
requirement,
|
|
61
|
+
})));
|
|
62
|
+
const duplicateRequirements = requirementCollisions(occurrences);
|
|
63
|
+
ctx.diagnostics.push(...duplicateRequirements.diagnostics);
|
|
64
|
+
const refusedRequirements = new Set([...duplicateRequirements.refused].map((occurrence) => occurrence.requirement));
|
|
65
|
+
const final = related.map((draft) => {
|
|
66
|
+
const requirements = draft.record.requirements.filter((requirement) => !refusedRequirements.has(requirement));
|
|
67
|
+
return {
|
|
68
|
+
...draft,
|
|
69
|
+
record: { ...draft.record, requirements },
|
|
70
|
+
map: { ...draft.map, requirements: requirements.map((requirement) => requirement.span) },
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
records: final.map((draft) => draft.record),
|
|
75
|
+
diagnostics: sortDiagnostics(ctx.diagnostics),
|
|
76
|
+
sourceMap: final.map((draft) => draft.map),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Schema extraction owns all of that dialect's conditions, including extra field blocks. */
|
|
80
|
+
function schemaOwnsRefusal(node) {
|
|
81
|
+
return (node.discriminator === 'schema' &&
|
|
82
|
+
(node.sections.some((section) => section.name === 'when') ||
|
|
83
|
+
conditionsIn([...node.head, ...node.sections.flatMap((section) => section.children)]).length > 0));
|
|
84
|
+
}
|
|
85
|
+
function lowerProducts(draft, ctx) {
|
|
86
|
+
if (schemaOwnsRefusal(draft.node))
|
|
87
|
+
return draft;
|
|
88
|
+
const registration = ctx.registry.registrations.get(draft.record.discriminator);
|
|
89
|
+
const cells = readCells(draft.node, ctx.path);
|
|
90
|
+
const selectors = readSelectors(draft.node, ctx.path);
|
|
91
|
+
const variants = readVariants(draft.node, ctx.path, spellingsFor(registration, ctx.registry.schemas.get(registration.schema), 'governance'));
|
|
92
|
+
ctx.diagnostics.push(...misplacedConditions(draft.node, ctx.path), ...cells.diagnostics, ...selectors.diagnostics, ...variants.diagnostics);
|
|
93
|
+
return {
|
|
94
|
+
...draft,
|
|
95
|
+
record: { ...draft.record, cells: cells.cells, selectors: selectors.selectors, variants: variants.variants },
|
|
96
|
+
map: {
|
|
97
|
+
...draft.map,
|
|
98
|
+
cells: cells.cells.map((cell) => cell.span),
|
|
99
|
+
selectors: selectors.spans,
|
|
100
|
+
variants: variants.variants.map((variant) => variant.span),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function lowerRelationships(draft, pool, ctx) {
|
|
105
|
+
if (schemaOwnsRefusal(draft.node))
|
|
106
|
+
return draft;
|
|
107
|
+
const edges = readEdges(draft.node, draft.record, ctx.registry, pool, draft.record.edges);
|
|
108
|
+
const contract = readContract(draft.node, ctx.path, ctx.registry, edges.edges, edges.refusedBindings);
|
|
109
|
+
const scenario = validateCase(draft.node, ctx.path, ctx.registry, edges.edges, edges.refusedBindings);
|
|
110
|
+
ctx.diagnostics.push(...edges.diagnostics, ...contract.diagnostics, ...scenario.diagnostics);
|
|
111
|
+
return {
|
|
112
|
+
...draft,
|
|
113
|
+
record: { ...draft.record, edges: edges.edges, requirements: contract.requirements },
|
|
114
|
+
map: { ...draft.map, edges: edges.edges.map((edge) => edge.span) },
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function compileRecord(record, parent, ctx) {
|
|
118
|
+
if (ctx.syntaxRefused.has(record))
|
|
119
|
+
return; // parser owns this refusal; descendants cannot outlive their parent
|
|
120
|
+
const { registry, path } = ctx;
|
|
121
|
+
const line = record.span.line;
|
|
122
|
+
const registration = registry.registrations.get(record.discriminator);
|
|
123
|
+
if (registration === undefined) {
|
|
124
|
+
const why = registry.blocked.has(record.discriminator)
|
|
125
|
+
? 'is blocked at this location: two systems register it at the winning band'
|
|
126
|
+
: 'is not registered at this location';
|
|
127
|
+
ctx.diagnostics.push(diag('IA-LANG-DISCRIMINATOR-UNREGISTERED', path, line, `${path}:${line}: discriminator '${record.discriminator}' ${why}; visible systems: ${registry.order.join(', ')}`));
|
|
128
|
+
return; // nothing beneath a refused record compiles: a nested record would have no parent identity
|
|
129
|
+
}
|
|
130
|
+
const identified = identityOf(record, registration, path);
|
|
131
|
+
ctx.diagnostics.push(...identified.diagnostics);
|
|
132
|
+
const identity = identified.identity;
|
|
133
|
+
if (identity === undefined)
|
|
134
|
+
return;
|
|
135
|
+
const occurrence = { identity: identity.identity, path, line, band: ctx.location.placement.band };
|
|
136
|
+
const schema = registry.schemas.get(registration.schema);
|
|
137
|
+
const fieldSpans = [];
|
|
138
|
+
const head = [];
|
|
139
|
+
for (const field of record.head) {
|
|
140
|
+
const compiled = compileField(field, spellingsFor(registration, schema, 'head'), 'head', occurrence, fieldSpans, ctx);
|
|
141
|
+
if (!spelledAs(field, ['facet']))
|
|
142
|
+
head.push(compiled); // facet is consumed; its source span and nested records survive
|
|
143
|
+
}
|
|
144
|
+
const sections = record.sections.map((section) => ({
|
|
145
|
+
name: section.name,
|
|
146
|
+
span: section.span,
|
|
147
|
+
fields: compileChildren(section.children, spellingsFor(registration, schema, section.name), section.name, occurrence, fieldSpans, ctx),
|
|
148
|
+
}));
|
|
149
|
+
const edges = registration.system === FLOOR_SYSTEM && registration.keyword === 'system' ? groundEdges(record, identity, ctx) : [];
|
|
150
|
+
const compiled = {
|
|
151
|
+
identity: identity.identity,
|
|
152
|
+
system: identity.system,
|
|
153
|
+
kind: identity.kind,
|
|
154
|
+
facet: identity.facet,
|
|
155
|
+
name: identity.name,
|
|
156
|
+
displayName: identity.displayName,
|
|
157
|
+
discriminator: record.discriminator,
|
|
158
|
+
...(parent === undefined ? {} : { parent: parent.identity }),
|
|
159
|
+
source: { path, line: record.span.line, endLine: record.span.endLine },
|
|
160
|
+
head,
|
|
161
|
+
sections,
|
|
162
|
+
edges,
|
|
163
|
+
cells: [],
|
|
164
|
+
selectors: [],
|
|
165
|
+
variants: [],
|
|
166
|
+
requirements: [],
|
|
167
|
+
schema: renderIdentity(FLOOR_SYSTEM, 'contract', 'head', registration.schema),
|
|
168
|
+
provenance: ctx.location.provenance,
|
|
169
|
+
placement: ctx.location.placement,
|
|
170
|
+
};
|
|
171
|
+
ctx.drafts.push({
|
|
172
|
+
node: record,
|
|
173
|
+
record: compiled,
|
|
174
|
+
map: {
|
|
175
|
+
identity: identity.identity,
|
|
176
|
+
header: { line, endLine: line },
|
|
177
|
+
sections: sections.map((s) => ({ name: s.name, span: s.span })),
|
|
178
|
+
fields: fieldSpans,
|
|
179
|
+
edges: edges.map((edge) => edge.span),
|
|
180
|
+
cells: [],
|
|
181
|
+
selectors: [],
|
|
182
|
+
variants: [],
|
|
183
|
+
requirements: [],
|
|
184
|
+
},
|
|
185
|
+
occurrence,
|
|
186
|
+
parent,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function compileChildren(children, spellings, prefix, parent, fieldSpans, ctx) {
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const child of children) {
|
|
192
|
+
if (child.kind === 'record') {
|
|
193
|
+
compileRecord(child, parent, ctx);
|
|
194
|
+
continue;
|
|
195
|
+
} // containment is structural, not a field (spec 2.5)
|
|
196
|
+
if (child.kind === 'item') {
|
|
197
|
+
out.push({ item: compiledValue(child.value), span: child.span });
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
out.push(compileField(child, spellings, prefix, parent, fieldSpans, ctx));
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
function compileField(field, spellings, prefix, parent, fieldSpans, ctx) {
|
|
205
|
+
const { key, value } = resolveKey(field, spellings);
|
|
206
|
+
const fieldPath = `${prefix}.${key}`;
|
|
207
|
+
fieldSpans.push({ path: fieldPath, span: field.span });
|
|
208
|
+
const nested = field.children.length === 0
|
|
209
|
+
? undefined
|
|
210
|
+
: compileChildren(field.children, spellings, fieldPath, parent, fieldSpans, ctx);
|
|
211
|
+
return {
|
|
212
|
+
key,
|
|
213
|
+
value,
|
|
214
|
+
...(field.when === undefined ? {} : { when: field.when }),
|
|
215
|
+
span: field.span,
|
|
216
|
+
...(nested === undefined ? {} : { fields: nested }),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** Spec 4.2: the compiler emits a `ground` edge from a system record to each schema an entry it registered names. */
|
|
220
|
+
function groundEdges(record, identity, ctx) {
|
|
221
|
+
const { registry } = ctx;
|
|
222
|
+
const system = registry.systems.get(identity.name);
|
|
223
|
+
if (system === undefined ||
|
|
224
|
+
canonicalPath(system.path) !== ctx.path ||
|
|
225
|
+
system.band !== ctx.location.placement.band ||
|
|
226
|
+
system.span.line !== record.span.line)
|
|
227
|
+
return [];
|
|
228
|
+
const edges = [];
|
|
229
|
+
const named = new Set();
|
|
230
|
+
for (const entry of system.entries) {
|
|
231
|
+
const registration = registry.registrations.get(entry.keyword);
|
|
232
|
+
if (registration === undefined ||
|
|
233
|
+
registration.system !== system.name ||
|
|
234
|
+
registration.band !== system.band ||
|
|
235
|
+
registration.schema !== entry.schema ||
|
|
236
|
+
named.has(entry.schema))
|
|
237
|
+
continue;
|
|
238
|
+
named.add(entry.schema);
|
|
239
|
+
edges.push({
|
|
240
|
+
predicate: 'ground',
|
|
241
|
+
direction: 'out',
|
|
242
|
+
reference: { kind: 'ref', discriminator: 'schema', name: entry.schema },
|
|
243
|
+
target: renderIdentity(FLOOR_SYSTEM, 'contract', 'head', entry.schema),
|
|
244
|
+
span: entry.span,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return edges;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,U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K,CAAC,OAAO,CAAC,CAAC;QAC/D,IACE,YAAY,KAAK,SAAS;YAC1B,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI;YACnC,YAAY,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;YACjC,YAAY,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;YACpC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;YAEvB,SAAS;QACX,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC;YACT,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE;YACvE,MAAM,EAAE,cAAc,CAAC,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YACtE,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { compile } from './compile.js';
|
|
2
|
+
export type { CompileResult, CompiledChild, CompiledEdge, CompiledField, CompiledItem, CompiledRecord, CompiledSection, SourceMapEntry, } from './compile.js';
|
|
3
|
+
export { HEAD_SPELLINGS, spellingsFor } from './spellings.js';
|
|
4
|
+
export { compiledValue, resolveKey } from './values.js';
|
|
5
|
+
export type { CompiledValue, Spelling } from './values.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAWvC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Registration, SchemaDeclaration } from '../registry/types.js';
|
|
2
|
+
import type { Spelling } from './values.js';
|
|
3
|
+
/** The head keys spec 2.2 names. A schema spells more under `head.<key>` fields. */
|
|
4
|
+
export declare const HEAD_SPELLINGS: readonly Spelling[];
|
|
5
|
+
/** The keys spelled for one section of a record, or for its head. */
|
|
6
|
+
export declare function spellingsFor(registration: Registration, schema: SchemaDeclaration | undefined, section: 'head' | string): readonly Spelling[];
|
|
7
|
+
//# sourceMappingURL=spellings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spellings.d.ts","sourceRoot":"","sources":["../../src/compile/spellings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,SAAS,QAAQ,EAO7C,CAAC;AA6BF,qEAAqE;AACrE,wBAAgB,YAAY,CAC1B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,SAAS,QAAQ,EAAE,CAOrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FLOOR_SYSTEM } from '../registry/floor.js';
|
|
2
|
+
/** The head keys spec 2.2 names. A schema spells more under `head.<key>` fields. */
|
|
3
|
+
export const HEAD_SPELLINGS = [
|
|
4
|
+
['facet'],
|
|
5
|
+
['version'],
|
|
6
|
+
['provider'],
|
|
7
|
+
['describes'],
|
|
8
|
+
['steward'],
|
|
9
|
+
['lowers', 'to'],
|
|
10
|
+
];
|
|
11
|
+
/** What the floor spells inside its own two records (spec 4.2 and 4.3). An entry `agent lowers to binding` keeps `agent` as its key: the registry reads it, compile only carries it. */
|
|
12
|
+
const FLOOR = new Map([
|
|
13
|
+
[
|
|
14
|
+
'system',
|
|
15
|
+
new Map([
|
|
16
|
+
['requires', []],
|
|
17
|
+
['discriminators', []],
|
|
18
|
+
['edges', []],
|
|
19
|
+
['relationships', []],
|
|
20
|
+
]),
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
'schema',
|
|
24
|
+
new Map([
|
|
25
|
+
['sections', [['must', 'have'], ['may', 'have'], ['closed'], ['open']]],
|
|
26
|
+
[
|
|
27
|
+
'fields',
|
|
28
|
+
[
|
|
29
|
+
['must', 'have'],
|
|
30
|
+
['may', 'have'],
|
|
31
|
+
],
|
|
32
|
+
],
|
|
33
|
+
['edges', [['must'], ['may']]],
|
|
34
|
+
]),
|
|
35
|
+
],
|
|
36
|
+
]);
|
|
37
|
+
/** The keys spelled for one section of a record, or for its head. */
|
|
38
|
+
export function spellingsFor(registration, schema, section) {
|
|
39
|
+
const floor = registration.system === FLOOR_SYSTEM ? FLOOR.get(registration.keyword) : undefined;
|
|
40
|
+
if (floor !== undefined)
|
|
41
|
+
return section === 'head' ? HEAD_SPELLINGS : (floor.get(section) ?? []);
|
|
42
|
+
const spelled = (schema?.fields ?? [])
|
|
43
|
+
.filter((field) => field.section === section)
|
|
44
|
+
.map((field) => field.key.split(' '));
|
|
45
|
+
return section === 'head' ? [...HEAD_SPELLINGS, ...spelled] : spelled;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=spellings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spellings.js","sourceRoot":"","sources":["../../src/compile/spellings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,CAAC,OAAO,CAAC;IACT,CAAC,SAAS,CAAC;IACX,CAAC,UAAU,CAAC;IACZ,CAAC,WAAW,CAAC;IACb,CAAC,SAAS,CAAC;IACX,CAAC,QAAQ,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,wLAAwL;AACxL,MAAM,KAAK,GAAkE,IAAI,GAAG,CAAC;IACnF;QACE,QAAQ;QACR,IAAI,GAAG,CAA8B;YACnC,CAAC,UAAU,EAAE,EAAE,CAAC;YAChB,CAAC,gBAAgB,EAAE,EAAE,CAAC;YACtB,CAAC,OAAO,EAAE,EAAE,CAAC;YACb,CAAC,eAAe,EAAE,EAAE,CAAC;SACtB,CAAC;KACH;IACD;QACE,QAAQ;QACR,IAAI,GAAG,CAA8B;YACnC,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;YACvE;gBACE,QAAQ;gBACR;oBACE,CAAC,MAAM,EAAE,MAAM,CAAC;oBAChB,CAAC,KAAK,EAAE,MAAM,CAAC;iBAChB;aACF;YACD,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;SAC/B,CAAC;KACH;CACF,CAAC,CAAC;AAEH,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAC1B,YAA0B,EAC1B,MAAqC,EACrC,OAAwB;IAExB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjG,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;SACnC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC;SAC5C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FieldNode, Value } from '../ast.js';
|
|
2
|
+
/** A compiled value: the AST value without its raw spelling (spec 10.2). */
|
|
3
|
+
export type CompiledValue = {
|
|
4
|
+
readonly kind: 'scalar' | 'string' | 'prose';
|
|
5
|
+
readonly text: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'ref';
|
|
8
|
+
readonly discriminator: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly fragment?: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'list';
|
|
13
|
+
readonly items: readonly CompiledValue[];
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'block';
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'none';
|
|
18
|
+
};
|
|
19
|
+
export declare function compiledValue(value: Value): CompiledValue;
|
|
20
|
+
/** The words of a spelled key: `['lowers', 'to']`. */
|
|
21
|
+
export type Spelling = readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The key rule (spec 2.1) resolved against spelled keys (spec 10.2). A line whose value is not a
|
|
24
|
+
* bare scalar keeps the parser's key: every word before the value. On an all-words line the longest
|
|
25
|
+
* spelling that starts the words is the key and the remaining words are the scalar; with no spelling
|
|
26
|
+
* the parser's first-word key stands. The assertive form keeps the parser's reading.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveKey(field: FieldNode, spellings: readonly Spelling[]): {
|
|
29
|
+
readonly key: string;
|
|
30
|
+
readonly value: CompiledValue;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/compile/values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElD,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3G;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9B,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAoBzD;AAED,sDAAsD;AACtD,MAAM,MAAM,QAAQ,GAAG,SAAS,MAAM,EAAE,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,QAAQ,EAAE,GAC7B;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAezD"}
|