archimaid 0.0.0-stage → 0.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.
Files changed (154) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/FOUNDATION.md +108 -0
  3. package/LICENSE +21 -0
  4. package/README.md +271 -2
  5. package/dist/archimate/catalogue.d.ts +106 -0
  6. package/dist/archimate/catalogue.js +219 -0
  7. package/dist/archimate/catalogue.js.map +1 -0
  8. package/dist/archimate/diagnostics.d.ts +48 -0
  9. package/dist/archimate/diagnostics.js +64 -0
  10. package/dist/archimate/diagnostics.js.map +1 -0
  11. package/dist/archimate/frontmatter.d.ts +13 -0
  12. package/dist/archimate/frontmatter.js +62 -0
  13. package/dist/archimate/frontmatter.js.map +1 -0
  14. package/dist/archimate/grammar.d.ts +60 -0
  15. package/dist/archimate/grammar.js +273 -0
  16. package/dist/archimate/grammar.js.map +1 -0
  17. package/dist/archimate/lexer.d.ts +91 -0
  18. package/dist/archimate/lexer.js +215 -0
  19. package/dist/archimate/lexer.js.map +1 -0
  20. package/dist/archimate/model.d.ts +46 -0
  21. package/dist/archimate/model.js +2 -0
  22. package/dist/archimate/model.js.map +1 -0
  23. package/dist/archimate/nesting.d.ts +14 -0
  24. package/dist/archimate/nesting.js +84 -0
  25. package/dist/archimate/nesting.js.map +1 -0
  26. package/dist/archimate/parser.d.ts +14 -0
  27. package/dist/archimate/parser.js +53 -0
  28. package/dist/archimate/parser.js.map +1 -0
  29. package/dist/archimate/suggestions.d.ts +1 -0
  30. package/dist/archimate/suggestions.js +44 -0
  31. package/dist/archimate/suggestions.js.map +1 -0
  32. package/dist/archimate/validate.d.ts +4 -0
  33. package/dist/archimate/validate.js +402 -0
  34. package/dist/archimate/validate.js.map +1 -0
  35. package/dist/bundle/archimaid.esm.min.mjs +1 -0
  36. package/dist/bundle/chunks/archimateDiagram-WUCF6KHR.mjs +132 -0
  37. package/dist/bundle/chunks/chunk-QBMRZFD3.mjs +1 -0
  38. package/dist/bundle/chunks/elk.bundled-2VSLVJGB.mjs +26 -0
  39. package/dist/cli/render.d.ts +10 -0
  40. package/dist/cli/render.js +102 -0
  41. package/dist/cli/render.js.map +1 -0
  42. package/dist/cli/report.d.ts +20 -0
  43. package/dist/cli/report.js +39 -0
  44. package/dist/cli/report.js.map +1 -0
  45. package/dist/cli/sources.d.ts +19 -0
  46. package/dist/cli/sources.js +86 -0
  47. package/dist/cli/sources.js.map +1 -0
  48. package/dist/cli.d.ts +2 -0
  49. package/dist/cli.js +137 -0
  50. package/dist/cli.js.map +1 -0
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +2 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/language.d.ts +5 -0
  55. package/dist/language.js +3 -0
  56. package/dist/language.js.map +1 -0
  57. package/dist/mermaid/archimateDetector.d.ts +12 -0
  58. package/dist/mermaid/archimateDetector.js +29 -0
  59. package/dist/mermaid/archimateDetector.js.map +1 -0
  60. package/dist/mermaid/archimateDiagram.d.ts +9 -0
  61. package/dist/mermaid/archimateDiagram.js +75 -0
  62. package/dist/mermaid/archimateDiagram.js.map +1 -0
  63. package/dist/mermaid/archimateRenderer.d.ts +6 -0
  64. package/dist/mermaid/archimateRenderer.js +40 -0
  65. package/dist/mermaid/archimateRenderer.js.map +1 -0
  66. package/dist/mermaid/architectureLayout.d.ts +50 -0
  67. package/dist/mermaid/architectureLayout.js +144 -0
  68. package/dist/mermaid/architectureLayout.js.map +1 -0
  69. package/dist/mermaid/geometry.d.ts +3 -0
  70. package/dist/mermaid/geometry.js +20 -0
  71. package/dist/mermaid/geometry.js.map +1 -0
  72. package/dist/mermaid/hierarchy.d.ts +1 -0
  73. package/dist/mermaid/hierarchy.js +8 -0
  74. package/dist/mermaid/hierarchy.js.map +1 -0
  75. package/dist/mermaid/invariant.d.ts +1 -0
  76. package/dist/mermaid/invariant.js +7 -0
  77. package/dist/mermaid/invariant.js.map +1 -0
  78. package/dist/mermaid/orthogonalRouter.d.ts +4 -0
  79. package/dist/mermaid/orthogonalRouter.js +249 -0
  80. package/dist/mermaid/orthogonalRouter.js.map +1 -0
  81. package/dist/mermaid/relationshipPlacement.d.ts +3 -0
  82. package/dist/mermaid/relationshipPlacement.js +350 -0
  83. package/dist/mermaid/relationshipPlacement.js.map +1 -0
  84. package/dist/mermaid/render/draw.d.ts +17 -0
  85. package/dist/mermaid/render/draw.js +275 -0
  86. package/dist/mermaid/render/draw.js.map +1 -0
  87. package/dist/mermaid/render/elkRoutes.d.ts +6 -0
  88. package/dist/mermaid/render/elkRoutes.js +216 -0
  89. package/dist/mermaid/render/elkRoutes.js.map +1 -0
  90. package/dist/mermaid/render/graph.d.ts +17 -0
  91. package/dist/mermaid/render/graph.js +200 -0
  92. package/dist/mermaid/render/graph.js.map +1 -0
  93. package/dist/mermaid/render/labels.d.ts +12 -0
  94. package/dist/mermaid/render/labels.js +148 -0
  95. package/dist/mermaid/render/labels.js.map +1 -0
  96. package/dist/mermaid/render/layout.d.ts +12 -0
  97. package/dist/mermaid/render/layout.js +60 -0
  98. package/dist/mermaid/render/layout.js.map +1 -0
  99. package/dist/mermaid/render/measure.d.ts +16 -0
  100. package/dist/mermaid/render/measure.js +96 -0
  101. package/dist/mermaid/render/measure.js.map +1 -0
  102. package/dist/mermaid/render/place.d.ts +20 -0
  103. package/dist/mermaid/render/place.js +63 -0
  104. package/dist/mermaid/render/place.js.map +1 -0
  105. package/dist/mermaid/render/route.d.ts +29 -0
  106. package/dist/mermaid/render/route.js +113 -0
  107. package/dist/mermaid/render/route.js.map +1 -0
  108. package/dist/mermaid/render/shared.d.ts +83 -0
  109. package/dist/mermaid/render/shared.js +52 -0
  110. package/dist/mermaid/render/shared.js.map +1 -0
  111. package/dist/mermaid/render/svg.d.ts +6 -0
  112. package/dist/mermaid/render/svg.js +33 -0
  113. package/dist/mermaid/render/svg.js.map +1 -0
  114. package/dist/mermaid/render/viewport.d.ts +14 -0
  115. package/dist/mermaid/render/viewport.js +58 -0
  116. package/dist/mermaid/render/viewport.js.map +1 -0
  117. package/dist/mermaid/routing/anchors.d.ts +14 -0
  118. package/dist/mermaid/routing/anchors.js +134 -0
  119. package/dist/mermaid/routing/anchors.js.map +1 -0
  120. package/dist/mermaid/routing/bundles.d.ts +14 -0
  121. package/dist/mermaid/routing/bundles.js +94 -0
  122. package/dist/mermaid/routing/bundles.js.map +1 -0
  123. package/dist/mermaid/routing/congestion.d.ts +8 -0
  124. package/dist/mermaid/routing/congestion.js +70 -0
  125. package/dist/mermaid/routing/congestion.js.map +1 -0
  126. package/dist/mermaid/routing/constants.d.ts +13 -0
  127. package/dist/mermaid/routing/constants.js +17 -0
  128. package/dist/mermaid/routing/constants.js.map +1 -0
  129. package/dist/mermaid/routing/primitives.d.ts +33 -0
  130. package/dist/mermaid/routing/primitives.js +110 -0
  131. package/dist/mermaid/routing/primitives.js.map +1 -0
  132. package/dist/mermaid/routing/search.d.ts +4 -0
  133. package/dist/mermaid/routing/search.js +171 -0
  134. package/dist/mermaid/routing/search.js.map +1 -0
  135. package/dist/mermaid/routing/shapes.d.ts +8 -0
  136. package/dist/mermaid/routing/shapes.js +82 -0
  137. package/dist/mermaid/routing/shapes.js.map +1 -0
  138. package/dist/mermaid/routing/types.d.ts +37 -0
  139. package/dist/mermaid/routing/types.js +14 -0
  140. package/dist/mermaid/routing/types.js.map +1 -0
  141. package/dist/mermaid/styles.d.ts +89 -0
  142. package/dist/mermaid/styles.js +166 -0
  143. package/dist/mermaid/styles.js.map +1 -0
  144. package/docs/reference.md +86 -0
  145. package/examples/cross-layer-relationships.mmd +79 -0
  146. package/examples/cross-layer-relationships.svg +33 -0
  147. package/examples/element-preview.svg +1 -0
  148. package/examples/nested-components.mmd +21 -0
  149. package/examples/nested-components.svg +4 -0
  150. package/examples/order-fulfilment.mmd +10 -0
  151. package/examples/order-management.mmd +15 -0
  152. package/examples/order-management.svg +2 -0
  153. package/package.json +91 -4
  154. package/skills/archimaid/SKILL.md +123 -0
