@sprig-and-prose/sprig-universe 0.3.3 → 0.4.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/package.json +1 -2
- package/src/ast.js +62 -8
- package/src/graph.js +454 -11
- package/src/ir.js +39 -2
- package/src/parser.js +714 -51
- package/src/scanner.js +1 -0
- package/test/aliases.test.js +91 -0
- package/test/fixtures/aliases-basic.prose +7 -0
- package/test/fixtures/aliases-conflict.prose +6 -0
- package/test/fixtures/aliases-no-leak.prose +5 -0
- package/test/fixtures/aliases-shadowing.prose +11 -0
- package/test/fixtures/aliases-single-line.prose +7 -0
- package/test/fixtures/relationship-errors.prose +20 -0
- package/test/fixtures/relationship-paired.prose +28 -0
- package/test/fixtures/relationship-scoped.prose +23 -0
- package/test/fixtures/relationship-symmetric.prose +18 -0
- package/test/fixtures/relationship-usage.prose +31 -0
package/package.json
CHANGED
package/src/ast.js
CHANGED
|
@@ -43,6 +43,13 @@
|
|
|
43
43
|
* @property {SourceSpan} source - Source span
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} OrderingBlock
|
|
48
|
+
* @property {string} kind - Always 'ordering'
|
|
49
|
+
* @property {string[]} identifiers - Array of identifier names
|
|
50
|
+
* @property {SourceSpan} source - Source span
|
|
51
|
+
*/
|
|
52
|
+
|
|
46
53
|
/**
|
|
47
54
|
* @typedef {Object} DocumentBlock
|
|
48
55
|
* @property {string} kind - Always 'document'
|
|
@@ -106,60 +113,85 @@
|
|
|
106
113
|
/**
|
|
107
114
|
* @typedef {Object} UniverseDecl
|
|
108
115
|
* @property {string} kind - Always 'universe'
|
|
116
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
109
117
|
* @property {string} name - Universe name
|
|
110
|
-
* @property {
|
|
118
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
119
|
+
* @property {Array<AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | RepositoryDecl | ReferenceDecl | NamedDocumentBlock | UnknownBlock>} body - Body declarations
|
|
111
120
|
* @property {SourceSpan} source - Source span
|
|
112
121
|
*/
|
|
113
122
|
|
|
114
123
|
/**
|
|
115
124
|
* @typedef {Object} AnthologyDecl
|
|
116
125
|
* @property {string} kind - Always 'anthology'
|
|
126
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
117
127
|
* @property {string} name - Anthology name
|
|
118
128
|
* @property {string} [parentName] - Optional parent universe name (from "in UniverseName")
|
|
119
|
-
* @property {
|
|
129
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
130
|
+
* @property {Array<SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
|
|
120
131
|
* @property {SourceSpan} source - Source span
|
|
121
132
|
*/
|
|
122
133
|
|
|
123
134
|
/**
|
|
124
135
|
* @typedef {Object} SeriesDecl
|
|
125
136
|
* @property {string} kind - Always 'series'
|
|
137
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
126
138
|
* @property {string} name - Series name
|
|
127
139
|
* @property {string} [parentName] - Optional parent anthology name (from "in AnthologyName")
|
|
128
|
-
* @property {
|
|
140
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
141
|
+
* @property {Array<BookDecl | ChapterDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
|
|
129
142
|
* @property {SourceSpan} source - Source span
|
|
130
143
|
*/
|
|
131
144
|
|
|
132
145
|
/**
|
|
133
146
|
* @typedef {Object} BookDecl
|
|
134
147
|
* @property {string} kind - Always 'book'
|
|
148
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
135
149
|
* @property {string} name - Book name
|
|
136
150
|
* @property {string} [parentName] - Optional parent name (from "in ParentName")
|
|
137
|
-
* @property {
|
|
151
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
152
|
+
* @property {Array<ChapterDecl | DescribeBlock | TitleBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
|
|
138
153
|
* @property {SourceSpan} source - Source span
|
|
139
154
|
*/
|
|
140
155
|
|
|
141
156
|
/**
|
|
142
157
|
* @typedef {Object} ChapterDecl
|
|
143
158
|
* @property {string} kind - Always 'chapter'
|
|
159
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
144
160
|
* @property {string} name - Chapter name
|
|
145
161
|
* @property {string} parentName - Parent name (from "in ParentName")
|
|
146
|
-
* @property {
|
|
162
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
163
|
+
* @property {Array<DescribeBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
|
|
147
164
|
* @property {SourceSpan} source - Source span
|
|
148
165
|
*/
|
|
149
166
|
|
|
150
167
|
/**
|
|
151
168
|
* @typedef {Object} ConceptDecl
|
|
152
169
|
* @property {string} kind - Always 'concept'
|
|
170
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
153
171
|
* @property {string} name - Concept name
|
|
154
172
|
* @property {string} [parentName] - Optional parent name (from "in ParentName")
|
|
155
|
-
* @property {
|
|
173
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
174
|
+
* @property {Array<DescribeBlock | ReferencesBlock | OrderingBlock | DocumentationBlock | RepositoryDecl | ReferenceDecl | UnknownBlock>} body - Body declarations
|
|
156
175
|
* @property {SourceSpan} source - Source span
|
|
157
176
|
*/
|
|
158
177
|
|
|
178
|
+
/**
|
|
179
|
+
* @typedef {Object} RelationshipTarget
|
|
180
|
+
* @property {string} id - Target identifier
|
|
181
|
+
* @property {DescribeBlock} [metadata] - Optional metadata block (describe) attached to this target
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @typedef {Object} RelationshipEntry
|
|
186
|
+
* @property {string} relationshipId - Relationship identifier being used
|
|
187
|
+
* @property {RelationshipTarget[]} targets - Array of target identifiers with optional metadata
|
|
188
|
+
*/
|
|
189
|
+
|
|
159
190
|
/**
|
|
160
191
|
* @typedef {Object} RelationshipsBlock
|
|
161
192
|
* @property {string} kind - Always 'relationships'
|
|
162
|
-
* @property {
|
|
193
|
+
* @property {RelationshipEntry[]} entries - Array of relationship entries (new syntax)
|
|
194
|
+
* @property {string[]} [values] - Array of string literal values (legacy syntax for relates blocks)
|
|
163
195
|
* @property {SourceSpan} source - Source span
|
|
164
196
|
*/
|
|
165
197
|
|
|
@@ -171,11 +203,33 @@
|
|
|
171
203
|
* @property {SourceSpan} source - Source span
|
|
172
204
|
*/
|
|
173
205
|
|
|
206
|
+
/**
|
|
207
|
+
* @typedef {Object} RelationshipFromSide
|
|
208
|
+
* @property {string} [label] - Optional label string
|
|
209
|
+
* @property {DescribeBlock} [describe] - Optional describe block
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @typedef {Object} RelationshipDecl
|
|
214
|
+
* @property {string} kind - Always 'relationship'
|
|
215
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
216
|
+
* @property {'symmetric' | 'paired'} type - Relationship type
|
|
217
|
+
* @property {string} [id] - Relationship identifier (for symmetric)
|
|
218
|
+
* @property {string} [leftId] - Left side identifier (for paired)
|
|
219
|
+
* @property {string} [rightId] - Right side identifier (for paired)
|
|
220
|
+
* @property {DescribeBlock} [describe] - Optional pair-level describe block
|
|
221
|
+
* @property {string} [label] - Optional label (for symmetric)
|
|
222
|
+
* @property {Record<string, RelationshipFromSide>} [from] - Per-side metadata (for paired)
|
|
223
|
+
* @property {SourceSpan} source - Source span
|
|
224
|
+
*/
|
|
225
|
+
|
|
174
226
|
/**
|
|
175
227
|
* @typedef {Object} RelatesDecl
|
|
176
228
|
* @property {string} kind - Always 'relates'
|
|
229
|
+
* @property {string} spelledKind - Kind token as written (may be alias)
|
|
177
230
|
* @property {string} a - First endpoint text
|
|
178
231
|
* @property {string} b - Second endpoint text
|
|
232
|
+
* @property {Record<string, string>} [aliases] - Alias mappings declared in this scope
|
|
179
233
|
* @property {Array<DescribeBlock | TitleBlock | FromBlock | RelationshipsBlock | UnknownBlock>} body - Body declarations
|
|
180
234
|
* @property {SourceSpan} source - Source span
|
|
181
235
|
*/
|
|
@@ -241,7 +295,7 @@
|
|
|
241
295
|
*/
|
|
242
296
|
|
|
243
297
|
/**
|
|
244
|
-
* @typedef {UniverseDecl | AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | DescribeBlock | NoteBlock | TitleBlock | FromBlock | RelationshipsBlock | ReferencesBlock | ReferenceDecl | DocumentationBlock | DocumentBlock | NamedDocumentBlock | RepositoryDecl | UnknownBlock | SceneDecl | UsingBlock | ActorDecl | TypeBlock | IdentityBlock | SourceBlock | TransformsBlock | TransformBlock} ASTNode
|
|
298
|
+
* @typedef {UniverseDecl | AnthologyDecl | SeriesDecl | BookDecl | ChapterDecl | ConceptDecl | RelatesDecl | RelationshipDecl | DescribeBlock | NoteBlock | TitleBlock | FromBlock | RelationshipsBlock | ReferencesBlock | ReferenceDecl | DocumentationBlock | DocumentBlock | NamedDocumentBlock | RepositoryDecl | UnknownBlock | SceneDecl | UsingBlock | ActorDecl | TypeBlock | IdentityBlock | SourceBlock | TransformsBlock | TransformBlock} ASTNode
|
|
245
299
|
*/
|
|
246
300
|
|
|
247
301
|
/**
|