@mermanjs/tree-sitter-mermaid 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.
- package/CMakeLists.txt +44 -0
- package/LICENSE +22 -0
- package/Makefile +80 -0
- package/README.md +201 -0
- package/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/monaqa-tree-sitter-mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/pappasam-tree-sitter-mermaid/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/singularity-tree-sitter-mermaid/LICENSE +22 -0
- package/THIRD_PARTY_LICENSES/tree-sitter/LICENSE +21 -0
- package/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.md +47 -0
- package/binding.gyp +56 -0
- package/bindings/c/tree-sitter-mermaid.pc.in +10 -0
- package/bindings/c/tree_sitter/tree-sitter-mermaid.h +16 -0
- package/bindings/node/binding.cc +25 -0
- package/bindings/node/index.d.ts +5 -0
- package/bindings/node/index.js +10 -0
- package/grammar/families/architecture.js +361 -0
- package/grammar/families/block.js +370 -0
- package/grammar/families/c4.js +394 -0
- package/grammar/families/class.js +441 -0
- package/grammar/families/cynefin.js +127 -0
- package/grammar/families/entity-relationship.js +408 -0
- package/grammar/families/event-modeling.js +307 -0
- package/grammar/families/flowchart.js +690 -0
- package/grammar/families/gantt.js +445 -0
- package/grammar/families/git-graph.js +326 -0
- package/grammar/families/info.js +77 -0
- package/grammar/families/ishikawa.js +103 -0
- package/grammar/families/journey.js +221 -0
- package/grammar/families/kanban.js +264 -0
- package/grammar/families/mindmap.js +221 -0
- package/grammar/families/packet.js +108 -0
- package/grammar/families/pie.js +118 -0
- package/grammar/families/quadrant-chart.js +385 -0
- package/grammar/families/radar.js +286 -0
- package/grammar/families/railroad-abnf.js +124 -0
- package/grammar/families/railroad-ebnf.js +179 -0
- package/grammar/families/railroad-peg.js +128 -0
- package/grammar/families/railroad-shared.js +114 -0
- package/grammar/families/railroad.js +143 -0
- package/grammar/families/requirement.js +475 -0
- package/grammar/families/sankey.js +139 -0
- package/grammar/families/sequence.js +437 -0
- package/grammar/families/state.js +400 -0
- package/grammar/families/swimlane.js +25 -0
- package/grammar/families/timeline.js +251 -0
- package/grammar/families/tree-view.js +189 -0
- package/grammar/families/treemap.js +146 -0
- package/grammar/families/venn.js +256 -0
- package/grammar/families/wardley.js +530 -0
- package/grammar/families/xy-chart.js +460 -0
- package/grammar/families/zenuml.js +725 -0
- package/grammar/shared/common.js +78 -0
- package/grammar/shared/header.js +16 -0
- package/grammar/shared/indentation.js +22 -0
- package/grammar/shared/langium.js +166 -0
- package/grammar/shared/preamble.js +26 -0
- package/grammar.js +188 -0
- package/metadata/derivations.json +519 -0
- package/metadata/provenance.json +98 -0
- package/package.json +107 -0
- package/prebuilds/darwin-arm64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/darwin-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/linux-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/prebuilds/win32-x64/@mermanjs+tree-sitter-mermaid.node +0 -0
- package/queries/helix/highlights.scm +960 -0
- package/queries/helix/indents.scm +45 -0
- package/queries/helix/injections.scm +15 -0
- package/queries/helix/locals.scm +134 -0
- package/queries/helix/textobjects.scm +264 -0
- package/queries/neovim/README.md +28 -0
- package/queries/neovim/brackets.scm +65 -0
- package/queries/neovim/folds.scm +53 -0
- package/queries/neovim/highlights.scm +121 -0
- package/queries/neovim/indents.scm +110 -0
- package/queries/neovim/injections.scm +86 -0
- package/queries/neovim/locals.scm +277 -0
- package/queries/neovim/outline.scm +117 -0
- package/queries/neovim/tags.scm +149 -0
- package/queries/neovim/textobjects.scm +97 -0
- package/queries/portable/highlights.scm +961 -0
- package/queries/portable/injections.scm +45 -0
- package/queries/portable/locals.scm +290 -0
- package/queries/portable/tags.scm +182 -0
- package/queries/zed/README.md +48 -0
- package/queries/zed/brackets.scm +111 -0
- package/queries/zed/highlights.scm +961 -0
- package/queries/zed/indents.scm +111 -0
- package/queries/zed/injections.scm +11 -0
- package/queries/zed/outline.scm +167 -0
- package/queries/zed/textobjects.scm +68 -0
- package/src/grammar.json +71138 -0
- package/src/node-types.json +34871 -0
- package/src/parser.c +321353 -0
- package/src/scanner.c +462 -0
- package/src/tree_sitter/alloc.h +54 -0
- package/src/tree_sitter/array.h +336 -0
- package/src/tree_sitter/parser.h +286 -0
- package/tree-sitter-mermaid.wasm +0 -0
- package/tree-sitter.json +40 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// Source translation:
|
|
2
|
+
// Mermaid 11.16.1 packages/parser/src/language/architecture/{architecture,arch}.langium
|
|
3
|
+
|
|
4
|
+
const diagramKeyword = ($) => field(
|
|
5
|
+
'keyword',
|
|
6
|
+
alias(token(prec(20, 'architecture-beta')), $.diagram_keyword),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const statementKeyword = ($, keyword) => field(
|
|
10
|
+
'keyword',
|
|
11
|
+
alias(token(keyword), $.statement_keyword),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const alignmentKeyword = ($) => field(
|
|
15
|
+
'keyword',
|
|
16
|
+
alias(token('align'), $.statement_keyword),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const architectureRules = {
|
|
20
|
+
architecture_diagram: ($) => seq(
|
|
21
|
+
field('header', $.architecture_header),
|
|
22
|
+
optional(seq(
|
|
23
|
+
choice(
|
|
24
|
+
$._langium_inline_space,
|
|
25
|
+
$._line_ending,
|
|
26
|
+
$.comment,
|
|
27
|
+
$.directive,
|
|
28
|
+
),
|
|
29
|
+
optional(field('body', $.architecture_body)),
|
|
30
|
+
)),
|
|
31
|
+
),
|
|
32
|
+
|
|
33
|
+
architecture_header: ($) => seq(
|
|
34
|
+
diagramKeyword($),
|
|
35
|
+
),
|
|
36
|
+
|
|
37
|
+
architecture_body: ($) => choice(
|
|
38
|
+
repeat1($._architecture_line_item),
|
|
39
|
+
seq(
|
|
40
|
+
repeat($._architecture_line_item),
|
|
41
|
+
$._architecture_eof_item,
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
|
|
45
|
+
_architecture_line_item: ($) => choice(
|
|
46
|
+
seq(
|
|
47
|
+
$._architecture_statement,
|
|
48
|
+
optional(choice($.comment, $.directive)),
|
|
49
|
+
$._line_ending,
|
|
50
|
+
),
|
|
51
|
+
seq(choice($.comment, $.directive), $._line_ending),
|
|
52
|
+
$._blank_line,
|
|
53
|
+
),
|
|
54
|
+
|
|
55
|
+
_architecture_eof_item: ($) => choice(
|
|
56
|
+
seq($._architecture_statement, optional(choice($.comment, $.directive))),
|
|
57
|
+
$.comment,
|
|
58
|
+
$.directive,
|
|
59
|
+
),
|
|
60
|
+
|
|
61
|
+
_architecture_statement: ($) => choice(
|
|
62
|
+
$.architecture_title_statement,
|
|
63
|
+
$.architecture_accessibility_title_statement,
|
|
64
|
+
$.architecture_accessibility_description_statement,
|
|
65
|
+
$.architecture_group_statement,
|
|
66
|
+
$.architecture_service_statement,
|
|
67
|
+
$.architecture_junction_statement,
|
|
68
|
+
$.architecture_alignment_statement,
|
|
69
|
+
$.architecture_edge_statement,
|
|
70
|
+
$.architecture_malformed_edge_statement,
|
|
71
|
+
),
|
|
72
|
+
|
|
73
|
+
architecture_title_statement: ($) => prec.right(seq(
|
|
74
|
+
statementKeyword($, 'title'),
|
|
75
|
+
optional(seq(
|
|
76
|
+
token.immediate(/[ \t]+/),
|
|
77
|
+
optional(field('text', $.architecture_line_text)),
|
|
78
|
+
)),
|
|
79
|
+
)),
|
|
80
|
+
|
|
81
|
+
architecture_accessibility_title_statement: ($) => prec.right(seq(
|
|
82
|
+
statementKeyword($, 'accTitle'),
|
|
83
|
+
field('separator', ':'),
|
|
84
|
+
optional(field('text', $.architecture_line_text)),
|
|
85
|
+
)),
|
|
86
|
+
|
|
87
|
+
architecture_accessibility_description_statement: ($) => prec.right(choice(
|
|
88
|
+
seq(
|
|
89
|
+
statementKeyword($, 'accDescr'),
|
|
90
|
+
field('block', $.architecture_accessibility_description_block),
|
|
91
|
+
),
|
|
92
|
+
seq(
|
|
93
|
+
statementKeyword($, 'accDescr'),
|
|
94
|
+
field('separator', ':'),
|
|
95
|
+
optional(field('text', $.architecture_line_text)),
|
|
96
|
+
),
|
|
97
|
+
)),
|
|
98
|
+
|
|
99
|
+
architecture_accessibility_description_block: ($) => seq(
|
|
100
|
+
repeat($._line_ending),
|
|
101
|
+
'{',
|
|
102
|
+
optional(field('text', $.architecture_accessibility_text)),
|
|
103
|
+
'}',
|
|
104
|
+
),
|
|
105
|
+
|
|
106
|
+
architecture_group_statement: ($) => prec(20, seq(
|
|
107
|
+
statementKeyword($, 'group'),
|
|
108
|
+
field('id', $._architecture_identifier),
|
|
109
|
+
optional(field('icon', $.architecture_icon)),
|
|
110
|
+
optional(field('title', choice(
|
|
111
|
+
$.architecture_title,
|
|
112
|
+
$.architecture_unclosed_title,
|
|
113
|
+
))),
|
|
114
|
+
optional(field('parent', $.architecture_parent_clause)),
|
|
115
|
+
)),
|
|
116
|
+
|
|
117
|
+
architecture_service_statement: ($) => prec(20, seq(
|
|
118
|
+
statementKeyword($, 'service'),
|
|
119
|
+
field('id', $._architecture_identifier),
|
|
120
|
+
optional(choice(
|
|
121
|
+
field('icon_text', $.architecture_quoted_string),
|
|
122
|
+
field('icon_text', $.architecture_unclosed_quoted_string),
|
|
123
|
+
field('icon', $.architecture_icon),
|
|
124
|
+
)),
|
|
125
|
+
optional(field('title', choice(
|
|
126
|
+
$.architecture_title,
|
|
127
|
+
$.architecture_unclosed_title,
|
|
128
|
+
))),
|
|
129
|
+
optional(field('parent', $.architecture_parent_clause)),
|
|
130
|
+
)),
|
|
131
|
+
|
|
132
|
+
architecture_junction_statement: ($) => prec(20, seq(
|
|
133
|
+
statementKeyword($, 'junction'),
|
|
134
|
+
field('id', $._architecture_identifier),
|
|
135
|
+
optional(field('parent', $.architecture_parent_clause)),
|
|
136
|
+
)),
|
|
137
|
+
|
|
138
|
+
architecture_alignment_statement: ($) => prec(20, seq(
|
|
139
|
+
alignmentKeyword($),
|
|
140
|
+
token.immediate(/[ \t]+/),
|
|
141
|
+
field('direction', $.architecture_alignment_direction),
|
|
142
|
+
field('member', $._architecture_identifier),
|
|
143
|
+
repeat1(field('member', $._architecture_identifier)),
|
|
144
|
+
)),
|
|
145
|
+
|
|
146
|
+
architecture_parent_clause: ($) => seq(
|
|
147
|
+
field(
|
|
148
|
+
'keyword',
|
|
149
|
+
alias(token('in'), $.statement_keyword),
|
|
150
|
+
),
|
|
151
|
+
field('parent', $._architecture_identifier),
|
|
152
|
+
),
|
|
153
|
+
|
|
154
|
+
architecture_edge_statement: ($) => prec(30, seq(
|
|
155
|
+
field('source', $.architecture_edge_endpoint),
|
|
156
|
+
field('source_port', $.architecture_left_port),
|
|
157
|
+
field('arrow', $.architecture_arrow),
|
|
158
|
+
field('target_port', $.architecture_right_port),
|
|
159
|
+
field('target', $.architecture_edge_endpoint),
|
|
160
|
+
)),
|
|
161
|
+
|
|
162
|
+
architecture_malformed_edge_statement: ($) => prec(-20, seq(
|
|
163
|
+
field('source', $.architecture_edge_endpoint),
|
|
164
|
+
field('source_port', $.architecture_left_port),
|
|
165
|
+
field('recovery', $.architecture_edge_recovery),
|
|
166
|
+
)),
|
|
167
|
+
|
|
168
|
+
architecture_edge_recovery: ($) => choice(
|
|
169
|
+
field('arrow', $.architecture_arrow),
|
|
170
|
+
seq(
|
|
171
|
+
optional(field('arrow', $.architecture_arrow)),
|
|
172
|
+
field('text', $._architecture_edge_recovery_text),
|
|
173
|
+
),
|
|
174
|
+
),
|
|
175
|
+
|
|
176
|
+
architecture_edge_endpoint: ($) => seq(
|
|
177
|
+
field('id', $._architecture_identifier),
|
|
178
|
+
optional(field('group', $.architecture_group_modifier)),
|
|
179
|
+
),
|
|
180
|
+
|
|
181
|
+
architecture_left_port: ($) => seq(
|
|
182
|
+
field('delimiter', ':'),
|
|
183
|
+
field('direction', $.architecture_port_direction),
|
|
184
|
+
),
|
|
185
|
+
|
|
186
|
+
architecture_right_port: ($) => seq(
|
|
187
|
+
field('direction', $.architecture_port_direction),
|
|
188
|
+
field('delimiter', ':'),
|
|
189
|
+
),
|
|
190
|
+
|
|
191
|
+
architecture_arrow: ($) => seq(
|
|
192
|
+
optional(field('source_arrowhead', $.architecture_arrowhead)),
|
|
193
|
+
field('connector', choice(
|
|
194
|
+
$.architecture_plain_connector,
|
|
195
|
+
$.architecture_titled_connector,
|
|
196
|
+
)),
|
|
197
|
+
optional(field('target_arrowhead', $.architecture_arrowhead)),
|
|
198
|
+
),
|
|
199
|
+
|
|
200
|
+
architecture_plain_connector: (_) => '--',
|
|
201
|
+
|
|
202
|
+
architecture_titled_connector: ($) => seq(
|
|
203
|
+
'-',
|
|
204
|
+
field('title', $.architecture_title),
|
|
205
|
+
'-',
|
|
206
|
+
),
|
|
207
|
+
|
|
208
|
+
architecture_arrowhead: (_) => choice('<', '>'),
|
|
209
|
+
|
|
210
|
+
architecture_group_modifier: (_) => token('{group}'),
|
|
211
|
+
|
|
212
|
+
architecture_port_direction: (_) => choice('L', 'R', 'T', 'B'),
|
|
213
|
+
|
|
214
|
+
architecture_alignment_direction: (_) => token.immediate(choice('row', 'column')),
|
|
215
|
+
|
|
216
|
+
architecture_icon: ($) => seq(
|
|
217
|
+
'(',
|
|
218
|
+
field('name', $.architecture_icon_name),
|
|
219
|
+
token.immediate(')'),
|
|
220
|
+
),
|
|
221
|
+
|
|
222
|
+
architecture_title: ($) => seq(
|
|
223
|
+
'[',
|
|
224
|
+
field('text', choice(
|
|
225
|
+
alias($._architecture_title_quoted_string, $.architecture_quoted_string),
|
|
226
|
+
$.architecture_bare_title,
|
|
227
|
+
)),
|
|
228
|
+
token.immediate(']'),
|
|
229
|
+
),
|
|
230
|
+
|
|
231
|
+
architecture_unclosed_title: ($) => seq(
|
|
232
|
+
'[',
|
|
233
|
+
field(
|
|
234
|
+
'recovery',
|
|
235
|
+
alias(
|
|
236
|
+
$._architecture_title_unclosed_quoted_string,
|
|
237
|
+
$.architecture_unclosed_quoted_string,
|
|
238
|
+
),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
|
|
242
|
+
_architecture_title_quoted_string: ($) => prec.dynamic(10, choice(
|
|
243
|
+
seq(
|
|
244
|
+
token.immediate('"'),
|
|
245
|
+
repeat(choice(
|
|
246
|
+
$._architecture_double_quoted_content,
|
|
247
|
+
$._architecture_escape_sequence,
|
|
248
|
+
$._line_ending,
|
|
249
|
+
)),
|
|
250
|
+
token.immediate('"'),
|
|
251
|
+
),
|
|
252
|
+
seq(
|
|
253
|
+
token.immediate("'"),
|
|
254
|
+
repeat(choice(
|
|
255
|
+
$._architecture_single_quoted_content,
|
|
256
|
+
$._architecture_escape_sequence,
|
|
257
|
+
$._line_ending,
|
|
258
|
+
)),
|
|
259
|
+
token.immediate("'"),
|
|
260
|
+
),
|
|
261
|
+
)),
|
|
262
|
+
|
|
263
|
+
_architecture_title_unclosed_quoted_string: ($) => prec.dynamic(-10, choice(
|
|
264
|
+
seq(
|
|
265
|
+
token.immediate('"'),
|
|
266
|
+
repeat(choice(
|
|
267
|
+
$._architecture_double_quoted_content,
|
|
268
|
+
$._architecture_escape_sequence,
|
|
269
|
+
)),
|
|
270
|
+
),
|
|
271
|
+
seq(
|
|
272
|
+
token.immediate("'"),
|
|
273
|
+
repeat(choice(
|
|
274
|
+
$._architecture_single_quoted_content,
|
|
275
|
+
$._architecture_escape_sequence,
|
|
276
|
+
)),
|
|
277
|
+
),
|
|
278
|
+
)),
|
|
279
|
+
|
|
280
|
+
architecture_quoted_string: ($) => prec.dynamic(10, choice(
|
|
281
|
+
seq(
|
|
282
|
+
'"',
|
|
283
|
+
repeat(choice(
|
|
284
|
+
$._architecture_double_quoted_content,
|
|
285
|
+
$._architecture_escape_sequence,
|
|
286
|
+
$._line_ending,
|
|
287
|
+
)),
|
|
288
|
+
'"',
|
|
289
|
+
),
|
|
290
|
+
seq(
|
|
291
|
+
"'",
|
|
292
|
+
repeat(choice(
|
|
293
|
+
$._architecture_single_quoted_content,
|
|
294
|
+
$._architecture_escape_sequence,
|
|
295
|
+
$._line_ending,
|
|
296
|
+
)),
|
|
297
|
+
"'",
|
|
298
|
+
),
|
|
299
|
+
)),
|
|
300
|
+
|
|
301
|
+
architecture_unclosed_quoted_string: ($) => prec.dynamic(-10, choice(
|
|
302
|
+
seq(
|
|
303
|
+
'"',
|
|
304
|
+
repeat(choice(
|
|
305
|
+
$._architecture_double_quoted_content,
|
|
306
|
+
$._architecture_escape_sequence,
|
|
307
|
+
)),
|
|
308
|
+
),
|
|
309
|
+
seq(
|
|
310
|
+
"'",
|
|
311
|
+
repeat(choice(
|
|
312
|
+
$._architecture_single_quoted_content,
|
|
313
|
+
$._architecture_escape_sequence,
|
|
314
|
+
)),
|
|
315
|
+
),
|
|
316
|
+
)),
|
|
317
|
+
|
|
318
|
+
architecture_line_text: ($) => repeat1(choice(
|
|
319
|
+
$._architecture_line_text_fragment,
|
|
320
|
+
'%',
|
|
321
|
+
)),
|
|
322
|
+
|
|
323
|
+
architecture_identifier: (_) => token(prec(
|
|
324
|
+
0,
|
|
325
|
+
/[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?/,
|
|
326
|
+
)),
|
|
327
|
+
|
|
328
|
+
architecture_malformed_reserved_identifier: (_) => choice(
|
|
329
|
+
'align',
|
|
330
|
+
'row',
|
|
331
|
+
'column',
|
|
332
|
+
),
|
|
333
|
+
|
|
334
|
+
_architecture_identifier: ($) => choice(
|
|
335
|
+
$.architecture_malformed_reserved_identifier,
|
|
336
|
+
$.architecture_identifier,
|
|
337
|
+
),
|
|
338
|
+
|
|
339
|
+
architecture_icon_name: (_) => token.immediate(/[A-Za-z0-9_:-]+/),
|
|
340
|
+
|
|
341
|
+
architecture_bare_title: (_) => token.immediate(prec(-1, /[A-Za-z0-9_ ]+/)),
|
|
342
|
+
|
|
343
|
+
architecture_accessibility_text: (_) => token(prec(-5, /[^}]+/)),
|
|
344
|
+
|
|
345
|
+
_architecture_double_quoted_content: (_) => token.immediate(/[^"\\\r\n]+/),
|
|
346
|
+
|
|
347
|
+
_architecture_single_quoted_content: (_) => token.immediate(/[^'\\\r\n]+/),
|
|
348
|
+
|
|
349
|
+
_architecture_escape_sequence: (_) => token.immediate(/\\[^\r\n]/),
|
|
350
|
+
|
|
351
|
+
_architecture_line_text_fragment: (_) => token(prec(-5, /[^%\r\n]+/)),
|
|
352
|
+
|
|
353
|
+
_architecture_edge_recovery_text: (_) => token(prec(-100, /[^\r\n]+/)),
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const architectureConflicts = ($) => [
|
|
357
|
+
[$.architecture_quoted_string, $.architecture_unclosed_quoted_string],
|
|
358
|
+
[$._architecture_title_quoted_string, $._architecture_title_unclosed_quoted_string],
|
|
359
|
+
];
|
|
360
|
+
|
|
361
|
+
module.exports = { architectureConflicts, architectureRules };
|