@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,690 @@
|
|
|
1
|
+
// Source translation: Mermaid 11.16.1
|
|
2
|
+
// packages/mermaid/src/diagrams/flowchart/parser/flow.jison
|
|
3
|
+
// commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
|
|
4
|
+
|
|
5
|
+
const familyRule = (prefix, suffix) => `${prefix}_${suffix}`;
|
|
6
|
+
const privateFamilyRule = (prefix, suffix) => `_${familyRule(prefix, suffix)}`;
|
|
7
|
+
|
|
8
|
+
const ref = ($, prefix, suffix) => $[familyRule(prefix, suffix)];
|
|
9
|
+
const privateRef = ($, prefix, suffix) => $[privateFamilyRule(prefix, suffix)];
|
|
10
|
+
|
|
11
|
+
const diagramKeyword = ($, keywords) => field(
|
|
12
|
+
'keyword',
|
|
13
|
+
alias(
|
|
14
|
+
token(prec(40, keywords.length === 1 ? keywords[0] : choice(...keywords))),
|
|
15
|
+
$.diagram_keyword,
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const statementKeyword = ($, prefix, keyword) => field(
|
|
20
|
+
'keyword',
|
|
21
|
+
alias(
|
|
22
|
+
token(prec(keyword === 'classDef' ? 50 : 30, keyword)),
|
|
23
|
+
ref($, prefix, 'statement_keyword'),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const optionalInlineGap = () => optional(token.immediate(/[ \t]+/));
|
|
28
|
+
|
|
29
|
+
const keywordPrefixedIdentifier = () => choice(
|
|
30
|
+
token(prec(
|
|
31
|
+
60,
|
|
32
|
+
/classDef(?:[A-Za-z0-9_.!?$%#\u00c0-\uffff]|-[A-Za-z0-9_\u00c0-\uffff])+/
|
|
33
|
+
)),
|
|
34
|
+
token(prec(
|
|
35
|
+
40,
|
|
36
|
+
/(?:subgraph|direction|class|style|linkStyle|click|accTitle|accDescr|end)(?:[A-Za-z0-9_.!?$%#\u00c0-\uffff]|-[A-Za-z0-9_\u00c0-\uffff])+/
|
|
37
|
+
)),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const headerDirection = ($) => seq(
|
|
41
|
+
token.immediate(/[ \t]+/),
|
|
42
|
+
field(
|
|
43
|
+
'direction',
|
|
44
|
+
alias(
|
|
45
|
+
token.immediate(/(?:LR|RL|TB|BT|TD|BR|[<>^v])/),
|
|
46
|
+
$.direction,
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const shapeDelimiter = ($, prefix, delimiter) => alias(
|
|
52
|
+
delimiter,
|
|
53
|
+
ref($, prefix, 'shape_delimiter'),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const shape = ($, prefix, open, close, textRule) => seq(
|
|
57
|
+
field('open', shapeDelimiter($, prefix, open)),
|
|
58
|
+
optional(field('label', choice(
|
|
59
|
+
ref($, prefix, 'markdown_label'),
|
|
60
|
+
ref($, prefix, 'quoted_label'),
|
|
61
|
+
ref($, prefix, textRule),
|
|
62
|
+
))),
|
|
63
|
+
field('close', shapeDelimiter($, prefix, close)),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const quotedText = () => token(prec(30, choice(
|
|
67
|
+
seq('"', /(?:[^"\\]|\\.)*/, '"'),
|
|
68
|
+
seq("'", /(?:[^'\\]|\\.)*/, "'"),
|
|
69
|
+
)));
|
|
70
|
+
|
|
71
|
+
const immediateQuotedText = () => token.immediate(prec(30, choice(
|
|
72
|
+
seq('"', /(?:[^"\\]|\\.)*/, '"'),
|
|
73
|
+
seq("'", /(?:[^'\\]|\\.)*/, "'"),
|
|
74
|
+
)));
|
|
75
|
+
|
|
76
|
+
const clickSuffix = ($, prefix) => seq(
|
|
77
|
+
token.immediate(/[ \t]+/),
|
|
78
|
+
choice(
|
|
79
|
+
seq(
|
|
80
|
+
field('tooltip', alias(
|
|
81
|
+
immediateQuotedText(),
|
|
82
|
+
ref($, prefix, 'quoted_label'),
|
|
83
|
+
)),
|
|
84
|
+
optional(seq(
|
|
85
|
+
token.immediate(/[ \t]+/),
|
|
86
|
+
field('link_target', alias(
|
|
87
|
+
token.immediate(choice('_self', '_blank', '_parent', '_top')),
|
|
88
|
+
ref($, prefix, 'link_target'),
|
|
89
|
+
)),
|
|
90
|
+
)),
|
|
91
|
+
),
|
|
92
|
+
field('link_target', alias(
|
|
93
|
+
token.immediate(choice('_self', '_blank', '_parent', '_top')),
|
|
94
|
+
ref($, prefix, 'link_target'),
|
|
95
|
+
)),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const clickTooltip = ($, prefix) => seq(
|
|
100
|
+
token.immediate(/[ \t]+/),
|
|
101
|
+
field('tooltip', alias(
|
|
102
|
+
immediateQuotedText(),
|
|
103
|
+
ref($, prefix, 'quoted_label'),
|
|
104
|
+
)),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const markdownText = () => token(prec(40, seq('"`', /[^`]*/, '`"')));
|
|
108
|
+
|
|
109
|
+
const createFlowFamilyRules = ({
|
|
110
|
+
prefix,
|
|
111
|
+
diagram,
|
|
112
|
+
header,
|
|
113
|
+
headerEof,
|
|
114
|
+
keywords,
|
|
115
|
+
}) => ({
|
|
116
|
+
[diagram]: ($) => choice(
|
|
117
|
+
seq(
|
|
118
|
+
field('header', $[header]),
|
|
119
|
+
optional(field('body', ref($, prefix, 'body'))),
|
|
120
|
+
),
|
|
121
|
+
field('header', alias($[headerEof], $[header])),
|
|
122
|
+
),
|
|
123
|
+
|
|
124
|
+
[header]: ($) => prec(50, seq(
|
|
125
|
+
diagramKeyword($, keywords),
|
|
126
|
+
choice(
|
|
127
|
+
seq(
|
|
128
|
+
headerDirection($),
|
|
129
|
+
optional(choice(
|
|
130
|
+
field('comment', $.comment),
|
|
131
|
+
field('directive', $.directive),
|
|
132
|
+
)),
|
|
133
|
+
field('terminator', $._statement_terminator),
|
|
134
|
+
),
|
|
135
|
+
seq(
|
|
136
|
+
optional(choice(
|
|
137
|
+
field('comment', $.comment),
|
|
138
|
+
field('directive', $.directive),
|
|
139
|
+
)),
|
|
140
|
+
field('terminator', $._line_ending),
|
|
141
|
+
),
|
|
142
|
+
),
|
|
143
|
+
)),
|
|
144
|
+
|
|
145
|
+
[headerEof]: ($) => seq(
|
|
146
|
+
diagramKeyword($, keywords),
|
|
147
|
+
optional(headerDirection($)),
|
|
148
|
+
$._end_of_input,
|
|
149
|
+
),
|
|
150
|
+
|
|
151
|
+
[familyRule(prefix, 'body')]: ($) => choice(
|
|
152
|
+
repeat1(ref($, prefix, 'line_item')),
|
|
153
|
+
seq(
|
|
154
|
+
repeat(ref($, prefix, 'line_item')),
|
|
155
|
+
ref($, prefix, 'eof_item'),
|
|
156
|
+
),
|
|
157
|
+
),
|
|
158
|
+
|
|
159
|
+
[familyRule(prefix, 'line_item')]: ($) => choice(
|
|
160
|
+
seq(
|
|
161
|
+
field('statement', choice(
|
|
162
|
+
ref($, prefix, 'statement'),
|
|
163
|
+
ref($, prefix, 'incomplete_edge_statement'),
|
|
164
|
+
)),
|
|
165
|
+
field('terminator', $._statement_terminator),
|
|
166
|
+
),
|
|
167
|
+
seq(choice($.comment, $.directive), $._line_ending),
|
|
168
|
+
$._blank_line,
|
|
169
|
+
),
|
|
170
|
+
|
|
171
|
+
[familyRule(prefix, 'eof_item')]: ($) => choice(
|
|
172
|
+
field('statement', choice(
|
|
173
|
+
ref($, prefix, 'statement'),
|
|
174
|
+
ref($, prefix, 'incomplete_edge_statement'),
|
|
175
|
+
)),
|
|
176
|
+
$.comment,
|
|
177
|
+
$.directive,
|
|
178
|
+
),
|
|
179
|
+
|
|
180
|
+
[familyRule(prefix, 'statement')]: ($) => choice(
|
|
181
|
+
ref($, prefix, 'subgraph'),
|
|
182
|
+
ref($, prefix, 'edge_statement'),
|
|
183
|
+
ref($, prefix, 'node_statement'),
|
|
184
|
+
ref($, prefix, 'direction_statement'),
|
|
185
|
+
ref($, prefix, 'class_definition_statement'),
|
|
186
|
+
ref($, prefix, 'class_assignment_statement'),
|
|
187
|
+
ref($, prefix, 'style_statement'),
|
|
188
|
+
ref($, prefix, 'link_style_statement'),
|
|
189
|
+
ref($, prefix, 'click_statement'),
|
|
190
|
+
ref($, prefix, 'accessibility_title_statement'),
|
|
191
|
+
ref($, prefix, 'accessibility_description_statement'),
|
|
192
|
+
),
|
|
193
|
+
|
|
194
|
+
[familyRule(prefix, 'subgraph')]: ($) => prec.right(50, seq(
|
|
195
|
+
statementKeyword($, prefix, 'subgraph'),
|
|
196
|
+
optional(field('identity', choice(
|
|
197
|
+
seq(
|
|
198
|
+
field('id', alias(ref($, prefix, 'identifier'), ref($, prefix, 'node_id'))),
|
|
199
|
+
field('label', ref($, prefix, 'square_label')),
|
|
200
|
+
),
|
|
201
|
+
field('name', ref($, prefix, 'subgraph_name')),
|
|
202
|
+
))),
|
|
203
|
+
field('terminator', $._statement_terminator),
|
|
204
|
+
repeat(ref($, prefix, 'line_item')),
|
|
205
|
+
field('end', ref($, prefix, 'subgraph_end')),
|
|
206
|
+
)),
|
|
207
|
+
|
|
208
|
+
[familyRule(prefix, 'subgraph_name')]: ($) => choice(
|
|
209
|
+
ref($, prefix, 'identifier'),
|
|
210
|
+
ref($, prefix, 'markdown_label'),
|
|
211
|
+
ref($, prefix, 'quoted_label'),
|
|
212
|
+
ref($, prefix, 'subgraph_title'),
|
|
213
|
+
),
|
|
214
|
+
|
|
215
|
+
[familyRule(prefix, 'subgraph_title')]: (_) => token(prec(
|
|
216
|
+
10,
|
|
217
|
+
/[^;%\[\]\s\r\n](?:[^;%\[\]\r\n]*[ \t][^;%\[\]\s\r\n][^;%\[\]\r\n]*)/,
|
|
218
|
+
)),
|
|
219
|
+
|
|
220
|
+
[familyRule(prefix, 'subgraph_end')]: (_) => token(prec(30, 'end')),
|
|
221
|
+
|
|
222
|
+
[familyRule(prefix, 'direction_statement')]: ($) => seq(
|
|
223
|
+
statementKeyword($, prefix, 'direction'),
|
|
224
|
+
token.immediate(/[ \t]+/),
|
|
225
|
+
field('direction', alias(
|
|
226
|
+
token.immediate(/(?:LR|RL|TB|BT|TD)/),
|
|
227
|
+
ref($, prefix, 'direction'),
|
|
228
|
+
)),
|
|
229
|
+
),
|
|
230
|
+
|
|
231
|
+
[familyRule(prefix, 'edge_statement')]: ($) => prec.right(60, seq(
|
|
232
|
+
field('source', ref($, prefix, 'node')),
|
|
233
|
+
field('edge', ref($, prefix, 'edge')),
|
|
234
|
+
optionalInlineGap(),
|
|
235
|
+
field('target', ref($, prefix, 'node')),
|
|
236
|
+
repeat(seq(
|
|
237
|
+
field('edge', ref($, prefix, 'edge')),
|
|
238
|
+
optionalInlineGap(),
|
|
239
|
+
field('target', ref($, prefix, 'node')),
|
|
240
|
+
)),
|
|
241
|
+
)),
|
|
242
|
+
|
|
243
|
+
[familyRule(prefix, 'incomplete_edge_statement')]: ($) => prec(-30, seq(
|
|
244
|
+
field('source', ref($, prefix, 'node')),
|
|
245
|
+
field('edge', ref($, prefix, 'edge')),
|
|
246
|
+
)),
|
|
247
|
+
|
|
248
|
+
[familyRule(prefix, 'node_statement')]: ($) => field(
|
|
249
|
+
'node',
|
|
250
|
+
ref($, prefix, 'node'),
|
|
251
|
+
),
|
|
252
|
+
|
|
253
|
+
[familyRule(prefix, 'node')]: ($) => seq(
|
|
254
|
+
field('vertex', ref($, prefix, 'vertex')),
|
|
255
|
+
repeat(seq(
|
|
256
|
+
field('separator', '&'),
|
|
257
|
+
field('vertex', ref($, prefix, 'vertex')),
|
|
258
|
+
)),
|
|
259
|
+
),
|
|
260
|
+
|
|
261
|
+
[familyRule(prefix, 'vertex')]: ($) => seq(
|
|
262
|
+
field('id', alias(ref($, prefix, 'identifier'), ref($, prefix, 'node_id'))),
|
|
263
|
+
optional(field('shape', ref($, prefix, 'shape'))),
|
|
264
|
+
optional(field('data', ref($, prefix, 'shape_data'))),
|
|
265
|
+
optional(field('class', ref($, prefix, 'class_annotation'))),
|
|
266
|
+
),
|
|
267
|
+
|
|
268
|
+
[familyRule(prefix, 'shape')]: ($) => choice(
|
|
269
|
+
ref($, prefix, 'square_label'),
|
|
270
|
+
ref($, prefix, 'round_label'),
|
|
271
|
+
ref($, prefix, 'circle_label'),
|
|
272
|
+
ref($, prefix, 'ellipse_label'),
|
|
273
|
+
ref($, prefix, 'stadium_label'),
|
|
274
|
+
ref($, prefix, 'subroutine_label'),
|
|
275
|
+
ref($, prefix, 'property_label'),
|
|
276
|
+
ref($, prefix, 'cylinder_label'),
|
|
277
|
+
ref($, prefix, 'double_circle_label'),
|
|
278
|
+
ref($, prefix, 'diamond_label'),
|
|
279
|
+
ref($, prefix, 'hexagon_label'),
|
|
280
|
+
ref($, prefix, 'odd_label'),
|
|
281
|
+
ref($, prefix, 'slash_label'),
|
|
282
|
+
ref($, prefix, 'backslash_label'),
|
|
283
|
+
),
|
|
284
|
+
|
|
285
|
+
[familyRule(prefix, 'square_label')]: ($) => shape($, prefix, '[', ']', 'square_label_text'),
|
|
286
|
+
[familyRule(prefix, 'round_label')]: ($) => shape($, prefix, '(', ')', 'round_label_text'),
|
|
287
|
+
[familyRule(prefix, 'circle_label')]: ($) => shape($, prefix, '((', '))', 'round_label_text'),
|
|
288
|
+
[familyRule(prefix, 'ellipse_label')]: ($) => shape($, prefix, '(-', '-)', 'ellipse_label_text'),
|
|
289
|
+
[familyRule(prefix, 'stadium_label')]: ($) => shape($, prefix, '([', '])', 'square_label_text'),
|
|
290
|
+
[familyRule(prefix, 'subroutine_label')]: ($) => shape($, prefix, '[[', ']]', 'square_label_text'),
|
|
291
|
+
[familyRule(prefix, 'cylinder_label')]: ($) => shape($, prefix, '[(', ')]', 'round_label_text'),
|
|
292
|
+
[familyRule(prefix, 'double_circle_label')]: ($) => shape($, prefix, '(((', ')))', 'round_label_text'),
|
|
293
|
+
[familyRule(prefix, 'diamond_label')]: ($) => shape($, prefix, '{', '}', 'curly_label_text'),
|
|
294
|
+
[familyRule(prefix, 'hexagon_label')]: ($) => shape($, prefix, '{{', '}}', 'curly_label_text'),
|
|
295
|
+
[familyRule(prefix, 'odd_label')]: ($) => seq(
|
|
296
|
+
optional(token.immediate('-')),
|
|
297
|
+
shape($, prefix, '>', ']', 'square_label_text'),
|
|
298
|
+
),
|
|
299
|
+
[familyRule(prefix, 'slash_label')]: ($) => shape(
|
|
300
|
+
$,
|
|
301
|
+
prefix,
|
|
302
|
+
'[/',
|
|
303
|
+
choice('\\]', '/]'),
|
|
304
|
+
'trap_label_text',
|
|
305
|
+
),
|
|
306
|
+
[familyRule(prefix, 'backslash_label')]: ($) => shape(
|
|
307
|
+
$,
|
|
308
|
+
prefix,
|
|
309
|
+
'[\\',
|
|
310
|
+
choice('/]', '\\]'),
|
|
311
|
+
'trap_label_text',
|
|
312
|
+
),
|
|
313
|
+
|
|
314
|
+
[familyRule(prefix, 'square_label_text')]: (_) => token(prec(-10, /[^\]\r\n]+/)),
|
|
315
|
+
[familyRule(prefix, 'round_label_text')]: (_) => token(prec(-10, /[^)\r\n]+/)),
|
|
316
|
+
[familyRule(prefix, 'curly_label_text')]: (_) => token(prec(-10, /[^}\r\n]+/)),
|
|
317
|
+
[familyRule(prefix, 'ellipse_label_text')]: ($) => repeat1(choice(
|
|
318
|
+
ref($, prefix, 'ellipse_label_fragment'),
|
|
319
|
+
token.immediate('-'),
|
|
320
|
+
)),
|
|
321
|
+
[familyRule(prefix, 'ellipse_label_fragment')]: (_) => token.immediate(/[^-)\r\n]+/),
|
|
322
|
+
[familyRule(prefix, 'trap_label_text')]: ($) => repeat1(choice(
|
|
323
|
+
ref($, prefix, 'trap_label_fragment'),
|
|
324
|
+
token.immediate('/'),
|
|
325
|
+
token.immediate('\\'),
|
|
326
|
+
)),
|
|
327
|
+
[familyRule(prefix, 'trap_label_fragment')]: (_) => token.immediate(/[^/\\\]\r\n]+/),
|
|
328
|
+
|
|
329
|
+
[familyRule(prefix, 'property_label')]: ($) => seq(
|
|
330
|
+
field('open', shapeDelimiter($, prefix, '[|')),
|
|
331
|
+
field('property', ref($, prefix, 'property_pair')),
|
|
332
|
+
field('separator', '|'),
|
|
333
|
+
optional(field('label', ref($, prefix, 'label'))),
|
|
334
|
+
field('close', shapeDelimiter($, prefix, ']')),
|
|
335
|
+
),
|
|
336
|
+
|
|
337
|
+
[familyRule(prefix, 'property_pair')]: ($) => seq(
|
|
338
|
+
field('name', alias(ref($, prefix, 'identifier'), ref($, prefix, 'property_name'))),
|
|
339
|
+
field('delimiter', ':'),
|
|
340
|
+
field('value', ref($, prefix, 'property_value')),
|
|
341
|
+
),
|
|
342
|
+
|
|
343
|
+
[familyRule(prefix, 'property_value')]: (_) => token(prec(-10, /[^|\]\r\n]+/)),
|
|
344
|
+
|
|
345
|
+
[familyRule(prefix, 'label')]: ($) => choice(
|
|
346
|
+
ref($, prefix, 'markdown_label'),
|
|
347
|
+
ref($, prefix, 'quoted_label'),
|
|
348
|
+
ref($, prefix, 'label_text'),
|
|
349
|
+
),
|
|
350
|
+
|
|
351
|
+
[familyRule(prefix, 'markdown_label')]: (_) => markdownText(),
|
|
352
|
+
[familyRule(prefix, 'quoted_label')]: (_) => quotedText(),
|
|
353
|
+
[familyRule(prefix, 'label_text')]: (_) => token(prec(
|
|
354
|
+
-10,
|
|
355
|
+
/[^"'`\[\](){}|\r\n]+/,
|
|
356
|
+
)),
|
|
357
|
+
|
|
358
|
+
[familyRule(prefix, 'shape_data')]: ($) => seq(
|
|
359
|
+
field('open', '@{'),
|
|
360
|
+
repeat(field('content', choice(
|
|
361
|
+
ref($, prefix, 'shape_data_string'),
|
|
362
|
+
ref($, prefix, 'shape_data_content'),
|
|
363
|
+
))),
|
|
364
|
+
field('close', '}'),
|
|
365
|
+
),
|
|
366
|
+
|
|
367
|
+
[familyRule(prefix, 'shape_data_string')]: (_) => token(prec(30, choice(
|
|
368
|
+
seq('"', /(?:[^"\\]|\\.)*/, '"'),
|
|
369
|
+
seq("'", /(?:[^'\\]|\\.)*/, "'"),
|
|
370
|
+
))),
|
|
371
|
+
[familyRule(prefix, 'shape_data_content')]: (_) => token(prec(-20, /[^}"']+/)),
|
|
372
|
+
|
|
373
|
+
[familyRule(prefix, 'edge')]: ($) => prec.right(choice(
|
|
374
|
+
prec(50, seq(
|
|
375
|
+
optional(field('id', ref($, prefix, 'edge_id'))),
|
|
376
|
+
field('operator', ref($, prefix, 'arrow_start')),
|
|
377
|
+
field('label', ref($, prefix, 'middle_edge_label')),
|
|
378
|
+
field('operator_end', ref($, prefix, 'arrow')),
|
|
379
|
+
)),
|
|
380
|
+
prec(50, seq(
|
|
381
|
+
field('operator', ref($, prefix, 'continued_arrow_start')),
|
|
382
|
+
field('label', ref($, prefix, 'middle_edge_label')),
|
|
383
|
+
field('operator_end', ref($, prefix, 'arrow')),
|
|
384
|
+
)),
|
|
385
|
+
privateRef($, prefix, 'labeled_edge'),
|
|
386
|
+
privateRef($, prefix, 'continued_labeled_edge'),
|
|
387
|
+
privateRef($, prefix, 'unlabeled_edge'),
|
|
388
|
+
privateRef($, prefix, 'continued_unlabeled_edge'),
|
|
389
|
+
)),
|
|
390
|
+
|
|
391
|
+
[privateFamilyRule(prefix, 'labeled_edge')]: ($) => seq(
|
|
392
|
+
optional(field('id', ref($, prefix, 'edge_id'))),
|
|
393
|
+
field('operator', ref($, prefix, 'arrow')),
|
|
394
|
+
choice(
|
|
395
|
+
seq(
|
|
396
|
+
token.immediate(/[ \t]+/),
|
|
397
|
+
field('label', ref($, prefix, 'edge_label')),
|
|
398
|
+
),
|
|
399
|
+
field('label', ref($, prefix, 'edge_label')),
|
|
400
|
+
),
|
|
401
|
+
),
|
|
402
|
+
|
|
403
|
+
[privateFamilyRule(prefix, 'continued_labeled_edge')]: ($) => seq(
|
|
404
|
+
field('operator', ref($, prefix, 'continued_arrow')),
|
|
405
|
+
choice(
|
|
406
|
+
seq(
|
|
407
|
+
token.immediate(/[ \t]+/),
|
|
408
|
+
field('label', ref($, prefix, 'edge_label')),
|
|
409
|
+
),
|
|
410
|
+
field('label', ref($, prefix, 'edge_label')),
|
|
411
|
+
),
|
|
412
|
+
),
|
|
413
|
+
|
|
414
|
+
[privateFamilyRule(prefix, 'unlabeled_edge')]: ($) => seq(
|
|
415
|
+
optional(field('id', ref($, prefix, 'edge_id'))),
|
|
416
|
+
field('operator', ref($, prefix, 'arrow')),
|
|
417
|
+
),
|
|
418
|
+
|
|
419
|
+
[privateFamilyRule(prefix, 'continued_unlabeled_edge')]: ($) => field(
|
|
420
|
+
'operator',
|
|
421
|
+
ref($, prefix, 'continued_arrow'),
|
|
422
|
+
),
|
|
423
|
+
|
|
424
|
+
[familyRule(prefix, 'edge_id')]: ($) => seq(
|
|
425
|
+
field('name', alias(ref($, prefix, 'identifier'), ref($, prefix, 'edge_name'))),
|
|
426
|
+
field('delimiter', '@'),
|
|
427
|
+
),
|
|
428
|
+
|
|
429
|
+
[familyRule(prefix, 'edge_label')]: ($) => seq(
|
|
430
|
+
field('open', '|'),
|
|
431
|
+
optional(field('text', choice(
|
|
432
|
+
ref($, prefix, 'markdown_label'),
|
|
433
|
+
ref($, prefix, 'quoted_label'),
|
|
434
|
+
ref($, prefix, 'edge_label_text'),
|
|
435
|
+
))),
|
|
436
|
+
field('close', '|'),
|
|
437
|
+
),
|
|
438
|
+
|
|
439
|
+
[familyRule(prefix, 'edge_label_text')]: (_) => token(prec(-10, /[^|\r\n]+/)),
|
|
440
|
+
|
|
441
|
+
[familyRule(prefix, 'middle_edge_label')]: ($) => choice(
|
|
442
|
+
ref($, prefix, 'markdown_label'),
|
|
443
|
+
ref($, prefix, 'quoted_label'),
|
|
444
|
+
ref($, prefix, 'middle_edge_label_text'),
|
|
445
|
+
),
|
|
446
|
+
|
|
447
|
+
[familyRule(prefix, 'middle_edge_label_text')]: ($) => repeat1(choice(
|
|
448
|
+
ref($, prefix, 'middle_edge_label_fragment'),
|
|
449
|
+
token.immediate('-'),
|
|
450
|
+
token.immediate('='),
|
|
451
|
+
token.immediate('.'),
|
|
452
|
+
)),
|
|
453
|
+
[familyRule(prefix, 'middle_edge_label_fragment')]: (_) => token.immediate(/[^-=.\r\n]+/),
|
|
454
|
+
|
|
455
|
+
[familyRule(prefix, 'arrow_start')]: (_) => token(prec(
|
|
456
|
+
20,
|
|
457
|
+
/[xo<]?(?:--|==|-\.)/,
|
|
458
|
+
)),
|
|
459
|
+
|
|
460
|
+
[familyRule(prefix, 'continued_arrow_start')]: (_) => token(prec(
|
|
461
|
+
25,
|
|
462
|
+
/(?:\r\n|\n|\r)[ \t]*[xo<]?(?:--|==|-\.)/,
|
|
463
|
+
)),
|
|
464
|
+
|
|
465
|
+
[familyRule(prefix, 'arrow')]: (_) => token(prec(
|
|
466
|
+
20,
|
|
467
|
+
/[xo<]?(?:--+[-xo>]|==+[=xo>]|-?\.+-[xo>]?|~~~+)/,
|
|
468
|
+
)),
|
|
469
|
+
|
|
470
|
+
[familyRule(prefix, 'continued_arrow')]: (_) => token(prec(
|
|
471
|
+
25,
|
|
472
|
+
/(?:\r\n|\n|\r)[ \t]*[xo<]?(?:--+[-xo>]|==+[=xo>]|-?\.+-[xo>]?|~~~+)/,
|
|
473
|
+
)),
|
|
474
|
+
|
|
475
|
+
[familyRule(prefix, 'class_annotation')]: ($) => seq(
|
|
476
|
+
field('operator', ':::'),
|
|
477
|
+
field('name', alias(ref($, prefix, 'identifier'), ref($, prefix, 'class_name'))),
|
|
478
|
+
),
|
|
479
|
+
|
|
480
|
+
[familyRule(prefix, 'class_definition_statement')]: ($) => seq(
|
|
481
|
+
statementKeyword($, prefix, 'classDef'),
|
|
482
|
+
token.immediate(/[ \t]+/),
|
|
483
|
+
field('classes', ref($, prefix, 'identifier_list')),
|
|
484
|
+
optional(seq(
|
|
485
|
+
token.immediate(/[ \t]+/),
|
|
486
|
+
field('style', ref($, prefix, 'style_list')),
|
|
487
|
+
)),
|
|
488
|
+
),
|
|
489
|
+
|
|
490
|
+
[familyRule(prefix, 'class_assignment_statement')]: ($) => seq(
|
|
491
|
+
statementKeyword($, prefix, 'class'),
|
|
492
|
+
token.immediate(/[ \t]+/),
|
|
493
|
+
field('targets', ref($, prefix, 'identifier_list')),
|
|
494
|
+
token.immediate(/[ \t]+/),
|
|
495
|
+
field('class', alias(ref($, prefix, 'identifier'), ref($, prefix, 'class_name'))),
|
|
496
|
+
),
|
|
497
|
+
|
|
498
|
+
[familyRule(prefix, 'style_statement')]: ($) => seq(
|
|
499
|
+
statementKeyword($, prefix, 'style'),
|
|
500
|
+
token.immediate(/[ \t]+/),
|
|
501
|
+
field('target', alias(ref($, prefix, 'identifier'), ref($, prefix, 'node_id'))),
|
|
502
|
+
token.immediate(/[ \t]+/),
|
|
503
|
+
field('style', ref($, prefix, 'style_list')),
|
|
504
|
+
),
|
|
505
|
+
|
|
506
|
+
[familyRule(prefix, 'link_style_statement')]: ($) => seq(
|
|
507
|
+
statementKeyword($, prefix, 'linkStyle'),
|
|
508
|
+
field('targets', choice(
|
|
509
|
+
alias(token(prec(20, 'default')), ref($, prefix, 'link_style_default')),
|
|
510
|
+
ref($, prefix, 'number_list'),
|
|
511
|
+
)),
|
|
512
|
+
optional(seq(
|
|
513
|
+
statementKeyword($, prefix, 'interpolate'),
|
|
514
|
+
field('interpolation', alias(
|
|
515
|
+
ref($, prefix, 'identifier'),
|
|
516
|
+
ref($, prefix, 'interpolation'),
|
|
517
|
+
)),
|
|
518
|
+
)),
|
|
519
|
+
optional(field('style', ref($, prefix, 'style_list'))),
|
|
520
|
+
),
|
|
521
|
+
|
|
522
|
+
[familyRule(prefix, 'identifier_list')]: ($) => seq(
|
|
523
|
+
field('item', alias(ref($, prefix, 'identifier'), ref($, prefix, 'reference'))),
|
|
524
|
+
repeat(seq(
|
|
525
|
+
field('delimiter', ','),
|
|
526
|
+
field('item', alias(ref($, prefix, 'identifier'), ref($, prefix, 'reference'))),
|
|
527
|
+
)),
|
|
528
|
+
),
|
|
529
|
+
|
|
530
|
+
[familyRule(prefix, 'number_list')]: ($) => seq(
|
|
531
|
+
field('item', alias(/[0-9]+/, ref($, prefix, 'edge_index'))),
|
|
532
|
+
repeat(seq(
|
|
533
|
+
field('delimiter', ','),
|
|
534
|
+
field('item', alias(/[0-9]+/, ref($, prefix, 'edge_index'))),
|
|
535
|
+
)),
|
|
536
|
+
),
|
|
537
|
+
|
|
538
|
+
[familyRule(prefix, 'style_list')]: ($) => seq(
|
|
539
|
+
field('item', ref($, prefix, 'style_item')),
|
|
540
|
+
repeat(seq(
|
|
541
|
+
optional(field('delimiter', ',')),
|
|
542
|
+
field('item', ref($, prefix, 'style_item')),
|
|
543
|
+
)),
|
|
544
|
+
optional(field('delimiter', ',')),
|
|
545
|
+
),
|
|
546
|
+
|
|
547
|
+
[familyRule(prefix, 'style_item')]: ($) => choice(
|
|
548
|
+
prec(30, ref($, prefix, 'style_declaration')),
|
|
549
|
+
field('value', alias(
|
|
550
|
+
ref($, prefix, 'style_property'),
|
|
551
|
+
ref($, prefix, 'style_fragment'),
|
|
552
|
+
)),
|
|
553
|
+
ref($, prefix, 'style_fragment'),
|
|
554
|
+
),
|
|
555
|
+
|
|
556
|
+
[familyRule(prefix, 'style_declaration')]: ($) => seq(
|
|
557
|
+
field('property', ref($, prefix, 'style_property')),
|
|
558
|
+
field('delimiter', ':'),
|
|
559
|
+
field('value', ref($, prefix, 'style_value')),
|
|
560
|
+
),
|
|
561
|
+
|
|
562
|
+
[familyRule(prefix, 'style_property')]: (_) => token(prec(10, /[A-Za-z_-][A-Za-z0-9_-]*/)),
|
|
563
|
+
[familyRule(prefix, 'style_value')]: (_) => token(prec(-20, /[^,;\r\n]+/)),
|
|
564
|
+
[familyRule(prefix, 'style_fragment')]: (_) => token(prec(-40, /[^,;\r\n]+/)),
|
|
565
|
+
|
|
566
|
+
[familyRule(prefix, 'click_statement')]: ($) => seq(
|
|
567
|
+
statementKeyword($, prefix, 'click'),
|
|
568
|
+
token.immediate(/[ \t]+/),
|
|
569
|
+
field('target', alias(ref($, prefix, 'identifier'), ref($, prefix, 'node_id'))),
|
|
570
|
+
optional(choice(
|
|
571
|
+
seq(
|
|
572
|
+
token.immediate(/[ \t]+/),
|
|
573
|
+
field('action', ref($, prefix, 'href_action')),
|
|
574
|
+
optional(clickSuffix($, prefix)),
|
|
575
|
+
),
|
|
576
|
+
seq(
|
|
577
|
+
token.immediate(/[ \t]+/),
|
|
578
|
+
field('action', ref($, prefix, 'call_action')),
|
|
579
|
+
optional(clickTooltip($, prefix)),
|
|
580
|
+
),
|
|
581
|
+
seq(
|
|
582
|
+
token.immediate(/[ \t]+/),
|
|
583
|
+
field('action', ref($, prefix, 'callback_action')),
|
|
584
|
+
optional(clickTooltip($, prefix)),
|
|
585
|
+
),
|
|
586
|
+
seq(
|
|
587
|
+
token.immediate(/[ \t]+/),
|
|
588
|
+
field('action', ref($, prefix, 'quoted_label')),
|
|
589
|
+
optional(clickSuffix($, prefix)),
|
|
590
|
+
),
|
|
591
|
+
)),
|
|
592
|
+
),
|
|
593
|
+
|
|
594
|
+
[familyRule(prefix, 'href_action')]: ($) => seq(
|
|
595
|
+
statementKeyword($, prefix, 'href'),
|
|
596
|
+
token.immediate(/[ \t]+/),
|
|
597
|
+
field('url', ref($, prefix, 'quoted_label')),
|
|
598
|
+
),
|
|
599
|
+
|
|
600
|
+
[familyRule(prefix, 'call_action')]: ($) => seq(
|
|
601
|
+
optional(field('keyword', ref($, prefix, 'call_keyword'))),
|
|
602
|
+
field('function', alias(
|
|
603
|
+
ref($, prefix, 'identifier'),
|
|
604
|
+
ref($, prefix, 'callback_name'),
|
|
605
|
+
)),
|
|
606
|
+
field('arguments', ref($, prefix, 'argument_list')),
|
|
607
|
+
),
|
|
608
|
+
|
|
609
|
+
[familyRule(prefix, 'call_keyword')]: ($) => alias(
|
|
610
|
+
token(prec(30, /call[ \t]+/)),
|
|
611
|
+
ref($, prefix, 'statement_keyword'),
|
|
612
|
+
),
|
|
613
|
+
|
|
614
|
+
[familyRule(prefix, 'callback_action')]: ($) => field(
|
|
615
|
+
'function',
|
|
616
|
+
alias(ref($, prefix, 'identifier'), ref($, prefix, 'callback_name')),
|
|
617
|
+
),
|
|
618
|
+
|
|
619
|
+
[familyRule(prefix, 'argument_list')]: ($) => seq(
|
|
620
|
+
field('open', '('),
|
|
621
|
+
optional(field('value', ref($, prefix, 'arguments'))),
|
|
622
|
+
field('close', ')'),
|
|
623
|
+
),
|
|
624
|
+
|
|
625
|
+
[familyRule(prefix, 'arguments')]: (_) => token(prec(-10, /[^)\r\n]+/)),
|
|
626
|
+
[familyRule(prefix, 'link_target')]: (_) => choice('_self', '_blank', '_parent', '_top'),
|
|
627
|
+
|
|
628
|
+
[familyRule(prefix, 'accessibility_title_statement')]: ($) => seq(
|
|
629
|
+
statementKeyword($, prefix, 'accTitle'),
|
|
630
|
+
field('delimiter', ':'),
|
|
631
|
+
optional(field('text', ref($, prefix, 'accessibility_text'))),
|
|
632
|
+
),
|
|
633
|
+
|
|
634
|
+
[familyRule(prefix, 'accessibility_description_statement')]: ($) => seq(
|
|
635
|
+
statementKeyword($, prefix, 'accDescr'),
|
|
636
|
+
choice(
|
|
637
|
+
seq(
|
|
638
|
+
field('delimiter', ':'),
|
|
639
|
+
optional(field('text', ref($, prefix, 'accessibility_text'))),
|
|
640
|
+
),
|
|
641
|
+
field('description', ref($, prefix, 'accessibility_description_block')),
|
|
642
|
+
),
|
|
643
|
+
),
|
|
644
|
+
|
|
645
|
+
[familyRule(prefix, 'accessibility_text')]: (_) => token(prec(-10, /[^;%\r\n]+/)),
|
|
646
|
+
|
|
647
|
+
[familyRule(prefix, 'accessibility_description_block')]: ($) => seq(
|
|
648
|
+
field('open', '{'),
|
|
649
|
+
optional(field('text', ref($, prefix, 'accessibility_block_text'))),
|
|
650
|
+
field('close', token.immediate('}')),
|
|
651
|
+
),
|
|
652
|
+
|
|
653
|
+
[familyRule(prefix, 'accessibility_block_text')]: (_) => token.immediate(/[^}]+/),
|
|
654
|
+
|
|
655
|
+
[familyRule(prefix, 'identifier')]: (_) => choice(
|
|
656
|
+
keywordPrefixedIdentifier(),
|
|
657
|
+
token(prec(
|
|
658
|
+
-5,
|
|
659
|
+
/[A-Za-z0-9_\u00c0-\uffff][A-Za-z0-9_.!?$%#\u00c0-\uffff]*(?:-[A-Za-z0-9_\u00c0-\uffff][A-Za-z0-9_.!?$%#\u00c0-\uffff]*)*/,
|
|
660
|
+
)),
|
|
661
|
+
),
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
const createFlowFamilyConflicts = ($, prefix) => [
|
|
665
|
+
[
|
|
666
|
+
privateRef($, prefix, 'labeled_edge'),
|
|
667
|
+
privateRef($, prefix, 'unlabeled_edge'),
|
|
668
|
+
],
|
|
669
|
+
[
|
|
670
|
+
privateRef($, prefix, 'continued_labeled_edge'),
|
|
671
|
+
privateRef($, prefix, 'continued_unlabeled_edge'),
|
|
672
|
+
],
|
|
673
|
+
];
|
|
674
|
+
|
|
675
|
+
const flowchartRules = createFlowFamilyRules({
|
|
676
|
+
prefix: 'flow',
|
|
677
|
+
diagram: 'flowchart_diagram',
|
|
678
|
+
header: 'flowchart_header',
|
|
679
|
+
headerEof: '_flowchart_header_eof',
|
|
680
|
+
keywords: ['flowchart-elk', 'flowchart', 'graph'],
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
const flowchartConflicts = ($) => createFlowFamilyConflicts($, 'flow');
|
|
684
|
+
|
|
685
|
+
module.exports = {
|
|
686
|
+
createFlowFamilyConflicts,
|
|
687
|
+
createFlowFamilyRules,
|
|
688
|
+
flowchartConflicts,
|
|
689
|
+
flowchartRules,
|
|
690
|
+
};
|