@cr_docs_t/dts 0.26.0 → 0.28.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.
@@ -0,0 +1,2262 @@
1
+ // Auto-generated from node-types.json
2
+ import { v4 } from "uuid";
3
+ // Unmarshalers
4
+ function unmarshalerAcronymDefinitionNode(node, ctx, parentId) {
5
+ const id = v4();
6
+ const n = {
7
+ id,
8
+ parentId,
9
+ type: "acronym_definition",
10
+ text: node.text,
11
+ };
12
+ ctx.nodes.set(id, n);
13
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
14
+ n.long = unmarshalNode(node.childForFieldName("long"), ctx, id);
15
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
16
+ const optionsNode = node.childForFieldName("options");
17
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
18
+ n.short = unmarshalNode(node.childForFieldName("short"), ctx, id);
19
+ const fieldNodes = new Set([
20
+ node.childForFieldName("command").id,
21
+ node.childForFieldName("long").id,
22
+ node.childForFieldName("name").id,
23
+ optionsNode ? optionsNode.id : undefined,
24
+ node.childForFieldName("short").id,
25
+ ].filter((id) => id !== undefined));
26
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
27
+ return id;
28
+ }
29
+ function unmarshalerAcronymReferenceNode(node, ctx, parentId) {
30
+ const id = v4();
31
+ const n = {
32
+ id,
33
+ parentId,
34
+ type: "acronym_reference",
35
+ text: node.text,
36
+ };
37
+ ctx.nodes.set(id, n);
38
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
39
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
40
+ const optionsNode = node.childForFieldName("options");
41
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
42
+ const fieldNodes = new Set([
43
+ node.childForFieldName("command").id,
44
+ node.childForFieldName("name").id,
45
+ optionsNode ? optionsNode.id : undefined,
46
+ ].filter((id) => id !== undefined));
47
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
48
+ return id;
49
+ }
50
+ function unmarshalerAsyEnvironmentNode(node, ctx, parentId) {
51
+ const id = v4();
52
+ const n = {
53
+ id,
54
+ parentId,
55
+ type: "asy_environment",
56
+ text: node.text,
57
+ };
58
+ ctx.nodes.set(id, n);
59
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
60
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
61
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
62
+ const fieldNodes = new Set([
63
+ node.childForFieldName("begin").id,
64
+ node.childForFieldName("code").id,
65
+ node.childForFieldName("end").id,
66
+ ].filter((id) => id !== undefined));
67
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
68
+ return id;
69
+ }
70
+ function unmarshalerAsydefEnvironmentNode(node, ctx, parentId) {
71
+ const id = v4();
72
+ const n = {
73
+ id,
74
+ parentId,
75
+ type: "asydef_environment",
76
+ text: node.text,
77
+ };
78
+ ctx.nodes.set(id, n);
79
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
80
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
81
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
82
+ const fieldNodes = new Set([
83
+ node.childForFieldName("begin").id,
84
+ node.childForFieldName("code").id,
85
+ node.childForFieldName("end").id,
86
+ ].filter((id) => id !== undefined));
87
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
88
+ return id;
89
+ }
90
+ function unmarshalerAuthorNode(node, ctx, parentId) {
91
+ const id = v4();
92
+ const n = {
93
+ id,
94
+ parentId,
95
+ type: "author",
96
+ text: node.text,
97
+ };
98
+ ctx.nodes.set(id, n);
99
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
100
+ return id;
101
+ }
102
+ function unmarshalerAuthorDeclarationNode(node, ctx, parentId) {
103
+ const id = v4();
104
+ const n = {
105
+ id,
106
+ parentId,
107
+ type: "author_declaration",
108
+ text: node.text,
109
+ };
110
+ ctx.nodes.set(id, n);
111
+ n.authors = unmarshalNode(node.childForFieldName("authors"), ctx, id);
112
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
113
+ const optionsNode = node.childForFieldName("options");
114
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
115
+ const fieldNodes = new Set([
116
+ node.childForFieldName("authors").id,
117
+ node.childForFieldName("command").id,
118
+ optionsNode ? optionsNode.id : undefined,
119
+ ].filter((id) => id !== undefined));
120
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
121
+ return id;
122
+ }
123
+ function unmarshalerBeginNode(node, ctx, parentId) {
124
+ const id = v4();
125
+ const n = {
126
+ id,
127
+ parentId,
128
+ type: "begin",
129
+ text: node.text,
130
+ };
131
+ ctx.nodes.set(id, n);
132
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
133
+ const languageNode = node.childForFieldName("language");
134
+ n.language = languageNode ? unmarshalNode(languageNode, ctx, id) : undefined;
135
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
136
+ const optionsNode = node.childForFieldName("options");
137
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
138
+ const fieldNodes = new Set([
139
+ node.childForFieldName("command").id,
140
+ languageNode ? languageNode.id : undefined,
141
+ node.childForFieldName("name").id,
142
+ optionsNode ? optionsNode.id : undefined,
143
+ ].filter((id) => id !== undefined));
144
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
145
+ return id;
146
+ }
147
+ function unmarshalerBiblatexIncludeNode(node, ctx, parentId) {
148
+ const id = v4();
149
+ const n = {
150
+ id,
151
+ parentId,
152
+ type: "biblatex_include",
153
+ text: node.text,
154
+ };
155
+ ctx.nodes.set(id, n);
156
+ n.glob = unmarshalNode(node.childForFieldName("glob"), ctx, id);
157
+ const optionsNode = node.childForFieldName("options");
158
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
159
+ const fieldNodes = new Set([node.childForFieldName("glob").id, optionsNode ? optionsNode.id : undefined].filter((id) => id !== undefined));
160
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
161
+ return id;
162
+ }
163
+ function unmarshalerBibstyleIncludeNode(node, ctx, parentId) {
164
+ const id = v4();
165
+ const n = {
166
+ id,
167
+ parentId,
168
+ type: "bibstyle_include",
169
+ text: node.text,
170
+ };
171
+ ctx.nodes.set(id, n);
172
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
173
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
174
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("path").id].filter((id) => id !== undefined));
175
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
176
+ return id;
177
+ }
178
+ function unmarshalerBibtexIncludeNode(node, ctx, parentId) {
179
+ const id = v4();
180
+ const n = {
181
+ id,
182
+ parentId,
183
+ type: "bibtex_include",
184
+ text: node.text,
185
+ };
186
+ ctx.nodes.set(id, n);
187
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
188
+ n.paths = unmarshalNode(node.childForFieldName("paths"), ctx, id);
189
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("paths").id].filter((id) => id !== undefined));
190
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
191
+ return id;
192
+ }
193
+ function unmarshalerBlockCommentNode(node, ctx, parentId) {
194
+ const id = v4();
195
+ const n = {
196
+ id,
197
+ parentId,
198
+ type: "block_comment",
199
+ text: node.text,
200
+ };
201
+ ctx.nodes.set(id, n);
202
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
203
+ const commentNode = node.childForFieldName("comment");
204
+ n.comment = commentNode ? unmarshalNode(commentNode, ctx, id) : undefined;
205
+ const endNode = node.childForFieldName("end");
206
+ n.end = endNode ? unmarshalNode(endNode, ctx, id) : undefined;
207
+ const fieldNodes = new Set([
208
+ node.childForFieldName("begin").id,
209
+ commentNode ? commentNode.id : undefined,
210
+ endNode ? endNode.id : undefined,
211
+ ].filter((id) => id !== undefined));
212
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
213
+ return id;
214
+ }
215
+ function unmarshalerBrackGroupNode(node, ctx, parentId) {
216
+ const id = v4();
217
+ const n = {
218
+ id,
219
+ parentId,
220
+ type: "brack_group",
221
+ text: node.text,
222
+ };
223
+ ctx.nodes.set(id, n);
224
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
225
+ return id;
226
+ }
227
+ function unmarshalerBrackGroupArgcNode(node, ctx, parentId) {
228
+ const id = v4();
229
+ const n = {
230
+ id,
231
+ parentId,
232
+ type: "brack_group_argc",
233
+ text: node.text,
234
+ };
235
+ ctx.nodes.set(id, n);
236
+ n.value = unmarshalNode(node.childForFieldName("value"), ctx, id);
237
+ const fieldNodes = new Set([node.childForFieldName("value").id].filter((id) => id !== undefined));
238
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
239
+ return id;
240
+ }
241
+ function unmarshalerBrackGroupKeyValueNode(node, ctx, parentId) {
242
+ const id = v4();
243
+ const n = {
244
+ id,
245
+ parentId,
246
+ type: "brack_group_key_value",
247
+ text: node.text,
248
+ };
249
+ ctx.nodes.set(id, n);
250
+ n.pair = node.childrenForFieldName("pair").map((n) => unmarshalNode(n, ctx, id));
251
+ const fieldNodes = new Set([...node.childrenForFieldName("pair").map((n) => n.id)].filter((id) => id !== undefined));
252
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
253
+ return id;
254
+ }
255
+ function unmarshalerBrackGroupTextNode(node, ctx, parentId) {
256
+ const id = v4();
257
+ const n = {
258
+ id,
259
+ parentId,
260
+ type: "brack_group_text",
261
+ text: node.text,
262
+ };
263
+ ctx.nodes.set(id, n);
264
+ n.text = unmarshalNode(node.childForFieldName("text"), ctx, id);
265
+ const fieldNodes = new Set([node.childForFieldName("text").id].filter((id) => id !== undefined));
266
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
267
+ return id;
268
+ }
269
+ function unmarshalerBrackGroupWordNode(node, ctx, parentId) {
270
+ const id = v4();
271
+ const n = {
272
+ id,
273
+ parentId,
274
+ type: "brack_group_word",
275
+ text: node.text,
276
+ };
277
+ ctx.nodes.set(id, n);
278
+ n.word = unmarshalNode(node.childForFieldName("word"), ctx, id);
279
+ const fieldNodes = new Set([node.childForFieldName("word").id].filter((id) => id !== undefined));
280
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
281
+ return id;
282
+ }
283
+ function unmarshalerCaptionNode(node, ctx, parentId) {
284
+ const id = v4();
285
+ const n = {
286
+ id,
287
+ parentId,
288
+ type: "caption",
289
+ text: node.text,
290
+ };
291
+ ctx.nodes.set(id, n);
292
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
293
+ n.long = unmarshalNode(node.childForFieldName("long"), ctx, id);
294
+ const shortNode = node.childForFieldName("short");
295
+ n.short = shortNode ? unmarshalNode(shortNode, ctx, id) : undefined;
296
+ const fieldNodes = new Set([
297
+ node.childForFieldName("command").id,
298
+ node.childForFieldName("long").id,
299
+ shortNode ? shortNode.id : undefined,
300
+ ].filter((id) => id !== undefined));
301
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
302
+ return id;
303
+ }
304
+ function unmarshalerChangesReplacedNode(node, ctx, parentId) {
305
+ const id = v4();
306
+ const n = {
307
+ id,
308
+ parentId,
309
+ type: "changes_replaced",
310
+ text: node.text,
311
+ };
312
+ ctx.nodes.set(id, n);
313
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
314
+ n.text_added = unmarshalNode(node.childForFieldName("text_added"), ctx, id);
315
+ n.text_deleted = unmarshalNode(node.childForFieldName("text_deleted"), ctx, id);
316
+ const fieldNodes = new Set([
317
+ node.childForFieldName("command").id,
318
+ node.childForFieldName("text_added").id,
319
+ node.childForFieldName("text_deleted").id,
320
+ ].filter((id) => id !== undefined));
321
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
322
+ return id;
323
+ }
324
+ function unmarshalerChapterNode(node, ctx, parentId) {
325
+ const id = v4();
326
+ const n = {
327
+ id,
328
+ parentId,
329
+ type: "chapter",
330
+ text: node.text,
331
+ };
332
+ ctx.nodes.set(id, n);
333
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
334
+ const textNode = node.childForFieldName("text");
335
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
336
+ const tocNode = node.childForFieldName("toc");
337
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
338
+ const fieldNodes = new Set([
339
+ node.childForFieldName("command").id,
340
+ textNode ? textNode.id : undefined,
341
+ tocNode ? tocNode.id : undefined,
342
+ ].filter((id) => id !== undefined));
343
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
344
+ return id;
345
+ }
346
+ function unmarshalerCitationNode(node, ctx, parentId) {
347
+ const id = v4();
348
+ const n = {
349
+ id,
350
+ parentId,
351
+ type: "citation",
352
+ text: node.text,
353
+ };
354
+ ctx.nodes.set(id, n);
355
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
356
+ n.keys = unmarshalNode(node.childForFieldName("keys"), ctx, id);
357
+ const postnoteNode = node.childForFieldName("postnote");
358
+ n.postnote = postnoteNode ? unmarshalNode(postnoteNode, ctx, id) : undefined;
359
+ const prenoteNode = node.childForFieldName("prenote");
360
+ n.prenote = prenoteNode ? unmarshalNode(prenoteNode, ctx, id) : undefined;
361
+ const fieldNodes = new Set([
362
+ node.childForFieldName("command").id,
363
+ node.childForFieldName("keys").id,
364
+ postnoteNode ? postnoteNode.id : undefined,
365
+ prenoteNode ? prenoteNode.id : undefined,
366
+ ].filter((id) => id !== undefined));
367
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
368
+ return id;
369
+ }
370
+ function unmarshalerClassIncludeNode(node, ctx, parentId) {
371
+ const id = v4();
372
+ const n = {
373
+ id,
374
+ parentId,
375
+ type: "class_include",
376
+ text: node.text,
377
+ };
378
+ ctx.nodes.set(id, n);
379
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
380
+ const optionsNode = node.childForFieldName("options");
381
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
382
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
383
+ const fieldNodes = new Set([
384
+ node.childForFieldName("command").id,
385
+ optionsNode ? optionsNode.id : undefined,
386
+ node.childForFieldName("path").id,
387
+ ].filter((id) => id !== undefined));
388
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
389
+ return id;
390
+ }
391
+ function unmarshalerColorDefinitionNode(node, ctx, parentId) {
392
+ const id = v4();
393
+ const n = {
394
+ id,
395
+ parentId,
396
+ type: "color_definition",
397
+ text: node.text,
398
+ };
399
+ ctx.nodes.set(id, n);
400
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
401
+ n.model = unmarshalNode(node.childForFieldName("model"), ctx, id);
402
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
403
+ n.spec = unmarshalNode(node.childForFieldName("spec"), ctx, id);
404
+ const fieldNodes = new Set([
405
+ node.childForFieldName("command").id,
406
+ node.childForFieldName("model").id,
407
+ node.childForFieldName("name").id,
408
+ node.childForFieldName("spec").id,
409
+ ].filter((id) => id !== undefined));
410
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
411
+ return id;
412
+ }
413
+ function unmarshalerColorReferenceNode(node, ctx, parentId) {
414
+ const id = v4();
415
+ const n = {
416
+ id,
417
+ parentId,
418
+ type: "color_reference",
419
+ text: node.text,
420
+ };
421
+ ctx.nodes.set(id, n);
422
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
423
+ const modelNode = node.childForFieldName("model");
424
+ n.model = modelNode ? unmarshalNode(modelNode, ctx, id) : undefined;
425
+ const nameNode = node.childForFieldName("name");
426
+ n.name = nameNode ? unmarshalNode(nameNode, ctx, id) : undefined;
427
+ const specNode = node.childForFieldName("spec");
428
+ n.spec = specNode ? unmarshalNode(specNode, ctx, id) : undefined;
429
+ const textNode = node.childForFieldName("text");
430
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
431
+ const fieldNodes = new Set([
432
+ node.childForFieldName("command").id,
433
+ modelNode ? modelNode.id : undefined,
434
+ nameNode ? nameNode.id : undefined,
435
+ specNode ? specNode.id : undefined,
436
+ textNode ? textNode.id : undefined,
437
+ ].filter((id) => id !== undefined));
438
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
439
+ return id;
440
+ }
441
+ function unmarshalerColorSetDefinitionNode(node, ctx, parentId) {
442
+ const id = v4();
443
+ const n = {
444
+ id,
445
+ parentId,
446
+ type: "color_set_definition",
447
+ text: node.text,
448
+ };
449
+ ctx.nodes.set(id, n);
450
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
451
+ n.head = unmarshalNode(node.childForFieldName("head"), ctx, id);
452
+ n.model = unmarshalNode(node.childForFieldName("model"), ctx, id);
453
+ n.spec = unmarshalNode(node.childForFieldName("spec"), ctx, id);
454
+ n.tail = unmarshalNode(node.childForFieldName("tail"), ctx, id);
455
+ const tyNode = node.childForFieldName("ty");
456
+ n.ty = tyNode ? unmarshalNode(tyNode, ctx, id) : undefined;
457
+ const fieldNodes = new Set([
458
+ node.childForFieldName("command").id,
459
+ node.childForFieldName("head").id,
460
+ node.childForFieldName("model").id,
461
+ node.childForFieldName("spec").id,
462
+ node.childForFieldName("tail").id,
463
+ tyNode ? tyNode.id : undefined,
464
+ ].filter((id) => id !== undefined));
465
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
466
+ return id;
467
+ }
468
+ function unmarshalerCommentEnvironmentNode(node, ctx, parentId) {
469
+ const id = v4();
470
+ const n = {
471
+ id,
472
+ parentId,
473
+ type: "comment_environment",
474
+ text: node.text,
475
+ };
476
+ ctx.nodes.set(id, n);
477
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
478
+ n.comment = unmarshalNode(node.childForFieldName("comment"), ctx, id);
479
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
480
+ const fieldNodes = new Set([
481
+ node.childForFieldName("begin").id,
482
+ node.childForFieldName("comment").id,
483
+ node.childForFieldName("end").id,
484
+ ].filter((id) => id !== undefined));
485
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
486
+ return id;
487
+ }
488
+ function unmarshalerCounterAdditionNode(node, ctx, parentId) {
489
+ const id = v4();
490
+ const n = {
491
+ id,
492
+ parentId,
493
+ type: "counter_addition",
494
+ text: node.text,
495
+ };
496
+ ctx.nodes.set(id, n);
497
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
498
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
499
+ n.value = node.childrenForFieldName("value").map((n) => unmarshalNode(n, ctx, id));
500
+ const fieldNodes = new Set([
501
+ node.childForFieldName("command").id,
502
+ node.childForFieldName("counter").id,
503
+ ...node.childrenForFieldName("value").map((n) => n.id),
504
+ ].filter((id) => id !== undefined));
505
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
506
+ return id;
507
+ }
508
+ function unmarshalerCounterDeclarationNode(node, ctx, parentId) {
509
+ const id = v4();
510
+ const n = {
511
+ id,
512
+ parentId,
513
+ type: "counter_declaration",
514
+ text: node.text,
515
+ };
516
+ ctx.nodes.set(id, n);
517
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
518
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
519
+ const supercounterNode = node.childForFieldName("supercounter");
520
+ n.supercounter = supercounterNode ? unmarshalNode(supercounterNode, ctx, id) : undefined;
521
+ const fieldNodes = new Set([
522
+ node.childForFieldName("command").id,
523
+ node.childForFieldName("counter").id,
524
+ supercounterNode ? supercounterNode.id : undefined,
525
+ ].filter((id) => id !== undefined));
526
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
527
+ return id;
528
+ }
529
+ function unmarshalerCounterDefinitionNode(node, ctx, parentId) {
530
+ const id = v4();
531
+ const n = {
532
+ id,
533
+ parentId,
534
+ type: "counter_definition",
535
+ text: node.text,
536
+ };
537
+ ctx.nodes.set(id, n);
538
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
539
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
540
+ n.value = node.childrenForFieldName("value").map((n) => unmarshalNode(n, ctx, id));
541
+ const fieldNodes = new Set([
542
+ node.childForFieldName("command").id,
543
+ node.childForFieldName("counter").id,
544
+ ...node.childrenForFieldName("value").map((n) => n.id),
545
+ ].filter((id) => id !== undefined));
546
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
547
+ return id;
548
+ }
549
+ function unmarshalerCounterIncrementNode(node, ctx, parentId) {
550
+ const id = v4();
551
+ const n = {
552
+ id,
553
+ parentId,
554
+ type: "counter_increment",
555
+ text: node.text,
556
+ };
557
+ ctx.nodes.set(id, n);
558
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
559
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
560
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("counter").id].filter((id) => id !== undefined));
561
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
562
+ return id;
563
+ }
564
+ function unmarshalerCounterTypesettingNode(node, ctx, parentId) {
565
+ const id = v4();
566
+ const n = {
567
+ id,
568
+ parentId,
569
+ type: "counter_typesetting",
570
+ text: node.text,
571
+ };
572
+ ctx.nodes.set(id, n);
573
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
574
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
575
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("counter").id].filter((id) => id !== undefined));
576
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
577
+ return id;
578
+ }
579
+ function unmarshalerCounterValueNode(node, ctx, parentId) {
580
+ const id = v4();
581
+ const n = {
582
+ id,
583
+ parentId,
584
+ type: "counter_value",
585
+ text: node.text,
586
+ };
587
+ ctx.nodes.set(id, n);
588
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
589
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
590
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("counter").id].filter((id) => id !== undefined));
591
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
592
+ return id;
593
+ }
594
+ function unmarshalerCounterWithinDeclarationNode(node, ctx, parentId) {
595
+ const id = v4();
596
+ const n = {
597
+ id,
598
+ parentId,
599
+ type: "counter_within_declaration",
600
+ text: node.text,
601
+ };
602
+ ctx.nodes.set(id, n);
603
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
604
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
605
+ n.supercounter = unmarshalNode(node.childForFieldName("supercounter"), ctx, id);
606
+ const fieldNodes = new Set([
607
+ node.childForFieldName("command").id,
608
+ node.childForFieldName("counter").id,
609
+ node.childForFieldName("supercounter").id,
610
+ ].filter((id) => id !== undefined));
611
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
612
+ return id;
613
+ }
614
+ function unmarshalerCounterWithoutDeclarationNode(node, ctx, parentId) {
615
+ const id = v4();
616
+ const n = {
617
+ id,
618
+ parentId,
619
+ type: "counter_without_declaration",
620
+ text: node.text,
621
+ };
622
+ ctx.nodes.set(id, n);
623
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
624
+ n.counter = unmarshalNode(node.childForFieldName("counter"), ctx, id);
625
+ n.supercounter = unmarshalNode(node.childForFieldName("supercounter"), ctx, id);
626
+ const fieldNodes = new Set([
627
+ node.childForFieldName("command").id,
628
+ node.childForFieldName("counter").id,
629
+ node.childForFieldName("supercounter").id,
630
+ ].filter((id) => id !== undefined));
631
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
632
+ return id;
633
+ }
634
+ function unmarshalerCurlyGroupNode(node, ctx, parentId) {
635
+ const id = v4();
636
+ const n = {
637
+ id,
638
+ parentId,
639
+ type: "curly_group",
640
+ text: node.text,
641
+ };
642
+ ctx.nodes.set(id, n);
643
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
644
+ return id;
645
+ }
646
+ function unmarshalerCurlyGroupAuthorListNode(node, ctx, parentId) {
647
+ const id = v4();
648
+ const n = {
649
+ id,
650
+ parentId,
651
+ type: "curly_group_author_list",
652
+ text: node.text,
653
+ };
654
+ ctx.nodes.set(id, n);
655
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
656
+ return id;
657
+ }
658
+ function unmarshalerCurlyGroupCommandNameNode(node, ctx, parentId) {
659
+ const id = v4();
660
+ const n = {
661
+ id,
662
+ parentId,
663
+ type: "curly_group_command_name",
664
+ text: node.text,
665
+ };
666
+ ctx.nodes.set(id, n);
667
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
668
+ const fieldNodes = new Set([node.childForFieldName("command").id].filter((id) => id !== undefined));
669
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
670
+ return id;
671
+ }
672
+ function unmarshalerCurlyGroupGlobPatternNode(node, ctx, parentId) {
673
+ const id = v4();
674
+ const n = {
675
+ id,
676
+ parentId,
677
+ type: "curly_group_glob_pattern",
678
+ text: node.text,
679
+ };
680
+ ctx.nodes.set(id, n);
681
+ n.pattern = unmarshalNode(node.childForFieldName("pattern"), ctx, id);
682
+ const fieldNodes = new Set([node.childForFieldName("pattern").id].filter((id) => id !== undefined));
683
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
684
+ return id;
685
+ }
686
+ function unmarshalerCurlyGroupImplNode(node, ctx, parentId) {
687
+ const id = v4();
688
+ const n = {
689
+ id,
690
+ parentId,
691
+ type: "curly_group_impl",
692
+ text: node.text,
693
+ };
694
+ ctx.nodes.set(id, n);
695
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
696
+ return id;
697
+ }
698
+ function unmarshalerCurlyGroupKeyValueNode(node, ctx, parentId) {
699
+ const id = v4();
700
+ const n = {
701
+ id,
702
+ parentId,
703
+ type: "curly_group_key_value",
704
+ text: node.text,
705
+ };
706
+ ctx.nodes.set(id, n);
707
+ n.pair = node.childrenForFieldName("pair").map((n) => unmarshalNode(n, ctx, id));
708
+ const fieldNodes = new Set([...node.childrenForFieldName("pair").map((n) => n.id)].filter((id) => id !== undefined));
709
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
710
+ return id;
711
+ }
712
+ function unmarshalerCurlyGroupLabelNode(node, ctx, parentId) {
713
+ const id = v4();
714
+ const n = {
715
+ id,
716
+ parentId,
717
+ type: "curly_group_label",
718
+ text: node.text,
719
+ };
720
+ ctx.nodes.set(id, n);
721
+ n.label = unmarshalNode(node.childForFieldName("label"), ctx, id);
722
+ const fieldNodes = new Set([node.childForFieldName("label").id].filter((id) => id !== undefined));
723
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
724
+ return id;
725
+ }
726
+ function unmarshalerCurlyGroupLabelListNode(node, ctx, parentId) {
727
+ const id = v4();
728
+ const n = {
729
+ id,
730
+ parentId,
731
+ type: "curly_group_label_list",
732
+ text: node.text,
733
+ };
734
+ ctx.nodes.set(id, n);
735
+ n.label = node.childrenForFieldName("label").map((n) => unmarshalNode(n, ctx, id));
736
+ const fieldNodes = new Set([...node.childrenForFieldName("label").map((n) => n.id)].filter((id) => id !== undefined));
737
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
738
+ return id;
739
+ }
740
+ function unmarshalerCurlyGroupPathNode(node, ctx, parentId) {
741
+ const id = v4();
742
+ const n = {
743
+ id,
744
+ parentId,
745
+ type: "curly_group_path",
746
+ text: node.text,
747
+ };
748
+ ctx.nodes.set(id, n);
749
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
750
+ const fieldNodes = new Set([node.childForFieldName("path").id].filter((id) => id !== undefined));
751
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
752
+ return id;
753
+ }
754
+ function unmarshalerCurlyGroupPathListNode(node, ctx, parentId) {
755
+ const id = v4();
756
+ const n = {
757
+ id,
758
+ parentId,
759
+ type: "curly_group_path_list",
760
+ text: node.text,
761
+ };
762
+ ctx.nodes.set(id, n);
763
+ n.path = node.childrenForFieldName("path").map((n) => unmarshalNode(n, ctx, id));
764
+ const fieldNodes = new Set([...node.childrenForFieldName("path").map((n) => n.id)].filter((id) => id !== undefined));
765
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
766
+ return id;
767
+ }
768
+ function unmarshalerCurlyGroupSpecNode(node, ctx, parentId) {
769
+ const id = v4();
770
+ const n = {
771
+ id,
772
+ parentId,
773
+ type: "curly_group_spec",
774
+ text: node.text,
775
+ };
776
+ ctx.nodes.set(id, n);
777
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
778
+ return id;
779
+ }
780
+ function unmarshalerCurlyGroupTextNode(node, ctx, parentId) {
781
+ const id = v4();
782
+ const n = {
783
+ id,
784
+ parentId,
785
+ type: "curly_group_text",
786
+ text: node.text,
787
+ };
788
+ ctx.nodes.set(id, n);
789
+ n.text = unmarshalNode(node.childForFieldName("text"), ctx, id);
790
+ const fieldNodes = new Set([node.childForFieldName("text").id].filter((id) => id !== undefined));
791
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
792
+ return id;
793
+ }
794
+ function unmarshalerCurlyGroupTextListNode(node, ctx, parentId) {
795
+ const id = v4();
796
+ const n = {
797
+ id,
798
+ parentId,
799
+ type: "curly_group_text_list",
800
+ text: node.text,
801
+ };
802
+ ctx.nodes.set(id, n);
803
+ n.text = node.childrenForFieldName("text").map((n) => unmarshalNode(n, ctx, id));
804
+ const fieldNodes = new Set([...node.childrenForFieldName("text").map((n) => n.id)].filter((id) => id !== undefined));
805
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
806
+ return id;
807
+ }
808
+ function unmarshalerCurlyGroupUriNode(node, ctx, parentId) {
809
+ const id = v4();
810
+ const n = {
811
+ id,
812
+ parentId,
813
+ type: "curly_group_uri",
814
+ text: node.text,
815
+ };
816
+ ctx.nodes.set(id, n);
817
+ n.uri = unmarshalNode(node.childForFieldName("uri"), ctx, id);
818
+ const fieldNodes = new Set([node.childForFieldName("uri").id].filter((id) => id !== undefined));
819
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
820
+ return id;
821
+ }
822
+ function unmarshalerCurlyGroupValueNode(node, ctx, parentId) {
823
+ const id = v4();
824
+ const n = {
825
+ id,
826
+ parentId,
827
+ type: "curly_group_value",
828
+ text: node.text,
829
+ };
830
+ ctx.nodes.set(id, n);
831
+ n.value = unmarshalNode(node.childForFieldName("value"), ctx, id);
832
+ const fieldNodes = new Set([node.childForFieldName("value").id].filter((id) => id !== undefined));
833
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
834
+ return id;
835
+ }
836
+ function unmarshalerCurlyGroupWordNode(node, ctx, parentId) {
837
+ const id = v4();
838
+ const n = {
839
+ id,
840
+ parentId,
841
+ type: "curly_group_word",
842
+ text: node.text,
843
+ };
844
+ ctx.nodes.set(id, n);
845
+ n.word = unmarshalNode(node.childForFieldName("word"), ctx, id);
846
+ const fieldNodes = new Set([node.childForFieldName("word").id].filter((id) => id !== undefined));
847
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
848
+ return id;
849
+ }
850
+ function unmarshalerDisplayedEquationNode(node, ctx, parentId) {
851
+ const id = v4();
852
+ const n = {
853
+ id,
854
+ parentId,
855
+ type: "displayed_equation",
856
+ text: node.text,
857
+ };
858
+ ctx.nodes.set(id, n);
859
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
860
+ return id;
861
+ }
862
+ function unmarshalerEndNode(node, ctx, parentId) {
863
+ const id = v4();
864
+ const n = {
865
+ id,
866
+ parentId,
867
+ type: "end",
868
+ text: node.text,
869
+ };
870
+ ctx.nodes.set(id, n);
871
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
872
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
873
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("name").id].filter((id) => id !== undefined));
874
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
875
+ return id;
876
+ }
877
+ function unmarshalerEnumItemNode(node, ctx, parentId) {
878
+ const id = v4();
879
+ const n = {
880
+ id,
881
+ parentId,
882
+ type: "enum_item",
883
+ text: node.text,
884
+ };
885
+ ctx.nodes.set(id, n);
886
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
887
+ const labelNode = node.childForFieldName("label");
888
+ n.label = labelNode ? unmarshalNode(labelNode, ctx, id) : undefined;
889
+ const fieldNodes = new Set([node.childForFieldName("command").id, labelNode ? labelNode.id : undefined].filter((id) => id !== undefined));
890
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
891
+ return id;
892
+ }
893
+ function unmarshalerEnvironmentDefinitionNode(node, ctx, parentId) {
894
+ const id = v4();
895
+ const n = {
896
+ id,
897
+ parentId,
898
+ type: "environment_definition",
899
+ text: node.text,
900
+ };
901
+ ctx.nodes.set(id, n);
902
+ const argcNode = node.childForFieldName("argc");
903
+ n.argc = argcNode ? unmarshalNode(argcNode, ctx, id) : undefined;
904
+ const beginNode = node.childForFieldName("begin");
905
+ n.begin = beginNode ? unmarshalNode(beginNode, ctx, id) : undefined;
906
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
907
+ const endNode = node.childForFieldName("end");
908
+ n.end = endNode ? unmarshalNode(endNode, ctx, id) : undefined;
909
+ n.name = node.childrenForFieldName("name").map((n) => unmarshalNode(n, ctx, id));
910
+ const specNode = node.childForFieldName("spec");
911
+ n.spec = specNode ? unmarshalNode(specNode, ctx, id) : undefined;
912
+ const fieldNodes = new Set([
913
+ argcNode ? argcNode.id : undefined,
914
+ beginNode ? beginNode.id : undefined,
915
+ node.childForFieldName("command").id,
916
+ endNode ? endNode.id : undefined,
917
+ ...node.childrenForFieldName("name").map((n) => n.id),
918
+ specNode ? specNode.id : undefined,
919
+ ].filter((id) => id !== undefined));
920
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
921
+ return id;
922
+ }
923
+ function unmarshalerGenericCommandNode(node, ctx, parentId) {
924
+ const id = v4();
925
+ const n = {
926
+ id,
927
+ parentId,
928
+ type: "generic_command",
929
+ text: node.text,
930
+ };
931
+ ctx.nodes.set(id, n);
932
+ n.arg = node.childrenForFieldName("arg").map((n) => unmarshalNode(n, ctx, id));
933
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
934
+ const fieldNodes = new Set([...node.childrenForFieldName("arg").map((n) => n.id), node.childForFieldName("command").id].filter((id) => id !== undefined));
935
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
936
+ return id;
937
+ }
938
+ function unmarshalerGenericEnvironmentNode(node, ctx, parentId) {
939
+ const id = v4();
940
+ const n = {
941
+ id,
942
+ parentId,
943
+ type: "generic_environment",
944
+ text: node.text,
945
+ };
946
+ ctx.nodes.set(id, n);
947
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
948
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
949
+ const fieldNodes = new Set([node.childForFieldName("begin").id, node.childForFieldName("end").id].filter((id) => id !== undefined));
950
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
951
+ return id;
952
+ }
953
+ function unmarshalerGlobPatternNode(node, ctx, parentId) {
954
+ const id = v4();
955
+ const n = {
956
+ id,
957
+ parentId,
958
+ type: "glob_pattern",
959
+ text: node.text,
960
+ };
961
+ ctx.nodes.set(id, n);
962
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
963
+ return id;
964
+ }
965
+ function unmarshalerGlossaryEntryDefinitionNode(node, ctx, parentId) {
966
+ const id = v4();
967
+ const n = {
968
+ id,
969
+ parentId,
970
+ type: "glossary_entry_definition",
971
+ text: node.text,
972
+ };
973
+ ctx.nodes.set(id, n);
974
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
975
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
976
+ n.options = unmarshalNode(node.childForFieldName("options"), ctx, id);
977
+ const fieldNodes = new Set([
978
+ node.childForFieldName("command").id,
979
+ node.childForFieldName("name").id,
980
+ node.childForFieldName("options").id,
981
+ ].filter((id) => id !== undefined));
982
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
983
+ return id;
984
+ }
985
+ function unmarshalerGlossaryEntryReferenceNode(node, ctx, parentId) {
986
+ const id = v4();
987
+ const n = {
988
+ id,
989
+ parentId,
990
+ type: "glossary_entry_reference",
991
+ text: node.text,
992
+ };
993
+ ctx.nodes.set(id, n);
994
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
995
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
996
+ const optionsNode = node.childForFieldName("options");
997
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
998
+ const fieldNodes = new Set([
999
+ node.childForFieldName("command").id,
1000
+ node.childForFieldName("name").id,
1001
+ optionsNode ? optionsNode.id : undefined,
1002
+ ].filter((id) => id !== undefined));
1003
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1004
+ return id;
1005
+ }
1006
+ function unmarshalerGraphicsIncludeNode(node, ctx, parentId) {
1007
+ const id = v4();
1008
+ const n = {
1009
+ id,
1010
+ parentId,
1011
+ type: "graphics_include",
1012
+ text: node.text,
1013
+ };
1014
+ ctx.nodes.set(id, n);
1015
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1016
+ const optionsNode = node.childForFieldName("options");
1017
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1018
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
1019
+ const fieldNodes = new Set([
1020
+ node.childForFieldName("command").id,
1021
+ optionsNode ? optionsNode.id : undefined,
1022
+ node.childForFieldName("path").id,
1023
+ ].filter((id) => id !== undefined));
1024
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1025
+ return id;
1026
+ }
1027
+ function unmarshalerHyperlinkNode(node, ctx, parentId) {
1028
+ const id = v4();
1029
+ const n = {
1030
+ id,
1031
+ parentId,
1032
+ type: "hyperlink",
1033
+ text: node.text,
1034
+ };
1035
+ ctx.nodes.set(id, n);
1036
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1037
+ const labelNode = node.childForFieldName("label");
1038
+ n.label = labelNode ? unmarshalNode(labelNode, ctx, id) : undefined;
1039
+ n.uri = unmarshalNode(node.childForFieldName("uri"), ctx, id);
1040
+ const fieldNodes = new Set([
1041
+ node.childForFieldName("command").id,
1042
+ labelNode ? labelNode.id : undefined,
1043
+ node.childForFieldName("uri").id,
1044
+ ].filter((id) => id !== undefined));
1045
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1046
+ return id;
1047
+ }
1048
+ function unmarshalerImportIncludeNode(node, ctx, parentId) {
1049
+ const id = v4();
1050
+ const n = {
1051
+ id,
1052
+ parentId,
1053
+ type: "import_include",
1054
+ text: node.text,
1055
+ };
1056
+ ctx.nodes.set(id, n);
1057
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1058
+ n.directory = unmarshalNode(node.childForFieldName("directory"), ctx, id);
1059
+ n.file = unmarshalNode(node.childForFieldName("file"), ctx, id);
1060
+ const fieldNodes = new Set([
1061
+ node.childForFieldName("command").id,
1062
+ node.childForFieldName("directory").id,
1063
+ node.childForFieldName("file").id,
1064
+ ].filter((id) => id !== undefined));
1065
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1066
+ return id;
1067
+ }
1068
+ function unmarshalerInkscapeIncludeNode(node, ctx, parentId) {
1069
+ const id = v4();
1070
+ const n = {
1071
+ id,
1072
+ parentId,
1073
+ type: "inkscape_include",
1074
+ text: node.text,
1075
+ };
1076
+ ctx.nodes.set(id, n);
1077
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1078
+ const optionsNode = node.childForFieldName("options");
1079
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1080
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
1081
+ const fieldNodes = new Set([
1082
+ node.childForFieldName("command").id,
1083
+ optionsNode ? optionsNode.id : undefined,
1084
+ node.childForFieldName("path").id,
1085
+ ].filter((id) => id !== undefined));
1086
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1087
+ return id;
1088
+ }
1089
+ function unmarshalerInlineFormulaNode(node, ctx, parentId) {
1090
+ const id = v4();
1091
+ const n = {
1092
+ id,
1093
+ parentId,
1094
+ type: "inline_formula",
1095
+ text: node.text,
1096
+ };
1097
+ ctx.nodes.set(id, n);
1098
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1099
+ return id;
1100
+ }
1101
+ function unmarshalerKeyValuePairNode(node, ctx, parentId) {
1102
+ const id = v4();
1103
+ const n = {
1104
+ id,
1105
+ parentId,
1106
+ type: "key_value_pair",
1107
+ text: node.text,
1108
+ };
1109
+ ctx.nodes.set(id, n);
1110
+ n.key = unmarshalNode(node.childForFieldName("key"), ctx, id);
1111
+ const valueNode = node.childForFieldName("value");
1112
+ n.value = valueNode ? unmarshalNode(valueNode, ctx, id) : undefined;
1113
+ const fieldNodes = new Set([node.childForFieldName("key").id, valueNode ? valueNode.id : undefined].filter((id) => id !== undefined));
1114
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1115
+ return id;
1116
+ }
1117
+ function unmarshalerLabelDefinitionNode(node, ctx, parentId) {
1118
+ const id = v4();
1119
+ const n = {
1120
+ id,
1121
+ parentId,
1122
+ type: "label_definition",
1123
+ text: node.text,
1124
+ };
1125
+ ctx.nodes.set(id, n);
1126
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1127
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
1128
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("name").id].filter((id) => id !== undefined));
1129
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1130
+ return id;
1131
+ }
1132
+ function unmarshalerLabelNumberNode(node, ctx, parentId) {
1133
+ const id = v4();
1134
+ const n = {
1135
+ id,
1136
+ parentId,
1137
+ type: "label_number",
1138
+ text: node.text,
1139
+ };
1140
+ ctx.nodes.set(id, n);
1141
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1142
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
1143
+ n.number = unmarshalNode(node.childForFieldName("number"), ctx, id);
1144
+ const fieldNodes = new Set([
1145
+ node.childForFieldName("command").id,
1146
+ node.childForFieldName("name").id,
1147
+ node.childForFieldName("number").id,
1148
+ ].filter((id) => id !== undefined));
1149
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1150
+ return id;
1151
+ }
1152
+ function unmarshalerLabelReferenceNode(node, ctx, parentId) {
1153
+ const id = v4();
1154
+ const n = {
1155
+ id,
1156
+ parentId,
1157
+ type: "label_reference",
1158
+ text: node.text,
1159
+ };
1160
+ ctx.nodes.set(id, n);
1161
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1162
+ n.names = unmarshalNode(node.childForFieldName("names"), ctx, id);
1163
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("names").id].filter((id) => id !== undefined));
1164
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1165
+ return id;
1166
+ }
1167
+ function unmarshalerLabelReferenceRangeNode(node, ctx, parentId) {
1168
+ const id = v4();
1169
+ const n = {
1170
+ id,
1171
+ parentId,
1172
+ type: "label_reference_range",
1173
+ text: node.text,
1174
+ };
1175
+ ctx.nodes.set(id, n);
1176
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1177
+ n.from = unmarshalNode(node.childForFieldName("from"), ctx, id);
1178
+ n.to = unmarshalNode(node.childForFieldName("to"), ctx, id);
1179
+ const fieldNodes = new Set([
1180
+ node.childForFieldName("command").id,
1181
+ node.childForFieldName("from").id,
1182
+ node.childForFieldName("to").id,
1183
+ ].filter((id) => id !== undefined));
1184
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1185
+ return id;
1186
+ }
1187
+ function unmarshalerLatexIncludeNode(node, ctx, parentId) {
1188
+ const id = v4();
1189
+ const n = {
1190
+ id,
1191
+ parentId,
1192
+ type: "latex_include",
1193
+ text: node.text,
1194
+ };
1195
+ ctx.nodes.set(id, n);
1196
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1197
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
1198
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("path").id].filter((id) => id !== undefined));
1199
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1200
+ return id;
1201
+ }
1202
+ function unmarshalerLetCommandDefinitionNode(node, ctx, parentId) {
1203
+ const id = v4();
1204
+ const n = {
1205
+ id,
1206
+ parentId,
1207
+ type: "let_command_definition",
1208
+ text: node.text,
1209
+ };
1210
+ ctx.nodes.set(id, n);
1211
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1212
+ n.declaration = unmarshalNode(node.childForFieldName("declaration"), ctx, id);
1213
+ n.implementation = unmarshalNode(node.childForFieldName("implementation"), ctx, id);
1214
+ const fieldNodes = new Set([
1215
+ node.childForFieldName("command").id,
1216
+ node.childForFieldName("declaration").id,
1217
+ node.childForFieldName("implementation").id,
1218
+ ].filter((id) => id !== undefined));
1219
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1220
+ return id;
1221
+ }
1222
+ function unmarshalerListingEnvironmentNode(node, ctx, parentId) {
1223
+ const id = v4();
1224
+ const n = {
1225
+ id,
1226
+ parentId,
1227
+ type: "listing_environment",
1228
+ text: node.text,
1229
+ };
1230
+ ctx.nodes.set(id, n);
1231
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1232
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1233
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1234
+ const fieldNodes = new Set([
1235
+ node.childForFieldName("begin").id,
1236
+ node.childForFieldName("code").id,
1237
+ node.childForFieldName("end").id,
1238
+ ].filter((id) => id !== undefined));
1239
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1240
+ return id;
1241
+ }
1242
+ function unmarshalerLuacodeEnvironmentNode(node, ctx, parentId) {
1243
+ const id = v4();
1244
+ const n = {
1245
+ id,
1246
+ parentId,
1247
+ type: "luacode_environment",
1248
+ text: node.text,
1249
+ };
1250
+ ctx.nodes.set(id, n);
1251
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1252
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1253
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1254
+ const fieldNodes = new Set([
1255
+ node.childForFieldName("begin").id,
1256
+ node.childForFieldName("code").id,
1257
+ node.childForFieldName("end").id,
1258
+ ].filter((id) => id !== undefined));
1259
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1260
+ return id;
1261
+ }
1262
+ function unmarshalerMathDelimiterNode(node, ctx, parentId) {
1263
+ const id = v4();
1264
+ const n = {
1265
+ id,
1266
+ parentId,
1267
+ type: "math_delimiter",
1268
+ text: node.text,
1269
+ };
1270
+ ctx.nodes.set(id, n);
1271
+ n.left_command = unmarshalNode(node.childForFieldName("left_command"), ctx, id);
1272
+ n.left_delimiter = unmarshalNode(node.childForFieldName("left_delimiter"), ctx, id);
1273
+ n.right_command = unmarshalNode(node.childForFieldName("right_command"), ctx, id);
1274
+ n.right_delimiter = unmarshalNode(node.childForFieldName("right_delimiter"), ctx, id);
1275
+ const fieldNodes = new Set([
1276
+ node.childForFieldName("left_command").id,
1277
+ node.childForFieldName("left_delimiter").id,
1278
+ node.childForFieldName("right_command").id,
1279
+ node.childForFieldName("right_delimiter").id,
1280
+ ].filter((id) => id !== undefined));
1281
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1282
+ return id;
1283
+ }
1284
+ function unmarshalerMathEnvironmentNode(node, ctx, parentId) {
1285
+ const id = v4();
1286
+ const n = {
1287
+ id,
1288
+ parentId,
1289
+ type: "math_environment",
1290
+ text: node.text,
1291
+ };
1292
+ ctx.nodes.set(id, n);
1293
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1294
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1295
+ const fieldNodes = new Set([node.childForFieldName("begin").id, node.childForFieldName("end").id].filter((id) => id !== undefined));
1296
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1297
+ return id;
1298
+ }
1299
+ function unmarshalerMintedEnvironmentNode(node, ctx, parentId) {
1300
+ const id = v4();
1301
+ const n = {
1302
+ id,
1303
+ parentId,
1304
+ type: "minted_environment",
1305
+ text: node.text,
1306
+ };
1307
+ ctx.nodes.set(id, n);
1308
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1309
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1310
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1311
+ const fieldNodes = new Set([
1312
+ node.childForFieldName("begin").id,
1313
+ node.childForFieldName("code").id,
1314
+ node.childForFieldName("end").id,
1315
+ ].filter((id) => id !== undefined));
1316
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1317
+ return id;
1318
+ }
1319
+ function unmarshalerNewCommandDefinitionNode(node, ctx, parentId) {
1320
+ const id = v4();
1321
+ const n = {
1322
+ id,
1323
+ parentId,
1324
+ type: "new_command_definition",
1325
+ text: node.text,
1326
+ };
1327
+ ctx.nodes.set(id, n);
1328
+ const argcNode = node.childForFieldName("argc");
1329
+ n.argc = argcNode ? unmarshalNode(argcNode, ctx, id) : undefined;
1330
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1331
+ n.declaration = unmarshalNode(node.childForFieldName("declaration"), ctx, id);
1332
+ const defaultNode = node.childForFieldName("default");
1333
+ n.default = defaultNode ? unmarshalNode(defaultNode, ctx, id) : undefined;
1334
+ n.implementation = unmarshalNode(node.childForFieldName("implementation"), ctx, id);
1335
+ const specNode = node.childForFieldName("spec");
1336
+ n.spec = specNode ? unmarshalNode(specNode, ctx, id) : undefined;
1337
+ const fieldNodes = new Set([
1338
+ argcNode ? argcNode.id : undefined,
1339
+ node.childForFieldName("command").id,
1340
+ node.childForFieldName("declaration").id,
1341
+ defaultNode ? defaultNode.id : undefined,
1342
+ node.childForFieldName("implementation").id,
1343
+ specNode ? specNode.id : undefined,
1344
+ ].filter((id) => id !== undefined));
1345
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1346
+ return id;
1347
+ }
1348
+ function unmarshalerOldCommandDefinitionNode(node, ctx, parentId) {
1349
+ const id = v4();
1350
+ const n = {
1351
+ id,
1352
+ parentId,
1353
+ type: "old_command_definition",
1354
+ text: node.text,
1355
+ };
1356
+ ctx.nodes.set(id, n);
1357
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1358
+ n.declaration = unmarshalNode(node.childForFieldName("declaration"), ctx, id);
1359
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("declaration").id].filter((id) => id !== undefined));
1360
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1361
+ return id;
1362
+ }
1363
+ function unmarshalerOperatorNode(node, ctx, parentId) {
1364
+ const id = v4();
1365
+ const n = {
1366
+ id,
1367
+ parentId,
1368
+ type: "operator",
1369
+ text: node.text,
1370
+ };
1371
+ ctx.nodes.set(id, n);
1372
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1373
+ return id;
1374
+ }
1375
+ function unmarshalerPackageIncludeNode(node, ctx, parentId) {
1376
+ const id = v4();
1377
+ const n = {
1378
+ id,
1379
+ parentId,
1380
+ type: "package_include",
1381
+ text: node.text,
1382
+ };
1383
+ ctx.nodes.set(id, n);
1384
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1385
+ const optionsNode = node.childForFieldName("options");
1386
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1387
+ n.paths = unmarshalNode(node.childForFieldName("paths"), ctx, id);
1388
+ const fieldNodes = new Set([
1389
+ node.childForFieldName("command").id,
1390
+ optionsNode ? optionsNode.id : undefined,
1391
+ node.childForFieldName("paths").id,
1392
+ ].filter((id) => id !== undefined));
1393
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1394
+ return id;
1395
+ }
1396
+ function unmarshalerPairedDelimiterDefinitionNode(node, ctx, parentId) {
1397
+ const id = v4();
1398
+ const n = {
1399
+ id,
1400
+ parentId,
1401
+ type: "paired_delimiter_definition",
1402
+ text: node.text,
1403
+ };
1404
+ ctx.nodes.set(id, n);
1405
+ const argcNode = node.childForFieldName("argc");
1406
+ n.argc = argcNode ? unmarshalNode(argcNode, ctx, id) : undefined;
1407
+ const bodyNode = node.childForFieldName("body");
1408
+ n.body = bodyNode ? unmarshalNode(bodyNode, ctx, id) : undefined;
1409
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1410
+ n.declaration = unmarshalNode(node.childForFieldName("declaration"), ctx, id);
1411
+ n.left = unmarshalNode(node.childForFieldName("left"), ctx, id);
1412
+ n.right = unmarshalNode(node.childForFieldName("right"), ctx, id);
1413
+ const fieldNodes = new Set([
1414
+ argcNode ? argcNode.id : undefined,
1415
+ bodyNode ? bodyNode.id : undefined,
1416
+ node.childForFieldName("command").id,
1417
+ node.childForFieldName("declaration").id,
1418
+ node.childForFieldName("left").id,
1419
+ node.childForFieldName("right").id,
1420
+ ].filter((id) => id !== undefined));
1421
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1422
+ return id;
1423
+ }
1424
+ function unmarshalerParagraphNode(node, ctx, parentId) {
1425
+ const id = v4();
1426
+ const n = {
1427
+ id,
1428
+ parentId,
1429
+ type: "paragraph",
1430
+ text: node.text,
1431
+ };
1432
+ ctx.nodes.set(id, n);
1433
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1434
+ const textNode = node.childForFieldName("text");
1435
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1436
+ const tocNode = node.childForFieldName("toc");
1437
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1438
+ const fieldNodes = new Set([
1439
+ node.childForFieldName("command").id,
1440
+ textNode ? textNode.id : undefined,
1441
+ tocNode ? tocNode.id : undefined,
1442
+ ].filter((id) => id !== undefined));
1443
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1444
+ return id;
1445
+ }
1446
+ function unmarshalerPartNode(node, ctx, parentId) {
1447
+ const id = v4();
1448
+ const n = {
1449
+ id,
1450
+ parentId,
1451
+ type: "part",
1452
+ text: node.text,
1453
+ };
1454
+ ctx.nodes.set(id, n);
1455
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1456
+ const textNode = node.childForFieldName("text");
1457
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1458
+ const tocNode = node.childForFieldName("toc");
1459
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1460
+ const fieldNodes = new Set([
1461
+ node.childForFieldName("command").id,
1462
+ textNode ? textNode.id : undefined,
1463
+ tocNode ? tocNode.id : undefined,
1464
+ ].filter((id) => id !== undefined));
1465
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1466
+ return id;
1467
+ }
1468
+ function unmarshalerPycodeEnvironmentNode(node, ctx, parentId) {
1469
+ const id = v4();
1470
+ const n = {
1471
+ id,
1472
+ parentId,
1473
+ type: "pycode_environment",
1474
+ text: node.text,
1475
+ };
1476
+ ctx.nodes.set(id, n);
1477
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1478
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1479
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1480
+ const fieldNodes = new Set([
1481
+ node.childForFieldName("begin").id,
1482
+ node.childForFieldName("code").id,
1483
+ node.childForFieldName("end").id,
1484
+ ].filter((id) => id !== undefined));
1485
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1486
+ return id;
1487
+ }
1488
+ function unmarshalerSageblockEnvironmentNode(node, ctx, parentId) {
1489
+ const id = v4();
1490
+ const n = {
1491
+ id,
1492
+ parentId,
1493
+ type: "sageblock_environment",
1494
+ text: node.text,
1495
+ };
1496
+ ctx.nodes.set(id, n);
1497
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1498
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1499
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1500
+ const fieldNodes = new Set([
1501
+ node.childForFieldName("begin").id,
1502
+ node.childForFieldName("code").id,
1503
+ node.childForFieldName("end").id,
1504
+ ].filter((id) => id !== undefined));
1505
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1506
+ return id;
1507
+ }
1508
+ function unmarshalerSagesilentEnvironmentNode(node, ctx, parentId) {
1509
+ const id = v4();
1510
+ const n = {
1511
+ id,
1512
+ parentId,
1513
+ type: "sagesilent_environment",
1514
+ text: node.text,
1515
+ };
1516
+ ctx.nodes.set(id, n);
1517
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1518
+ n.code = unmarshalNode(node.childForFieldName("code"), ctx, id);
1519
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1520
+ const fieldNodes = new Set([
1521
+ node.childForFieldName("begin").id,
1522
+ node.childForFieldName("code").id,
1523
+ node.childForFieldName("end").id,
1524
+ ].filter((id) => id !== undefined));
1525
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1526
+ return id;
1527
+ }
1528
+ function unmarshalerSectionNode(node, ctx, parentId) {
1529
+ const id = v4();
1530
+ const n = {
1531
+ id,
1532
+ parentId,
1533
+ type: "section",
1534
+ text: node.text,
1535
+ };
1536
+ ctx.nodes.set(id, n);
1537
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1538
+ const textNode = node.childForFieldName("text");
1539
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1540
+ const tocNode = node.childForFieldName("toc");
1541
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1542
+ const fieldNodes = new Set([
1543
+ node.childForFieldName("command").id,
1544
+ textNode ? textNode.id : undefined,
1545
+ tocNode ? tocNode.id : undefined,
1546
+ ].filter((id) => id !== undefined));
1547
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1548
+ return id;
1549
+ }
1550
+ function unmarshalerSourceFileNode(node, ctx, parentId) {
1551
+ const id = v4();
1552
+ const n = {
1553
+ id,
1554
+ parentId,
1555
+ type: "source_file",
1556
+ text: node.text,
1557
+ };
1558
+ ctx.nodes.set(id, n);
1559
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1560
+ return id;
1561
+ }
1562
+ function unmarshalerSubparagraphNode(node, ctx, parentId) {
1563
+ const id = v4();
1564
+ const n = {
1565
+ id,
1566
+ parentId,
1567
+ type: "subparagraph",
1568
+ text: node.text,
1569
+ };
1570
+ ctx.nodes.set(id, n);
1571
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1572
+ const textNode = node.childForFieldName("text");
1573
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1574
+ const tocNode = node.childForFieldName("toc");
1575
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1576
+ const fieldNodes = new Set([
1577
+ node.childForFieldName("command").id,
1578
+ textNode ? textNode.id : undefined,
1579
+ tocNode ? tocNode.id : undefined,
1580
+ ].filter((id) => id !== undefined));
1581
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1582
+ return id;
1583
+ }
1584
+ function unmarshalerSubscriptNode(node, ctx, parentId) {
1585
+ const id = v4();
1586
+ const n = {
1587
+ id,
1588
+ parentId,
1589
+ type: "subscript",
1590
+ text: node.text,
1591
+ };
1592
+ ctx.nodes.set(id, n);
1593
+ n.subscript = unmarshalNode(node.childForFieldName("subscript"), ctx, id);
1594
+ const fieldNodes = new Set([node.childForFieldName("subscript").id].filter((id) => id !== undefined));
1595
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1596
+ return id;
1597
+ }
1598
+ function unmarshalerSubsectionNode(node, ctx, parentId) {
1599
+ const id = v4();
1600
+ const n = {
1601
+ id,
1602
+ parentId,
1603
+ type: "subsection",
1604
+ text: node.text,
1605
+ };
1606
+ ctx.nodes.set(id, n);
1607
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1608
+ const textNode = node.childForFieldName("text");
1609
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1610
+ const tocNode = node.childForFieldName("toc");
1611
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1612
+ const fieldNodes = new Set([
1613
+ node.childForFieldName("command").id,
1614
+ textNode ? textNode.id : undefined,
1615
+ tocNode ? tocNode.id : undefined,
1616
+ ].filter((id) => id !== undefined));
1617
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1618
+ return id;
1619
+ }
1620
+ function unmarshalerSubsubsectionNode(node, ctx, parentId) {
1621
+ const id = v4();
1622
+ const n = {
1623
+ id,
1624
+ parentId,
1625
+ type: "subsubsection",
1626
+ text: node.text,
1627
+ };
1628
+ ctx.nodes.set(id, n);
1629
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1630
+ const textNode = node.childForFieldName("text");
1631
+ n.text = textNode ? unmarshalNode(textNode, ctx, id) : undefined;
1632
+ const tocNode = node.childForFieldName("toc");
1633
+ n.toc = tocNode ? unmarshalNode(tocNode, ctx, id) : undefined;
1634
+ const fieldNodes = new Set([
1635
+ node.childForFieldName("command").id,
1636
+ textNode ? textNode.id : undefined,
1637
+ tocNode ? tocNode.id : undefined,
1638
+ ].filter((id) => id !== undefined));
1639
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1640
+ return id;
1641
+ }
1642
+ function unmarshalerSuperscriptNode(node, ctx, parentId) {
1643
+ const id = v4();
1644
+ const n = {
1645
+ id,
1646
+ parentId,
1647
+ type: "superscript",
1648
+ text: node.text,
1649
+ };
1650
+ ctx.nodes.set(id, n);
1651
+ n.superscript = unmarshalNode(node.childForFieldName("superscript"), ctx, id);
1652
+ const fieldNodes = new Set([node.childForFieldName("superscript").id].filter((id) => id !== undefined));
1653
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1654
+ return id;
1655
+ }
1656
+ function unmarshalerSvgIncludeNode(node, ctx, parentId) {
1657
+ const id = v4();
1658
+ const n = {
1659
+ id,
1660
+ parentId,
1661
+ type: "svg_include",
1662
+ text: node.text,
1663
+ };
1664
+ ctx.nodes.set(id, n);
1665
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1666
+ const optionsNode = node.childForFieldName("options");
1667
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1668
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
1669
+ const fieldNodes = new Set([
1670
+ node.childForFieldName("command").id,
1671
+ optionsNode ? optionsNode.id : undefined,
1672
+ node.childForFieldName("path").id,
1673
+ ].filter((id) => id !== undefined));
1674
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1675
+ return id;
1676
+ }
1677
+ function unmarshalerTextNode(node, ctx, parentId) {
1678
+ const id = v4();
1679
+ const n = {
1680
+ id,
1681
+ parentId,
1682
+ type: "text",
1683
+ text: node.text,
1684
+ };
1685
+ ctx.nodes.set(id, n);
1686
+ n.word = node.childrenForFieldName("word").map((n) => unmarshalNode(n, ctx, id));
1687
+ const fieldNodes = new Set([...node.childrenForFieldName("word").map((n) => n.id)].filter((id) => id !== undefined));
1688
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1689
+ return id;
1690
+ }
1691
+ function unmarshalerTextModeNode(node, ctx, parentId) {
1692
+ const id = v4();
1693
+ const n = {
1694
+ id,
1695
+ parentId,
1696
+ type: "text_mode",
1697
+ text: node.text,
1698
+ };
1699
+ ctx.nodes.set(id, n);
1700
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1701
+ n.content = unmarshalNode(node.childForFieldName("content"), ctx, id);
1702
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("content").id].filter((id) => id !== undefined));
1703
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1704
+ return id;
1705
+ }
1706
+ function unmarshalerTheoremDefinitionNode(node, ctx, parentId) {
1707
+ const id = v4();
1708
+ const n = {
1709
+ id,
1710
+ parentId,
1711
+ type: "theorem_definition",
1712
+ text: node.text,
1713
+ };
1714
+ ctx.nodes.set(id, n);
1715
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1716
+ const counterNode = node.childForFieldName("counter");
1717
+ n.counter = counterNode ? unmarshalNode(counterNode, ctx, id) : undefined;
1718
+ n.name = unmarshalNode(node.childForFieldName("name"), ctx, id);
1719
+ const optionsNode = node.childForFieldName("options");
1720
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1721
+ const titleNode = node.childForFieldName("title");
1722
+ n.title = titleNode ? unmarshalNode(titleNode, ctx, id) : undefined;
1723
+ const fieldNodes = new Set([
1724
+ node.childForFieldName("command").id,
1725
+ counterNode ? counterNode.id : undefined,
1726
+ node.childForFieldName("name").id,
1727
+ optionsNode ? optionsNode.id : undefined,
1728
+ titleNode ? titleNode.id : undefined,
1729
+ ].filter((id) => id !== undefined));
1730
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1731
+ return id;
1732
+ }
1733
+ function unmarshalerTikzLibraryImportNode(node, ctx, parentId) {
1734
+ const id = v4();
1735
+ const n = {
1736
+ id,
1737
+ parentId,
1738
+ type: "tikz_library_import",
1739
+ text: node.text,
1740
+ };
1741
+ ctx.nodes.set(id, n);
1742
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1743
+ n.paths = unmarshalNode(node.childForFieldName("paths"), ctx, id);
1744
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("paths").id].filter((id) => id !== undefined));
1745
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1746
+ return id;
1747
+ }
1748
+ function unmarshalerTitleDeclarationNode(node, ctx, parentId) {
1749
+ const id = v4();
1750
+ const n = {
1751
+ id,
1752
+ parentId,
1753
+ type: "title_declaration",
1754
+ text: node.text,
1755
+ };
1756
+ ctx.nodes.set(id, n);
1757
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1758
+ const optionsNode = node.childForFieldName("options");
1759
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1760
+ n.text = unmarshalNode(node.childForFieldName("text"), ctx, id);
1761
+ const fieldNodes = new Set([
1762
+ node.childForFieldName("command").id,
1763
+ optionsNode ? optionsNode.id : undefined,
1764
+ node.childForFieldName("text").id,
1765
+ ].filter((id) => id !== undefined));
1766
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1767
+ return id;
1768
+ }
1769
+ function unmarshalerTodoNode(node, ctx, parentId) {
1770
+ const id = v4();
1771
+ const n = {
1772
+ id,
1773
+ parentId,
1774
+ type: "todo",
1775
+ text: node.text,
1776
+ };
1777
+ ctx.nodes.set(id, n);
1778
+ n.arg = unmarshalNode(node.childForFieldName("arg"), ctx, id);
1779
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1780
+ const optionsNode = node.childForFieldName("options");
1781
+ n.options = optionsNode ? unmarshalNode(optionsNode, ctx, id) : undefined;
1782
+ const fieldNodes = new Set([
1783
+ node.childForFieldName("arg").id,
1784
+ node.childForFieldName("command").id,
1785
+ optionsNode ? optionsNode.id : undefined,
1786
+ ].filter((id) => id !== undefined));
1787
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1788
+ return id;
1789
+ }
1790
+ function unmarshalerValueNode(node, ctx, parentId) {
1791
+ const id = v4();
1792
+ const n = {
1793
+ id,
1794
+ parentId,
1795
+ type: "value",
1796
+ text: node.text,
1797
+ };
1798
+ ctx.nodes.set(id, n);
1799
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1800
+ return id;
1801
+ }
1802
+ function unmarshalerVerbatimEnvironmentNode(node, ctx, parentId) {
1803
+ const id = v4();
1804
+ const n = {
1805
+ id,
1806
+ parentId,
1807
+ type: "verbatim_environment",
1808
+ text: node.text,
1809
+ };
1810
+ ctx.nodes.set(id, n);
1811
+ n.begin = unmarshalNode(node.childForFieldName("begin"), ctx, id);
1812
+ n.end = unmarshalNode(node.childForFieldName("end"), ctx, id);
1813
+ n.verbatim = unmarshalNode(node.childForFieldName("verbatim"), ctx, id);
1814
+ const fieldNodes = new Set([
1815
+ node.childForFieldName("begin").id,
1816
+ node.childForFieldName("end").id,
1817
+ node.childForFieldName("verbatim").id,
1818
+ ].filter((id) => id !== undefined));
1819
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1820
+ return id;
1821
+ }
1822
+ function unmarshalerVerbatimIncludeNode(node, ctx, parentId) {
1823
+ const id = v4();
1824
+ const n = {
1825
+ id,
1826
+ parentId,
1827
+ type: "verbatim_include",
1828
+ text: node.text,
1829
+ };
1830
+ ctx.nodes.set(id, n);
1831
+ n.command = unmarshalNode(node.childForFieldName("command"), ctx, id);
1832
+ n.path = unmarshalNode(node.childForFieldName("path"), ctx, id);
1833
+ const fieldNodes = new Set([node.childForFieldName("command").id, node.childForFieldName("path").id].filter((id) => id !== undefined));
1834
+ n.childrenIds = node.namedChildren.filter((n) => !fieldNodes.has(n.id)).map((n) => unmarshalNode(n, ctx, id));
1835
+ return id;
1836
+ }
1837
+ function unmarshalerArgcNode(node, ctx, parentId) {
1838
+ const id = v4();
1839
+ const n = {
1840
+ id,
1841
+ parentId,
1842
+ type: "argc",
1843
+ text: node.text,
1844
+ };
1845
+ ctx.nodes.set(id, n);
1846
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1847
+ return id;
1848
+ }
1849
+ function unmarshalerCommandNameNode(node, ctx, parentId) {
1850
+ const id = v4();
1851
+ const n = {
1852
+ id,
1853
+ parentId,
1854
+ type: "command_name",
1855
+ text: node.text,
1856
+ };
1857
+ ctx.nodes.set(id, n);
1858
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1859
+ return id;
1860
+ }
1861
+ function unmarshalerCommentNode(node, ctx, parentId) {
1862
+ const id = v4();
1863
+ const n = {
1864
+ id,
1865
+ parentId,
1866
+ type: "comment",
1867
+ text: node.text,
1868
+ };
1869
+ ctx.nodes.set(id, n);
1870
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1871
+ return id;
1872
+ }
1873
+ function unmarshalerDelimiterNode(node, ctx, parentId) {
1874
+ const id = v4();
1875
+ const n = {
1876
+ id,
1877
+ parentId,
1878
+ type: "delimiter",
1879
+ text: node.text,
1880
+ };
1881
+ ctx.nodes.set(id, n);
1882
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1883
+ return id;
1884
+ }
1885
+ function unmarshalerLabelNode(node, ctx, parentId) {
1886
+ const id = v4();
1887
+ const n = {
1888
+ id,
1889
+ parentId,
1890
+ type: "label",
1891
+ text: node.text,
1892
+ };
1893
+ ctx.nodes.set(id, n);
1894
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1895
+ return id;
1896
+ }
1897
+ function unmarshalerLetterNode(node, ctx, parentId) {
1898
+ const id = v4();
1899
+ const n = {
1900
+ id,
1901
+ parentId,
1902
+ type: "letter",
1903
+ text: node.text,
1904
+ };
1905
+ ctx.nodes.set(id, n);
1906
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1907
+ return id;
1908
+ }
1909
+ function unmarshalerLineCommentNode(node, ctx, parentId) {
1910
+ const id = v4();
1911
+ const n = {
1912
+ id,
1913
+ parentId,
1914
+ type: "line_comment",
1915
+ text: node.text,
1916
+ };
1917
+ ctx.nodes.set(id, n);
1918
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1919
+ return id;
1920
+ }
1921
+ function unmarshalerPathNode(node, ctx, parentId) {
1922
+ const id = v4();
1923
+ const n = {
1924
+ id,
1925
+ parentId,
1926
+ type: "path",
1927
+ text: node.text,
1928
+ };
1929
+ ctx.nodes.set(id, n);
1930
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1931
+ return id;
1932
+ }
1933
+ function unmarshalerPlaceholderNode(node, ctx, parentId) {
1934
+ const id = v4();
1935
+ const n = {
1936
+ id,
1937
+ parentId,
1938
+ type: "placeholder",
1939
+ text: node.text,
1940
+ };
1941
+ ctx.nodes.set(id, n);
1942
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1943
+ return id;
1944
+ }
1945
+ function unmarshalerSourceCodeNode(node, ctx, parentId) {
1946
+ const id = v4();
1947
+ const n = {
1948
+ id,
1949
+ parentId,
1950
+ type: "source_code",
1951
+ text: node.text,
1952
+ };
1953
+ ctx.nodes.set(id, n);
1954
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1955
+ return id;
1956
+ }
1957
+ function unmarshalerTodoCommandNameNode(node, ctx, parentId) {
1958
+ const id = v4();
1959
+ const n = {
1960
+ id,
1961
+ parentId,
1962
+ type: "todo_command_name",
1963
+ text: node.text,
1964
+ };
1965
+ ctx.nodes.set(id, n);
1966
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1967
+ return id;
1968
+ }
1969
+ function unmarshalerUriNode(node, ctx, parentId) {
1970
+ const id = v4();
1971
+ const n = {
1972
+ id,
1973
+ parentId,
1974
+ type: "uri",
1975
+ text: node.text,
1976
+ };
1977
+ ctx.nodes.set(id, n);
1978
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1979
+ return id;
1980
+ }
1981
+ function unmarshalerValueLiteralNode(node, ctx, parentId) {
1982
+ const id = v4();
1983
+ const n = {
1984
+ id,
1985
+ parentId,
1986
+ type: "value_literal",
1987
+ text: node.text,
1988
+ };
1989
+ ctx.nodes.set(id, n);
1990
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
1991
+ return id;
1992
+ }
1993
+ function unmarshalerWordNode(node, ctx, parentId) {
1994
+ const id = v4();
1995
+ const n = {
1996
+ id,
1997
+ parentId,
1998
+ type: "word",
1999
+ text: node.text,
2000
+ };
2001
+ ctx.nodes.set(id, n);
2002
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
2003
+ return id;
2004
+ }
2005
+ // Parser core
2006
+ export const unmarshalNode = (node, ctx, parentId) => {
2007
+ switch (node.type) {
2008
+ case "acronym_definition":
2009
+ return unmarshalerAcronymDefinitionNode(node, ctx, parentId);
2010
+ case "acronym_reference":
2011
+ return unmarshalerAcronymReferenceNode(node, ctx, parentId);
2012
+ case "asy_environment":
2013
+ return unmarshalerAsyEnvironmentNode(node, ctx, parentId);
2014
+ case "asydef_environment":
2015
+ return unmarshalerAsydefEnvironmentNode(node, ctx, parentId);
2016
+ case "author":
2017
+ return unmarshalerAuthorNode(node, ctx, parentId);
2018
+ case "author_declaration":
2019
+ return unmarshalerAuthorDeclarationNode(node, ctx, parentId);
2020
+ case "begin":
2021
+ return unmarshalerBeginNode(node, ctx, parentId);
2022
+ case "biblatex_include":
2023
+ return unmarshalerBiblatexIncludeNode(node, ctx, parentId);
2024
+ case "bibstyle_include":
2025
+ return unmarshalerBibstyleIncludeNode(node, ctx, parentId);
2026
+ case "bibtex_include":
2027
+ return unmarshalerBibtexIncludeNode(node, ctx, parentId);
2028
+ case "block_comment":
2029
+ return unmarshalerBlockCommentNode(node, ctx, parentId);
2030
+ case "brack_group":
2031
+ return unmarshalerBrackGroupNode(node, ctx, parentId);
2032
+ case "brack_group_argc":
2033
+ return unmarshalerBrackGroupArgcNode(node, ctx, parentId);
2034
+ case "brack_group_key_value":
2035
+ return unmarshalerBrackGroupKeyValueNode(node, ctx, parentId);
2036
+ case "brack_group_text":
2037
+ return unmarshalerBrackGroupTextNode(node, ctx, parentId);
2038
+ case "brack_group_word":
2039
+ return unmarshalerBrackGroupWordNode(node, ctx, parentId);
2040
+ case "caption":
2041
+ return unmarshalerCaptionNode(node, ctx, parentId);
2042
+ case "changes_replaced":
2043
+ return unmarshalerChangesReplacedNode(node, ctx, parentId);
2044
+ case "chapter":
2045
+ return unmarshalerChapterNode(node, ctx, parentId);
2046
+ case "citation":
2047
+ return unmarshalerCitationNode(node, ctx, parentId);
2048
+ case "class_include":
2049
+ return unmarshalerClassIncludeNode(node, ctx, parentId);
2050
+ case "color_definition":
2051
+ return unmarshalerColorDefinitionNode(node, ctx, parentId);
2052
+ case "color_reference":
2053
+ return unmarshalerColorReferenceNode(node, ctx, parentId);
2054
+ case "color_set_definition":
2055
+ return unmarshalerColorSetDefinitionNode(node, ctx, parentId);
2056
+ case "comment_environment":
2057
+ return unmarshalerCommentEnvironmentNode(node, ctx, parentId);
2058
+ case "counter_addition":
2059
+ return unmarshalerCounterAdditionNode(node, ctx, parentId);
2060
+ case "counter_declaration":
2061
+ return unmarshalerCounterDeclarationNode(node, ctx, parentId);
2062
+ case "counter_definition":
2063
+ return unmarshalerCounterDefinitionNode(node, ctx, parentId);
2064
+ case "counter_increment":
2065
+ return unmarshalerCounterIncrementNode(node, ctx, parentId);
2066
+ case "counter_typesetting":
2067
+ return unmarshalerCounterTypesettingNode(node, ctx, parentId);
2068
+ case "counter_value":
2069
+ return unmarshalerCounterValueNode(node, ctx, parentId);
2070
+ case "counter_within_declaration":
2071
+ return unmarshalerCounterWithinDeclarationNode(node, ctx, parentId);
2072
+ case "counter_without_declaration":
2073
+ return unmarshalerCounterWithoutDeclarationNode(node, ctx, parentId);
2074
+ case "curly_group":
2075
+ return unmarshalerCurlyGroupNode(node, ctx, parentId);
2076
+ case "curly_group_author_list":
2077
+ return unmarshalerCurlyGroupAuthorListNode(node, ctx, parentId);
2078
+ case "curly_group_command_name":
2079
+ return unmarshalerCurlyGroupCommandNameNode(node, ctx, parentId);
2080
+ case "curly_group_glob_pattern":
2081
+ return unmarshalerCurlyGroupGlobPatternNode(node, ctx, parentId);
2082
+ case "curly_group_impl":
2083
+ return unmarshalerCurlyGroupImplNode(node, ctx, parentId);
2084
+ case "curly_group_key_value":
2085
+ return unmarshalerCurlyGroupKeyValueNode(node, ctx, parentId);
2086
+ case "curly_group_label":
2087
+ return unmarshalerCurlyGroupLabelNode(node, ctx, parentId);
2088
+ case "curly_group_label_list":
2089
+ return unmarshalerCurlyGroupLabelListNode(node, ctx, parentId);
2090
+ case "curly_group_path":
2091
+ return unmarshalerCurlyGroupPathNode(node, ctx, parentId);
2092
+ case "curly_group_path_list":
2093
+ return unmarshalerCurlyGroupPathListNode(node, ctx, parentId);
2094
+ case "curly_group_spec":
2095
+ return unmarshalerCurlyGroupSpecNode(node, ctx, parentId);
2096
+ case "curly_group_text":
2097
+ return unmarshalerCurlyGroupTextNode(node, ctx, parentId);
2098
+ case "curly_group_text_list":
2099
+ return unmarshalerCurlyGroupTextListNode(node, ctx, parentId);
2100
+ case "curly_group_uri":
2101
+ return unmarshalerCurlyGroupUriNode(node, ctx, parentId);
2102
+ case "curly_group_value":
2103
+ return unmarshalerCurlyGroupValueNode(node, ctx, parentId);
2104
+ case "curly_group_word":
2105
+ return unmarshalerCurlyGroupWordNode(node, ctx, parentId);
2106
+ case "displayed_equation":
2107
+ return unmarshalerDisplayedEquationNode(node, ctx, parentId);
2108
+ case "end":
2109
+ return unmarshalerEndNode(node, ctx, parentId);
2110
+ case "enum_item":
2111
+ return unmarshalerEnumItemNode(node, ctx, parentId);
2112
+ case "environment_definition":
2113
+ return unmarshalerEnvironmentDefinitionNode(node, ctx, parentId);
2114
+ case "generic_command":
2115
+ return unmarshalerGenericCommandNode(node, ctx, parentId);
2116
+ case "generic_environment":
2117
+ return unmarshalerGenericEnvironmentNode(node, ctx, parentId);
2118
+ case "glob_pattern":
2119
+ return unmarshalerGlobPatternNode(node, ctx, parentId);
2120
+ case "glossary_entry_definition":
2121
+ return unmarshalerGlossaryEntryDefinitionNode(node, ctx, parentId);
2122
+ case "glossary_entry_reference":
2123
+ return unmarshalerGlossaryEntryReferenceNode(node, ctx, parentId);
2124
+ case "graphics_include":
2125
+ return unmarshalerGraphicsIncludeNode(node, ctx, parentId);
2126
+ case "hyperlink":
2127
+ return unmarshalerHyperlinkNode(node, ctx, parentId);
2128
+ case "import_include":
2129
+ return unmarshalerImportIncludeNode(node, ctx, parentId);
2130
+ case "inkscape_include":
2131
+ return unmarshalerInkscapeIncludeNode(node, ctx, parentId);
2132
+ case "inline_formula":
2133
+ return unmarshalerInlineFormulaNode(node, ctx, parentId);
2134
+ case "key_value_pair":
2135
+ return unmarshalerKeyValuePairNode(node, ctx, parentId);
2136
+ case "label_definition":
2137
+ return unmarshalerLabelDefinitionNode(node, ctx, parentId);
2138
+ case "label_number":
2139
+ return unmarshalerLabelNumberNode(node, ctx, parentId);
2140
+ case "label_reference":
2141
+ return unmarshalerLabelReferenceNode(node, ctx, parentId);
2142
+ case "label_reference_range":
2143
+ return unmarshalerLabelReferenceRangeNode(node, ctx, parentId);
2144
+ case "latex_include":
2145
+ return unmarshalerLatexIncludeNode(node, ctx, parentId);
2146
+ case "let_command_definition":
2147
+ return unmarshalerLetCommandDefinitionNode(node, ctx, parentId);
2148
+ case "listing_environment":
2149
+ return unmarshalerListingEnvironmentNode(node, ctx, parentId);
2150
+ case "luacode_environment":
2151
+ return unmarshalerLuacodeEnvironmentNode(node, ctx, parentId);
2152
+ case "math_delimiter":
2153
+ return unmarshalerMathDelimiterNode(node, ctx, parentId);
2154
+ case "math_environment":
2155
+ return unmarshalerMathEnvironmentNode(node, ctx, parentId);
2156
+ case "minted_environment":
2157
+ return unmarshalerMintedEnvironmentNode(node, ctx, parentId);
2158
+ case "new_command_definition":
2159
+ return unmarshalerNewCommandDefinitionNode(node, ctx, parentId);
2160
+ case "old_command_definition":
2161
+ return unmarshalerOldCommandDefinitionNode(node, ctx, parentId);
2162
+ case "operator":
2163
+ return unmarshalerOperatorNode(node, ctx, parentId);
2164
+ case "package_include":
2165
+ return unmarshalerPackageIncludeNode(node, ctx, parentId);
2166
+ case "paired_delimiter_definition":
2167
+ return unmarshalerPairedDelimiterDefinitionNode(node, ctx, parentId);
2168
+ case "paragraph":
2169
+ return unmarshalerParagraphNode(node, ctx, parentId);
2170
+ case "part":
2171
+ return unmarshalerPartNode(node, ctx, parentId);
2172
+ case "pycode_environment":
2173
+ return unmarshalerPycodeEnvironmentNode(node, ctx, parentId);
2174
+ case "sageblock_environment":
2175
+ return unmarshalerSageblockEnvironmentNode(node, ctx, parentId);
2176
+ case "sagesilent_environment":
2177
+ return unmarshalerSagesilentEnvironmentNode(node, ctx, parentId);
2178
+ case "section":
2179
+ return unmarshalerSectionNode(node, ctx, parentId);
2180
+ case "source_file":
2181
+ return unmarshalerSourceFileNode(node, ctx, parentId);
2182
+ case "subparagraph":
2183
+ return unmarshalerSubparagraphNode(node, ctx, parentId);
2184
+ case "subscript":
2185
+ return unmarshalerSubscriptNode(node, ctx, parentId);
2186
+ case "subsection":
2187
+ return unmarshalerSubsectionNode(node, ctx, parentId);
2188
+ case "subsubsection":
2189
+ return unmarshalerSubsubsectionNode(node, ctx, parentId);
2190
+ case "superscript":
2191
+ return unmarshalerSuperscriptNode(node, ctx, parentId);
2192
+ case "svg_include":
2193
+ return unmarshalerSvgIncludeNode(node, ctx, parentId);
2194
+ case "text":
2195
+ return unmarshalerTextNode(node, ctx, parentId);
2196
+ case "text_mode":
2197
+ return unmarshalerTextModeNode(node, ctx, parentId);
2198
+ case "theorem_definition":
2199
+ return unmarshalerTheoremDefinitionNode(node, ctx, parentId);
2200
+ case "tikz_library_import":
2201
+ return unmarshalerTikzLibraryImportNode(node, ctx, parentId);
2202
+ case "title_declaration":
2203
+ return unmarshalerTitleDeclarationNode(node, ctx, parentId);
2204
+ case "todo":
2205
+ return unmarshalerTodoNode(node, ctx, parentId);
2206
+ case "value":
2207
+ return unmarshalerValueNode(node, ctx, parentId);
2208
+ case "verbatim_environment":
2209
+ return unmarshalerVerbatimEnvironmentNode(node, ctx, parentId);
2210
+ case "verbatim_include":
2211
+ return unmarshalerVerbatimIncludeNode(node, ctx, parentId);
2212
+ case "argc":
2213
+ return unmarshalerArgcNode(node, ctx, parentId);
2214
+ case "command_name":
2215
+ return unmarshalerCommandNameNode(node, ctx, parentId);
2216
+ case "comment":
2217
+ return unmarshalerCommentNode(node, ctx, parentId);
2218
+ case "delimiter":
2219
+ return unmarshalerDelimiterNode(node, ctx, parentId);
2220
+ case "label":
2221
+ return unmarshalerLabelNode(node, ctx, parentId);
2222
+ case "letter":
2223
+ return unmarshalerLetterNode(node, ctx, parentId);
2224
+ case "line_comment":
2225
+ return unmarshalerLineCommentNode(node, ctx, parentId);
2226
+ case "path":
2227
+ return unmarshalerPathNode(node, ctx, parentId);
2228
+ case "placeholder":
2229
+ return unmarshalerPlaceholderNode(node, ctx, parentId);
2230
+ case "source_code":
2231
+ return unmarshalerSourceCodeNode(node, ctx, parentId);
2232
+ case "todo_command_name":
2233
+ return unmarshalerTodoCommandNameNode(node, ctx, parentId);
2234
+ case "uri":
2235
+ return unmarshalerUriNode(node, ctx, parentId);
2236
+ case "value_literal":
2237
+ return unmarshalerValueLiteralNode(node, ctx, parentId);
2238
+ case "word":
2239
+ return unmarshalerWordNode(node, ctx, parentId);
2240
+ default: {
2241
+ const id = v4();
2242
+ const n = {
2243
+ id,
2244
+ parentId,
2245
+ type: node.type,
2246
+ text: node.text,
2247
+ childrenIds: [],
2248
+ };
2249
+ ctx.nodes.set(id, n);
2250
+ n.childrenIds = node.namedChildren.map((n) => unmarshalNode(n, ctx, id));
2251
+ return id;
2252
+ }
2253
+ }
2254
+ };
2255
+ // Parses a treesitter CST into a Bragi AST node map
2256
+ export const parseCST = (root) => {
2257
+ if (!root)
2258
+ throw new Error("No root node provided");
2259
+ const ctx = { nodes: new Map() };
2260
+ const rootId = unmarshalNode(root, ctx, null);
2261
+ return { rootId, nodes: ctx.nodes };
2262
+ };