@domainlang/language 0.1.20

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 (212) hide show
  1. package/README.md +163 -0
  2. package/out/ast-augmentation.d.ts +6 -0
  3. package/out/ast-augmentation.js +2 -0
  4. package/out/ast-augmentation.js.map +1 -0
  5. package/out/domain-lang-module.d.ts +57 -0
  6. package/out/domain-lang-module.js +67 -0
  7. package/out/domain-lang-module.js.map +1 -0
  8. package/out/generated/ast.d.ts +759 -0
  9. package/out/generated/ast.js +556 -0
  10. package/out/generated/ast.js.map +1 -0
  11. package/out/generated/grammar.d.ts +6 -0
  12. package/out/generated/grammar.js +2407 -0
  13. package/out/generated/grammar.js.map +1 -0
  14. package/out/generated/module.d.ts +13 -0
  15. package/out/generated/module.js +21 -0
  16. package/out/generated/module.js.map +1 -0
  17. package/out/index.d.ts +16 -0
  18. package/out/index.js +22 -0
  19. package/out/index.js.map +1 -0
  20. package/out/lsp/domain-lang-code-actions.d.ts +55 -0
  21. package/out/lsp/domain-lang-code-actions.js +143 -0
  22. package/out/lsp/domain-lang-code-actions.js.map +1 -0
  23. package/out/lsp/domain-lang-completion.d.ts +37 -0
  24. package/out/lsp/domain-lang-completion.js +452 -0
  25. package/out/lsp/domain-lang-completion.js.map +1 -0
  26. package/out/lsp/domain-lang-formatter.d.ts +15 -0
  27. package/out/lsp/domain-lang-formatter.js +43 -0
  28. package/out/lsp/domain-lang-formatter.js.map +1 -0
  29. package/out/lsp/domain-lang-naming.d.ts +34 -0
  30. package/out/lsp/domain-lang-naming.js +49 -0
  31. package/out/lsp/domain-lang-naming.js.map +1 -0
  32. package/out/lsp/domain-lang-scope.d.ts +59 -0
  33. package/out/lsp/domain-lang-scope.js +102 -0
  34. package/out/lsp/domain-lang-scope.js.map +1 -0
  35. package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
  36. package/out/lsp/domain-lang-workspace-manager.js +93 -0
  37. package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
  38. package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
  39. package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
  40. package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
  41. package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
  42. package/out/lsp/hover/domain-lang-hover.js +302 -0
  43. package/out/lsp/hover/domain-lang-hover.js.map +1 -0
  44. package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
  45. package/out/lsp/hover/domain-lang-keywords.js +47 -0
  46. package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
  47. package/out/lsp/manifest-diagnostics.d.ts +82 -0
  48. package/out/lsp/manifest-diagnostics.js +230 -0
  49. package/out/lsp/manifest-diagnostics.js.map +1 -0
  50. package/out/main-browser.d.ts +1 -0
  51. package/out/main-browser.js +11 -0
  52. package/out/main-browser.js.map +1 -0
  53. package/out/main.d.ts +1 -0
  54. package/out/main.js +74 -0
  55. package/out/main.js.map +1 -0
  56. package/out/sdk/ast-augmentation.d.ts +136 -0
  57. package/out/sdk/ast-augmentation.js +62 -0
  58. package/out/sdk/ast-augmentation.js.map +1 -0
  59. package/out/sdk/index.d.ts +94 -0
  60. package/out/sdk/index.js +97 -0
  61. package/out/sdk/index.js.map +1 -0
  62. package/out/sdk/indexes.d.ts +16 -0
  63. package/out/sdk/indexes.js +97 -0
  64. package/out/sdk/indexes.js.map +1 -0
  65. package/out/sdk/loader-node.d.ts +51 -0
  66. package/out/sdk/loader-node.js +119 -0
  67. package/out/sdk/loader-node.js.map +1 -0
  68. package/out/sdk/loader.d.ts +49 -0
  69. package/out/sdk/loader.js +85 -0
  70. package/out/sdk/loader.js.map +1 -0
  71. package/out/sdk/patterns.d.ts +93 -0
  72. package/out/sdk/patterns.js +123 -0
  73. package/out/sdk/patterns.js.map +1 -0
  74. package/out/sdk/query.d.ts +90 -0
  75. package/out/sdk/query.js +679 -0
  76. package/out/sdk/query.js.map +1 -0
  77. package/out/sdk/resolution.d.ts +52 -0
  78. package/out/sdk/resolution.js +68 -0
  79. package/out/sdk/resolution.js.map +1 -0
  80. package/out/sdk/types.d.ts +280 -0
  81. package/out/sdk/types.js +8 -0
  82. package/out/sdk/types.js.map +1 -0
  83. package/out/services/dependency-analyzer.d.ts +58 -0
  84. package/out/services/dependency-analyzer.js +254 -0
  85. package/out/services/dependency-analyzer.js.map +1 -0
  86. package/out/services/dependency-resolver.d.ts +146 -0
  87. package/out/services/dependency-resolver.js +452 -0
  88. package/out/services/dependency-resolver.js.map +1 -0
  89. package/out/services/git-url-resolver.browser.d.ts +10 -0
  90. package/out/services/git-url-resolver.browser.js +19 -0
  91. package/out/services/git-url-resolver.browser.js.map +1 -0
  92. package/out/services/git-url-resolver.d.ts +158 -0
  93. package/out/services/git-url-resolver.js +416 -0
  94. package/out/services/git-url-resolver.js.map +1 -0
  95. package/out/services/governance-validator.d.ts +44 -0
  96. package/out/services/governance-validator.js +153 -0
  97. package/out/services/governance-validator.js.map +1 -0
  98. package/out/services/import-resolver.d.ts +77 -0
  99. package/out/services/import-resolver.js +240 -0
  100. package/out/services/import-resolver.js.map +1 -0
  101. package/out/services/performance-optimizer.d.ts +60 -0
  102. package/out/services/performance-optimizer.js +140 -0
  103. package/out/services/performance-optimizer.js.map +1 -0
  104. package/out/services/relationship-inference.d.ts +11 -0
  105. package/out/services/relationship-inference.js +98 -0
  106. package/out/services/relationship-inference.js.map +1 -0
  107. package/out/services/semver.d.ts +98 -0
  108. package/out/services/semver.js +195 -0
  109. package/out/services/semver.js.map +1 -0
  110. package/out/services/types.d.ts +340 -0
  111. package/out/services/types.js +46 -0
  112. package/out/services/types.js.map +1 -0
  113. package/out/services/workspace-manager.d.ts +123 -0
  114. package/out/services/workspace-manager.js +489 -0
  115. package/out/services/workspace-manager.js.map +1 -0
  116. package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
  117. package/out/syntaxes/domain-lang.monarch.js +29 -0
  118. package/out/syntaxes/domain-lang.monarch.js.map +1 -0
  119. package/out/utils/import-utils.d.ts +49 -0
  120. package/out/utils/import-utils.js +128 -0
  121. package/out/utils/import-utils.js.map +1 -0
  122. package/out/validation/bounded-context.d.ts +11 -0
  123. package/out/validation/bounded-context.js +79 -0
  124. package/out/validation/bounded-context.js.map +1 -0
  125. package/out/validation/classification.d.ts +3 -0
  126. package/out/validation/classification.js +3 -0
  127. package/out/validation/classification.js.map +1 -0
  128. package/out/validation/constants.d.ts +180 -0
  129. package/out/validation/constants.js +235 -0
  130. package/out/validation/constants.js.map +1 -0
  131. package/out/validation/domain-lang-validator.d.ts +2 -0
  132. package/out/validation/domain-lang-validator.js +27 -0
  133. package/out/validation/domain-lang-validator.js.map +1 -0
  134. package/out/validation/domain.d.ts +11 -0
  135. package/out/validation/domain.js +63 -0
  136. package/out/validation/domain.js.map +1 -0
  137. package/out/validation/import.d.ts +68 -0
  138. package/out/validation/import.js +237 -0
  139. package/out/validation/import.js.map +1 -0
  140. package/out/validation/manifest.d.ts +144 -0
  141. package/out/validation/manifest.js +327 -0
  142. package/out/validation/manifest.js.map +1 -0
  143. package/out/validation/maps.d.ts +21 -0
  144. package/out/validation/maps.js +60 -0
  145. package/out/validation/maps.js.map +1 -0
  146. package/out/validation/metadata.d.ts +7 -0
  147. package/out/validation/metadata.js +16 -0
  148. package/out/validation/metadata.js.map +1 -0
  149. package/out/validation/model.d.ts +12 -0
  150. package/out/validation/model.js +29 -0
  151. package/out/validation/model.js.map +1 -0
  152. package/out/validation/relationships.d.ts +12 -0
  153. package/out/validation/relationships.js +94 -0
  154. package/out/validation/relationships.js.map +1 -0
  155. package/out/validation/shared.d.ts +6 -0
  156. package/out/validation/shared.js +12 -0
  157. package/out/validation/shared.js.map +1 -0
  158. package/package.json +110 -0
  159. package/src/ast-augmentation.ts +5 -0
  160. package/src/domain-lang-module.ts +112 -0
  161. package/src/domain-lang.langium +351 -0
  162. package/src/generated/ast.ts +986 -0
  163. package/src/generated/grammar.ts +2409 -0
  164. package/src/generated/module.ts +25 -0
  165. package/src/index.ts +24 -0
  166. package/src/lsp/domain-lang-code-actions.ts +189 -0
  167. package/src/lsp/domain-lang-completion.ts +514 -0
  168. package/src/lsp/domain-lang-formatter.ts +51 -0
  169. package/src/lsp/domain-lang-naming.ts +56 -0
  170. package/src/lsp/domain-lang-scope.ts +137 -0
  171. package/src/lsp/domain-lang-workspace-manager.ts +104 -0
  172. package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
  173. package/src/lsp/hover/domain-lang-hover.ts +338 -0
  174. package/src/lsp/hover/domain-lang-keywords.ts +50 -0
  175. package/src/lsp/manifest-diagnostics.ts +290 -0
  176. package/src/main-browser.ts +15 -0
  177. package/src/main.ts +85 -0
  178. package/src/sdk/README.md +297 -0
  179. package/src/sdk/ast-augmentation.ts +157 -0
  180. package/src/sdk/index.ts +126 -0
  181. package/src/sdk/indexes.ts +155 -0
  182. package/src/sdk/loader-node.ts +146 -0
  183. package/src/sdk/loader.ts +99 -0
  184. package/src/sdk/patterns.ts +147 -0
  185. package/src/sdk/query.ts +802 -0
  186. package/src/sdk/resolution.ts +78 -0
  187. package/src/sdk/types.ts +323 -0
  188. package/src/services/dependency-analyzer.ts +321 -0
  189. package/src/services/dependency-resolver.ts +551 -0
  190. package/src/services/git-url-resolver.browser.ts +26 -0
  191. package/src/services/git-url-resolver.ts +517 -0
  192. package/src/services/governance-validator.ts +177 -0
  193. package/src/services/import-resolver.ts +292 -0
  194. package/src/services/performance-optimizer.ts +170 -0
  195. package/src/services/relationship-inference.ts +121 -0
  196. package/src/services/semver.ts +213 -0
  197. package/src/services/types.ts +415 -0
  198. package/src/services/workspace-manager.ts +607 -0
  199. package/src/syntaxes/domain-lang.monarch.ts +29 -0
  200. package/src/utils/import-utils.ts +152 -0
  201. package/src/validation/bounded-context.ts +99 -0
  202. package/src/validation/classification.ts +5 -0
  203. package/src/validation/constants.ts +304 -0
  204. package/src/validation/domain-lang-validator.ts +33 -0
  205. package/src/validation/domain.ts +77 -0
  206. package/src/validation/import.ts +295 -0
  207. package/src/validation/manifest.ts +439 -0
  208. package/src/validation/maps.ts +76 -0
  209. package/src/validation/metadata.ts +18 -0
  210. package/src/validation/model.ts +37 -0
  211. package/src/validation/relationships.ts +154 -0
  212. package/src/validation/shared.ts +14 -0
