@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,725 @@
|
|
|
1
|
+
// Source translation:
|
|
2
|
+
// - Mermaid 11.16.1 @ 7ecca0cd7f1658ef74f4e7e91f925724ef403bbf
|
|
3
|
+
// packages/mermaid-zenuml/src/{detector,parser,zenumlRenderer}.ts
|
|
4
|
+
// - @zenuml/core 3.50.1 @ 38404ccc14243ed54ab45b804b2eb6f2ca73af36
|
|
5
|
+
// src/g4/sequenceLexer.g4 and src/g4/sequenceParser.g4
|
|
6
|
+
//
|
|
7
|
+
// The companion parser deliberately accepts incomplete editor states. This
|
|
8
|
+
// translation keeps those states local to the construct that introduced them;
|
|
9
|
+
// it does not use an opaque whole-line or whole-body fallback.
|
|
10
|
+
|
|
11
|
+
const keywordChoice = (keywords) => (
|
|
12
|
+
keywords.length === 1
|
|
13
|
+
? keywords[0]
|
|
14
|
+
: choice(...keywords)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const diagramKeyword = ($) => field(
|
|
18
|
+
'keyword',
|
|
19
|
+
alias(keywordChoice(['zenuml']), $.diagram_keyword),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const statementKeyword = ($, ...keywords) => field(
|
|
23
|
+
'keyword',
|
|
24
|
+
alias(keywordChoice(keywords), $.zenuml_statement_keyword),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const controlKeyword = ($, ...keywords) => field(
|
|
28
|
+
'keyword',
|
|
29
|
+
alias(keywordChoice(keywords), $.zenuml_control_keyword),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const operatorToken = ($, ...operators) => alias(
|
|
33
|
+
operators.length === 1
|
|
34
|
+
? operators[0]
|
|
35
|
+
: choice(...operators),
|
|
36
|
+
$.zenuml_operator,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const binaryExpression = ($, precedence, ...operators) => prec.left(precedence, seq(
|
|
40
|
+
field('left', $.zenuml_expression),
|
|
41
|
+
field('operator', operatorToken($, ...operators)),
|
|
42
|
+
field('right', $.zenuml_expression),
|
|
43
|
+
));
|
|
44
|
+
|
|
45
|
+
const modifiers = ($) => repeat(field('modifier', $.zenuml_modifier));
|
|
46
|
+
|
|
47
|
+
const zenumlRules = {
|
|
48
|
+
zenuml_diagram: ($) => seq(
|
|
49
|
+
field('header', $.zenuml_header),
|
|
50
|
+
optional(field('body', $.zenuml_body)),
|
|
51
|
+
),
|
|
52
|
+
|
|
53
|
+
zenuml_header: ($) => diagramKeyword($),
|
|
54
|
+
|
|
55
|
+
zenuml_body: ($) => choice(
|
|
56
|
+
repeat1($._zenuml_body_line),
|
|
57
|
+
seq(
|
|
58
|
+
repeat($._zenuml_body_line),
|
|
59
|
+
$._zenuml_body_final_item,
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
|
|
63
|
+
_zenuml_body_line: ($) => choice(
|
|
64
|
+
prec.right(70, seq(
|
|
65
|
+
field('declaration', $._zenuml_declaration),
|
|
66
|
+
field('terminator', $._statement_terminator),
|
|
67
|
+
)),
|
|
68
|
+
prec.right(10, seq(
|
|
69
|
+
field('statement', $._zenuml_statement),
|
|
70
|
+
field('terminator', $._statement_terminator),
|
|
71
|
+
)),
|
|
72
|
+
prec.right(10, seq(
|
|
73
|
+
field('comment', $.zenuml_comment),
|
|
74
|
+
$._line_ending,
|
|
75
|
+
)),
|
|
76
|
+
$._blank_line,
|
|
77
|
+
),
|
|
78
|
+
|
|
79
|
+
_zenuml_body_final_item: ($) => choice(
|
|
80
|
+
prec.right(60, field('declaration', $._zenuml_declaration)),
|
|
81
|
+
prec.right(-10, field('statement', $._zenuml_statement)),
|
|
82
|
+
prec.right(-10, field('comment', $.zenuml_comment)),
|
|
83
|
+
),
|
|
84
|
+
|
|
85
|
+
_zenuml_declaration: ($) => choice(
|
|
86
|
+
$.zenuml_title_statement,
|
|
87
|
+
$.zenuml_group_declaration,
|
|
88
|
+
$.zenuml_starter_declaration,
|
|
89
|
+
$.zenuml_participant_declaration,
|
|
90
|
+
),
|
|
91
|
+
|
|
92
|
+
_zenuml_statement: ($) => choice(
|
|
93
|
+
$.zenuml_if_statement,
|
|
94
|
+
$.zenuml_parallel_statement,
|
|
95
|
+
$.zenuml_optional_statement,
|
|
96
|
+
$.zenuml_critical_statement,
|
|
97
|
+
$.zenuml_section_statement,
|
|
98
|
+
$.zenuml_loop_statement,
|
|
99
|
+
$.zenuml_try_statement,
|
|
100
|
+
$.zenuml_reference_statement,
|
|
101
|
+
$.zenuml_creation_statement,
|
|
102
|
+
$.zenuml_return_statement,
|
|
103
|
+
$.zenuml_reply_message_statement,
|
|
104
|
+
$.zenuml_async_message_statement,
|
|
105
|
+
$.zenuml_sync_message_statement,
|
|
106
|
+
$.zenuml_incomplete_message_statement,
|
|
107
|
+
$.zenuml_divider_statement,
|
|
108
|
+
),
|
|
109
|
+
|
|
110
|
+
zenuml_title_statement: ($) => prec.right(70, seq(
|
|
111
|
+
statementKeyword($, 'title'),
|
|
112
|
+
optional(seq(
|
|
113
|
+
token.immediate(/[ \t]+/),
|
|
114
|
+
optional(field('text', $.zenuml_title_text)),
|
|
115
|
+
)),
|
|
116
|
+
)),
|
|
117
|
+
|
|
118
|
+
zenuml_title_text: (_) => token.immediate(/[^\r\n]+/),
|
|
119
|
+
|
|
120
|
+
zenuml_group_declaration: ($) => prec.right(70, seq(
|
|
121
|
+
statementKeyword($, 'group'),
|
|
122
|
+
optional(field('name', $.zenuml_name)),
|
|
123
|
+
optional(field('body', choice(
|
|
124
|
+
$.zenuml_group_block,
|
|
125
|
+
$.zenuml_unclosed_group_block,
|
|
126
|
+
))),
|
|
127
|
+
)),
|
|
128
|
+
|
|
129
|
+
zenuml_group_block: ($) => prec(30, seq(
|
|
130
|
+
field('open', '{'),
|
|
131
|
+
repeat($._zenuml_group_line),
|
|
132
|
+
optional($._zenuml_group_final_item),
|
|
133
|
+
field('close', '}'),
|
|
134
|
+
)),
|
|
135
|
+
|
|
136
|
+
zenuml_unclosed_group_block: ($) => prec(-50, seq(
|
|
137
|
+
field('open', '{'),
|
|
138
|
+
repeat($._zenuml_group_line),
|
|
139
|
+
optional($._zenuml_group_final_item),
|
|
140
|
+
)),
|
|
141
|
+
|
|
142
|
+
_zenuml_group_line: ($) => choice(
|
|
143
|
+
prec.right(10, seq(
|
|
144
|
+
field('participant', $.zenuml_participant_declaration),
|
|
145
|
+
field('terminator', $._statement_terminator),
|
|
146
|
+
)),
|
|
147
|
+
prec.right(10, seq(field('comment', $.zenuml_comment), $._line_ending)),
|
|
148
|
+
$._blank_line,
|
|
149
|
+
),
|
|
150
|
+
|
|
151
|
+
_zenuml_group_final_item: ($) => choice(
|
|
152
|
+
prec.right(-10, field('participant', $.zenuml_participant_declaration)),
|
|
153
|
+
prec.right(-10, field('comment', $.zenuml_comment)),
|
|
154
|
+
),
|
|
155
|
+
|
|
156
|
+
zenuml_starter_declaration: ($) => prec.right(80, seq(
|
|
157
|
+
field('annotation', $.zenuml_starter_annotation),
|
|
158
|
+
optional(seq(
|
|
159
|
+
field('open', '('),
|
|
160
|
+
optional(field('participant', $.zenuml_name)),
|
|
161
|
+
optional(field('close', ')')),
|
|
162
|
+
)),
|
|
163
|
+
)),
|
|
164
|
+
|
|
165
|
+
zenuml_participant_declaration: ($) => prec.dynamic(20, choice(
|
|
166
|
+
prec.right(60, seq(
|
|
167
|
+
optional(field('type', $.zenuml_participant_annotation)),
|
|
168
|
+
optional(field('stereotype', $.zenuml_stereotype)),
|
|
169
|
+
optional(field('emoji', $.zenuml_emoji)),
|
|
170
|
+
field('name', $.zenuml_name),
|
|
171
|
+
optional(field('width', $.zenuml_width)),
|
|
172
|
+
optional(field('alias', $.zenuml_alias_clause)),
|
|
173
|
+
optional(field('color', $.zenuml_color)),
|
|
174
|
+
)),
|
|
175
|
+
field('stereotype', $.zenuml_stereotype),
|
|
176
|
+
field('type', $.zenuml_participant_annotation),
|
|
177
|
+
)),
|
|
178
|
+
|
|
179
|
+
zenuml_alias_clause: ($) => prec.right(seq(
|
|
180
|
+
field(
|
|
181
|
+
'keyword',
|
|
182
|
+
alias('as', $.zenuml_statement_keyword),
|
|
183
|
+
),
|
|
184
|
+
optional(seq(
|
|
185
|
+
token.immediate(/[ \t]+/),
|
|
186
|
+
field('label', $.zenuml_name),
|
|
187
|
+
)),
|
|
188
|
+
)),
|
|
189
|
+
|
|
190
|
+
zenuml_stereotype: ($) => prec.right(seq(
|
|
191
|
+
field('open', choice('<<', '<')),
|
|
192
|
+
optional(field('name', $.zenuml_name)),
|
|
193
|
+
optional(field('close', choice('>>', '>'))),
|
|
194
|
+
)),
|
|
195
|
+
|
|
196
|
+
zenuml_emoji: ($) => seq(
|
|
197
|
+
field('open', '['),
|
|
198
|
+
field('name', $.zenuml_name),
|
|
199
|
+
field('close', ']'),
|
|
200
|
+
),
|
|
201
|
+
|
|
202
|
+
zenuml_width: ($) => field('value', $.zenuml_number),
|
|
203
|
+
|
|
204
|
+
zenuml_if_statement: ($) => prec.right(60, seq(
|
|
205
|
+
controlKeyword($, 'if'),
|
|
206
|
+
field('condition', choice(
|
|
207
|
+
$.zenuml_condition_clause,
|
|
208
|
+
$.zenuml_unclosed_condition_clause,
|
|
209
|
+
)),
|
|
210
|
+
optional(field('body', $._zenuml_any_block)),
|
|
211
|
+
repeat(seq(
|
|
212
|
+
repeat($._line_ending),
|
|
213
|
+
field('branch', $.zenuml_else_if_clause),
|
|
214
|
+
)),
|
|
215
|
+
optional(seq(
|
|
216
|
+
repeat($._line_ending),
|
|
217
|
+
field('branch', $.zenuml_else_clause),
|
|
218
|
+
)),
|
|
219
|
+
)),
|
|
220
|
+
|
|
221
|
+
zenuml_else_if_clause: ($) => prec.right(seq(
|
|
222
|
+
controlKeyword($, 'else'),
|
|
223
|
+
controlKeyword($, 'if'),
|
|
224
|
+
field('condition', choice(
|
|
225
|
+
$.zenuml_condition_clause,
|
|
226
|
+
$.zenuml_unclosed_condition_clause,
|
|
227
|
+
)),
|
|
228
|
+
optional(field('body', $._zenuml_any_block)),
|
|
229
|
+
)),
|
|
230
|
+
|
|
231
|
+
zenuml_else_clause: ($) => prec.right(seq(
|
|
232
|
+
controlKeyword($, 'else'),
|
|
233
|
+
optional(field('body', $._zenuml_any_block)),
|
|
234
|
+
)),
|
|
235
|
+
|
|
236
|
+
zenuml_parallel_statement: ($) => prec.right(50, seq(
|
|
237
|
+
controlKeyword($, 'par'),
|
|
238
|
+
optional(field('condition', choice(
|
|
239
|
+
$.zenuml_condition_clause,
|
|
240
|
+
$.zenuml_unclosed_condition_clause,
|
|
241
|
+
))),
|
|
242
|
+
optional(field('body', $._zenuml_any_block)),
|
|
243
|
+
)),
|
|
244
|
+
|
|
245
|
+
zenuml_optional_statement: ($) => prec.right(50, seq(
|
|
246
|
+
controlKeyword($, 'opt'),
|
|
247
|
+
optional(field('condition', choice(
|
|
248
|
+
$.zenuml_condition_clause,
|
|
249
|
+
$.zenuml_unclosed_condition_clause,
|
|
250
|
+
))),
|
|
251
|
+
optional(field('body', $._zenuml_any_block)),
|
|
252
|
+
)),
|
|
253
|
+
|
|
254
|
+
zenuml_critical_statement: ($) => prec.right(50, seq(
|
|
255
|
+
controlKeyword($, 'critical'),
|
|
256
|
+
optional(field('condition', choice(
|
|
257
|
+
$.zenuml_condition_clause,
|
|
258
|
+
$.zenuml_unclosed_condition_clause,
|
|
259
|
+
))),
|
|
260
|
+
optional(field('body', $._zenuml_any_block)),
|
|
261
|
+
)),
|
|
262
|
+
|
|
263
|
+
zenuml_section_statement: ($) => prec.right(50, choice(
|
|
264
|
+
seq(
|
|
265
|
+
controlKeyword($, 'section', 'frame'),
|
|
266
|
+
optional(field('condition', choice(
|
|
267
|
+
$.zenuml_condition_clause,
|
|
268
|
+
$.zenuml_unclosed_condition_clause,
|
|
269
|
+
))),
|
|
270
|
+
optional(field('body', $._zenuml_any_block)),
|
|
271
|
+
),
|
|
272
|
+
field('body', $._zenuml_any_block),
|
|
273
|
+
)),
|
|
274
|
+
|
|
275
|
+
zenuml_loop_statement: ($) => prec.right(50, seq(
|
|
276
|
+
controlKeyword($, 'while', 'for', 'foreach', 'forEach', 'loop'),
|
|
277
|
+
optional(field('condition', choice(
|
|
278
|
+
$.zenuml_condition_clause,
|
|
279
|
+
$.zenuml_unclosed_condition_clause,
|
|
280
|
+
))),
|
|
281
|
+
optional(field('body', $._zenuml_any_block)),
|
|
282
|
+
)),
|
|
283
|
+
|
|
284
|
+
zenuml_try_statement: ($) => prec.right(60, seq(
|
|
285
|
+
controlKeyword($, 'try'),
|
|
286
|
+
field('body', $._zenuml_any_block),
|
|
287
|
+
repeat(seq(
|
|
288
|
+
repeat($._line_ending),
|
|
289
|
+
field('catch', $.zenuml_catch_clause),
|
|
290
|
+
)),
|
|
291
|
+
optional(seq(
|
|
292
|
+
repeat($._line_ending),
|
|
293
|
+
field('finally', $.zenuml_finally_clause),
|
|
294
|
+
)),
|
|
295
|
+
)),
|
|
296
|
+
|
|
297
|
+
zenuml_catch_clause: ($) => seq(
|
|
298
|
+
controlKeyword($, 'catch'),
|
|
299
|
+
optional(field('exception', choice(
|
|
300
|
+
$.zenuml_argument_list,
|
|
301
|
+
$.zenuml_unclosed_argument_list,
|
|
302
|
+
))),
|
|
303
|
+
field('body', $._zenuml_any_block),
|
|
304
|
+
),
|
|
305
|
+
|
|
306
|
+
zenuml_finally_clause: ($) => seq(
|
|
307
|
+
controlKeyword($, 'finally'),
|
|
308
|
+
field('body', $._zenuml_any_block),
|
|
309
|
+
),
|
|
310
|
+
|
|
311
|
+
zenuml_reference_statement: ($) => prec.right(50, seq(
|
|
312
|
+
controlKeyword($, 'ref'),
|
|
313
|
+
field('participants', choice(
|
|
314
|
+
$.zenuml_reference_list,
|
|
315
|
+
$.zenuml_unclosed_reference_list,
|
|
316
|
+
)),
|
|
317
|
+
)),
|
|
318
|
+
|
|
319
|
+
zenuml_reference_list: ($) => prec(30, seq(
|
|
320
|
+
field('open', '('),
|
|
321
|
+
optional(seq(
|
|
322
|
+
field('participant', $.zenuml_name),
|
|
323
|
+
repeat(seq(
|
|
324
|
+
field('delimiter', ','),
|
|
325
|
+
optional(field('participant', $.zenuml_name)),
|
|
326
|
+
)),
|
|
327
|
+
)),
|
|
328
|
+
field('close', ')'),
|
|
329
|
+
)),
|
|
330
|
+
|
|
331
|
+
zenuml_unclosed_reference_list: ($) => prec(-40, seq(
|
|
332
|
+
field('open', '('),
|
|
333
|
+
optional(seq(
|
|
334
|
+
field('participant', $.zenuml_name),
|
|
335
|
+
repeat(seq(
|
|
336
|
+
field('delimiter', ','),
|
|
337
|
+
optional(field('participant', $.zenuml_name)),
|
|
338
|
+
)),
|
|
339
|
+
)),
|
|
340
|
+
)),
|
|
341
|
+
|
|
342
|
+
zenuml_creation_statement: ($) => prec.right(55, seq(
|
|
343
|
+
modifiers($),
|
|
344
|
+
optional(field('assignment', $.zenuml_assignment)),
|
|
345
|
+
statementKeyword($, 'new'),
|
|
346
|
+
optional(field('constructor', $.zenuml_construct)),
|
|
347
|
+
optional(field('arguments', choice(
|
|
348
|
+
$.zenuml_argument_list,
|
|
349
|
+
$.zenuml_unclosed_argument_list,
|
|
350
|
+
))),
|
|
351
|
+
optional(field('body', $._zenuml_any_block)),
|
|
352
|
+
)),
|
|
353
|
+
|
|
354
|
+
zenuml_sync_message_statement: ($) => prec.dynamic(10, prec.right(45, seq(
|
|
355
|
+
modifiers($),
|
|
356
|
+
optional(field('assignment', $.zenuml_assignment)),
|
|
357
|
+
choice(
|
|
358
|
+
seq(
|
|
359
|
+
optional(seq(
|
|
360
|
+
field('source', $.zenuml_endpoint),
|
|
361
|
+
field('arrow', $.zenuml_arrow),
|
|
362
|
+
)),
|
|
363
|
+
field('target', $.zenuml_endpoint),
|
|
364
|
+
field('delimiter', '.'),
|
|
365
|
+
field('message', $.zenuml_call_chain),
|
|
366
|
+
),
|
|
367
|
+
field('message', $.zenuml_signature),
|
|
368
|
+
),
|
|
369
|
+
optional(field('body', $._zenuml_any_block)),
|
|
370
|
+
))),
|
|
371
|
+
|
|
372
|
+
zenuml_async_message_statement: ($) => prec.right(50, seq(
|
|
373
|
+
modifiers($),
|
|
374
|
+
optional(seq(
|
|
375
|
+
field('source', $.zenuml_endpoint),
|
|
376
|
+
field('arrow', $.zenuml_arrow),
|
|
377
|
+
)),
|
|
378
|
+
field('target', $.zenuml_endpoint),
|
|
379
|
+
field('delimiter', ':'),
|
|
380
|
+
optional(seq(
|
|
381
|
+
optional(token.immediate(/[ \t]+/)),
|
|
382
|
+
field('message', $.zenuml_event_payload),
|
|
383
|
+
)),
|
|
384
|
+
)),
|
|
385
|
+
|
|
386
|
+
zenuml_reply_message_statement: ($) => prec.right(55, seq(
|
|
387
|
+
field('source', $.zenuml_endpoint),
|
|
388
|
+
field('arrow', $.zenuml_return_arrow),
|
|
389
|
+
optional(field('target', $.zenuml_endpoint)),
|
|
390
|
+
optional(seq(
|
|
391
|
+
field('delimiter', ':'),
|
|
392
|
+
optional(seq(
|
|
393
|
+
optional(token.immediate(/[ \t]+/)),
|
|
394
|
+
field('message', $.zenuml_event_payload),
|
|
395
|
+
)),
|
|
396
|
+
)),
|
|
397
|
+
)),
|
|
398
|
+
|
|
399
|
+
zenuml_return_statement: ($) => prec.right(65, choice(
|
|
400
|
+
seq(
|
|
401
|
+
controlKeyword($, 'return'),
|
|
402
|
+
optional(field('value', $.zenuml_expression)),
|
|
403
|
+
),
|
|
404
|
+
seq(
|
|
405
|
+
field('annotation', $.zenuml_reply_annotation),
|
|
406
|
+
optional(seq(
|
|
407
|
+
repeat($._line_ending),
|
|
408
|
+
field('message', choice(
|
|
409
|
+
$.zenuml_reply_message_statement,
|
|
410
|
+
$.zenuml_async_message_statement,
|
|
411
|
+
)),
|
|
412
|
+
)),
|
|
413
|
+
),
|
|
414
|
+
)),
|
|
415
|
+
|
|
416
|
+
zenuml_incomplete_message_statement: ($) => prec.right(-30, choice(
|
|
417
|
+
seq(
|
|
418
|
+
field('source', $.zenuml_endpoint),
|
|
419
|
+
field('arrow', choice($.zenuml_arrow, alias('-', $.zenuml_arrow))),
|
|
420
|
+
optional(field('target', $.zenuml_endpoint)),
|
|
421
|
+
),
|
|
422
|
+
seq(
|
|
423
|
+
field('target', $.zenuml_endpoint),
|
|
424
|
+
field('delimiter', '.'),
|
|
425
|
+
),
|
|
426
|
+
seq(
|
|
427
|
+
field('target', $.zenuml_endpoint),
|
|
428
|
+
field('delimiter', ':'),
|
|
429
|
+
),
|
|
430
|
+
)),
|
|
431
|
+
|
|
432
|
+
zenuml_divider_statement: ($) => prec.right(40, seq(
|
|
433
|
+
field('operator', alias(token(prec(70, /==+/)), $.zenuml_operator)),
|
|
434
|
+
optional(field('text', $.zenuml_divider_text)),
|
|
435
|
+
)),
|
|
436
|
+
|
|
437
|
+
zenuml_divider_text: (_) => token.immediate(/[^\r\n]+/),
|
|
438
|
+
|
|
439
|
+
_zenuml_any_block: ($) => choice(
|
|
440
|
+
$.zenuml_block,
|
|
441
|
+
$.zenuml_unclosed_block,
|
|
442
|
+
),
|
|
443
|
+
|
|
444
|
+
zenuml_block: ($) => prec(30, seq(
|
|
445
|
+
field('open', '{'),
|
|
446
|
+
repeat($._zenuml_block_line),
|
|
447
|
+
optional($._zenuml_block_final_item),
|
|
448
|
+
field('close', '}'),
|
|
449
|
+
)),
|
|
450
|
+
|
|
451
|
+
zenuml_unclosed_block: ($) => prec(-50, seq(
|
|
452
|
+
field('open', '{'),
|
|
453
|
+
repeat($._zenuml_block_line),
|
|
454
|
+
optional($._zenuml_block_final_item),
|
|
455
|
+
)),
|
|
456
|
+
|
|
457
|
+
_zenuml_block_line: ($) => choice(
|
|
458
|
+
prec.right(10, seq(
|
|
459
|
+
field('statement', $._zenuml_statement),
|
|
460
|
+
field('terminator', $._statement_terminator),
|
|
461
|
+
)),
|
|
462
|
+
prec.right(10, seq(field('comment', $.zenuml_comment), $._line_ending)),
|
|
463
|
+
$._blank_line,
|
|
464
|
+
),
|
|
465
|
+
|
|
466
|
+
_zenuml_block_final_item: ($) => choice(
|
|
467
|
+
prec.right(-10, field('statement', $._zenuml_statement)),
|
|
468
|
+
prec.right(-10, field('comment', $.zenuml_comment)),
|
|
469
|
+
),
|
|
470
|
+
|
|
471
|
+
zenuml_condition_clause: ($) => prec(30, seq(
|
|
472
|
+
field('open', '('),
|
|
473
|
+
optional(field('value', $.zenuml_expression)),
|
|
474
|
+
field('close', ')'),
|
|
475
|
+
)),
|
|
476
|
+
|
|
477
|
+
zenuml_unclosed_condition_clause: ($) => prec(-40, seq(
|
|
478
|
+
field('open', '('),
|
|
479
|
+
optional(field('value', $.zenuml_expression)),
|
|
480
|
+
)),
|
|
481
|
+
|
|
482
|
+
zenuml_assignment: ($) => prec.right(45, choice(
|
|
483
|
+
seq(
|
|
484
|
+
field('type', $.zenuml_name),
|
|
485
|
+
field('assignee', $.zenuml_assignee),
|
|
486
|
+
field('operator', alias('=', $.zenuml_assignment_operator)),
|
|
487
|
+
),
|
|
488
|
+
seq(
|
|
489
|
+
field('assignee', $.zenuml_assignee),
|
|
490
|
+
field('operator', alias('=', $.zenuml_assignment_operator)),
|
|
491
|
+
),
|
|
492
|
+
)),
|
|
493
|
+
|
|
494
|
+
zenuml_assignee: ($) => seq(
|
|
495
|
+
field('item', $._zenuml_assignment_target),
|
|
496
|
+
repeat(seq(
|
|
497
|
+
field('delimiter', ','),
|
|
498
|
+
field('item', $._zenuml_assignment_target),
|
|
499
|
+
)),
|
|
500
|
+
),
|
|
501
|
+
|
|
502
|
+
_zenuml_assignment_target: ($) => choice(
|
|
503
|
+
$.zenuml_identifier,
|
|
504
|
+
$.zenuml_digit_leading_name,
|
|
505
|
+
$.zenuml_string,
|
|
506
|
+
$.zenuml_unclosed_string,
|
|
507
|
+
$.zenuml_number,
|
|
508
|
+
$.zenuml_number_unit,
|
|
509
|
+
$.zenuml_money,
|
|
510
|
+
$.zenuml_boolean,
|
|
511
|
+
$.zenuml_nil,
|
|
512
|
+
alias(keywordChoice(['new']), $.zenuml_statement_keyword),
|
|
513
|
+
),
|
|
514
|
+
|
|
515
|
+
zenuml_construct: ($) => field('name', $.zenuml_name),
|
|
516
|
+
|
|
517
|
+
zenuml_endpoint: ($) => seq(
|
|
518
|
+
optional(field('emoji', $.zenuml_emoji)),
|
|
519
|
+
field('name', $.zenuml_name),
|
|
520
|
+
),
|
|
521
|
+
|
|
522
|
+
zenuml_call_chain: ($) => prec.right(seq(
|
|
523
|
+
field('call', $.zenuml_signature),
|
|
524
|
+
repeat(seq(
|
|
525
|
+
field('delimiter', '.'),
|
|
526
|
+
field('call', $.zenuml_signature),
|
|
527
|
+
)),
|
|
528
|
+
)),
|
|
529
|
+
|
|
530
|
+
zenuml_signature: ($) => seq(
|
|
531
|
+
optional(field('emoji', $.zenuml_emoji)),
|
|
532
|
+
field('name', $.zenuml_name),
|
|
533
|
+
optional(field('arguments', choice(
|
|
534
|
+
$.zenuml_argument_list,
|
|
535
|
+
$.zenuml_unclosed_argument_list,
|
|
536
|
+
))),
|
|
537
|
+
),
|
|
538
|
+
|
|
539
|
+
zenuml_argument_list: ($) => prec.right(30, seq(
|
|
540
|
+
field('open', '('),
|
|
541
|
+
optional(seq(
|
|
542
|
+
field('argument', $.zenuml_argument),
|
|
543
|
+
repeat(seq(
|
|
544
|
+
field('delimiter', ','),
|
|
545
|
+
optional(field('argument', $.zenuml_argument)),
|
|
546
|
+
)),
|
|
547
|
+
)),
|
|
548
|
+
field('close', ')'),
|
|
549
|
+
)),
|
|
550
|
+
|
|
551
|
+
zenuml_unclosed_argument_list: ($) => prec.right(-40, seq(
|
|
552
|
+
field('open', '('),
|
|
553
|
+
optional(seq(
|
|
554
|
+
field('argument', $.zenuml_argument),
|
|
555
|
+
repeat(seq(
|
|
556
|
+
field('delimiter', ','),
|
|
557
|
+
optional(field('argument', $.zenuml_argument)),
|
|
558
|
+
)),
|
|
559
|
+
)),
|
|
560
|
+
)),
|
|
561
|
+
|
|
562
|
+
zenuml_argument: ($) => choice(
|
|
563
|
+
$.zenuml_named_argument,
|
|
564
|
+
$.zenuml_declaration_argument,
|
|
565
|
+
$.zenuml_expression,
|
|
566
|
+
),
|
|
567
|
+
|
|
568
|
+
zenuml_named_argument: ($) => prec.right(45, seq(
|
|
569
|
+
field('name', choice($.zenuml_identifier, $.zenuml_digit_leading_name)),
|
|
570
|
+
field('operator', alias('=', $.zenuml_assignment_operator)),
|
|
571
|
+
optional(field('value', $.zenuml_expression)),
|
|
572
|
+
)),
|
|
573
|
+
|
|
574
|
+
zenuml_declaration_argument: ($) => prec(35, seq(
|
|
575
|
+
field('type', $.zenuml_name),
|
|
576
|
+
field('name', choice($.zenuml_identifier, $.zenuml_digit_leading_name)),
|
|
577
|
+
)),
|
|
578
|
+
|
|
579
|
+
zenuml_expression: ($) => prec(10, choice(
|
|
580
|
+
$.zenuml_binary_expression,
|
|
581
|
+
$.zenuml_unary_expression,
|
|
582
|
+
$.zenuml_parenthesized_expression,
|
|
583
|
+
$.zenuml_assignment_expression,
|
|
584
|
+
$.zenuml_creation_expression,
|
|
585
|
+
$.zenuml_call_expression,
|
|
586
|
+
$.zenuml_text_expression,
|
|
587
|
+
$.zenuml_identifier,
|
|
588
|
+
$.zenuml_digit_leading_name,
|
|
589
|
+
$.zenuml_string,
|
|
590
|
+
$.zenuml_unclosed_string,
|
|
591
|
+
$.zenuml_number,
|
|
592
|
+
$.zenuml_number_unit,
|
|
593
|
+
$.zenuml_money,
|
|
594
|
+
$.zenuml_boolean,
|
|
595
|
+
$.zenuml_nil,
|
|
596
|
+
)),
|
|
597
|
+
|
|
598
|
+
zenuml_binary_expression: ($) => choice(
|
|
599
|
+
binaryExpression($, 1, '||'),
|
|
600
|
+
binaryExpression($, 2, '&&'),
|
|
601
|
+
binaryExpression($, 3, '==', '!='),
|
|
602
|
+
binaryExpression($, 4, '<=', '>=', '<', '>'),
|
|
603
|
+
binaryExpression($, 5, '+', '-'),
|
|
604
|
+
binaryExpression($, 6, '*', '/', '%'),
|
|
605
|
+
binaryExpression($, 4, 'in'),
|
|
606
|
+
),
|
|
607
|
+
|
|
608
|
+
zenuml_unary_expression: ($) => prec.right(7, seq(
|
|
609
|
+
field('operator', operatorToken($, '-', '!')),
|
|
610
|
+
field('operand', $.zenuml_expression),
|
|
611
|
+
)),
|
|
612
|
+
|
|
613
|
+
zenuml_parenthesized_expression: ($) => seq(
|
|
614
|
+
field('open', '('),
|
|
615
|
+
field('value', $.zenuml_expression),
|
|
616
|
+
field('close', ')'),
|
|
617
|
+
),
|
|
618
|
+
|
|
619
|
+
zenuml_assignment_expression: ($) => prec.right(1, seq(
|
|
620
|
+
field('assignment', $.zenuml_assignment),
|
|
621
|
+
field('value', $.zenuml_expression),
|
|
622
|
+
)),
|
|
623
|
+
|
|
624
|
+
zenuml_creation_expression: ($) => prec.right(8, seq(
|
|
625
|
+
statementKeyword($, 'new'),
|
|
626
|
+
optional(field('constructor', $.zenuml_construct)),
|
|
627
|
+
optional(field('arguments', choice(
|
|
628
|
+
$.zenuml_argument_list,
|
|
629
|
+
$.zenuml_unclosed_argument_list,
|
|
630
|
+
))),
|
|
631
|
+
)),
|
|
632
|
+
|
|
633
|
+
zenuml_call_expression: ($) => prec.right(8, choice(
|
|
634
|
+
seq(
|
|
635
|
+
field('target', $.zenuml_endpoint),
|
|
636
|
+
field('delimiter', '.'),
|
|
637
|
+
field('message', $.zenuml_call_chain),
|
|
638
|
+
),
|
|
639
|
+
seq(
|
|
640
|
+
field('name', $.zenuml_name),
|
|
641
|
+
field('arguments', choice(
|
|
642
|
+
$.zenuml_argument_list,
|
|
643
|
+
$.zenuml_unclosed_argument_list,
|
|
644
|
+
)),
|
|
645
|
+
),
|
|
646
|
+
)),
|
|
647
|
+
|
|
648
|
+
zenuml_text_expression: ($) => prec(-30, seq(
|
|
649
|
+
field('word', choice(
|
|
650
|
+
$.zenuml_identifier,
|
|
651
|
+
$.zenuml_digit_leading_name,
|
|
652
|
+
$.zenuml_number_unit,
|
|
653
|
+
)),
|
|
654
|
+
repeat1(field('word', choice(
|
|
655
|
+
$.zenuml_identifier,
|
|
656
|
+
$.zenuml_digit_leading_name,
|
|
657
|
+
$.zenuml_number_unit,
|
|
658
|
+
))),
|
|
659
|
+
)),
|
|
660
|
+
|
|
661
|
+
zenuml_name: ($) => prec(1, choice(
|
|
662
|
+
$.zenuml_identifier,
|
|
663
|
+
$.zenuml_digit_leading_name,
|
|
664
|
+
$.zenuml_string,
|
|
665
|
+
$.zenuml_unclosed_string,
|
|
666
|
+
)),
|
|
667
|
+
|
|
668
|
+
zenuml_identifier: (_) => token(prec(
|
|
669
|
+
0,
|
|
670
|
+
/[A-Za-z_\u00c0-\uffff][A-Za-z0-9_\u00c0-\uffff]*/,
|
|
671
|
+
)),
|
|
672
|
+
|
|
673
|
+
zenuml_digit_leading_name: (_) => token(prec(
|
|
674
|
+
40,
|
|
675
|
+
/[0-9]+[A-Za-z\u00c0-\uffff][A-Za-z0-9_\u00c0-\uffff]*/,
|
|
676
|
+
)),
|
|
677
|
+
|
|
678
|
+
zenuml_number: (_) => token(prec(35, choice(
|
|
679
|
+
/[0-9]+\.[0-9]*/,
|
|
680
|
+
/\.[0-9]+/,
|
|
681
|
+
/[0-9]+/,
|
|
682
|
+
))),
|
|
683
|
+
|
|
684
|
+
zenuml_number_unit: (_) => token(prec(
|
|
685
|
+
45,
|
|
686
|
+
/(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)(?:milliseconds|millisecond|ms|seconds|second|secs|sec|s|minutes|minute|mins|min|hours|hour|hrs|hr|h|days|day|d|weeks|week|w|KiB|MiB|GiB|TiB|KB|MB|GB|TB|kb|mb|gb|tb|B|rem|em|px|mm|cm|km|m|mg|kg|g)/,
|
|
687
|
+
)),
|
|
688
|
+
|
|
689
|
+
zenuml_money: (_) => token(prec(45, /\$(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)/)),
|
|
690
|
+
|
|
691
|
+
zenuml_boolean: (_) => keywordChoice(['true', 'false']),
|
|
692
|
+
|
|
693
|
+
zenuml_nil: (_) => keywordChoice(['nil', 'null']),
|
|
694
|
+
|
|
695
|
+
zenuml_string: (_) => token(prec(50, seq(
|
|
696
|
+
'"',
|
|
697
|
+
repeat(choice('""', /[^"\r\n]/)),
|
|
698
|
+
'"',
|
|
699
|
+
))),
|
|
700
|
+
|
|
701
|
+
zenuml_unclosed_string: (_) => token(prec(-20, seq(
|
|
702
|
+
'"',
|
|
703
|
+
repeat(choice('""', /[^"\r\n]/)),
|
|
704
|
+
))),
|
|
705
|
+
|
|
706
|
+
zenuml_arrow: (_) => token(prec(70, '->')),
|
|
707
|
+
|
|
708
|
+
zenuml_return_arrow: (_) => token(prec(75, '-->')),
|
|
709
|
+
|
|
710
|
+
zenuml_starter_annotation: (_) => choice('@Starter', '@starter'),
|
|
711
|
+
|
|
712
|
+
zenuml_reply_annotation: (_) => choice('@Return', '@return', '@Reply', '@reply'),
|
|
713
|
+
|
|
714
|
+
zenuml_participant_annotation: (_) => token(/@[A-Za-z0-9_]*/),
|
|
715
|
+
|
|
716
|
+
zenuml_modifier: (_) => keywordChoice(['const', 'readonly', 'static', 'await']),
|
|
717
|
+
|
|
718
|
+
zenuml_color: (_) => token(prec(60, /#[0-9a-fA-F]+/)),
|
|
719
|
+
|
|
720
|
+
zenuml_event_payload: (_) => token.immediate(/[^\r\n]+/),
|
|
721
|
+
|
|
722
|
+
zenuml_comment: (_) => token(prec(75, seq('//', /[^\r\n]*/))),
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
module.exports = { zenumlRules };
|