@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,78 @@
|
|
|
1
|
+
const commonRules = {
|
|
2
|
+
_blank_line: ($) => $._line_ending,
|
|
3
|
+
|
|
4
|
+
_line_ending: (_) => token(choice('\r\n', '\n', '\r')),
|
|
5
|
+
|
|
6
|
+
_statement_terminator: ($) => choice($._line_ending, ';'),
|
|
7
|
+
|
|
8
|
+
direction: (_) => choice('LR', 'RL', 'TB', 'BT', 'TD', 'BR', '<', '>', '^', 'v'),
|
|
9
|
+
|
|
10
|
+
identifier: (_) => token(/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_\-\u00c0-\uffff]*/),
|
|
11
|
+
|
|
12
|
+
quoted_string: (_) => token(choice(
|
|
13
|
+
seq('"', /(?:[^"\\]|\\.)*/, '"'),
|
|
14
|
+
seq("'", /(?:[^'\\]|\\.)*/, "'"),
|
|
15
|
+
)),
|
|
16
|
+
|
|
17
|
+
_radar_wardley_quoted_string: ($) => prec.dynamic(10, choice(
|
|
18
|
+
seq(
|
|
19
|
+
'"',
|
|
20
|
+
repeat(choice(
|
|
21
|
+
$._radar_wardley_double_quoted_content,
|
|
22
|
+
$._radar_wardley_escape_sequence,
|
|
23
|
+
$._line_ending,
|
|
24
|
+
)),
|
|
25
|
+
token.immediate('"'),
|
|
26
|
+
),
|
|
27
|
+
seq(
|
|
28
|
+
"'",
|
|
29
|
+
repeat(choice(
|
|
30
|
+
$._radar_wardley_single_quoted_content,
|
|
31
|
+
$._radar_wardley_escape_sequence,
|
|
32
|
+
$._line_ending,
|
|
33
|
+
)),
|
|
34
|
+
token.immediate("'"),
|
|
35
|
+
),
|
|
36
|
+
)),
|
|
37
|
+
|
|
38
|
+
_radar_wardley_unclosed_quoted_string: ($) => prec.dynamic(-10, choice(
|
|
39
|
+
seq(
|
|
40
|
+
'"',
|
|
41
|
+
repeat(choice(
|
|
42
|
+
$._radar_wardley_double_quoted_content,
|
|
43
|
+
$._radar_wardley_escape_sequence,
|
|
44
|
+
)),
|
|
45
|
+
),
|
|
46
|
+
seq(
|
|
47
|
+
"'",
|
|
48
|
+
repeat(choice(
|
|
49
|
+
$._radar_wardley_single_quoted_content,
|
|
50
|
+
$._radar_wardley_escape_sequence,
|
|
51
|
+
)),
|
|
52
|
+
),
|
|
53
|
+
)),
|
|
54
|
+
|
|
55
|
+
_radar_wardley_double_quoted_content: (_) => token.immediate(/[^"\\\r\n]+/),
|
|
56
|
+
|
|
57
|
+
_radar_wardley_single_quoted_content: (_) => token.immediate(/[^'\\\r\n]+/),
|
|
58
|
+
|
|
59
|
+
_radar_wardley_escape_sequence: (_) => token.immediate(/\\[^\r\n]/),
|
|
60
|
+
|
|
61
|
+
_radar_wardley_title_text: (_) => token(prec(
|
|
62
|
+
5,
|
|
63
|
+
/[^\s%\r\n](?:[^%\r\n]|%[^%\r\n])*/,
|
|
64
|
+
)),
|
|
65
|
+
|
|
66
|
+
_radar_wardley_accessibility_text: (_) => token(prec(
|
|
67
|
+
5,
|
|
68
|
+
/(?:[^%\r\n]|%[^%\r\n])+/
|
|
69
|
+
)),
|
|
70
|
+
|
|
71
|
+
_radar_wardley_accessibility_block: (_) => token(seq('{', /[^}]*/, '}')),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const commonConflicts = ($) => [
|
|
75
|
+
[$._radar_wardley_quoted_string, $._radar_wardley_unclosed_quoted_string],
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
module.exports = { commonConflicts, commonRules };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const terminatedHeader = ($, keyword, ...suffix) => seq(
|
|
2
|
+
field('keyword', alias(keyword, $.diagram_keyword)),
|
|
3
|
+
...suffix,
|
|
4
|
+
field('terminator', $._line_ending),
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
const optionallyColonTerminatedHeader = ($, keyword) => terminatedHeader(
|
|
8
|
+
$,
|
|
9
|
+
keyword,
|
|
10
|
+
optional(field('colon', ':')),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
optionallyColonTerminatedHeader,
|
|
15
|
+
terminatedHeader,
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const INDENTATION_FAMILIES = ['mindmap', 'treemap', 'tree_view', 'kanban'];
|
|
2
|
+
|
|
3
|
+
const indentationExternals = ($) => INDENTATION_FAMILIES.flatMap((family) => [
|
|
4
|
+
$[`_${family}_start`],
|
|
5
|
+
$[`_${family}_indent`],
|
|
6
|
+
$[`_${family}_reindent`],
|
|
7
|
+
$[`_${family}_dedent`],
|
|
8
|
+
$[`${family}_indentation_overflow`],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const indentationTransition = ($, family) => choice(
|
|
12
|
+
$[`_${family}_start`],
|
|
13
|
+
$[`_${family}_indent`],
|
|
14
|
+
$[`_${family}_reindent`],
|
|
15
|
+
$[`_${family}_dedent`],
|
|
16
|
+
$[`${family}_indentation_overflow`],
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
indentationExternals,
|
|
21
|
+
indentationTransition,
|
|
22
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// Source translation: Mermaid 11.16.1
|
|
2
|
+
// packages/parser/src/language/common/common.langium
|
|
3
|
+
// commit 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf.
|
|
4
|
+
|
|
5
|
+
const langiumInlineSpacing = () => optional(token.immediate(/[ \t]+/));
|
|
6
|
+
|
|
7
|
+
const langiumRules = {
|
|
8
|
+
// Mermaid's imported NEWLINE terminal is CRLF/LF-only, and EOL accepts one
|
|
9
|
+
// or more NEWLINE tokens. EOF is represented by the optional use at each
|
|
10
|
+
// statement boundary.
|
|
11
|
+
_langium_newline: (_) => token(/(?:\r?\n)+/),
|
|
12
|
+
|
|
13
|
+
_langium_inline_space: (_) => token.immediate(/[ \t]+/),
|
|
14
|
+
|
|
15
|
+
// Mermaid's Langium token builders accept a bare family keyword only at
|
|
16
|
+
// whitespace, comment/directive, or EOF. Families consume this boundary at
|
|
17
|
+
// the diagram seam so the first body node retains its exact byte range.
|
|
18
|
+
_langium_body_boundary: ($) => choice(
|
|
19
|
+
$._langium_inline_space,
|
|
20
|
+
$._langium_newline,
|
|
21
|
+
$.comment,
|
|
22
|
+
$.directive,
|
|
23
|
+
),
|
|
24
|
+
|
|
25
|
+
// Keep complete multiline strings structurally distinct from the line-local
|
|
26
|
+
// recovery form. The dynamic preference preserves Mermaid's multiline
|
|
27
|
+
// STRING behavior when a closing quote exists, while an unfinished edit can
|
|
28
|
+
// stop before the next statement instead of consuming its opening quote.
|
|
29
|
+
langium_string: ($) => prec.dynamic(10, choice(
|
|
30
|
+
seq(
|
|
31
|
+
'"',
|
|
32
|
+
repeat(choice(
|
|
33
|
+
$._langium_double_quoted_content,
|
|
34
|
+
$._langium_escape_sequence,
|
|
35
|
+
$._langium_newline,
|
|
36
|
+
)),
|
|
37
|
+
token.immediate('"'),
|
|
38
|
+
),
|
|
39
|
+
seq(
|
|
40
|
+
"'",
|
|
41
|
+
repeat(choice(
|
|
42
|
+
$._langium_single_quoted_content,
|
|
43
|
+
$._langium_escape_sequence,
|
|
44
|
+
$._langium_newline,
|
|
45
|
+
)),
|
|
46
|
+
token.immediate("'"),
|
|
47
|
+
),
|
|
48
|
+
)),
|
|
49
|
+
|
|
50
|
+
langium_unclosed_string: ($) => prec.dynamic(-10, choice(
|
|
51
|
+
seq(
|
|
52
|
+
'"',
|
|
53
|
+
repeat(choice(
|
|
54
|
+
$._langium_double_quoted_content,
|
|
55
|
+
$._langium_escape_sequence,
|
|
56
|
+
)),
|
|
57
|
+
),
|
|
58
|
+
seq(
|
|
59
|
+
"'",
|
|
60
|
+
repeat(choice(
|
|
61
|
+
$._langium_single_quoted_content,
|
|
62
|
+
$._langium_escape_sequence,
|
|
63
|
+
)),
|
|
64
|
+
),
|
|
65
|
+
)),
|
|
66
|
+
|
|
67
|
+
langium_title_statement: ($) => prec.right(seq(
|
|
68
|
+
field(
|
|
69
|
+
'keyword',
|
|
70
|
+
alias(token(prec(20, 'title')), $.statement_keyword),
|
|
71
|
+
),
|
|
72
|
+
optional(seq(
|
|
73
|
+
token.immediate(/[ \t]+/),
|
|
74
|
+
optional(field('text', $.langium_line_text)),
|
|
75
|
+
)),
|
|
76
|
+
optional(choice(
|
|
77
|
+
field('comment', $.comment),
|
|
78
|
+
field('directive', $.directive),
|
|
79
|
+
)),
|
|
80
|
+
)),
|
|
81
|
+
|
|
82
|
+
langium_acc_title_statement: ($) => prec.right(seq(
|
|
83
|
+
field(
|
|
84
|
+
'keyword',
|
|
85
|
+
alias(token(prec(20, 'accTitle')), $.statement_keyword),
|
|
86
|
+
),
|
|
87
|
+
langiumInlineSpacing(),
|
|
88
|
+
field('delimiter', token.immediate(':')),
|
|
89
|
+
langiumInlineSpacing(),
|
|
90
|
+
optional(field('text', $.langium_line_text)),
|
|
91
|
+
optional(choice(
|
|
92
|
+
field('comment', $.comment),
|
|
93
|
+
field('directive', $.directive),
|
|
94
|
+
)),
|
|
95
|
+
)),
|
|
96
|
+
|
|
97
|
+
langium_acc_descr_statement: ($) => prec.right(seq(
|
|
98
|
+
field(
|
|
99
|
+
'keyword',
|
|
100
|
+
alias(token(prec(20, 'accDescr')), $.statement_keyword),
|
|
101
|
+
),
|
|
102
|
+
choice(
|
|
103
|
+
seq(
|
|
104
|
+
field('delimiter', ':'),
|
|
105
|
+
langiumInlineSpacing(),
|
|
106
|
+
optional(field('text', $.langium_line_text)),
|
|
107
|
+
),
|
|
108
|
+
seq(
|
|
109
|
+
optional($._langium_newline),
|
|
110
|
+
field('description', choice(
|
|
111
|
+
$.langium_acc_descr_block,
|
|
112
|
+
$.langium_unclosed_acc_descr_block,
|
|
113
|
+
)),
|
|
114
|
+
),
|
|
115
|
+
),
|
|
116
|
+
optional(choice(
|
|
117
|
+
field('comment', $.comment),
|
|
118
|
+
field('directive', $.directive),
|
|
119
|
+
)),
|
|
120
|
+
)),
|
|
121
|
+
|
|
122
|
+
// The payload is intentionally opaque. Keeping each complete block in one
|
|
123
|
+
// lexical leaf prevents Tree-sitter from manufacturing a missing `}` after
|
|
124
|
+
// greedily consuming later declarations. The recovery token is line-local.
|
|
125
|
+
langium_acc_descr_block: ($) => field(
|
|
126
|
+
'text',
|
|
127
|
+
$.langium_acc_descr_block_text,
|
|
128
|
+
),
|
|
129
|
+
|
|
130
|
+
langium_unclosed_acc_descr_block: ($) => field(
|
|
131
|
+
'text',
|
|
132
|
+
$.langium_unclosed_acc_descr_block_text,
|
|
133
|
+
),
|
|
134
|
+
|
|
135
|
+
// Keep the payload opaque, but stop before a Langium single-line comment.
|
|
136
|
+
// A single '%' remains ordinary text; when '%%' is possible, the longer
|
|
137
|
+
// comment token wins and becomes a sibling inside the statement.
|
|
138
|
+
// Langium's value converter trims outer horizontal whitespace while
|
|
139
|
+
// preserving internal runs and stops before a `%%` comment.
|
|
140
|
+
langium_line_text: (_) => token(prec(
|
|
141
|
+
-1,
|
|
142
|
+
/[^\s%\r\n](?:(?:[^%\r\n]|%[^%\r\n])*[^\s%\r\n])?/,
|
|
143
|
+
)),
|
|
144
|
+
|
|
145
|
+
langium_acc_descr_block_text: (_) => token(prec(
|
|
146
|
+
10,
|
|
147
|
+
seq('{', /[^}]*/, '}'),
|
|
148
|
+
)),
|
|
149
|
+
|
|
150
|
+
langium_unclosed_acc_descr_block_text: (_) => token(prec(
|
|
151
|
+
-10,
|
|
152
|
+
seq('{', /[^\r\n]*/),
|
|
153
|
+
)),
|
|
154
|
+
|
|
155
|
+
_langium_double_quoted_content: (_) => token.immediate(/[^"\\\r\n]+/),
|
|
156
|
+
|
|
157
|
+
_langium_single_quoted_content: (_) => token.immediate(/[^'\\\r\n]+/),
|
|
158
|
+
|
|
159
|
+
_langium_escape_sequence: (_) => token.immediate(/\\[^\r\n]/),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const langiumConflicts = ($) => [
|
|
163
|
+
[$.langium_string, $.langium_unclosed_string],
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
module.exports = { langiumConflicts, langiumRules };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const preambleRules = {
|
|
2
|
+
bom: (_) => '\ufeff',
|
|
3
|
+
|
|
4
|
+
frontmatter: ($) => seq(
|
|
5
|
+
$.frontmatter_delimiter,
|
|
6
|
+
$._line_ending,
|
|
7
|
+
repeat($.frontmatter_line),
|
|
8
|
+
$.frontmatter_delimiter,
|
|
9
|
+
),
|
|
10
|
+
|
|
11
|
+
frontmatter_delimiter: (_) => '---',
|
|
12
|
+
|
|
13
|
+
frontmatter_line: ($) => seq(optional($.frontmatter_content), $._line_ending),
|
|
14
|
+
|
|
15
|
+
frontmatter_content: (_) => token(prec(-1, /[^\r\n]+/)),
|
|
16
|
+
|
|
17
|
+
directive: ($) => seq(
|
|
18
|
+
token(prec(10, '%%{')),
|
|
19
|
+
optional($._directive_body),
|
|
20
|
+
token.immediate('}%%'),
|
|
21
|
+
),
|
|
22
|
+
|
|
23
|
+
comment: (_) => token(seq('%%', /[^\r\n]*/)),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = { preambleRules };
|
package/grammar.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
const { commonConflicts, commonRules } = require('./grammar/shared/common');
|
|
2
|
+
const {
|
|
3
|
+
langiumConflicts,
|
|
4
|
+
langiumRules,
|
|
5
|
+
} = require('./grammar/shared/langium');
|
|
6
|
+
const { preambleRules } = require('./grammar/shared/preamble');
|
|
7
|
+
const {
|
|
8
|
+
architectureConflicts,
|
|
9
|
+
architectureRules,
|
|
10
|
+
} = require('./grammar/families/architecture');
|
|
11
|
+
const { blockConflicts, blockRules } = require('./grammar/families/block');
|
|
12
|
+
const { c4Rules } = require('./grammar/families/c4');
|
|
13
|
+
const {
|
|
14
|
+
classConflicts,
|
|
15
|
+
classRules,
|
|
16
|
+
} = require('./grammar/families/class');
|
|
17
|
+
const { cynefinRules } = require('./grammar/families/cynefin');
|
|
18
|
+
const {
|
|
19
|
+
entityRelationshipRules,
|
|
20
|
+
} = require('./grammar/families/entity-relationship');
|
|
21
|
+
const {
|
|
22
|
+
flowchartConflicts,
|
|
23
|
+
flowchartRules,
|
|
24
|
+
} = require('./grammar/families/flowchart');
|
|
25
|
+
const { ganttRules } = require('./grammar/families/gantt');
|
|
26
|
+
const {
|
|
27
|
+
gitGraphConflicts,
|
|
28
|
+
gitGraphRules,
|
|
29
|
+
} = require('./grammar/families/git-graph');
|
|
30
|
+
const { infoRules } = require('./grammar/families/info');
|
|
31
|
+
const { ishikawaRules } = require('./grammar/families/ishikawa');
|
|
32
|
+
const { journeyRules } = require('./grammar/families/journey');
|
|
33
|
+
const { packetRules } = require('./grammar/families/packet');
|
|
34
|
+
const { pieConflicts, pieRules } = require('./grammar/families/pie');
|
|
35
|
+
const { quadrantChartRules } = require('./grammar/families/quadrant-chart');
|
|
36
|
+
const { radarConflicts, radarRules } = require('./grammar/families/radar');
|
|
37
|
+
const { railroadAbnfRules } = require('./grammar/families/railroad-abnf');
|
|
38
|
+
const {
|
|
39
|
+
railroadEbnfConflicts,
|
|
40
|
+
railroadEbnfRules,
|
|
41
|
+
} = require('./grammar/families/railroad-ebnf');
|
|
42
|
+
const { railroadPegRules } = require('./grammar/families/railroad-peg');
|
|
43
|
+
const { railroadSharedRules } = require('./grammar/families/railroad-shared');
|
|
44
|
+
const { railroadRules } = require('./grammar/families/railroad');
|
|
45
|
+
const { requirementRules } = require('./grammar/families/requirement');
|
|
46
|
+
const {
|
|
47
|
+
sankeyConflicts,
|
|
48
|
+
sankeyRules,
|
|
49
|
+
} = require('./grammar/families/sankey');
|
|
50
|
+
const { sequenceRules } = require('./grammar/families/sequence');
|
|
51
|
+
const { stateConflicts, stateRules } = require('./grammar/families/state');
|
|
52
|
+
const {
|
|
53
|
+
swimlaneConflicts,
|
|
54
|
+
swimlaneRules,
|
|
55
|
+
} = require('./grammar/families/swimlane');
|
|
56
|
+
const { timelineRules } = require('./grammar/families/timeline');
|
|
57
|
+
const { vennRules } = require('./grammar/families/venn');
|
|
58
|
+
const {
|
|
59
|
+
eventModelingConflicts,
|
|
60
|
+
eventModelingRules,
|
|
61
|
+
} = require('./grammar/families/event-modeling');
|
|
62
|
+
const { zenumlRules } = require('./grammar/families/zenuml');
|
|
63
|
+
const { mindmapRules } = require('./grammar/families/mindmap');
|
|
64
|
+
const { kanbanRules } = require('./grammar/families/kanban');
|
|
65
|
+
const { treemapRules } = require('./grammar/families/treemap');
|
|
66
|
+
const { treeViewRules } = require('./grammar/families/tree-view');
|
|
67
|
+
const { wardleyRules } = require('./grammar/families/wardley');
|
|
68
|
+
const {
|
|
69
|
+
xyChartConflicts,
|
|
70
|
+
xyChartRules,
|
|
71
|
+
} = require('./grammar/families/xy-chart');
|
|
72
|
+
const { indentationExternals } = require('./grammar/shared/indentation');
|
|
73
|
+
|
|
74
|
+
module.exports = grammar({
|
|
75
|
+
name: 'mermaid',
|
|
76
|
+
|
|
77
|
+
extras: ($) => [/[ \t\f\u00a0]+/],
|
|
78
|
+
|
|
79
|
+
word: ($) => $.identifier,
|
|
80
|
+
|
|
81
|
+
externals: ($) => [
|
|
82
|
+
...indentationExternals($),
|
|
83
|
+
$._end_of_input,
|
|
84
|
+
$._directive_body,
|
|
85
|
+
],
|
|
86
|
+
|
|
87
|
+
conflicts: ($) => [
|
|
88
|
+
...commonConflicts($),
|
|
89
|
+
...langiumConflicts($),
|
|
90
|
+
...architectureConflicts($),
|
|
91
|
+
...blockConflicts($),
|
|
92
|
+
...classConflicts($),
|
|
93
|
+
...eventModelingConflicts($),
|
|
94
|
+
...flowchartConflicts($),
|
|
95
|
+
...gitGraphConflicts($),
|
|
96
|
+
...pieConflicts($),
|
|
97
|
+
...radarConflicts($),
|
|
98
|
+
...railroadEbnfConflicts($),
|
|
99
|
+
...sankeyConflicts($),
|
|
100
|
+
...stateConflicts($),
|
|
101
|
+
...swimlaneConflicts($),
|
|
102
|
+
...xyChartConflicts($),
|
|
103
|
+
],
|
|
104
|
+
|
|
105
|
+
rules: {
|
|
106
|
+
source_file: ($) => seq(
|
|
107
|
+
optional($.bom),
|
|
108
|
+
repeat(choice($.frontmatter, $.directive, $.comment, $._blank_line)),
|
|
109
|
+
optional(choice(
|
|
110
|
+
$.architecture_diagram,
|
|
111
|
+
$.block_diagram,
|
|
112
|
+
$.c4_diagram,
|
|
113
|
+
$.class_diagram,
|
|
114
|
+
$.entity_relationship_diagram,
|
|
115
|
+
$.flowchart_diagram,
|
|
116
|
+
$.event_modeling_diagram,
|
|
117
|
+
$.sequence_diagram,
|
|
118
|
+
$.sankey_diagram,
|
|
119
|
+
$.venn_diagram,
|
|
120
|
+
$.zenuml_diagram,
|
|
121
|
+
$.mindmap_diagram,
|
|
122
|
+
$.kanban_diagram,
|
|
123
|
+
$.treemap_diagram,
|
|
124
|
+
$.tree_view_diagram,
|
|
125
|
+
$.info_diagram,
|
|
126
|
+
$.cynefin_diagram,
|
|
127
|
+
$.gantt_diagram,
|
|
128
|
+
$.git_graph_diagram,
|
|
129
|
+
$.ishikawa_diagram,
|
|
130
|
+
$.journey_diagram,
|
|
131
|
+
$.packet_diagram,
|
|
132
|
+
$.pie_diagram,
|
|
133
|
+
$.quadrant_chart_diagram,
|
|
134
|
+
$.radar_diagram,
|
|
135
|
+
$.railroad_diagram,
|
|
136
|
+
$.railroad_abnf_diagram,
|
|
137
|
+
$.railroad_ebnf_diagram,
|
|
138
|
+
$.railroad_peg_diagram,
|
|
139
|
+
$.requirement_diagram,
|
|
140
|
+
$.state_diagram,
|
|
141
|
+
$.swimlane_diagram,
|
|
142
|
+
$.timeline_diagram,
|
|
143
|
+
$.wardley_diagram,
|
|
144
|
+
$.xy_chart_diagram,
|
|
145
|
+
)),
|
|
146
|
+
),
|
|
147
|
+
|
|
148
|
+
...preambleRules,
|
|
149
|
+
...commonRules,
|
|
150
|
+
...langiumRules,
|
|
151
|
+
...architectureRules,
|
|
152
|
+
...blockRules,
|
|
153
|
+
...c4Rules,
|
|
154
|
+
...classRules,
|
|
155
|
+
...entityRelationshipRules,
|
|
156
|
+
...infoRules,
|
|
157
|
+
...cynefinRules,
|
|
158
|
+
...ganttRules,
|
|
159
|
+
...gitGraphRules,
|
|
160
|
+
...ishikawaRules,
|
|
161
|
+
...journeyRules,
|
|
162
|
+
...packetRules,
|
|
163
|
+
...pieRules,
|
|
164
|
+
...quadrantChartRules,
|
|
165
|
+
...radarRules,
|
|
166
|
+
...railroadSharedRules,
|
|
167
|
+
...railroadRules,
|
|
168
|
+
...railroadAbnfRules,
|
|
169
|
+
...railroadEbnfRules,
|
|
170
|
+
...railroadPegRules,
|
|
171
|
+
...requirementRules,
|
|
172
|
+
...stateRules,
|
|
173
|
+
...swimlaneRules,
|
|
174
|
+
...timelineRules,
|
|
175
|
+
...wardleyRules,
|
|
176
|
+
...xyChartRules,
|
|
177
|
+
...flowchartRules,
|
|
178
|
+
...eventModelingRules,
|
|
179
|
+
...sequenceRules,
|
|
180
|
+
...sankeyRules,
|
|
181
|
+
...vennRules,
|
|
182
|
+
...zenumlRules,
|
|
183
|
+
...mindmapRules,
|
|
184
|
+
...kanbanRules,
|
|
185
|
+
...treemapRules,
|
|
186
|
+
...treeViewRules,
|
|
187
|
+
},
|
|
188
|
+
});
|