@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,326 @@
|
|
|
1
|
+
// Translated from Mermaid 11.16.1 at commit
|
|
2
|
+
// 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf:
|
|
3
|
+
// packages/parser/src/language/gitGraph/{gitGraph,reference}.langium.
|
|
4
|
+
|
|
5
|
+
const statementKeyword = ($, keyword) => field(
|
|
6
|
+
'keyword',
|
|
7
|
+
alias(keyword, $.git_graph_statement_keyword),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const clauseKeyword = ($, keyword) => field(
|
|
11
|
+
'keyword',
|
|
12
|
+
alias(keyword, $.git_graph_clause_keyword),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const clauseSeparator = ($) => field(
|
|
16
|
+
'separator',
|
|
17
|
+
alias(token.immediate(':'), $.git_graph_clause_separator),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const quotedClause = ($, keyword, fieldName) => seq(
|
|
21
|
+
clauseKeyword($, keyword),
|
|
22
|
+
clauseSeparator($),
|
|
23
|
+
optional($._langium_inline_space),
|
|
24
|
+
field(fieldName, choice($.langium_string, $.langium_unclosed_string)),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const gitGraphRules = {
|
|
28
|
+
git_graph_diagram: ($) => choice(
|
|
29
|
+
seq(
|
|
30
|
+
field('header', alias($._git_graph_colon_header, $.git_graph_header)),
|
|
31
|
+
optional(field('body', $.git_graph_body)),
|
|
32
|
+
),
|
|
33
|
+
seq(
|
|
34
|
+
field('header', $.git_graph_header),
|
|
35
|
+
optional(seq(
|
|
36
|
+
$._langium_body_boundary,
|
|
37
|
+
optional(field('body', $.git_graph_body)),
|
|
38
|
+
)),
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
|
|
42
|
+
git_graph_header: ($) => field(
|
|
43
|
+
'keyword',
|
|
44
|
+
alias(token(prec(20, 'gitGraph')), $.diagram_keyword),
|
|
45
|
+
),
|
|
46
|
+
|
|
47
|
+
_git_graph_colon_header: ($) => seq(
|
|
48
|
+
field(
|
|
49
|
+
'keyword',
|
|
50
|
+
alias(token(prec(20, 'gitGraph')), $.diagram_keyword),
|
|
51
|
+
),
|
|
52
|
+
choice(
|
|
53
|
+
field(
|
|
54
|
+
'separator',
|
|
55
|
+
alias(token.immediate(':'), $.git_graph_header_separator),
|
|
56
|
+
),
|
|
57
|
+
seq(
|
|
58
|
+
$._langium_inline_space,
|
|
59
|
+
choice(
|
|
60
|
+
field(
|
|
61
|
+
'separator',
|
|
62
|
+
alias(token.immediate(':'), $.git_graph_header_separator),
|
|
63
|
+
),
|
|
64
|
+
seq(
|
|
65
|
+
field(
|
|
66
|
+
'direction',
|
|
67
|
+
alias(token.immediate(/(?:LR|TB|BT)/), $.git_graph_direction),
|
|
68
|
+
),
|
|
69
|
+
optional($._langium_inline_space),
|
|
70
|
+
field(
|
|
71
|
+
'separator',
|
|
72
|
+
alias(token.immediate(':'), $.git_graph_header_separator),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
),
|
|
79
|
+
|
|
80
|
+
git_graph_body: ($) => choice(
|
|
81
|
+
repeat1($._git_graph_terminated_body_item),
|
|
82
|
+
seq(
|
|
83
|
+
repeat($._git_graph_terminated_body_item),
|
|
84
|
+
$._git_graph_eof_body_item,
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
|
|
88
|
+
_git_graph_terminated_body_item: ($) => choice(
|
|
89
|
+
$._langium_newline,
|
|
90
|
+
seq($.comment, $._langium_newline),
|
|
91
|
+
seq($.directive, $._langium_newline),
|
|
92
|
+
seq($.langium_title_statement, $._langium_newline),
|
|
93
|
+
seq($.langium_acc_title_statement, $._langium_newline),
|
|
94
|
+
seq($.langium_acc_descr_statement, $._langium_newline),
|
|
95
|
+
seq(
|
|
96
|
+
$._git_graph_statement,
|
|
97
|
+
optional(choice(
|
|
98
|
+
field('comment', $.comment),
|
|
99
|
+
field('directive', $.directive),
|
|
100
|
+
)),
|
|
101
|
+
$._langium_newline,
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
|
|
105
|
+
_git_graph_eof_body_item: ($) => choice(
|
|
106
|
+
$.comment,
|
|
107
|
+
$.directive,
|
|
108
|
+
$.langium_title_statement,
|
|
109
|
+
$.langium_acc_title_statement,
|
|
110
|
+
$.langium_acc_descr_statement,
|
|
111
|
+
seq(
|
|
112
|
+
$._git_graph_statement,
|
|
113
|
+
optional(choice(
|
|
114
|
+
field('comment', $.comment),
|
|
115
|
+
field('directive', $.directive),
|
|
116
|
+
)),
|
|
117
|
+
),
|
|
118
|
+
),
|
|
119
|
+
|
|
120
|
+
_git_graph_statement: ($) => choice(
|
|
121
|
+
$.git_graph_commit_statement,
|
|
122
|
+
$.git_graph_branch_statement,
|
|
123
|
+
$.git_graph_incomplete_branch_statement,
|
|
124
|
+
$.git_graph_merge_statement,
|
|
125
|
+
$.git_graph_incomplete_merge_statement,
|
|
126
|
+
$.git_graph_checkout_statement,
|
|
127
|
+
$.git_graph_incomplete_checkout_statement,
|
|
128
|
+
$.git_graph_cherry_pick_statement,
|
|
129
|
+
$.git_graph_malformed_statement,
|
|
130
|
+
),
|
|
131
|
+
|
|
132
|
+
git_graph_commit_statement: ($) => prec.right(seq(
|
|
133
|
+
statementKeyword($, 'commit'),
|
|
134
|
+
optional(seq(
|
|
135
|
+
$._langium_inline_space,
|
|
136
|
+
choice(
|
|
137
|
+
$.git_graph_id_clause,
|
|
138
|
+
$.git_graph_message_clause,
|
|
139
|
+
$.git_graph_tag_clause,
|
|
140
|
+
$.git_graph_type_clause,
|
|
141
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
142
|
+
),
|
|
143
|
+
repeat(seq(
|
|
144
|
+
$._langium_inline_space,
|
|
145
|
+
choice(
|
|
146
|
+
$.git_graph_id_clause,
|
|
147
|
+
$.git_graph_message_clause,
|
|
148
|
+
$.git_graph_tag_clause,
|
|
149
|
+
$.git_graph_type_clause,
|
|
150
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
151
|
+
),
|
|
152
|
+
)),
|
|
153
|
+
)),
|
|
154
|
+
)),
|
|
155
|
+
|
|
156
|
+
git_graph_branch_statement: ($) => prec.right(seq(
|
|
157
|
+
statementKeyword($, 'branch'),
|
|
158
|
+
$._langium_inline_space,
|
|
159
|
+
field('name', choice(
|
|
160
|
+
$.git_graph_reference,
|
|
161
|
+
$.langium_string,
|
|
162
|
+
$.langium_unclosed_string,
|
|
163
|
+
)),
|
|
164
|
+
optional(seq(
|
|
165
|
+
$._langium_inline_space,
|
|
166
|
+
choice(
|
|
167
|
+
field('order', $.git_graph_order_clause),
|
|
168
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
169
|
+
),
|
|
170
|
+
)),
|
|
171
|
+
)),
|
|
172
|
+
|
|
173
|
+
git_graph_incomplete_branch_statement: ($) => prec(
|
|
174
|
+
-10,
|
|
175
|
+
statementKeyword($, 'branch'),
|
|
176
|
+
),
|
|
177
|
+
|
|
178
|
+
git_graph_merge_statement: ($) => prec.right(seq(
|
|
179
|
+
statementKeyword($, 'merge'),
|
|
180
|
+
$._langium_inline_space,
|
|
181
|
+
field('branch', choice(
|
|
182
|
+
$.git_graph_reference,
|
|
183
|
+
$.langium_string,
|
|
184
|
+
$.langium_unclosed_string,
|
|
185
|
+
)),
|
|
186
|
+
repeat(seq(
|
|
187
|
+
$._langium_inline_space,
|
|
188
|
+
choice(
|
|
189
|
+
$.git_graph_id_clause,
|
|
190
|
+
$.git_graph_tag_clause,
|
|
191
|
+
$.git_graph_type_clause,
|
|
192
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
193
|
+
),
|
|
194
|
+
)),
|
|
195
|
+
)),
|
|
196
|
+
|
|
197
|
+
git_graph_incomplete_merge_statement: ($) => prec(
|
|
198
|
+
-10,
|
|
199
|
+
statementKeyword($, 'merge'),
|
|
200
|
+
),
|
|
201
|
+
|
|
202
|
+
git_graph_checkout_statement: ($) => prec.right(seq(
|
|
203
|
+
field(
|
|
204
|
+
'keyword',
|
|
205
|
+
alias(
|
|
206
|
+
choice('checkout', 'switch'),
|
|
207
|
+
$.git_graph_statement_keyword,
|
|
208
|
+
),
|
|
209
|
+
),
|
|
210
|
+
$._langium_inline_space,
|
|
211
|
+
field('branch', choice(
|
|
212
|
+
$.git_graph_reference,
|
|
213
|
+
$.langium_string,
|
|
214
|
+
$.langium_unclosed_string,
|
|
215
|
+
)),
|
|
216
|
+
optional(seq(
|
|
217
|
+
$._langium_inline_space,
|
|
218
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
219
|
+
)),
|
|
220
|
+
)),
|
|
221
|
+
|
|
222
|
+
git_graph_incomplete_checkout_statement: ($) => prec(-10, field(
|
|
223
|
+
'keyword',
|
|
224
|
+
alias(
|
|
225
|
+
choice('checkout', 'switch'),
|
|
226
|
+
$.git_graph_statement_keyword,
|
|
227
|
+
),
|
|
228
|
+
)),
|
|
229
|
+
|
|
230
|
+
git_graph_cherry_pick_statement: ($) => prec.right(seq(
|
|
231
|
+
statementKeyword($, 'cherry-pick'),
|
|
232
|
+
optional(seq(
|
|
233
|
+
$._langium_inline_space,
|
|
234
|
+
choice(
|
|
235
|
+
$.git_graph_id_clause,
|
|
236
|
+
$.git_graph_tag_clause,
|
|
237
|
+
$.git_graph_parent_clause,
|
|
238
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
239
|
+
),
|
|
240
|
+
repeat(seq(
|
|
241
|
+
$._langium_inline_space,
|
|
242
|
+
choice(
|
|
243
|
+
$.git_graph_id_clause,
|
|
244
|
+
$.git_graph_tag_clause,
|
|
245
|
+
$.git_graph_parent_clause,
|
|
246
|
+
field('recovery', $.git_graph_malformed_clause),
|
|
247
|
+
),
|
|
248
|
+
)),
|
|
249
|
+
)),
|
|
250
|
+
)),
|
|
251
|
+
|
|
252
|
+
// Recovery starts with one unknown word and remains on the same physical
|
|
253
|
+
// line. Exact GitGraph keywords win through Tree-sitter's `word` boundary,
|
|
254
|
+
// while keyword prefixes remain one malformed word instead of being split.
|
|
255
|
+
git_graph_malformed_statement: ($) => prec(-100, choice(
|
|
256
|
+
seq(
|
|
257
|
+
field(
|
|
258
|
+
'keyword',
|
|
259
|
+
alias($.identifier, $.git_graph_unknown_statement_keyword),
|
|
260
|
+
),
|
|
261
|
+
optional(field('tail', $.git_graph_malformed_statement_tail)),
|
|
262
|
+
),
|
|
263
|
+
field('text', $.git_graph_malformed_symbol_text),
|
|
264
|
+
)),
|
|
265
|
+
|
|
266
|
+
git_graph_id_clause: ($) => quotedClause($, 'id', 'id'),
|
|
267
|
+
|
|
268
|
+
git_graph_message_clause: ($) => choice(
|
|
269
|
+
quotedClause($, 'msg', 'message'),
|
|
270
|
+
field('message', choice($.langium_string, $.langium_unclosed_string)),
|
|
271
|
+
),
|
|
272
|
+
|
|
273
|
+
git_graph_tag_clause: ($) => quotedClause($, 'tag', 'tag'),
|
|
274
|
+
|
|
275
|
+
git_graph_parent_clause: ($) => quotedClause($, 'parent', 'parent'),
|
|
276
|
+
|
|
277
|
+
git_graph_type_clause: ($) => seq(
|
|
278
|
+
clauseKeyword($, 'type'),
|
|
279
|
+
clauseSeparator($),
|
|
280
|
+
optional($._langium_inline_space),
|
|
281
|
+
field('type', $.git_graph_commit_type),
|
|
282
|
+
),
|
|
283
|
+
|
|
284
|
+
git_graph_order_clause: ($) => seq(
|
|
285
|
+
clauseKeyword($, 'order'),
|
|
286
|
+
clauseSeparator($),
|
|
287
|
+
optional($._langium_inline_space),
|
|
288
|
+
field('value', $.git_graph_integer),
|
|
289
|
+
),
|
|
290
|
+
|
|
291
|
+
git_graph_commit_type: (_) => choice('NORMAL', 'REVERSE', 'HIGHLIGHT'),
|
|
292
|
+
|
|
293
|
+
git_graph_integer: (_) => token(choice('0', /[1-9][0-9]*/)),
|
|
294
|
+
|
|
295
|
+
// Langium's `\\w` is ASCII in this JavaScript grammar. The source rule's
|
|
296
|
+
// final `[-\\w]` deliberately permits a trailing dash, but not `.` or `/`.
|
|
297
|
+
git_graph_reference: (_) => token(prec(
|
|
298
|
+
5,
|
|
299
|
+
/[A-Za-z0-9_](?:[-./A-Za-z0-9_]*[-A-Za-z0-9_])?/,
|
|
300
|
+
)),
|
|
301
|
+
|
|
302
|
+
git_graph_malformed_statement_tail: (_) => token.immediate(/[^\r\n]+/),
|
|
303
|
+
|
|
304
|
+
git_graph_malformed_symbol_text: (_) => token(prec(
|
|
305
|
+
-100,
|
|
306
|
+
/[^A-Za-z0-9_\u00c0-\uffff%\r\n][^\r\n]*/,
|
|
307
|
+
)),
|
|
308
|
+
|
|
309
|
+
git_graph_malformed_clause: ($) => seq(
|
|
310
|
+
field('keyword', $.git_graph_unknown_clause_keyword),
|
|
311
|
+
optional(field('tail', $.git_graph_malformed_clause_tail)),
|
|
312
|
+
),
|
|
313
|
+
|
|
314
|
+
git_graph_unknown_clause_keyword: (_) => token(prec(
|
|
315
|
+
-1,
|
|
316
|
+
/[A-Za-z_][A-Za-z0-9_-]*/,
|
|
317
|
+
)),
|
|
318
|
+
|
|
319
|
+
git_graph_malformed_clause_tail: (_) => token.immediate(/[^\r\n]+/),
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const gitGraphConflicts = ($) => [
|
|
323
|
+
[$.git_graph_header, $._git_graph_colon_header],
|
|
324
|
+
];
|
|
325
|
+
|
|
326
|
+
module.exports = { gitGraphConflicts, gitGraphRules };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Source translation: Mermaid 11.16.1
|
|
2
|
+
// packages/parser/src/language/info/info.langium
|
|
3
|
+
// commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
|
|
4
|
+
|
|
5
|
+
const infoRules = {
|
|
6
|
+
info_diagram: ($) => seq(
|
|
7
|
+
field('header', $.info_header),
|
|
8
|
+
optional(seq(
|
|
9
|
+
$._langium_body_boundary,
|
|
10
|
+
optional(field('body', $.info_body)),
|
|
11
|
+
)),
|
|
12
|
+
),
|
|
13
|
+
|
|
14
|
+
// The diagram-level boundary accepts `info showInfo` and
|
|
15
|
+
// `info\nshowInfo` while preserving the exact keyword ranges.
|
|
16
|
+
info_header: ($) => seq(
|
|
17
|
+
field(
|
|
18
|
+
'keyword',
|
|
19
|
+
alias(token(prec(20, 'info')), $.diagram_keyword),
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
|
|
23
|
+
info_body: ($) => choice(
|
|
24
|
+
repeat1($._info_terminated_body_item),
|
|
25
|
+
seq(
|
|
26
|
+
repeat($._info_terminated_body_item),
|
|
27
|
+
$._info_eof_body_item,
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
|
|
31
|
+
info_show_statement: ($) => prec.right(seq(
|
|
32
|
+
field(
|
|
33
|
+
'keyword',
|
|
34
|
+
alias(token(prec(20, 'showInfo')), $.statement_keyword),
|
|
35
|
+
),
|
|
36
|
+
optional(choice(
|
|
37
|
+
field('comment', $.comment),
|
|
38
|
+
field('directive', $.directive),
|
|
39
|
+
)),
|
|
40
|
+
)),
|
|
41
|
+
|
|
42
|
+
_info_common_statement: ($) => choice(
|
|
43
|
+
$.langium_title_statement,
|
|
44
|
+
$.langium_acc_title_statement,
|
|
45
|
+
$.langium_acc_descr_statement,
|
|
46
|
+
),
|
|
47
|
+
|
|
48
|
+
_info_body_statement: ($) => choice(
|
|
49
|
+
field('statement', $._info_common_statement),
|
|
50
|
+
field('recovery', $.info_recovery_statement),
|
|
51
|
+
),
|
|
52
|
+
|
|
53
|
+
_info_terminated_body_item: ($) => choice(
|
|
54
|
+
field('show_info', $.info_show_statement),
|
|
55
|
+
$._langium_newline,
|
|
56
|
+
seq(choice($.comment, $.directive), $._langium_newline),
|
|
57
|
+
seq($._info_body_statement, $._langium_newline),
|
|
58
|
+
),
|
|
59
|
+
|
|
60
|
+
_info_eof_body_item: ($) => choice(
|
|
61
|
+
$.comment,
|
|
62
|
+
$.directive,
|
|
63
|
+
$._info_body_statement,
|
|
64
|
+
),
|
|
65
|
+
|
|
66
|
+
info_recovery_statement: ($) => field('text', $.info_recovery_text),
|
|
67
|
+
|
|
68
|
+
// Horizontal layout is an extra, not an invalid statement. Requiring the
|
|
69
|
+
// first visible character keeps whitespace-only lines in NEWLINE* while
|
|
70
|
+
// preserving line-local recovery for actual malformed content.
|
|
71
|
+
info_recovery_text: (_) => token(prec(
|
|
72
|
+
1,
|
|
73
|
+
/[^ \t\f\u00a0%\r\n][^\r\n]*/,
|
|
74
|
+
)),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = { infoRules };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Source translation: Mermaid 11.16.1
|
|
2
|
+
// packages/mermaid/src/diagrams/ishikawa/parser/ishikawa.jison
|
|
3
|
+
// commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
|
|
4
|
+
|
|
5
|
+
const diagramKeyword = ($) => field(
|
|
6
|
+
'keyword',
|
|
7
|
+
alias(token(prec(20, /ishikawa(?:-beta)?/i)), $.diagram_keyword),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const statement = ($) => prec.right(seq(
|
|
11
|
+
optional(field('indentation', $.ishikawa_indentation)),
|
|
12
|
+
field('label', $.ishikawa_label),
|
|
13
|
+
));
|
|
14
|
+
|
|
15
|
+
const ishikawaRules = {
|
|
16
|
+
ishikawa_diagram: ($) => choice(
|
|
17
|
+
seq(
|
|
18
|
+
field('header', $.ishikawa_header),
|
|
19
|
+
optional(field('body', $.ishikawa_body)),
|
|
20
|
+
),
|
|
21
|
+
seq(
|
|
22
|
+
field('header', alias($._ishikawa_inline_header, $.ishikawa_header)),
|
|
23
|
+
field('body', $.ishikawa_body),
|
|
24
|
+
),
|
|
25
|
+
),
|
|
26
|
+
|
|
27
|
+
ishikawa_header: ($) => prec(30, seq(
|
|
28
|
+
diagramKeyword($),
|
|
29
|
+
optional(token.immediate(/[ \t]+/)),
|
|
30
|
+
optional(choice($.comment, $.directive)),
|
|
31
|
+
field('terminator', $._line_ending),
|
|
32
|
+
)),
|
|
33
|
+
|
|
34
|
+
_ishikawa_inline_header: ($) => seq(
|
|
35
|
+
diagramKeyword($),
|
|
36
|
+
token.immediate(/[ \t]+/),
|
|
37
|
+
),
|
|
38
|
+
|
|
39
|
+
ishikawa_body: ($) => choice(
|
|
40
|
+
seq(
|
|
41
|
+
repeat($._ishikawa_trivia_line),
|
|
42
|
+
field('effect', $.ishikawa_effect_statement),
|
|
43
|
+
optional(seq(
|
|
44
|
+
$._line_ending,
|
|
45
|
+
repeat($._ishikawa_cause_line_item),
|
|
46
|
+
optional($._ishikawa_cause_eof_item),
|
|
47
|
+
)),
|
|
48
|
+
),
|
|
49
|
+
repeat1($._ishikawa_trivia_line),
|
|
50
|
+
seq(
|
|
51
|
+
repeat($._ishikawa_trivia_line),
|
|
52
|
+
$._ishikawa_trivia_eof_item,
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
|
|
56
|
+
_ishikawa_trivia_line: ($) => choice(
|
|
57
|
+
seq(
|
|
58
|
+
optional($.ishikawa_indentation),
|
|
59
|
+
choice($.comment, $.directive),
|
|
60
|
+
$._line_ending,
|
|
61
|
+
),
|
|
62
|
+
$.ishikawa_indented_blank_line,
|
|
63
|
+
$._blank_line,
|
|
64
|
+
),
|
|
65
|
+
|
|
66
|
+
_ishikawa_trivia_eof_item: ($) => choice(
|
|
67
|
+
seq(
|
|
68
|
+
optional($.ishikawa_indentation),
|
|
69
|
+
choice($.comment, $.directive),
|
|
70
|
+
),
|
|
71
|
+
$.ishikawa_indented_blank_eof,
|
|
72
|
+
),
|
|
73
|
+
|
|
74
|
+
_ishikawa_cause_line_item: ($) => choice(
|
|
75
|
+
seq(field('cause', $.ishikawa_cause_statement), $._line_ending),
|
|
76
|
+
$._ishikawa_trivia_line,
|
|
77
|
+
),
|
|
78
|
+
|
|
79
|
+
_ishikawa_cause_eof_item: ($) => choice(
|
|
80
|
+
field('cause', $.ishikawa_cause_statement),
|
|
81
|
+
$._ishikawa_trivia_eof_item,
|
|
82
|
+
),
|
|
83
|
+
|
|
84
|
+
ishikawa_effect_statement: ($) => statement($),
|
|
85
|
+
|
|
86
|
+
ishikawa_cause_statement: ($) => statement($),
|
|
87
|
+
|
|
88
|
+
ishikawa_indented_blank_line: ($) => seq(
|
|
89
|
+
field('indentation', $.ishikawa_indentation),
|
|
90
|
+
field('terminator', $._line_ending),
|
|
91
|
+
),
|
|
92
|
+
|
|
93
|
+
ishikawa_indented_blank_eof: ($) => field(
|
|
94
|
+
'indentation',
|
|
95
|
+
$.ishikawa_indentation,
|
|
96
|
+
),
|
|
97
|
+
|
|
98
|
+
ishikawa_indentation: (_) => token(prec(20, /[ \t]+/)),
|
|
99
|
+
|
|
100
|
+
ishikawa_label: (_) => token(prec(-5, /[^\r\n]+/)),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
module.exports = { ishikawaRules };
|