@@ -0,0 +1,351 @@
1
+ // ============================================================================
2
+ // DomainLang Grammar - Domain-Driven Design Specification Language
3
+ // ============================================================================
4
+ // Copyright (c) 2025, Lars Baunwall. All rights reserved.
5
+ //
6
+ // A Langium-based DSL for modeling DDD architectures with diagrams-as-code.
7
+ // Inspired by ContextMapper DSL with first-class IDE support.
8
+ //
9
+ // Organization:
10
+ // 1. Entry Point & Model Structure
11
+ // 2. DDD Strategic Design (Domains, Bounded Contexts)
12
+ // 3. DDD Tactical Design (Teams, Classifications)
13
+ // 4. Architecture Mapping (Context Maps, Domain Maps)
14
+ // 5. Relationships & Integration Patterns
15
+ // 6. Documentation & Governance (Decisions, Terminology)
16
+ // 7. Module System (Imports & Namespaces)
17
+ // 8. Terminals & Lexical Grammar
18
+ // ============================================================================
19
+
20
+ grammar DomainLang
21
+
22
+ // ============================================================================
23
+ // SECTION 1: ENTRY POINT & MODEL STRUCTURE
24
+ // ============================================================================
25
+
26
+ /**
27
+ * Root AST node - aggregates all top-level DDD elements.
28
+ * Produces the entry point for parsing .dlang files.
29
+ */
30
+ entry Model:
31
+ imports+=ImportStatement*
32
+ (children+=StructureElement)*
33
+ ;
34
+
35
+ type Container = NamespaceDeclaration | Model;
36
+
37
+ /**
38
+ * Top-level elements that can appear in the model.
39
+ * Unifies all major DDD constructs for flexible ordering.
40
+ */
41
+ StructureElement:
42
+ Type |
43
+ ObjectMap |
44
+ NamespaceDeclaration
45
+ ;
46
+
47
+ /**
48
+ * Union of all main DDD type constructs.
49
+ */
50
+ Type:
51
+ Domain |
52
+ BoundedContext |
53
+ Team |
54
+ Classification |
55
+ Metadata
56
+ ;
57
+
58
+ // ============================================================================
59
+ // SECTION 2: DDD STRATEGIC DESIGN - DOMAINS & BOUNDED CONTEXTS
60
+ // ============================================================================
61
+
62
+ /**
63
+ * Domain - A sphere of knowledge or activity in DDD.
64
+ * Can be nested via `in` to show subdomain hierarchy.
65
+ * The `type` property indicates strategic importance (Core, Supporting, Generic) per Bounded Context Canvas.
66
+ * Body is optional - allows header-only Domain definitions.
67
+ */
68
+ Domain:
69
+ (/** A Domain represents a sphere of knowledge, influence, or activity. In DDD, it is the subject area to which the user applies a program. Example: Sales, Shipping, Accounting. */ 'Domain' | 'dom') name=ID ('in' parent=[Domain:QualifiedName])?
70
+ ('{'
71
+ (
72
+ ('description' Assignment description=STRING) |
73
+ ('vision' Assignment vision=STRING) |
74
+ ('type' Assignment type=[Classification:QualifiedName])
75
+ )*
76
+ '}')?
77
+ ;
78
+
79
+ /**
80
+ * Bounded Context - A boundary within which a domain model is defined.
81
+ * Central pattern in DDD for managing complexity and team boundaries.
82
+ * Belongs to exactly ONE domain (fundamental DDD principle).
83
+ * Body properties can appear in any order. Validation enforces at-most-once constraint.
84
+ * The `classification` property indicates strategic importance per Bounded Context Canvas.
85
+ * The `evolution` property indicates maturity stage per Wardley Maps/BC Canvas.
86
+ * The `archetype` property indicates behavioral role per DDD archetypes (Gateway, Execution, etc).
87
+ */
88
+ BoundedContext:
89
+ (/** A Bounded Context defines the boundary within which a particular domain model is defined and applicable. It is a central pattern in DDD for managing complexity. Example: SalesContext, SupportContext. */ 'BoundedContext' | 'bc') name=ID
90
+ ('for' domain=[Domain:QualifiedName])?
91
+ (
92
+ ('as' classification+=[Classification:QualifiedName])?
93
+ ('by' team+=[Team:QualifiedName])?
94
+ )?
95
+ ('{'
96
+ (
97
+ ('description' Assignment description=STRING) |
98
+ ('classification' Assignment classification+=[Classification:QualifiedName]) |
99
+ ('team' Assignment team+=[Team:QualifiedName]) |
100
+ ('businessModel' Assignment businessModel=[Classification:QualifiedName]) |
101
+ ('evolution' Assignment evolution=[Classification:QualifiedName]) |
102
+ ('archetype' Assignment archetype=[Classification:QualifiedName]) |
103
+ (('metadata' | 'meta') '{' (metadata+=MetadataEntry)* '}') |
104
+ (('relationships' | 'integrations') '{'
105
+ (relationships += Relationship ((",")? relationships += Relationship)*)*
106
+ '}') |
107
+ (('terminology' | 'glossary') '{'
108
+ (terminology += DomainTerm (",")?)*
109
+ '}') |
110
+ (('decisions' | 'rules') '{'
111
+ (decisions += AbstractDecision (',')?)*
112
+ '}')
113
+ )*
114
+ '}')?
115
+ ;
116
+
117
+ MetadataEntry:
118
+ key=[Metadata:QualifiedName] Assignment value=STRING
119
+ ;
120
+
121
+
122
+ // ============================================================================
123
+ // SECTION 3: DDD TACTICAL DESIGN - TEAMS & CLASSIFICATIONS
124
+ // ============================================================================
125
+
126
+ /**
127
+ * Team - People responsible for a Bounded Context or Domain.
128
+ * Represents organizational boundaries in DDD.
129
+ */
130
+ Team:
131
+ (/** A Team represents the people responsible for a Bounded Context or Domain. */ 'Team') name=ID
132
+ ;
133
+
134
+ /**
135
+ * Classification - Reusable label for categorizing elements.
136
+ * Examples: Core, Supporting, Generic, Strategic, Commodity, Architectural, Business, Technical.
137
+ */
138
+ Classification:
139
+ (/** A Classification is a reusable label for categorizing domains, contexts, patterns, and decisions (e.g., Core, Supporting, Generic, Architectural, Business, Technical). */ 'Classification') name=ID
140
+ ;
141
+
142
+ /**
143
+ * Metadata - Defines a key that can be used in metadata blocks.
144
+ * Examples: Language, Framework, Database, Repository.
145
+ * Can be defined locally or imported from stdlib.
146
+ */
147
+ Metadata:
148
+ (/** A Metadata defines a key that can be used in metadata blocks. Examples: Language, Framework, Database, Repository. Can be defined locally or imported from stdlib. */ 'Metadata') name=ID
149
+ ;
150
+
151
+
152
+ // ============================================================================
153
+ // SECTION 4: ARCHITECTURE MAPPING - CONTEXT MAPS & DOMAIN MAPS
154
+ // ============================================================================
155
+
156
+ /**
157
+ * Union of mapping constructs for visualizing architecture.
158
+ */
159
+ ObjectMap:
160
+ ContextMap |
161
+ DomainMap
162
+ ;
163
+
164
+ /**
165
+ * Context Map - Visualizes relationships between Bounded Contexts.
166
+ * Shows integration patterns and team interactions.
167
+ */
168
+ ContextMap:
169
+ (/** A Context Map visualizes and documents the relationships between Bounded Contexts, including their integration patterns. */ 'ContextMap' | 'cmap') name=ID
170
+ '{'
171
+ ('contains' boundedContexts += [+BoundedContext:QualifiedName] ((",")? boundedContexts += [+BoundedContext:QualifiedName])*)*
172
+ (relationships += Relationship ((",")? relationships += Relationship)*)*
173
+ '}'
174
+ ;
175
+
176
+ /**
177
+ * Domain Map - Visualizes relationships between Domains.
178
+ * Shows high-level domain organization and subdomain structure.
179
+ */
180
+ DomainMap:
181
+ (/** A Domain Map visualizes and documents the relationships between Domains. */ 'DomainMap' | 'dmap') name=ID
182
+ '{'
183
+ ('contains' domains += [+Domain:QualifiedName] ((",")? domains += [+Domain:QualifiedName])*)*
184
+ '}'
185
+ ;
186
+
187
+ // ============================================================================
188
+ // SECTION 5: RELATIONSHIPS & INTEGRATION PATTERNS
189
+ // ============================================================================
190
+
191
+ /**
192
+ * Relationship - Connection between two Bounded Contexts.
193
+ * Supports DDD integration patterns (ACL, OHS, PL, etc.) and relationship types.
194
+ */
195
+ Relationship:
196
+ ('[' leftPatterns+=IntegrationPattern (',' leftPatterns+=IntegrationPattern)* ']')?
197
+ left=BoundedContextRef
198
+ arrow=RelationshipArrow
199
+ ('[' rightPatterns+=IntegrationPattern (',' rightPatterns+=IntegrationPattern)* ']')?
200
+ right=BoundedContextRef
201
+ (Assignment type=RelationshipType)?
202
+ ;
203
+
204
+ /**
205
+ * Context reference - can be 'this' (self-reference) or a qualified name.
206
+ */
207
+ BoundedContextRef:
208
+ {infer ThisRef} 'this' | link=[BoundedContext:QualifiedName]
209
+ ;
210
+
211
+ /**
212
+ * Relationship arrows - symbolic and named types.
213
+ *
214
+ * Arrow semantics:
215
+ * -> Upstream to downstream (left provides, right consumes)
216
+ * <- Downstream to upstream (right provides, left consumes)
217
+ * <-> Bidirectional/Partnership (mutual dependency)
218
+ * >< Separate Ways (no integration, teams go their own way)
219
+ */
220
+ RelationshipArrow returns string:
221
+ '<->' | '->' | '<-' | '><' // Separate Ways
222
+ ;
223
+
224
+ /**
225
+ * DDD Integration Patterns (used in relationships).
226
+ */
227
+ IntegrationPattern returns string:
228
+ 'PL' | 'PublishedLanguage' // Published Language
229
+ | 'OHS' | 'OpenHostService' // Open Host Service
230
+ | 'CF' | 'Conformist' // Conformist
231
+ | 'ACL' | 'AntiCorruptionLayer' // Anti-Corruption Layer
232
+ | 'P' | 'Partnership' // Partnership
233
+ | 'SK' | 'SharedKernel' // Shared Kernel
234
+ | 'BBoM' | 'BigBallOfMud' // Big Ball of Mud
235
+ ;
236
+
237
+ /**
238
+ * DDD Relationship Types.
239
+ */
240
+ RelationshipType returns string:
241
+ 'Partnership'
242
+ | 'SharedKernel'
243
+ | 'CustomerSupplier'
244
+ | 'UpstreamDownstream'
245
+ | 'SeparateWays'
246
+ ;
247
+
248
+ // ============================================================================
249
+ // SECTION 6: DOCUMENTATION & GOVERNANCE
250
+ // ============================================================================
251
+
252
+ /**
253
+ * Domain Terminology - Ubiquitous language terms with definitions.
254
+ * Supports synonyms and examples for richer glossaries.
255
+ */
256
+ DomainTerm:
257
+ ('Term' | 'term') name=ID (Assignment meaning=STRING)?
258
+ (('aka' | 'synonyms') Assignment? synonyms+=ID (',' synonyms+=ID)*)?
259
+ (('examples') Assignment? examples+=STRING (',' examples+=STRING)*)?
260
+ ;
261
+
262
+ /**
263
+ * Decisions, Policies, and Business Rules.
264
+ * All types are interchangeable - use what reads best for your domain.
265
+ */
266
+ AbstractDecision:
267
+ Decision |
268
+ Policy |
269
+ BusinessRule
270
+ ;
271
+
272
+ Decision:
273
+ (/** A documented choice or rule that affects the model or process. */ 'Decision' | 'decision')
274
+ ('[' classification=[Classification:QualifiedName] ']')?
275
+ name=ID Assignment value=STRING
276
+ ;
277
+
278
+ Policy:
279
+ (/** A business rule or guideline that governs behavior within a context. */ 'Policy' | 'policy')
280
+ ('[' classification=[Classification:QualifiedName] ']')?
281
+ name=ID Assignment value=STRING
282
+ ;
283
+
284
+ BusinessRule:
285
+ (/** A business rule or guideline that governs behavior within a context. */ 'Rule' | 'rule')
286
+ ('[' classification=[Classification:QualifiedName] ']')?
287
+ name=ID Assignment value=STRING
288
+ ;
289
+
290
+ // ============================================================================
291
+ // SECTION 7: MODULE SYSTEM - IMPORTS & NAMESPACES
292
+ // ============================================================================
293
+
294
+ /**
295
+ * Import Statement - Manifest-centric import system per PRS-010.
296
+ *
297
+ * Simplified syntax where import statements use short specifiers:
298
+ * - External dependencies (from manifest): import "core" as Core
299
+ * - Local files: import "./shared/types.dlang"
300
+ * - Workspace-relative: import "~/contexts/sales.dlang"
301
+ *
302
+ * All resolution details (source, version, integrity) live in model.yaml manifest.
303
+ * Named imports and inline integrity checks have been removed per PRS-010.
304
+ */
305
+ ImportStatement:
306
+ /** Imports types or namespaces from another file or module, enabling reuse and modularity. */ ('Import' | 'import') uri=STRING ('as' alias=ID)?
307
+ ;
308
+
309
+ /**
310
+ * Namespace Declaration - Hierarchical namespacing for organizing models.
311
+ * Combines package modularity with group-style nesting.
312
+ */
313
+ NamespaceDeclaration:
314
+ (/** Namespaces organize large models into hierarchical qualified names for symbol resolution. */ 'Namespace' | 'ns') name=QualifiedName '{'
315
+ (children+=StructureElement)*
316
+ '}'
317
+ ;
318
+
319
+ // ============================================================================
320
+ // SECTION 8: METADATA INTERFACES (DOCUMENTATION BLOCKS) - REMOVED
321
+ // ============================================================================
322
+
323
+ // Documentation blocks have been replaced by direct properties
324
+
325
+ // ============================================================================
326
+ // SECTION 9: HELPER RULES & FRAGMENTS
327
+ // ============================================================================
328
+
329
+ /**
330
+ * Assignment operators - flexible syntax.
331
+ */
332
+ Assignment returns string:
333
+ (':' | 'is' | '=')
334
+ ;
335
+
336
+ /**
337
+ * Qualified Name - Hierarchical namespacing with dots.
338
+ */
339
+ QualifiedName returns string:
340
+ ID ('.' ID)*
341
+ ;
342
+
343
+ // ============================================================================
344
+ // SECTION 10: TERMINALS & LEXICAL GRAMMAR
345
+ // ============================================================================
346
+
347
+ hidden terminal WS: /\s+/;
348
+ terminal ID: /[_a-zA-Z][\w_-]*/;
349
+ terminal STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/;
350
+ hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
351
+ hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;