@inventarch/language 0.0.0-stage → 1.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.
Files changed (181) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +33 -2
  4. package/SPEC.md +225 -0
  5. package/dist/ast.d.ts +114 -0
  6. package/dist/ast.d.ts.map +1 -0
  7. package/dist/ast.js +2 -0
  8. package/dist/ast.js.map +1 -0
  9. package/dist/compile/compile.d.ts +82 -0
  10. package/dist/compile/compile.d.ts.map +1 -0
  11. package/dist/compile/compile.js +249 -0
  12. package/dist/compile/compile.js.map +1 -0
  13. package/dist/compile/index.d.ts +6 -0
  14. package/dist/compile/index.d.ts.map +1 -0
  15. package/dist/compile/index.js +4 -0
  16. package/dist/compile/index.js.map +1 -0
  17. package/dist/compile/spellings.d.ts +7 -0
  18. package/dist/compile/spellings.d.ts.map +1 -0
  19. package/dist/compile/spellings.js +47 -0
  20. package/dist/compile/spellings.js.map +1 -0
  21. package/dist/compile/values.d.ts +32 -0
  22. package/dist/compile/values.d.ts.map +1 -0
  23. package/dist/compile/values.js +48 -0
  24. package/dist/compile/values.js.map +1 -0
  25. package/dist/diagnostics.d.ts +22 -0
  26. package/dist/diagnostics.d.ts.map +1 -0
  27. package/dist/diagnostics.js +71 -0
  28. package/dist/diagnostics.js.map +1 -0
  29. package/dist/editor/index.d.ts +49 -0
  30. package/dist/editor/index.d.ts.map +1 -0
  31. package/dist/editor/index.js +155 -0
  32. package/dist/editor/index.js.map +1 -0
  33. package/dist/fold.d.ts +8 -0
  34. package/dist/fold.d.ts.map +1 -0
  35. package/dist/fold.js +26 -0
  36. package/dist/fold.js.map +1 -0
  37. package/dist/formatter.d.ts +10 -0
  38. package/dist/formatter.d.ts.map +1 -0
  39. package/dist/formatter.js +108 -0
  40. package/dist/formatter.js.map +1 -0
  41. package/dist/identity.d.ts +31 -0
  42. package/dist/identity.d.ts.map +1 -0
  43. package/dist/identity.js +64 -0
  44. package/dist/identity.js.map +1 -0
  45. package/dist/index.d.ts +35 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +22 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/kernel.generated.d.ts +99 -0
  50. package/dist/kernel.generated.d.ts.map +1 -0
  51. package/dist/kernel.generated.js +422 -0
  52. package/dist/kernel.generated.js.map +1 -0
  53. package/dist/parser/index.d.ts +5 -0
  54. package/dist/parser/index.d.ts.map +1 -0
  55. package/dist/parser/index.js +3 -0
  56. package/dist/parser/index.js.map +1 -0
  57. package/dist/parser/parser.d.ts +11 -0
  58. package/dist/parser/parser.d.ts.map +1 -0
  59. package/dist/parser/parser.js +297 -0
  60. package/dist/parser/parser.js.map +1 -0
  61. package/dist/parser/values.d.ts +24 -0
  62. package/dist/parser/values.d.ts.map +1 -0
  63. package/dist/parser/values.js +284 -0
  64. package/dist/parser/values.js.map +1 -0
  65. package/dist/paths.d.ts +6 -0
  66. package/dist/paths.d.ts.map +1 -0
  67. package/dist/paths.js +21 -0
  68. package/dist/paths.js.map +1 -0
  69. package/dist/references.d.ts +15 -0
  70. package/dist/references.d.ts.map +1 -0
  71. package/dist/references.js +40 -0
  72. package/dist/references.js.map +1 -0
  73. package/dist/registry/consent.d.ts +11 -0
  74. package/dist/registry/consent.d.ts.map +1 -0
  75. package/dist/registry/consent.js +31 -0
  76. package/dist/registry/consent.js.map +1 -0
  77. package/dist/registry/extract.d.ts +11 -0
  78. package/dist/registry/extract.d.ts.map +1 -0
  79. package/dist/registry/extract.js +275 -0
  80. package/dist/registry/extract.js.map +1 -0
  81. package/dist/registry/fields.d.ts +14 -0
  82. package/dist/registry/fields.d.ts.map +1 -0
  83. package/dist/registry/fields.js +30 -0
  84. package/dist/registry/fields.js.map +1 -0
  85. package/dist/registry/floor.d.ts +17 -0
  86. package/dist/registry/floor.d.ts.map +1 -0
  87. package/dist/registry/floor.js +42 -0
  88. package/dist/registry/floor.js.map +1 -0
  89. package/dist/registry/index.d.ts +19 -0
  90. package/dist/registry/index.d.ts.map +1 -0
  91. package/dist/registry/index.js +80 -0
  92. package/dist/registry/index.js.map +1 -0
  93. package/dist/registry/merge.d.ts +32 -0
  94. package/dist/registry/merge.d.ts.map +1 -0
  95. package/dist/registry/merge.js +84 -0
  96. package/dist/registry/merge.js.map +1 -0
  97. package/dist/registry/order.d.ts +12 -0
  98. package/dist/registry/order.d.ts.map +1 -0
  99. package/dist/registry/order.js +134 -0
  100. package/dist/registry/order.js.map +1 -0
  101. package/dist/registry/records.d.ts +14 -0
  102. package/dist/registry/records.d.ts.map +1 -0
  103. package/dist/registry/records.js +64 -0
  104. package/dist/registry/records.js.map +1 -0
  105. package/dist/registry/schemas.d.ts +20 -0
  106. package/dist/registry/schemas.d.ts.map +1 -0
  107. package/dist/registry/schemas.js +282 -0
  108. package/dist/registry/schemas.js.map +1 -0
  109. package/dist/registry/types.d.ts +130 -0
  110. package/dist/registry/types.d.ts.map +1 -0
  111. package/dist/registry/types.js +2 -0
  112. package/dist/registry/types.js.map +1 -0
  113. package/dist/scanner/index.d.ts +16 -0
  114. package/dist/scanner/index.d.ts.map +1 -0
  115. package/dist/scanner/index.js +78 -0
  116. package/dist/scanner/index.js.map +1 -0
  117. package/dist/scanner/lines.d.ts +46 -0
  118. package/dist/scanner/lines.d.ts.map +1 -0
  119. package/dist/scanner/lines.js +210 -0
  120. package/dist/scanner/lines.js.map +1 -0
  121. package/dist/scanner/tokenize.d.ts +9 -0
  122. package/dist/scanner/tokenize.d.ts.map +1 -0
  123. package/dist/scanner/tokenize.js +125 -0
  124. package/dist/scanner/tokenize.js.map +1 -0
  125. package/dist/scanner/tokens.d.ts +52 -0
  126. package/dist/scanner/tokens.d.ts.map +1 -0
  127. package/dist/scanner/tokens.js +2 -0
  128. package/dist/scanner/tokens.js.map +1 -0
  129. package/dist/semantic/cases.d.ts +12 -0
  130. package/dist/semantic/cases.d.ts.map +1 -0
  131. package/dist/semantic/cases.js +81 -0
  132. package/dist/semantic/cases.js.map +1 -0
  133. package/dist/semantic/cells.d.ts +9 -0
  134. package/dist/semantic/cells.d.ts.map +1 -0
  135. package/dist/semantic/cells.js +120 -0
  136. package/dist/semantic/cells.js.map +1 -0
  137. package/dist/semantic/conditions.d.ts +22 -0
  138. package/dist/semantic/conditions.d.ts.map +1 -0
  139. package/dist/semantic/conditions.js +54 -0
  140. package/dist/semantic/conditions.js.map +1 -0
  141. package/dist/semantic/contracts.d.ts +11 -0
  142. package/dist/semantic/contracts.d.ts.map +1 -0
  143. package/dist/semantic/contracts.js +75 -0
  144. package/dist/semantic/contracts.js.map +1 -0
  145. package/dist/semantic/edges.d.ts +19 -0
  146. package/dist/semantic/edges.d.ts.map +1 -0
  147. package/dist/semantic/edges.js +129 -0
  148. package/dist/semantic/edges.js.map +1 -0
  149. package/dist/semantic/placement.d.ts +6 -0
  150. package/dist/semantic/placement.d.ts.map +1 -0
  151. package/dist/semantic/placement.js +47 -0
  152. package/dist/semantic/placement.js.map +1 -0
  153. package/dist/semantic/requirements.d.ts +14 -0
  154. package/dist/semantic/requirements.d.ts.map +1 -0
  155. package/dist/semantic/requirements.js +32 -0
  156. package/dist/semantic/requirements.js.map +1 -0
  157. package/dist/semantic/resolve.d.ts +23 -0
  158. package/dist/semantic/resolve.d.ts.map +1 -0
  159. package/dist/semantic/resolve.js +62 -0
  160. package/dist/semantic/resolve.js.map +1 -0
  161. package/dist/semantic/selectors.d.ts +10 -0
  162. package/dist/semantic/selectors.d.ts.map +1 -0
  163. package/dist/semantic/selectors.js +33 -0
  164. package/dist/semantic/selectors.js.map +1 -0
  165. package/dist/semantic/types.d.ts +56 -0
  166. package/dist/semantic/types.d.ts.map +1 -0
  167. package/dist/semantic/types.js +11 -0
  168. package/dist/semantic/types.js.map +1 -0
  169. package/dist/semantic/variants.d.ts +10 -0
  170. package/dist/semantic/variants.d.ts.map +1 -0
  171. package/dist/semantic/variants.js +63 -0
  172. package/dist/semantic/variants.js.map +1 -0
  173. package/dist/semantic/vocabulary.d.ts +12 -0
  174. package/dist/semantic/vocabulary.d.ts.map +1 -0
  175. package/dist/semantic/vocabulary.js +33 -0
  176. package/dist/semantic/vocabulary.js.map +1 -0
  177. package/dist/taxonomy.d.ts +51 -0
  178. package/dist/taxonomy.d.ts.map +1 -0
  179. package/dist/taxonomy.js +42 -0
  180. package/dist/taxonomy.js.map +1 -0
  181. package/package.json +220 -3