@@ -0,0 +1,273 @@
1
+ import { CstParser, EOF, defaultParserErrorProvider } from 'chevrotain';
2
+ import { access, accDescrBlock, arrow, click, closeBrace, colon, connector, description, directed, direction, element, header, href, identifier, inside, label, layout, metadata, nest, newline, note, on, openBrace, quoted, relationship, tokens, via, } from './lexer.js';
3
+ // A rule's own description replaces Chevrotain's "Expecting: … but found: …" wording.
4
+ const errorMessageProvider = {
5
+ ...defaultParserErrorProvider,
6
+ buildNoViableAltMessage: (options) => options.customUserDescription ?? defaultParserErrorProvider.buildNoViableAltMessage(options),
7
+ };
8
+ class ArchiMateParser extends CstParser {
9
+ document = this.RULE('document', () => {
10
+ this.MANY(() => this.CONSUME(newline));
11
+ this.CONSUME(header, { ERR_MSG: 'Expected the "archimate-beta" diagram header.' });
12
+ this.MANY2(() => {
13
+ this.CONSUME2(newline);
14
+ this.OPTION(() => this.SUBRULE(this.statement));
15
+ });
16
+ this.CONSUME(EOF, {
17
+ ERR_MSG: 'Expected a new line or an ArchiMate declaration (layout, direction, element, description, relationship, connector, note, nest, click, or metadata).',
18
+ });
19
+ });
20
+ statement = this.RULE('statement', () => {
21
+ this.OR([
22
+ { ALT: () => this.SUBRULE(this.directionStatement) },
23
+ { ALT: () => this.SUBRULE(this.layoutStatement) },
24
+ { ALT: () => this.SUBRULE(this.elementStatement) },
25
+ { ALT: () => this.SUBRULE(this.descriptionStatement) },
26
+ { ALT: () => this.SUBRULE(this.relationshipStatement) },
27
+ { ALT: () => this.SUBRULE(this.noteStatement) },
28
+ { ALT: () => this.SUBRULE(this.nestingStatement) },
29
+ { ALT: () => this.SUBRULE(this.clickStatement) },
30
+ { ALT: () => this.SUBRULE(this.metadataStatement) },
31
+ { ALT: () => this.SUBRULE(this.connectorStatement) },
32
+ ]);
33
+ });
34
+ // Diagram settings stay at the top level, so a block holds only model declarations.
35
+ blockStatement = this.RULE('blockStatement', () => {
36
+ this.OR({
37
+ DEF: [
38
+ { ALT: () => this.SUBRULE(this.elementStatement) },
39
+ { ALT: () => this.SUBRULE(this.descriptionStatement) },
40
+ { ALT: () => this.SUBRULE(this.relationshipStatement) },
41
+ { ALT: () => this.SUBRULE(this.noteStatement) },
42
+ { ALT: () => this.SUBRULE(this.nestingStatement) },
43
+ { ALT: () => this.SUBRULE(this.clickStatement) },
44
+ { ALT: () => this.SUBRULE(this.connectorStatement) },
45
+ ],
46
+ ERR_MSG: 'Expected "}" or a declaration inside the element block (element, description, relationship, connector, note, nest, or click).',
47
+ });
48
+ });
49
+ connectorStatement = this.RULE('connectorStatement', () => {
50
+ this.CONSUME(identifier, { LABEL: 'source' });
51
+ this.CONSUME(connector, { LABEL: 'connector' });
52
+ this.CONSUME2(identifier, { LABEL: 'target' });
53
+ this.OPTION(() => {
54
+ this.CONSUME(colon);
55
+ this.CONSUME(quoted, { LABEL: 'labelText' });
56
+ });
57
+ });
58
+ directionStatement = this.RULE('directionStatement', () => {
59
+ this.CONSUME(direction);
60
+ this.CONSUME(identifier, { LABEL: 'value' });
61
+ });
62
+ layoutStatement = this.RULE('layoutStatement', () => {
63
+ this.CONSUME(layout);
64
+ this.CONSUME(identifier, { LABEL: 'value' });
65
+ });
66
+ elementStatement = this.RULE('elementStatement', () => {
67
+ this.CONSUME(element);
68
+ this.CONSUME(identifier, { LABEL: 'type' });
69
+ this.CONSUME2(identifier, { LABEL: 'id' });
70
+ this.CONSUME(quoted, { LABEL: 'name' });
71
+ this.OPTION(() => {
72
+ this.CONSUME(openBrace);
73
+ this.MANY(() => {
74
+ this.CONSUME(newline);
75
+ this.OPTION2(() => this.SUBRULE(this.blockStatement));
76
+ });
77
+ this.CONSUME(closeBrace, { ERR_MSG: 'Expected "}" on its own line to close the element block.' });
78
+ });
79
+ });
80
+ clickStatement = this.RULE('clickStatement', () => {
81
+ this.CONSUME(click);
82
+ this.CONSUME(identifier, { LABEL: 'id' });
83
+ this.CONSUME(href);
84
+ this.CONSUME(quoted, { LABEL: 'url' });
85
+ this.OPTION(() => this.CONSUME2(quoted, { LABEL: 'tooltip' }));
86
+ this.OPTION2(() => this.CONSUME2(identifier, { LABEL: 'target' }));
87
+ });
88
+ descriptionStatement = this.RULE('descriptionStatement', () => {
89
+ this.CONSUME(description);
90
+ this.CONSUME(identifier, { LABEL: 'id' });
91
+ this.CONSUME(quoted, { LABEL: 'value' });
92
+ });
93
+ relationshipStatement = this.RULE('relationshipStatement', () => {
94
+ this.CONSUME(relationship);
95
+ this.CONSUME(identifier, { LABEL: 'type' });
96
+ this.CONSUME2(identifier, { LABEL: 'id' });
97
+ this.CONSUME3(identifier, { LABEL: 'source' });
98
+ this.CONSUME(arrow);
99
+ this.CONSUME4(identifier, { LABEL: 'target' });
100
+ this.OPTION(() => {
101
+ this.CONSUME(access);
102
+ this.CONSUME5(identifier, { LABEL: 'mode' });
103
+ });
104
+ this.OPTION2(() => this.CONSUME(directed));
105
+ this.OPTION3(() => {
106
+ this.CONSUME(label);
107
+ this.CONSUME(quoted, { LABEL: 'labelText' });
108
+ });
109
+ });
110
+ metadataStatement = this.RULE('metadataStatement', () => {
111
+ this.OR([
112
+ { ALT: () => this.CONSUME(metadata, { LABEL: 'value' }) },
113
+ { ALT: () => this.CONSUME(accDescrBlock, { LABEL: 'value' }) },
114
+ ]);
115
+ });
116
+ noteStatement = this.RULE('noteStatement', () => {
117
+ this.CONSUME(note);
118
+ this.CONSUME(identifier, { LABEL: 'id' });
119
+ this.CONSUME(quoted, { LABEL: 'text' });
120
+ this.OPTION(() => {
121
+ this.CONSUME(on);
122
+ this.CONSUME2(identifier, { LABEL: 'anchor' });
123
+ });
124
+ });
125
+ nestingStatement = this.RULE('nestingStatement', () => {
126
+ this.CONSUME(nest);
127
+ this.CONSUME(identifier, { LABEL: 'child' });
128
+ this.CONSUME(inside);
129
+ this.CONSUME2(identifier, { LABEL: 'parent' });
130
+ this.OPTION(() => {
131
+ this.CONSUME(via);
132
+ this.CONSUME3(identifier, { LABEL: 'relationshipId' });
133
+ });
134
+ });
135
+ constructor() {
136
+ super(tokens, { errorMessageProvider });
137
+ this.performSelfAnalysis();
138
+ }
139
+ }
140
+ function requiredToken(ctx, name) {
141
+ const item = ctx[name]?.[0];
142
+ if (!item || !('tokenType' in item))
143
+ throw new Error('Incomplete ArchiMate parse tree.');
144
+ return item;
145
+ }
146
+ const parser = new ArchiMateParser();
147
+ const BaseVisitor = parser.getBaseCstVisitorConstructor();
148
+ class DeclarationVisitor extends BaseVisitor {
149
+ constructor() {
150
+ super();
151
+ this.validateVisitor();
152
+ }
153
+ document(ctx) {
154
+ return (ctx.statement ?? []).flatMap((node) => {
155
+ if (!('children' in node))
156
+ throw new Error('Invalid ArchiMate parse tree.');
157
+ return this.visit(node);
158
+ });
159
+ }
160
+ statement(ctx) {
161
+ const child = Object.values(ctx)[0]?.[0];
162
+ if (!child || !('children' in child))
163
+ throw new Error('Incomplete ArchiMate statement.');
164
+ return this.visit(child);
165
+ }
166
+ directionStatement(ctx) {
167
+ return { kind: 'direction', value: requiredToken(ctx, 'value') };
168
+ }
169
+ layoutStatement(ctx) {
170
+ return { kind: 'layout', value: requiredToken(ctx, 'value') };
171
+ }
172
+ // A block nests every element declared directly inside it in the enclosing element.
173
+ elementStatement(ctx) {
174
+ const parent = requiredToken(ctx, 'id');
175
+ const declared = {
176
+ kind: 'element',
177
+ type: requiredToken(ctx, 'type'),
178
+ id: parent,
179
+ name: requiredToken(ctx, 'name'),
180
+ };
181
+ const body = (ctx.blockStatement ?? []).map((node) => {
182
+ if (!('children' in node))
183
+ throw new Error('Invalid ArchiMate parse tree.');
184
+ return [this.visit(node)].flat();
185
+ });
186
+ const nesting = body.flatMap(([first]) => first?.kind === 'element' ? [{ kind: 'nesting', child: first.id, parent }] : []);
187
+ return [declared, ...nesting, ...body.flat()];
188
+ }
189
+ blockStatement(ctx) {
190
+ return this.statement(ctx);
191
+ }
192
+ clickStatement(ctx) {
193
+ return {
194
+ kind: 'click',
195
+ id: requiredToken(ctx, 'id'),
196
+ url: requiredToken(ctx, 'url'),
197
+ ...(ctx.tooltip && { tooltip: requiredToken(ctx, 'tooltip') }),
198
+ ...(ctx.target && { target: requiredToken(ctx, 'target') }),
199
+ };
200
+ }
201
+ descriptionStatement(ctx) {
202
+ return { kind: 'description', id: requiredToken(ctx, 'id'), value: requiredToken(ctx, 'value') };
203
+ }
204
+ relationshipStatement(ctx) {
205
+ return {
206
+ kind: 'relationship',
207
+ type: requiredToken(ctx, 'type'),
208
+ id: requiredToken(ctx, 'id'),
209
+ source: requiredToken(ctx, 'source'),
210
+ target: requiredToken(ctx, 'target'),
211
+ ...(ctx.mode && { mode: requiredToken(ctx, 'mode') }),
212
+ ...(ctx.Directed && { directed: requiredToken(ctx, 'Directed') }),
213
+ ...(ctx.labelText && { label: requiredToken(ctx, 'labelText') }),
214
+ };
215
+ }
216
+ connectorStatement(ctx) {
217
+ return {
218
+ kind: 'connector',
219
+ source: requiredToken(ctx, 'source'),
220
+ connector: requiredToken(ctx, 'connector'),
221
+ target: requiredToken(ctx, 'target'),
222
+ ...(ctx.labelText && { label: requiredToken(ctx, 'labelText') }),
223
+ };
224
+ }
225
+ metadataStatement(ctx) {
226
+ return { kind: 'metadata', value: requiredToken(ctx, 'value') };
227
+ }
228
+ noteStatement(ctx) {
229
+ return {
230
+ kind: 'note',
231
+ id: requiredToken(ctx, 'id'),
232
+ text: requiredToken(ctx, 'text'),
233
+ ...(ctx.anchor && { anchor: requiredToken(ctx, 'anchor') }),
234
+ };
235
+ }
236
+ nestingStatement(ctx) {
237
+ return {
238
+ kind: 'nesting',
239
+ child: requiredToken(ctx, 'child'),
240
+ parent: requiredToken(ctx, 'parent'),
241
+ ...(ctx.relationshipId && { relationshipId: requiredToken(ctx, 'relationshipId') }),
242
+ };
243
+ }
244
+ }
245
+ const visitor = new DeclarationVisitor();
246
+ export function parseDeclarations(input) {
247
+ parser.input = input;
248
+ const tree = parser.document();
249
+ const syntaxError = parser.errors[0];
250
+ if (syntaxError)
251
+ return { syntaxError };
252
+ const declarations = visitor.visit(tree);
253
+ if (!Array.isArray(declarations))
254
+ throw new Error('Invalid ArchiMate document parse tree.');
255
+ return { declarations };
256
+ }
257
+ const relationshipOptionOrder = [access, directed, label];
258
+ // Chevrotain reports a misplaced relationship option as unexpected trailing input; name the ordering rule instead.
259
+ export function describeSyntaxError(error, tokens) {
260
+ const rank = relationshipOptionOrder.indexOf(error.token.tokenType);
261
+ const index = tokens.indexOf(error.token);
262
+ if (rank < 0 || index < 0)
263
+ return error.message;
264
+ let statementStart = index;
265
+ while (statementStart > 0 && tokens[statementStart - 1]?.tokenType !== newline)
266
+ statementStart--;
267
+ const statement = tokens.slice(statementStart, index);
268
+ if (statement[0]?.tokenType !== relationship)
269
+ return error.message;
270
+ const later = statement.find((token) => relationshipOptionOrder.indexOf(token.tokenType) > rank);
271
+ return later ? '"' + error.token.image + '" must come before "' + later.image + '".' : error.message;
272
+ }
273
+ //# sourceMappingURL=grammar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammar.js","sourceRoot":"","sources":["../../src/archimate/grammar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EACL,MAAM,EACN,aAAa,EACb,KAAK,EACL,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,EAAE,EACF,SAAS,EACT,MAAM,EACN,YAAY,EACZ,MAAM,EACN,GAAG,GACJ,MAAM,YAAY,CAAC;AAEpB,sFAAsF;AACtF,MAAM,oBAAoB,GAAgC;IACxD,GAAG,0BAA0B;IAC7B,uBAAuB,EAAE,CAAC,OAAO,EAAE,EAAE,CACnC,OAAO,CAAC,qBAAqB,IAAI,0BAA0B,CAAC,uBAAuB,CAAC,OAAO,CAAC;CAC/F,CAAC;A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OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAChD,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,OAAO,cAAc,GAAG,CAAC,IAAI,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,EAAE,SAAS,KAAK,OAAO;QAAE,cAAc,EAAE,CAAC;IACjG,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACtD,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACnE,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IACjG,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,sBAAsB,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;AACvG,CAAC","sourcesContent":["import { CstParser, EOF, defaultParserErrorProvider } from 'chevrotain';\nimport type { CstNode, IParserErrorMessageProvider, IRecognitionException, IToken, TokenType } from 'chevrotain';\nimport {\n access,\n accDescrBlock,\n arrow,\n click,\n closeBrace,\n colon,\n connector,\n description,\n directed,\n direction,\n element,\n header,\n href,\n identifier,\n inside,\n label,\n layout,\n metadata,\n nest,\n newline,\n note,\n on,\n openBrace,\n quoted,\n relationship,\n tokens,\n via,\n} from './lexer.js';\n\n// A rule's own description replaces Chevrotain's \"Expecting: … but found: …\" wording.\nconst errorMessageProvider: IParserErrorMessageProvider = {\n ...defaultParserErrorProvider,\n buildNoViableAltMessage: (options) =>\n options.customUserDescription ?? defaultParserErrorProvider.buildNoViableAltMessage(options),\n};\n\nclass ArchiMateParser extends CstParser {\n readonly document = this.RULE('document', () => {\n this.MANY(() => this.CONSUME(newline));\n this.CONSUME(header, { ERR_MSG: 'Expected the \"archimate-beta\" diagram header.' });\n this.MANY2(() => {\n this.CONSUME2(newline);\n this.OPTION(() => this.SUBRULE(this.statement));\n });\n this.CONSUME(EOF, {\n ERR_MSG:\n 'Expected a new line or an ArchiMate declaration (layout, direction, element, description, relationship, connector, note, nest, click, or metadata).',\n });\n });\n\n private readonly statement = this.RULE('statement', () => {\n this.OR([\n { ALT: () => this.SUBRULE(this.directionStatement) },\n { ALT: () => this.SUBRULE(this.layoutStatement) },\n { ALT: () => this.SUBRULE(this.elementStatement) },\n { ALT: () => this.SUBRULE(this.descriptionStatement) },\n { ALT: () => this.SUBRULE(this.relationshipStatement) },\n { ALT: () => this.SUBRULE(this.noteStatement) },\n { ALT: () => this.SUBRULE(this.nestingStatement) },\n { ALT: () => this.SUBRULE(this.clickStatement) },\n { ALT: () => this.SUBRULE(this.metadataStatement) },\n { ALT: () => this.SUBRULE(this.connectorStatement) },\n ]);\n });\n\n // Diagram settings stay at the top level, so a block holds only model declarations.\n private readonly blockStatement = this.RULE('blockStatement', () => {\n this.OR({\n DEF: [\n { ALT: () => this.SUBRULE(this.elementStatement) },\n { ALT: () => this.SUBRULE(this.descriptionStatement) },\n { ALT: () => this.SUBRULE(this.relationshipStatement) },\n { ALT: () => this.SUBRULE(this.noteStatement) },\n { ALT: () => this.SUBRULE(this.nestingStatement) },\n { ALT: () => this.SUBRULE(this.clickStatement) },\n { ALT: () => this.SUBRULE(this.connectorStatement) },\n ],\n ERR_MSG:\n 'Expected \"}\" or a declaration inside the element block (element, description, relationship, connector, note, nest, or click).',\n });\n });\n\n private readonly connectorStatement = this.RULE('connectorStatement', () => {\n this.CONSUME(identifier, { LABEL: 'source' });\n this.CONSUME(connector, { LABEL: 'connector' });\n this.CONSUME2(identifier, { LABEL: 'target' });\n this.OPTION(() => {\n this.CONSUME(colon);\n this.CONSUME(quoted, { LABEL: 'labelText' });\n });\n });\n\n private readonly directionStatement = this.RULE('directionStatement', () => {\n this.CONSUME(direction);\n this.CONSUME(identifier, { LABEL: 'value' });\n });\n\n private readonly layoutStatement = this.RULE('layoutStatement', () => {\n this.CONSUME(layout);\n this.CONSUME(identifier, { LABEL: 'value' });\n });\n\n private readonly elementStatement = this.RULE('elementStatement', () => {\n this.CONSUME(element);\n this.CONSUME(identifier, { LABEL: 'type' });\n this.CONSUME2(identifier, { LABEL: 'id' });\n this.CONSUME(quoted, { LABEL: 'name' });\n this.OPTION(() => {\n this.CONSUME(openBrace);\n this.MANY(() => {\n this.CONSUME(newline);\n this.OPTION2(() => this.SUBRULE(this.blockStatement));\n });\n this.CONSUME(closeBrace, { ERR_MSG: 'Expected \"}\" on its own line to close the element block.' });\n });\n });\n\n private readonly clickStatement = this.RULE('clickStatement', () => {\n this.CONSUME(click);\n this.CONSUME(identifier, { LABEL: 'id' });\n this.CONSUME(href);\n this.CONSUME(quoted, { LABEL: 'url' });\n this.OPTION(() => this.CONSUME2(quoted, { LABEL: 'tooltip' }));\n this.OPTION2(() => this.CONSUME2(identifier, { LABEL: 'target' }));\n });\n\n private readonly descriptionStatement = this.RULE('descriptionStatement', () => {\n this.CONSUME(description);\n this.CONSUME(identifier, { LABEL: 'id' });\n this.CONSUME(quoted, { LABEL: 'value' });\n });\n\n private readonly relationshipStatement = this.RULE('relationshipStatement', () => {\n this.CONSUME(relationship);\n this.CONSUME(identifier, { LABEL: 'type' });\n this.CONSUME2(identifier, { LABEL: 'id' });\n this.CONSUME3(identifier, { LABEL: 'source' });\n this.CONSUME(arrow);\n this.CONSUME4(identifier, { LABEL: 'target' });\n this.OPTION(() => {\n this.CONSUME(access);\n this.CONSUME5(identifier, { LABEL: 'mode' });\n });\n this.OPTION2(() => this.CONSUME(directed));\n this.OPTION3(() => {\n this.CONSUME(label);\n this.CONSUME(quoted, { LABEL: 'labelText' });\n });\n });\n\n private readonly metadataStatement = this.RULE('metadataStatement', () => {\n this.OR([\n { ALT: () => this.CONSUME(metadata, { LABEL: 'value' }) },\n { ALT: () => this.CONSUME(accDescrBlock, { LABEL: 'value' }) },\n ]);\n });\n\n private readonly noteStatement = this.RULE('noteStatement', () => {\n this.CONSUME(note);\n this.CONSUME(identifier, { LABEL: 'id' });\n this.CONSUME(quoted, { LABEL: 'text' });\n this.OPTION(() => {\n this.CONSUME(on);\n this.CONSUME2(identifier, { LABEL: 'anchor' });\n });\n });\n\n private readonly nestingStatement = this.RULE('nestingStatement', () => {\n this.CONSUME(nest);\n this.CONSUME(identifier, { LABEL: 'child' });\n this.CONSUME(inside);\n this.CONSUME2(identifier, { LABEL: 'parent' });\n this.OPTION(() => {\n this.CONSUME(via);\n this.CONSUME3(identifier, { LABEL: 'relationshipId' });\n });\n });\n\n constructor() {\n super(tokens, { errorMessageProvider });\n this.performSelfAnalysis();\n }\n}\n\ntype Context = CstNode['children'];\nexport type Declaration =\n | { kind: 'direction'; value: IToken }\n | { kind: 'layout'; value: IToken }\n | { kind: 'metadata'; value: IToken }\n | { kind: 'element'; type: IToken; id: IToken; name: IToken }\n | { kind: 'description'; id: IToken; value: IToken }\n | { kind: 'note'; id: IToken; text: IToken; anchor?: IToken }\n | { kind: 'nesting'; child: IToken; parent: IToken; relationshipId?: IToken }\n | { kind: 'click'; id: IToken; url: IToken; tooltip?: IToken; target?: IToken }\n | RelationshipDeclaration\n | ConnectorDeclaration;\n\nexport interface RelationshipDeclaration {\n kind: 'relationship';\n type: IToken;\n id: IToken;\n source: IToken;\n target: IToken;\n mode?: IToken;\n directed?: IToken;\n label?: IToken;\n}\n\nexport interface ConnectorDeclaration {\n kind: 'connector';\n source: IToken;\n connector: IToken;\n target: IToken;\n label?: IToken;\n}\n\nfunction requiredToken(ctx: Context, name: string): IToken {\n const item = ctx[name]?.[0];\n if (!item || !('tokenType' in item)) throw new Error('Incomplete ArchiMate parse tree.');\n return item;\n}\n\nconst parser = new ArchiMateParser();\nconst BaseVisitor = parser.getBaseCstVisitorConstructor<undefined, Declaration | Declaration[]>();\n\nclass DeclarationVisitor extends BaseVisitor {\n constructor() {\n super();\n this.validateVisitor();\n }\n\n document(ctx: Context): Declaration[] {\n return (ctx.statement ?? []).flatMap((node) => {\n if (!('children' in node)) throw new Error('Invalid ArchiMate parse tree.');\n return this.visit(node);\n });\n }\n\n statement(ctx: Context): Declaration | Declaration[] {\n const child = Object.values(ctx)[0]?.[0];\n if (!child || !('children' in child)) throw new Error('Incomplete ArchiMate statement.');\n return this.visit(child);\n }\n\n directionStatement(ctx: Context): Declaration {\n return { kind: 'direction', value: requiredToken(ctx, 'value') };\n }\n\n layoutStatement(ctx: Context): Declaration {\n return { kind: 'layout', value: requiredToken(ctx, 'value') };\n }\n\n // A block nests every element declared directly inside it in the enclosing element.\n elementStatement(ctx: Context): Declaration[] {\n const parent = requiredToken(ctx, 'id');\n const declared: Declaration = {\n kind: 'element',\n type: requiredToken(ctx, 'type'),\n id: parent,\n name: requiredToken(ctx, 'name'),\n };\n const body = (ctx.blockStatement ?? []).map((node) => {\n if (!('children' in node)) throw new Error('Invalid ArchiMate parse tree.');\n return [this.visit(node)].flat();\n });\n const nesting = body.flatMap(([first]): Declaration[] =>\n first?.kind === 'element' ? [{ kind: 'nesting', child: first.id, parent }] : [],\n );\n return [declared, ...nesting, ...body.flat()];\n }\n\n blockStatement(ctx: Context): Declaration | Declaration[] {\n return this.statement(ctx);\n }\n\n clickStatement(ctx: Context): Declaration {\n return {\n kind: 'click',\n id: requiredToken(ctx, 'id'),\n url: requiredToken(ctx, 'url'),\n ...(ctx.tooltip && { tooltip: requiredToken(ctx, 'tooltip') }),\n ...(ctx.target && { target: requiredToken(ctx, 'target') }),\n };\n }\n\n descriptionStatement(ctx: Context): Declaration {\n return { kind: 'description', id: requiredToken(ctx, 'id'), value: requiredToken(ctx, 'value') };\n }\n\n relationshipStatement(ctx: Context): Declaration {\n return {\n kind: 'relationship',\n type: requiredToken(ctx, 'type'),\n id: requiredToken(ctx, 'id'),\n source: requiredToken(ctx, 'source'),\n target: requiredToken(ctx, 'target'),\n ...(ctx.mode && { mode: requiredToken(ctx, 'mode') }),\n ...(ctx.Directed && { directed: requiredToken(ctx, 'Directed') }),\n ...(ctx.labelText && { label: requiredToken(ctx, 'labelText') }),\n };\n }\n\n connectorStatement(ctx: Context): Declaration {\n return {\n kind: 'connector',\n source: requiredToken(ctx, 'source'),\n connector: requiredToken(ctx, 'connector'),\n target: requiredToken(ctx, 'target'),\n ...(ctx.labelText && { label: requiredToken(ctx, 'labelText') }),\n };\n }\n\n metadataStatement(ctx: Context): Declaration {\n return { kind: 'metadata', value: requiredToken(ctx, 'value') };\n }\n\n noteStatement(ctx: Context): Declaration {\n return {\n kind: 'note',\n id: requiredToken(ctx, 'id'),\n text: requiredToken(ctx, 'text'),\n ...(ctx.anchor && { anchor: requiredToken(ctx, 'anchor') }),\n };\n }\n\n nestingStatement(ctx: Context): Declaration {\n return {\n kind: 'nesting',\n child: requiredToken(ctx, 'child'),\n parent: requiredToken(ctx, 'parent'),\n ...(ctx.relationshipId && { relationshipId: requiredToken(ctx, 'relationshipId') }),\n };\n }\n}\n\nconst visitor = new DeclarationVisitor();\n\nexport type GrammarResult = { readonly declarations: Declaration[] } | { readonly syntaxError: IRecognitionException };\n\nexport function parseDeclarations(input: IToken[]): GrammarResult {\n parser.input = input;\n const tree = parser.document();\n const syntaxError = parser.errors[0];\n if (syntaxError) return { syntaxError };\n const declarations = visitor.visit(tree);\n if (!Array.isArray(declarations)) throw new Error('Invalid ArchiMate document parse tree.');\n return { declarations };\n}\n\nconst relationshipOptionOrder: readonly TokenType[] = [access, directed, label];\n\n// Chevrotain reports a misplaced relationship option as unexpected trailing input; name the ordering rule instead.\nexport function describeSyntaxError(error: IRecognitionException, tokens: readonly IToken[]): string {\n const rank = relationshipOptionOrder.indexOf(error.token.tokenType);\n const index = tokens.indexOf(error.token);\n if (rank < 0 || index < 0) return error.message;\n let statementStart = index;\n while (statementStart > 0 && tokens[statementStart - 1]?.tokenType !== newline) statementStart--;\n const statement = tokens.slice(statementStart, index);\n if (statement[0]?.tokenType !== relationship) return error.message;\n const later = statement.find((token) => relationshipOptionOrder.indexOf(token.tokenType) > rank);\n return later ? '\"' + error.token.image + '\" must come before \"' + later.image + '\".' : error.message;\n}\n"]}
@@ -0,0 +1,91 @@
1
+ import { Lexer } from 'chevrotain';
2
+ import type { TokenType } from 'chevrotain';
3
+ import type { AccessMode, RelationshipType } from './catalogue.js';
4
+ export declare const newline: TokenType;
5
+ export declare const openBrace: TokenType;
6
+ export declare const closeBrace: TokenType;
7
+ export declare const accDescrBlock: TokenType;
8
+ export declare const metadata: TokenType;
9
+ export declare const quotedTextPattern: RegExp;
10
+ export declare const quoted: TokenType;
11
+ export declare const arrow: TokenType;
12
+ export declare const colon: TokenType;
13
+ export declare const identifier: TokenType;
14
+ export declare const header: TokenType;
15
+ export declare const direction: TokenType;
16
+ export declare const layout: TokenType;
17
+ export declare const element: TokenType;
18
+ export declare const description: TokenType;
19
+ export declare const relationship: TokenType;
20
+ export declare const access: TokenType;
21
+ export declare const directed: TokenType;
22
+ export declare const label: TokenType;
23
+ export declare const note: TokenType;
24
+ export declare const on: TokenType;
25
+ export declare const nest: TokenType;
26
+ export declare const inside: TokenType;
27
+ export declare const via: TokenType;
28
+ export declare const click: TokenType;
29
+ export declare const href: TokenType;
30
+ export interface ConnectorNotation {
31
+ readonly type: RelationshipType;
32
+ readonly access?: AccessMode;
33
+ readonly directed?: true;
34
+ }
35
+ export declare const relationshipConnectors: {
36
+ readonly '*--': {
37
+ readonly type: "composition";
38
+ };
39
+ readonly 'o--': {
40
+ readonly type: "aggregation";
41
+ };
42
+ readonly '@==>': {
43
+ readonly type: "assignment";
44
+ };
45
+ readonly '..|>': {
46
+ readonly type: "realization";
47
+ };
48
+ readonly '-->': {
49
+ readonly type: "serving";
50
+ };
51
+ readonly '..': {
52
+ readonly type: "access";
53
+ readonly access: "unspecified";
54
+ };
55
+ readonly '<..': {
56
+ readonly type: "access";
57
+ readonly access: "read";
58
+ };
59
+ readonly '..>': {
60
+ readonly type: "access";
61
+ readonly access: "write";
62
+ };
63
+ readonly '<..>': {
64
+ readonly type: "access";
65
+ readonly access: "readWrite";
66
+ };
67
+ readonly '-.->': {
68
+ readonly type: "influence";
69
+ };
70
+ readonly '---': {
71
+ readonly type: "association";
72
+ };
73
+ readonly '--/': {
74
+ readonly type: "association";
75
+ readonly directed: true;
76
+ };
77
+ readonly '==>': {
78
+ readonly type: "triggering";
79
+ };
80
+ readonly '-.=>': {
81
+ readonly type: "flow";
82
+ };
83
+ readonly '--|>': {
84
+ readonly type: "specialization";
85
+ };
86
+ };
87
+ export declare const connector: TokenType;
88
+ export declare const connectorNotations: Map<TokenType, ConnectorNotation>;
89
+ export declare const tokens: TokenType[];
90
+ export declare const lexer: Lexer;
91
+ export declare function describeLexicalError(text: string, offset: number, length: number): string;
@@ -0,0 +1,215 @@
1
+ import { createToken, Lexer } from 'chevrotain';
2
+ const space = createToken({ name: 'Space', pattern: /[ \t]+/, group: Lexer.SKIPPED });
3
+ const comment = createToken({ name: 'Comment', pattern: /%%[^\r\n]*/, group: Lexer.SKIPPED });
4
+ export const newline = createToken({ name: 'Newline', pattern: /\r\n|\r|\n/, line_breaks: true });
5
+ const metadataPattern = /(?:title|accTitle|accDescr)[ \t]*:[^\r\n]*/y;
6
+ const accDescrBlockPattern = /accDescr[ \t]*\{[^}]*\}/y;
7
+ const aggregationPattern = /o--(?![->|/])/y;
8
+ function startsStatement(text, offset) {
9
+ for (let index = offset - 1; index >= 0 && text[index] !== '\n' && text[index] !== '\r'; index--) {
10
+ if (text[index] !== ' ' && text[index] !== '\t')
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+ // A "%%" after whitespace starts a trailing comment, as on every other statement. Double quotes keep it literal.
16
+ function metadataValueEnd(image) {
17
+ let quoted = false;
18
+ for (let index = image.indexOf(':') + 1; index < image.length; index++) {
19
+ const character = image[index];
20
+ if (quoted && character === '\\') {
21
+ index++;
22
+ }
23
+ else if (character === '"') {
24
+ quoted = !quoted;
25
+ }
26
+ else if (!quoted && character === '%' && image[index + 1] === '%' && /[ \t]/.test(image[index - 1] ?? '')) {
27
+ return index;
28
+ }
29
+ }
30
+ return image.length;
31
+ }
32
+ // Metadata only starts a line, so an element named "title" can still precede a ": label".
33
+ function matchMetadata(text, offset) {
34
+ if (!startsStatement(text, offset))
35
+ return null;
36
+ metadataPattern.lastIndex = offset;
37
+ const match = metadataPattern.exec(text);
38
+ return match ? [match[0].slice(0, metadataValueEnd(match[0]))] : null;
39
+ }
40
+ function matchAccDescrBlock(text, offset) {
41
+ if (!startsStatement(text, offset))
42
+ return null;
43
+ accDescrBlockPattern.lastIndex = offset;
44
+ return accDescrBlockPattern.exec(text);
45
+ }
46
+ // An ID "o" at the start of "o--b" must not lex as the Aggregation glyph, so the glyph needs a source before it.
47
+ function matchAggregation(text, offset) {
48
+ if (startsStatement(text, offset) || !/[ \t]/.test(text[offset - 1] ?? ''))
49
+ return null;
50
+ aggregationPattern.lastIndex = offset;
51
+ return aggregationPattern.exec(text);
52
+ }
53
+ const openBracePattern = /\{/y;
54
+ // After "accDescr" a brace starts an accessible description, which has its own token and its own error message.
55
+ function matchOpenBrace(text, offset) {
56
+ const lineStart = Math.max(text.lastIndexOf('\n', offset - 1), text.lastIndexOf('\r', offset - 1)) + 1;
57
+ if (/^[ \t]*accDescr[ \t]*$/.test(text.slice(lineStart, offset)))
58
+ return null;
59
+ openBracePattern.lastIndex = offset;
60
+ return openBracePattern.exec(text);
61
+ }
62
+ export const openBrace = createToken({
63
+ name: 'OpenBrace',
64
+ pattern: { exec: matchOpenBrace },
65
+ line_breaks: false,
66
+ start_chars_hint: ['{'],
67
+ label: '"{"',
68
+ });
69
+ export const closeBrace = createToken({ name: 'CloseBrace', pattern: /\}/, label: '"}"' });
70
+ export const accDescrBlock = createToken({
71
+ name: 'AccDescrBlock',
72
+ pattern: { exec: matchAccDescrBlock },
73
+ line_breaks: true,
74
+ start_chars_hint: ['a'],
75
+ });
76
+ export const metadata = createToken({
77
+ name: 'Metadata',
78
+ pattern: { exec: matchMetadata },
79
+ line_breaks: false,
80
+ start_chars_hint: ['t', 'a'],
81
+ });
82
+ // eslint-disable-next-line no-control-regex -- JSON strings exclude unescaped control characters.
83
+ export const quotedTextPattern = /"(?:[^"\\\u0000-\u001F]|\\(?:["\\/bfnrt]|u[\da-fA-F]{4}))*"/;
84
+ export const quoted = createToken({
85
+ name: 'QuotedText',
86
+ pattern: quotedTextPattern,
87
+ line_breaks: false,
88
+ label: 'quoted text',
89
+ });
90
+ export const arrow = createToken({ name: 'Arrow', pattern: /->/, label: '"->"' });
91
+ export const colon = createToken({ name: 'Colon', pattern: /:/, label: '":"' });
92
+ export const identifier = createToken({ name: 'Identifier', pattern: /[a-zA-Z_]\w*(?:-\w+)*/, label: 'identifier' });
93
+ export const header = createToken({ name: 'Header', pattern: /archimate-beta(?![\w-])/, categories: identifier });
94
+ function keyword(name, text) {
95
+ return createToken({ name, pattern: new RegExp(text), longer_alt: identifier, categories: identifier });
96
+ }
97
+ export const direction = keyword('Direction', 'direction');
98
+ export const layout = keyword('Layout', 'layout');
99
+ export const element = keyword('Element', 'element');
100
+ export const description = keyword('Description', 'description');
101
+ export const relationship = keyword('Relationship', 'relationship');
102
+ export const access = keyword('Access', 'access');
103
+ export const directed = keyword('Directed', 'directed');
104
+ export const label = keyword('Label', 'label');
105
+ export const note = keyword('Note', 'note');
106
+ export const on = keyword('On', 'on');
107
+ export const nest = keyword('Nest', 'nest');
108
+ export const inside = keyword('In', 'in');
109
+ export const via = keyword('Via', 'via');
110
+ export const click = keyword('Click', 'click');
111
+ export const href = keyword('Href', 'href');
112
+ // The left endpoint is always the model source; glyphs mirror the rendered markers.
113
+ export const relationshipConnectors = {
114
+ '*--': { type: 'composition' },
115
+ 'o--': { type: 'aggregation' },
116
+ '@==>': { type: 'assignment' },
117
+ '..|>': { type: 'realization' },
118
+ '-->': { type: 'serving' },
119
+ '..': { type: 'access', access: 'unspecified' },
120
+ '<..': { type: 'access', access: 'read' },
121
+ '..>': { type: 'access', access: 'write' },
122
+ '<..>': { type: 'access', access: 'readWrite' },
123
+ '-.->': { type: 'influence' },
124
+ '---': { type: 'association' },
125
+ '--/': { type: 'association', directed: true },
126
+ '==>': { type: 'triggering' },
127
+ '-.=>': { type: 'flow' },
128
+ '--|>': { type: 'specialization' },
129
+ };
130
+ export const connector = createToken({ name: 'Connector', pattern: Lexer.NA, label: 'relationship connector' });
131
+ export const connectorNotations = new Map();
132
+ const connectorTokens = Object.entries(relationshipConnectors)
133
+ .sort(([left], [right]) => right.length - left.length)
134
+ .map(([glyph, notation], index) => {
135
+ const tokenLabel = '"' + glyph + '"';
136
+ const token = glyph === 'o--'
137
+ ? createToken({
138
+ name: `Connector${index}`,
139
+ pattern: { exec: matchAggregation },
140
+ line_breaks: false,
141
+ start_chars_hint: ['o'],
142
+ label: tokenLabel,
143
+ categories: connector,
144
+ })
145
+ : createToken({
146
+ name: `Connector${index}`,
147
+ pattern: new RegExp(glyph.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')),
148
+ label: tokenLabel,
149
+ categories: connector,
150
+ });
151
+ connectorNotations.set(token, notation);
152
+ return token;
153
+ });
154
+ export const tokens = [
155
+ space,
156
+ comment,
157
+ newline,
158
+ header,
159
+ accDescrBlock,
160
+ metadata,
161
+ quoted,
162
+ connector,
163
+ ...connectorTokens,
164
+ arrow,
165
+ colon,
166
+ openBrace,
167
+ closeBrace,
168
+ direction,
169
+ layout,
170
+ element,
171
+ description,
172
+ relationship,
173
+ access,
174
+ directed,
175
+ label,
176
+ note,
177
+ on,
178
+ nest,
179
+ inside,
180
+ via,
181
+ click,
182
+ href,
183
+ identifier,
184
+ ];
185
+ export const lexer = new Lexer(tokens);
186
+ // eslint-disable-next-line no-control-regex -- JSON strings exclude unescaped control characters.
187
+ const quotedTextPrefix = /(?:[^"\\\u0000-\u001F]|\\(?:["\\/bfnrt]|u[\da-fA-F]{4}))*/y;
188
+ function describeInvalidQuotedText(text, offset) {
189
+ quotedTextPrefix.lastIndex = offset + 1;
190
+ quotedTextPrefix.exec(text);
191
+ const end = quotedTextPrefix.lastIndex;
192
+ const character = text[end];
193
+ if (character === undefined || character === '\n' || character === '\r') {
194
+ return 'Text is missing its closing double quote.';
195
+ }
196
+ if (character === '\\') {
197
+ return 'Text contains the invalid escape sequence "' + text.slice(end, end + 2) + '". Use "\\\\" for a backslash.';
198
+ }
199
+ return 'Text contains a control character. Use an escape sequence such as "\\t" instead.';
200
+ }
201
+ export function describeLexicalError(text, offset, length) {
202
+ const skipped = text.slice(offset, offset + length);
203
+ const first = String.fromCodePoint(text.codePointAt(offset) ?? 0xfffd);
204
+ if (first === "'")
205
+ return 'Unexpected character "\'". Use double quotes for text.';
206
+ if (first === '"')
207
+ return describeInvalidQuotedText(text, offset);
208
+ if (first === '{' && /(?:^|[\r\n])[ \t]*accDescr[ \t]*$/.test(text.slice(0, offset))) {
209
+ return 'The accDescr block is missing its closing "}".';
210
+ }
211
+ if (/^[-.=<>@*|/]+$/.test(skipped))
212
+ return '"' + skipped + '" is not a relationship connector.';
213
+ return 'Unexpected character "' + first + '".';
214
+ }
215
+ //# sourceMappingURL=lexer.js.map