@@ -0,0 +1,282 @@
1
+ import { diag } from '../diagnostics.js';
2
+ import { CARDINALITIES, KINDS, PREDICATES, TEXT_FORMS, VALUE_TYPES, fieldTypeOf, isCardinality, isId, isKind, isPredicate, isTextForm, } from '../taxonomy.js';
3
+ import { conditionsIn, recordsIn } from './records.js';
4
+ const KEYWORD = /^[a-z][a-z0-9-]*$/;
5
+ /** The three W0 narrowings a field type may carry after it: `in [...]` (id), `to <word>` (ref), `form <form>` (text). */
6
+ const NARROWING_WORDS = ['in', 'to', 'form'];
7
+ /**
8
+ * Reads the narrowing spelled after a field type, or returns why it is malformed. `words` starts at the narrowing
9
+ * word; `value` is the row's value, which an `in [...]` set consumes so that row carries no description.
10
+ */
11
+ function narrowingOf(type, words, value) {
12
+ const scalar = type.startsWith('list of ') ? type.slice(8) : type;
13
+ const word = words[0];
14
+ const argument = words[1];
15
+ if (word === 'in') {
16
+ if (scalar !== 'id')
17
+ return '`in [...]` narrows id or list of id only';
18
+ if (words.length !== 1 || value.kind !== 'list' || value.items.length === 0)
19
+ return '`in` must be followed by a nonempty bracketed list of distinct ids: `as id in [a, b]`';
20
+ const values = [];
21
+ for (const item of value.items) {
22
+ if (item.kind !== 'scalar' || !isId(item.text) || values.includes(item.text))
23
+ return '`in` must be followed by a nonempty bracketed list of distinct ids: `as id in [a, b]`';
24
+ values.push(item.text);
25
+ }
26
+ return { values };
27
+ }
28
+ if (word === 'to') {
29
+ if (scalar !== 'ref')
30
+ return '`to <word>` narrows ref or list of ref only';
31
+ if (words.length !== 2 || argument === undefined || !KEYWORD.test(argument))
32
+ return '`to` must name one discriminator: `as ref to <word>`';
33
+ return { target: argument };
34
+ }
35
+ if (scalar !== 'text')
36
+ return '`form <form>` narrows text or list of text only';
37
+ if (words.length !== 2 || argument === undefined)
38
+ return '`form` must name one text form: `as text form <form>`';
39
+ if (!isTextForm(argument))
40
+ return `form '${argument}' is not a text form; admitted: ${TEXT_FORMS.join(', ')}`;
41
+ return { form: argument };
42
+ }
43
+ /** The field type as the dialect spells it, narrowing included: `id in [a, b]`, `list of ref to task`, `text form iso-date`. */
44
+ export function fieldTypeText(field) {
45
+ if (field.values !== undefined)
46
+ return `${field.type} in [${field.values.join(', ')}]`;
47
+ if (field.target !== undefined)
48
+ return `${field.type} to ${field.target}`;
49
+ if (field.form !== undefined)
50
+ return `${field.type} form ${field.form}`;
51
+ return field.type;
52
+ }
53
+ /** Every `@schema`, including nested declarations. The caller retains parser diagnostics once. */
54
+ export function extractSchemas(ast, band, parserDiagnostics) {
55
+ const schemas = [];
56
+ const diagnostics = [];
57
+ const refused = new Set();
58
+ for (const { record, errors } of recordsIn(ast, parserDiagnostics)) {
59
+ if (record.discriminator !== 'schema')
60
+ continue;
61
+ const schema = errors.length > 0 ? undefined : schemaOf(record, ast.path, band, diagnostics);
62
+ if (schema === undefined)
63
+ refused.add(record.name.toLowerCase());
64
+ else
65
+ schemas.push(schema);
66
+ }
67
+ return { schemas, diagnostics, refused };
68
+ }
69
+ function schemaOf(record, path, band, diagnostics) {
70
+ let ok = true;
71
+ const malformed = (element, line, why) => {
72
+ diagnostics.push(diag('IA-LANG-SCHEMA-MALFORMED', path, line, `${path}:${line}: @schema ${record.name}: ${element} ${why}`));
73
+ ok = false;
74
+ };
75
+ // Conditions own their diagnostic; judging the same refused row again would report it twice.
76
+ for (const section of record.sections)
77
+ if (section.name === 'when')
78
+ malformed('when', section.span.line, 'cannot open a schema condition block');
79
+ for (const child of conditionsIn([
80
+ ...record.head,
81
+ ...record.sections.filter((section) => section.name !== 'when').flatMap((section) => section.children),
82
+ ])) {
83
+ malformed(`'${child.key}'`, child.span.line, 'carries a when clause; a schema states no conditions');
84
+ }
85
+ const flatRow = (child, element) => {
86
+ if (conditionsIn([child]).length > 0)
87
+ return false;
88
+ if (child.kind !== 'field') {
89
+ malformed(element, child.span.line, 'holds field rows, not items or nested records');
90
+ return false;
91
+ }
92
+ if (child.children.length > 0) {
93
+ malformed(element, child.span.line, 'row cannot hold a child block');
94
+ return false;
95
+ }
96
+ return true;
97
+ };
98
+ const blocks = (name) => record.sections.filter((section) => section.name === name);
99
+ const rows = (name) => blocks(name).flatMap((section) => section.children);
100
+ let kind;
101
+ const lowersFields = record.head.filter((field) => field.words[0] === 'lowers' && field.words[1] === 'to');
102
+ const lowers = lowersFields[0];
103
+ for (const duplicate of lowersFields.slice(1))
104
+ malformed('lowers to', duplicate.span.line, 'appears twice; it is written once');
105
+ if (lowers === undefined)
106
+ malformed('lowers to', record.span.line, 'is required: `lowers to <kind>`');
107
+ else if (flatRow(lowers, 'lowers to')) {
108
+ const named = lowers.words[2];
109
+ if (lowers.value.kind !== 'scalar' || lowers.words.length !== 3 || named === undefined)
110
+ malformed('lowers to', lowers.span.line, 'must name one bare kind: `lowers to <kind>`');
111
+ else if (isKind(named))
112
+ kind = named;
113
+ else {
114
+ diagnostics.push(diag('IA-LANG-KIND-UNKNOWN', path, lowers.span.line, `${path}:${lowers.span.line}: '${named}' is not a closed kind; admitted: ${KINDS.join(', ')}`));
115
+ ok = false;
116
+ }
117
+ }
118
+ const sections = [];
119
+ let closed;
120
+ const sectionsBlock = blocks('sections')[0];
121
+ if (sectionsBlock === undefined)
122
+ malformed('sections', record.span.line, 'is required: `must have`/`may have` lines ending with `closed` or `open`');
123
+ else {
124
+ const children = rows('sections');
125
+ const terminators = [];
126
+ let lastSectionAt = -1;
127
+ let rowFault = false;
128
+ children.forEach((child, index) => {
129
+ const words = child.kind === 'field' ? child.words : [];
130
+ const first = words[0];
131
+ if (child.kind === 'field' && (first === 'closed' || first === 'open')) {
132
+ const flat = flatRow(child, 'sections');
133
+ const valid = flat && words.length === 1 && child.value.kind === 'none';
134
+ terminators.push({ field: child, index, valid });
135
+ if (valid)
136
+ closed = first === 'closed';
137
+ else if (flat)
138
+ malformed('sections', child.span.line, 'terminator must be bare `closed` or `open`');
139
+ return;
140
+ }
141
+ if (!flatRow(child, 'sections')) {
142
+ rowFault = true;
143
+ return;
144
+ }
145
+ const name = words[2];
146
+ if ((first === 'must' || first === 'may') &&
147
+ words[1] === 'have' &&
148
+ words.length === 3 &&
149
+ name !== undefined &&
150
+ KEYWORD.test(name) &&
151
+ child.value.kind === 'scalar') {
152
+ lastSectionAt = index;
153
+ if (sections.some((section) => section.name === name))
154
+ malformed('sections', child.span.line, `lists '${name}' twice`);
155
+ else
156
+ sections.push({ name, must: first === 'must', span: child.span });
157
+ return;
158
+ }
159
+ rowFault = true;
160
+ malformed('sections', child.span.line, 'holds `must have <section>` or `may have <section>` lines, then `closed` or `open`');
161
+ });
162
+ // A malformed terminator or already-refused trailing row must not also become a missing/end-position fault.
163
+ const terminal = terminators[0];
164
+ if (terminal === undefined && !rowFault)
165
+ malformed('sections', sectionsBlock.span.line, 'must end with exactly one of `closed` or `open`');
166
+ else if (terminators.length === 1 && terminal?.valid && terminal.index < lastSectionAt)
167
+ malformed('sections', terminal.field.span.line, 'must end with exactly one of `closed` or `open`');
168
+ for (const duplicate of terminators.slice(1))
169
+ if (duplicate.valid)
170
+ malformed('sections', duplicate.field.span.line, 'must end with exactly one of `closed` or `open`');
171
+ }
172
+ const fields = [];
173
+ for (const child of rows('fields')) {
174
+ const line = child.span.line;
175
+ if (!flatRow(child, 'fields'))
176
+ continue;
177
+ const words = child.words;
178
+ const first = words[0];
179
+ const pathWord = words[2];
180
+ if ((first !== 'must' && first !== 'may') ||
181
+ words[1] !== 'have' ||
182
+ pathWord === undefined ||
183
+ words[3] !== 'as' ||
184
+ words.length < 5) {
185
+ malformed('fields', line, 'entry must read `must have <section>.<key> as <type>` or `may have ...`');
186
+ continue;
187
+ }
188
+ const [section, key, ...more] = pathWord.split('.');
189
+ if (section === undefined || key === undefined || !KEYWORD.test(section) || key === '' || more.length > 0) {
190
+ malformed('fields', line, `path '${pathWord}' must be <section>.<key>`);
191
+ continue;
192
+ }
193
+ if (section === 'relationships') {
194
+ diagnostics.push(diag('IA-LANG-SCHEMA-EDGE-AS-FIELD', path, line, `${path}:${line}: @schema ${record.name}: '${pathWord}' states a relationship as a field; state it under \`edges\``));
195
+ ok = false;
196
+ continue;
197
+ }
198
+ const typeWords = words.slice(4);
199
+ const narrowAt = typeWords.findIndex((word) => NARROWING_WORDS.includes(word));
200
+ const type = fieldTypeOf(narrowAt === -1 ? typeWords : typeWords.slice(0, narrowAt));
201
+ if (type === undefined) {
202
+ malformed('fields', line, `type '${typeWords.join(' ')}' is not a value type; admitted: ${VALUE_TYPES.join(', ')}, or list of one`);
203
+ continue;
204
+ }
205
+ const narrowing = narrowAt === -1 ? {} : narrowingOf(type, typeWords.slice(narrowAt), child.value);
206
+ if (typeof narrowing === 'string') {
207
+ malformed('fields', line, narrowing);
208
+ continue;
209
+ }
210
+ if (narrowing.values === undefined && child.value.kind !== 'scalar' && child.value.kind !== 'string') {
211
+ malformed('fields', line, 'may carry only a quoted description after the type');
212
+ continue;
213
+ }
214
+ if (fields.some((field) => field.section === section && field.key === key)) {
215
+ malformed('fields', line, `lists '${pathWord}' twice`);
216
+ continue;
217
+ }
218
+ const description = child.value.kind === 'string' ? child.value.text : undefined;
219
+ fields.push({
220
+ section,
221
+ key,
222
+ type,
223
+ must: first === 'must',
224
+ ...(description === undefined ? {} : { description }),
225
+ ...narrowing,
226
+ span: child.span,
227
+ });
228
+ }
229
+ const edges = [];
230
+ for (const child of rows('edges')) {
231
+ const line = child.span.line;
232
+ if (!flatRow(child, 'edges'))
233
+ continue;
234
+ const words = child.words;
235
+ const first = words[0];
236
+ const predicate = words[1];
237
+ const target = words[2];
238
+ const cardinality = words[3];
239
+ if (child.value.kind !== 'scalar' ||
240
+ words.length !== 4 ||
241
+ (first !== 'must' && first !== 'may') ||
242
+ predicate === undefined ||
243
+ target === undefined ||
244
+ cardinality === undefined) {
245
+ malformed('edges', line, 'entry must read `must <predicate> <kind or discriminator> <cardinality>` or `may ...`');
246
+ continue;
247
+ }
248
+ if (!isPredicate(predicate)) {
249
+ diagnostics.push(diag('IA-LANG-PREDICATE-UNKNOWN', path, line, `${path}:${line}: '${predicate}' is not a predicate; admitted: ${PREDICATES.join(', ')}`));
250
+ ok = false;
251
+ continue;
252
+ }
253
+ if (!isCardinality(cardinality)) {
254
+ malformed('edges', line, `cardinality '${cardinality}' must be one of ${CARDINALITIES.join(', ')}`);
255
+ continue;
256
+ }
257
+ if (!KEYWORD.test(target)) {
258
+ malformed('edges', line, `target '${target}' must spell a kind or discriminator: [a-z][a-z0-9-]*`);
259
+ continue;
260
+ }
261
+ if (edges.some((edge) => edge.predicate === predicate && edge.target === target)) {
262
+ malformed('edges', line, `states '${predicate} ${target}' twice`);
263
+ continue;
264
+ }
265
+ edges.push({ predicate, target, must: first === 'must', cardinality, span: child.span });
266
+ }
267
+ if (!ok || kind === undefined || closed === undefined)
268
+ return undefined;
269
+ return {
270
+ name: record.name.toLowerCase(),
271
+ displayName: record.name,
272
+ kind,
273
+ sections,
274
+ closed,
275
+ fields,
276
+ edges,
277
+ path,
278
+ span: record.span,
279
+ band,
280
+ };
281
+ }
282
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/registry/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EACL,aAAa,EACb,KAAK,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,IAAI,EACJ,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGv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OAAO,EAAE,IAAI,EAAE,WAAW,MAAM,uDAAuD,CAAC,CAAC;YACnG,SAAS;QACX,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;YACjF,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,SAAS,IAAI,MAAM,SAAS,CAAC,CAAC;YAClE,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,KAAK,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,CAAC,EAAE,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxE,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;QAC/B,WAAW,EAAE,MAAM,CAAC,IAAI;QACxB,IAAI;QACJ,QAAQ;QACR,MAAM;QACN,MAAM;QACN,KAAK;QACL,IAAI;QACJ,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,130 @@
1
+ import type { FileNode, Span } from '../ast.js';
2
+ import type { Diagnostic } from '../diagnostics.js';
3
+ import type { Band, Cardinality, Category, FieldType, Kind, PlacementKind, Predicate, Provenance, TextForm } from '../taxonomy.js';
4
+ /** Where a source sits in the authority model (graph spec 3.3). `reach` is the path prefix the placement covers; '' is everywhere. */
5
+ export interface Placement {
6
+ readonly kind: PlacementKind;
7
+ readonly band: Band;
8
+ readonly reach: string;
9
+ }
10
+ /** The location a file is read at: its placement and provenance. Both are copied onto every record it compiles. */
11
+ export interface Location {
12
+ readonly placement: Placement;
13
+ readonly provenance: Provenance;
14
+ }
15
+ /** A parsed file with the location it was read at. */
16
+ export interface Source {
17
+ readonly ast: FileNode;
18
+ /** Parser diagnostics for this AST; retained once by the registry, never re-reported by extraction. */
19
+ readonly diagnostics: readonly Diagnostic[];
20
+ readonly location: Location;
21
+ }
22
+ /** One `<predicate> <targets> using <sources>` row of a system's consent ledger (spec 4.2). A side is `*` or discriminator keywords. */
23
+ export interface ConsentRow {
24
+ readonly predicate: Predicate;
25
+ readonly targets: readonly string[] | '*';
26
+ readonly sources: readonly string[] | '*';
27
+ readonly span: Span;
28
+ }
29
+ /** One `<keyword> lowers to <kind>` entry with its block, as authored. */
30
+ export interface Entry {
31
+ readonly keyword: string;
32
+ readonly kind: Kind;
33
+ readonly category: Category;
34
+ readonly facets: readonly string[];
35
+ /** The `@schema` name the entry points at; resolved by the registry, not here. */
36
+ readonly schema: string;
37
+ readonly span: Span;
38
+ }
39
+ /** One `requires` item: a system name and where it was written. */
40
+ export interface RequiredSystem {
41
+ readonly name: string;
42
+ readonly span: Span;
43
+ }
44
+ /** `steward @<discriminator> <name>`: the reference as written, its name lowercased for the identity slot. */
45
+ export interface Steward {
46
+ readonly discriminator: string;
47
+ readonly name: string;
48
+ }
49
+ /** A `@system` record read off the AST. `name` is lowercased for the identity slot; `displayName` is the authored spelling. */
50
+ export interface SystemDeclaration {
51
+ readonly name: string;
52
+ readonly displayName: string;
53
+ readonly provider: string;
54
+ readonly version: string;
55
+ readonly describes?: string;
56
+ readonly steward?: Steward;
57
+ readonly requires: readonly RequiredSystem[];
58
+ readonly entries: readonly Entry[];
59
+ readonly consent: readonly ConsentRow[];
60
+ readonly path: string;
61
+ readonly span: Span;
62
+ readonly band: Band;
63
+ }
64
+ export interface SchemaSection {
65
+ readonly name: string;
66
+ readonly must: boolean;
67
+ readonly span: Span;
68
+ }
69
+ export interface SchemaField {
70
+ readonly section: string;
71
+ readonly key: string;
72
+ readonly type: FieldType;
73
+ readonly must: boolean;
74
+ readonly description?: string;
75
+ /** `as id in [a, b]`: the closed set every value, or every list item, must belong to (W0-L1). Only an `id` type carries it. */
76
+ readonly values?: readonly string[];
77
+ /** `as ref to <word>`: the discriminator every reference must carry (W0-L2). Only a `ref` type carries it; the target's existence is a compliance concern. */
78
+ readonly target?: string;
79
+ /** `as text form <form>`: the closed text form every value must match (W0-L5). Only a `text` type carries it. */
80
+ readonly form?: TextForm;
81
+ readonly span: Span;
82
+ }
83
+ export interface SchemaEdge {
84
+ readonly predicate: Predicate;
85
+ /** A closed kind or a discriminator; which one is decided when the edge is checked, not here. */
86
+ readonly target: string;
87
+ readonly must: boolean;
88
+ readonly cardinality: Cardinality;
89
+ readonly span: Span;
90
+ }
91
+ /** A `@schema` record read off the AST (spec 4.3). */
92
+ export interface SchemaDeclaration {
93
+ readonly name: string;
94
+ readonly displayName: string;
95
+ readonly kind: Kind;
96
+ readonly sections: readonly SchemaSection[];
97
+ /** True under `closed`: an instance section the schema does not list is a compliance diagnostic. */
98
+ readonly closed: boolean;
99
+ readonly fields: readonly SchemaField[];
100
+ readonly edges: readonly SchemaEdge[];
101
+ readonly path: string;
102
+ readonly span: Span;
103
+ readonly band: Band;
104
+ }
105
+ /** A joined discriminator: the winner for its keyword after band merge and schema resolution. */
106
+ export interface Registration {
107
+ readonly keyword: string;
108
+ readonly system: string;
109
+ readonly kind: Kind;
110
+ readonly category: Category;
111
+ readonly facets: readonly string[];
112
+ readonly schema: string;
113
+ readonly band: Band;
114
+ }
115
+ /** The resolved vocabulary at a location. Read-only by type; `buildRegistry` freezes the object shallowly, and nothing in this package mutates a map it did not build. */
116
+ export interface FrozenRegistry {
117
+ /** The systems in force, by lowercased name; a system a cycle or a missing requirement refused is absent. */
118
+ readonly systems: ReadonlyMap<string, SystemDeclaration>;
119
+ /** Bootstrap order: the built-in systems first, then `requires` topologically, ties by name. */
120
+ readonly order: readonly string[];
121
+ /** Joined discriminators by keyword, the floor's two words included. */
122
+ readonly registrations: ReadonlyMap<string, Registration>;
123
+ /** Keywords two systems registered at the winning band; unusable at this location. */
124
+ readonly blocked: ReadonlySet<string>;
125
+ /** Schemas in force, by lowercased name. */
126
+ readonly schemas: ReadonlyMap<string, SchemaDeclaration>;
127
+ /** Consent ledgers by system name. */
128
+ readonly consent: ReadonlyMap<string, readonly ConsentRow[]>;
129
+ }
130
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,aAAa,EACb,SAAS,EACT,UAAU,EACV,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAExB,sIAAsI;AACtI,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,mHAAmH;AACnH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,uGAAuG;IACvG,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,wIAAwI;AACxI,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC;IAC1C,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AE,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { Diagnostic } from '../diagnostics.js';
2
+ import type { Trivia } from './lines.js';
3
+ import type { StreamToken } from './tokens.js';
4
+ export type { LogicalLine, Trivia } from './lines.js';
5
+ export type { StreamToken, Token } from './tokens.js';
6
+ export { tokenizeLine } from './tokenize.js';
7
+ export { logicalLines, trailingCommentIndex } from './lines.js';
8
+ export interface ScanResult {
9
+ readonly version?: string;
10
+ readonly tokens: readonly StreamToken[];
11
+ readonly trivia: readonly Trivia[];
12
+ readonly diagnostics: readonly Diagnostic[];
13
+ }
14
+ /** One token stream per file. The parser consumes this and nothing else. */
15
+ export declare function scan(source: string, path: string): ScanResult;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,4EAA4E;AAC5E,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CA0E7D"}
@@ -0,0 +1,78 @@
1
+ import { logicalLines } from './lines.js';
2
+ import { tokenizeLine } from './tokenize.js';
3
+ export { tokenizeLine } from './tokenize.js';
4
+ export { logicalLines, trailingCommentIndex } from './lines.js';
5
+ /** One token stream per file. The parser consumes this and nothing else. */
6
+ export function scan(source, path) {
7
+ const lines = logicalLines(source, path);
8
+ const diagnostics = [...lines.diagnostics];
9
+ const tokens = [];
10
+ if (lines.version !== undefined)
11
+ tokens.push({ kind: 'pragma', version: lines.version, line: 1 });
12
+ const comments = lines.trivia.filter((t) => t.kind === 'comment');
13
+ let commentIndex = 0;
14
+ let depth = 0;
15
+ // The block beneath a line the tokenizer refused produces nothing and is not judged; the comments
16
+ // on its lines are trivia, collected here because no accepted line carries them.
17
+ let dropDeeperThan;
18
+ const dropped = [];
19
+ const flushCommentsBefore = (line) => {
20
+ while (commentIndex < comments.length && (comments[commentIndex]?.line ?? Infinity) < line) {
21
+ const c = comments[commentIndex];
22
+ tokens.push({ kind: 'comment', line: c.line, text: c.text, trailing: false });
23
+ commentIndex++;
24
+ }
25
+ };
26
+ for (const logical of lines.lines) {
27
+ flushCommentsBefore(logical.line);
28
+ if (dropDeeperThan !== undefined) {
29
+ if (logical.depth > dropDeeperThan) {
30
+ // A comment inside a dropped block is trivia at its own line, as it is for a block the line scanner drops.
31
+ if (logical.trailingComment !== undefined) {
32
+ tokens.push({ kind: 'comment', line: logical.endLine, text: logical.trailingComment, trailing: false });
33
+ dropped.push({ kind: 'comment', line: logical.endLine, text: logical.trailingComment });
34
+ }
35
+ continue;
36
+ }
37
+ dropDeeperThan = undefined;
38
+ }
39
+ while (depth < logical.depth) {
40
+ tokens.push({ kind: 'indent', line: logical.line });
41
+ depth++;
42
+ }
43
+ while (depth > logical.depth) {
44
+ tokens.push({ kind: 'dedent', line: logical.line });
45
+ depth--;
46
+ }
47
+ const result = tokenizeLine(logical.text, path, logical.line);
48
+ if (result.diagnostics.length > 0) {
49
+ // A refused line produces nothing: no tokens and no newline, so the parser never sees
50
+ // a partial line and one mistake yields one diagnostic. Its comment is still trivia,
51
+ // and the block beneath it is dropped unjudged.
52
+ diagnostics.push(...result.diagnostics);
53
+ if (logical.trailingComment !== undefined)
54
+ tokens.push({ kind: 'comment', line: logical.endLine, text: logical.trailingComment, trailing: true });
55
+ dropDeeperThan = logical.depth;
56
+ continue;
57
+ }
58
+ tokens.push(...result.tokens);
59
+ if (logical.trailingComment !== undefined)
60
+ tokens.push({ kind: 'comment', line: logical.endLine, text: logical.trailingComment, trailing: true });
61
+ tokens.push({ kind: 'newline', line: logical.line, endLine: logical.endLine, depth: logical.depth });
62
+ }
63
+ flushCommentsBefore(Infinity);
64
+ const last = lines.lines[lines.lines.length - 1];
65
+ while (depth > 0) {
66
+ tokens.push({ kind: 'dedent', line: last?.endLine ?? 1 });
67
+ depth--;
68
+ }
69
+ // Line and tokenizer diagnostics interleave by source line, as parse() promises for the whole set; so does trivia.
70
+ const trivia = dropped.length === 0 ? lines.trivia : [...lines.trivia, ...dropped].sort((a, b) => a.line - b.line);
71
+ return {
72
+ ...(lines.version === undefined ? {} : { version: lines.version }),
73
+ tokens,
74
+ trivia,
75
+ diagnostics: diagnostics.sort((a, b) => a.line - b.line),
76
+ };
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAK7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,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HAAmH;IACnH,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;IACnH,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClE,MAAM;QACN,MAAM;QACN,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;KACzD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { Diagnostic } from '../diagnostics.js';
2
+ export interface LogicalLine {
3
+ /** 1-based first source line. */
4
+ readonly line: number;
5
+ /** 1-based last source line (equals `line` unless a prose or list span was joined). */
6
+ readonly endLine: number;
7
+ /** indent / 2 */
8
+ readonly depth: number;
9
+ /** Indentation stripped, trailing comment stripped, spans joined. */
10
+ readonly text: string;
11
+ /** A ` # ...` comment that followed content on the same line, if any. Comments on multi-line list lines go to trivia instead. */
12
+ readonly trailingComment?: string;
13
+ }
14
+ export type Trivia = {
15
+ readonly kind: 'comment';
16
+ readonly line: number;
17
+ readonly text: string;
18
+ } | {
19
+ readonly kind: 'blank';
20
+ readonly line: number;
21
+ };
22
+ export interface LinesResult {
23
+ readonly version?: string;
24
+ readonly lines: readonly LogicalLine[];
25
+ readonly trivia: readonly Trivia[];
26
+ readonly diagnostics: readonly Diagnostic[];
27
+ }
28
+ export interface Walk {
29
+ /** Index of the `#` that begins a trailing comment, or -1. Scanning stops there. */
30
+ readonly commentAt: number;
31
+ /** Net `[` minus `]` outside strings, prose and the comment. */
32
+ readonly bracketDelta: number;
33
+ /** True when the text ends inside an unclosed `"..."`. */
34
+ readonly endsInString: boolean;
35
+ /** True when the text ends inside an unclosed `"""`. */
36
+ readonly endsInProse: boolean;
37
+ }
38
+ /**
39
+ * One quote-aware pass over a line, or over a joined span. This is the only place in the
40
+ * package that knows how `"`, `"""`, `[`, `]` and `#` interact.
41
+ */
42
+ export declare function walk(text: string): Walk;
43
+ /** Index of a trailing comment's `#`, or -1. */
44
+ export declare function trailingCommentIndex(text: string): number;
45
+ export declare function logicalLines(source: string, path: string): LinesResult;
46
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/scanner/lines.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iBAAiB;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iIAAiI;IACjI,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,C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